diff --git a/src/Illuminate/Notifications/Channels/MailChannel.php b/src/Illuminate/Notifications/Channels/MailChannel.php index 23a17ffd9918..d28241ac40a6 100644 --- a/src/Illuminate/Notifications/Channels/MailChannel.php +++ b/src/Illuminate/Notifications/Channels/MailChannel.php @@ -112,6 +112,7 @@ protected function buildView($message) protected function additionalMessageData($notification) { return [ + '__laravel_notification_id' => $notification->id, '__laravel_notification' => get_class($notification), '__laravel_notification_queued' => in_array( ShouldQueue::class, class_implements($notification) diff --git a/tests/Integration/Notifications/SendingMailNotificationsTest.php b/tests/Integration/Notifications/SendingMailNotificationsTest.php index 09864117a27c..3be53abc6cf7 100644 --- a/tests/Integration/Notifications/SendingMailNotificationsTest.php +++ b/tests/Integration/Notifications/SendingMailNotificationsTest.php @@ -13,6 +13,7 @@ use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Notification; use Illuminate\Support\Facades\Schema; +use Illuminate\Support\Str; use Mockery as m; use Orchestra\Testbench\TestCase; @@ -69,6 +70,7 @@ protected function setUp(): void public function testMailIsSent() { $notification = new TestMailNotification; + $notification->id = Str::uuid()->toString(); $user = NotifiableUser::forceCreate([ 'email' => 'taylor@laravel.com', @@ -80,6 +82,7 @@ public function testMailIsSent() $this->mailer->shouldReceive('send')->once()->with( ['html' => 'htmlContent', 'text' => 'textContent'], array_merge($notification->toMail($user)->toArray(), [ + '__laravel_notification_id' => $notification->id, '__laravel_notification' => get_class($notification), '__laravel_notification_queued' => false, ]), @@ -112,6 +115,7 @@ public function testMailIsSent() public function testMailIsSentToNamedAddress() { $notification = new TestMailNotification; + $notification->id = Str::uuid()->toString(); $user = NotifiableUserWithNamedAddress::forceCreate([ 'email' => 'taylor@laravel.com', @@ -124,6 +128,7 @@ public function testMailIsSentToNamedAddress() $this->mailer->shouldReceive('send')->once()->with( ['html' => 'htmlContent', 'text' => 'textContent'], array_merge($notification->toMail($user)->toArray(), [ + '__laravel_notification_id' => $notification->id, '__laravel_notification' => get_class($notification), '__laravel_notification_queued' => false, ]), @@ -156,6 +161,7 @@ public function testMailIsSentToNamedAddress() public function testMailIsSentWithSubject() { $notification = new TestMailNotificationWithSubject; + $notification->id = Str::uuid()->toString(); $user = NotifiableUser::forceCreate([ 'email' => 'taylor@laravel.com', @@ -167,6 +173,7 @@ public function testMailIsSentWithSubject() $this->mailer->shouldReceive('send')->once()->with( ['html' => 'htmlContent', 'text' => 'textContent'], array_merge($notification->toMail($user)->toArray(), [ + '__laravel_notification_id' => $notification->id, '__laravel_notification' => get_class($notification), '__laravel_notification_queued' => false, ]), @@ -189,6 +196,7 @@ public function testMailIsSentWithSubject() public function testMailIsSentToMultipleAdresses() { $notification = new TestMailNotificationWithSubject; + $notification->id = Str::uuid()->toString(); $user = NotifiableUserWithMultipleAddreses::forceCreate([ 'email' => 'taylor@laravel.com', @@ -200,6 +208,7 @@ public function testMailIsSentToMultipleAdresses() $this->mailer->shouldReceive('send')->once()->with( ['html' => 'htmlContent', 'text' => 'textContent'], array_merge($notification->toMail($user)->toArray(), [ + '__laravel_notification_id' => $notification->id, '__laravel_notification' => get_class($notification), '__laravel_notification_queued' => false, ]),