I am writing unit test for code that sends email with the Mail :: queue function, as in the documentation: https://laravel.com/docs/5.4/mocking#mail-fake
My test:
public function send_reminder()
{
Mail::fake();
$response = $this->actingAs($this->existing_account)->json('POST', '/timeline-send-reminder', []);
$response->assertStatus(302);
Mail::assertSent(ClientEmail::class, function ($mail) use ($approver) {
return $mail->approver->id === $approver->id;
});
}
Checked code:
Mail::to($email, $name)->queue(new ClientEmail(Auth::user()));
Error message:
The expected [App\Mail\ClientEmail] mailable was not sent.
Failed asserting that false is true.
A letter is sent when I manually check it, but not from Unit Test. I think it could be because I use Mail::queuefunction instead Mail::send.
In the file .envI have
QUEUE_DRIVER=sync and MAIL_DRIVER=log
How can I check Mail::queuefor Laravel?
source
share