如何在测试时关闭Laravel控制器方法中的dispatch()帮助器?

I'm having a problem while testing this method of controller:

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();

}

This is a test method:

public function testFoo()
{
    $faker = Faker\Factory::create();
    $response = $this->call('POST', route('make.foo'), [
        'content' => $faker->text(200),
    ]);
    $response->assertRedirect('/');
}

What I should do with dispatch() helper for switch off the action?

Try like this,

Your controller

public function foo($check) {
    $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');

    if($check){
       dispatch($report);  Подскажите, как?
    }
    return back();
}

Your test method

public function testFoo()
{
    $faker = Faker\Factory::create();
    $response = $this->call('POST', route('make.foo',[$check => false]), [
        'content' => $faker->text(200),
    ]);
    $response->assertRedirect('/');
}

I hope your peace :)