mercredi 17 janvier 2018

Mail::fake and Artisan::call seems incompatible

I'm testing a Laravel application with a unit test (not really "unit" though, but anyway). I have to fake mail in order to test them.

This works:

Mail::fake();
Mail::to($client)->send(new ReminderClientMail());
Mail::assertSent(Invitation::class, function ($mail) use ($client) {
    return $mail->hasTo($client->email);
});

But this does not work:

Mail::fake();
\Artisan::call('reminder:client');
Mail::assertSent(Invitation::class, function ($mail) use ($client) {
    return $mail->hasTo($client->email);
});

I know that the Artisan command I call actually sends a mail, because there is an info logged just before. So it seems there is some incompatibility between Artisan and Mail Fake. Did I miss something?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2mHmbMD
via IFTTT

Aucun commentaire:

Enregistrer un commentaire