0
/**
 * @test
 */
public function xxx()
{
   $exitCode = Artisan::call('queue:work');
   //shell_exec('php artisan queue:work');
}

Run Artisan::call(...) or shell_exec(...) in PHPUnit test, it is not working.

matiaslauriti
  • 7,065
  • 4
  • 31
  • 43
jinhin xu
  • 1
  • 1

1 Answers1

1

For your unit tests you don't use your normal laravel queue like you do in the rest of your project.

Start your queue using Queue::fake(); and then apply your test logic.

Your tests will push events in this queue and the mock workers will pick up.

Read more about mocking methods here.

matiaslauriti
  • 7,065
  • 4
  • 31
  • 43
pr1nc3
  • 8,108
  • 3
  • 23
  • 36