Is it possible to write a test to make sure an email was sent that has a delay on it? I am able to test that it has been pushed to the queue, but i would like to make sure that the logic in the mailer send the correct email. This is what i have, the assertPushed works, but the assertSent returns a fail.
This is how i am running the job in the controller;
ProcessEmailJob::dispatch($this, $user)
->delay(now()->addMinutes(10));
This is the test
Queue::fake();
Mail::fake();
// processing here
Queue::assertPushed(ProcessEmailJob::class, function ($job) {
return ! is_null($job->delay);
});
Mail::assertSent(EmailUserMail::class);
Use sleep(10 * 60)
inside your job handler and remove the delay from the controller code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.