I am trying to run Laravel Command with PHPUnit like this ↓
public function testHandle(): void
{
Notification::fake();
// run command
exec('php artisan command:send_notification --env=local');
Notification::assertSentTo(XXXXXX, SendNotificatioin::class);
}
process works good, has output log, notification has sent. but coverage was 0% and process won't pause at breakpoint.
is there any other why to execute Command in PHPUnit? Thanks
CodePudding user response:
You can use:
$this->artisan('send_notification');
You can read more about this here
CodePudding user response:
You can try Artisan::call('command:send_notification', ['--env=local'])