Level 70
@devhobby This could be a possible scenario:
public function testJobIsDispatchedForFutureDates()
{
// Fake the queue
Queue::fake();
// Call the method with a future date
$this->scheduleDownload(now()->addDay()->format('Ymd'));
// Assert the job was pushed to the queue
Queue::assertPushed(FooFileDownloaderJob::class, function ($job) {
// Assert the job is scheduled for the correct date
return $job->date->isNextDay();
});
}
Please don't forget to write the test for the opposite case (if you feel).
3 likes