Код: Выделить всё
// attempt 1, results in:
// Expected parameter of type '\Illuminate\Contracts\Queue\Job', '\TestJob'
public function test_updates_job_status_to_processing_when_job_starts_processing(): void
{
$event = new JobProcessing(
'default',
new TestJob(),
);
$eventListener = $this->app->make(UpdateJobStatus::class);
$eventListener->handle($event);
// assertions
}
Код: Выделить всё
Queue::pop
Код: Выделить всё
// attempt 2, results in:
// Call to a member function uuid() on null (so Queue::pop returned null)
public function test_updates_job_status_to_processing_when_job_starts_processing(): void
{
Queue::push(new TestJob);
$event = new JobProcessing(
'default',
Queue::pop(),
);
$eventListener = $this->app->make(UpdateJobStatus::class);
$eventListener->handle($event);
// assertions
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... s-in-tests