Mocking post with Laravel 5.4 (twilight)

I am trying to check mail in browser tests in Laravel 5.4.

I have this code in a class InvitationTest

inside a callback function browse

:

\Mail::fake();

$browser->visit('projects')
    ->press('etc.')

\Mail::assertSent(InvitationMail::class, function ($mail) use ($project) {
    return $mail->invitation->project->id == $project->id;
});

      

I can see that the mail was sent in the logs:

[2017-04-06 15:36:10] local.INFO: Prompt xxxx-yyyy-zzz-aa-bb started
[2017-04-06 15:36:10] local.DEBUG: Message id: < xxx @ yyy .dev >
Date: Thu, 06 Apr 2017 15:36:10 +0200
Topic: hello world :)

But running php artisan dusk

, I got:

1) Tests \ Browser \ InvitationTest :: testCreateInvitation
The expected [App \ Mail \ InvitationMail] mail was not sent.
An error occurred while asserting false is true.

The mail is queued, but in mine .env.dusk.local

I set up a queue for sync (and mail for journal):

QUEUE_DRIVER=sync
MAIL_DRIVER=log

      

So everything should be fine. Am I doing something wrong? Why does dusk say mail has not been sent?

Important note: mail is not sent directly through the controller, but a delayed job is created and this job sends mail. Deferred work is sent in the past, so it may not have any impact. To be clear: the dispatcher sends a job, then this job sends multiple emails.

+3


source to share


1 answer


Sadly mock doesn't work for Laravel Dusk. Although there are two open issues on this issue:



+1


source







All Articles