Попытка 1 приводит к следующему:
Ожидаемый параметр введите '\Illuminate\Contracts\Queue\Job', 'namespace\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
Попытка 2 приводит к следующему:
Вызов участнику функция uuid() имеет значение null (поэтому Queue::pop возвращает значение 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