I am trying to test emails in laravel 5 and I have realised that Swift_Mailer
triggers Illuminate\Mail\Events\MessageSending
event whenever a mail is being sent.
But since I am beginner, I am having trouble comprehending how to listen to this event and take out the underlying message object?
I have tried this but I don't this is correct:
public function test_the_email_via_listening_to_message_sending_event()
{
$user = factory(User::class)->create();
Event::fire(new UserWasCreated($user));
Event::listen(Illuminate\Mail\Events\MessageSending::class, function($message){
echo 'Hello';
});
}
How to listen to a particular event in a test case and trigger code in response to it?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire