diff --git a/src/Illuminate/Support/Testing/Fakes/NotificationFake.php b/src/Illuminate/Support/Testing/Fakes/NotificationFake.php index 15dc07738e45..b610932b62da 100644 --- a/src/Illuminate/Support/Testing/Fakes/NotificationFake.php +++ b/src/Illuminate/Support/Testing/Fakes/NotificationFake.php @@ -174,7 +174,9 @@ public function sendNow($notifiables, $notification) } foreach ($notifiables as $notifiable) { - $notification->id = Uuid::uuid4()->toString(); + if (! $notification->id) { + $notification->id = Uuid::uuid4()->toString(); + } $this->notifications[get_class($notifiable)][$notifiable->getKey()][get_class($notification)][] = [ 'notification' => $notification, diff --git a/tests/Support/SupportTestingNotificationFakeTest.php b/tests/Support/SupportTestingNotificationFakeTest.php index 0f2a0c83af3d..8149981f759e 100644 --- a/tests/Support/SupportTestingNotificationFakeTest.php +++ b/tests/Support/SupportTestingNotificationFakeTest.php @@ -46,6 +46,26 @@ public function testAssertNotSentTo() $this->assertThat($e, new ExceptionMessage('The unexpected [Illuminate\Tests\Support\NotificationStub] notification was sent.')); } } + + public function testResettingNotificationId() + { + $notification = new NotificationStub(); + + $this->fake->send($this->user, $notification); + + $id = $notification->id; + + $this->fake->send($this->user, $notification); + + $this->assertSame($id, $notification->id); + + $notification->id = null; + + $this->fake->send($this->user, $notification); + + $this->assertNotNull($notification->id); + $this->assertNotSame($id, $notification->id); + } } class NotificationStub extends Notification