Answer the question
In order to leave comments, you need to log in
How to disable (mock?) dispatch() in a controller method in laravel unit tests?
Hello!
Can you please tell me how to mock the dispatch() helper in the laravel phpunit test of the controller method?
Here is the controller method I'm testing:
public function foo() {
$data = [
'content' => $content,
'from' => date('Y-m-d H:i:s'),
'to' => date('Y-m-d H:i:s'),
];
$report = (new BlockedItemsReport($data))->onQueue('default');
dispatch($report); <- Эту часть нужно как-то мокнуть.. Подскажите, как?
return back();
}
public function testFoo()
{
$faker = Faker\Factory::create();
$response = $this->call('POST', route('make.foo'), [
'content' => $faker->text(200),
]);
$response->assertRedirect('/');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question