Level 70
@devhobby You can try this:
/** @test */
public function it_sends_notification()
{
// Arrange
Notification::fake();
// Put your job dispatcher code here
// Assert
$this->assertEmailNotificationSentTo('[email protected]', FooNotification::class, function ($notification, $notifiable) {
$mail = $notification->toMail($notifiable);
// Ensure that email subject is correct
$this->assertSame("Subject", $mail->build()->subject);
$mail->assertSeeInText("Foo");
return true;
});
}
⚠️ Not tested. You may need to adjust!
Check more: https://laravel.com/docs/10.x/notifications#testing
1 like