From 6d3b393e44c76ceccbc6584f9e7e7c8659ff14bc Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 28 Aug 2024 12:37:59 +0200 Subject: [PATCH] wip --- .../NotifyUsersMentionedInThread.php | 2 +- tests/Feature/ReplyTest.php | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/Listeners/NotifyUsersMentionedInThread.php b/app/Listeners/NotifyUsersMentionedInThread.php index 69538d065..8bcf5b47e 100644 --- a/app/Listeners/NotifyUsersMentionedInThread.php +++ b/app/Listeners/NotifyUsersMentionedInThread.php @@ -10,7 +10,7 @@ final class NotifyUsersMentionedInThread { public function handle(ThreadWasCreated $event): void - { + {dd('test'); $event->thread->mentionedUsers()->each(function ($user) use ($event) { if (! $user->isNotificationAllowed(MentionNotification::class)) { return; diff --git a/tests/Feature/ReplyTest.php b/tests/Feature/ReplyTest.php index 52dcb512f..281374d07 100644 --- a/tests/Feature/ReplyTest.php +++ b/tests/Feature/ReplyTest.php @@ -201,11 +201,20 @@ 'replyable_type' => Thread::TABLE, ]); - $notification = DatabaseNotification::first(); - $this->assertSame($user->id, (int) $notification->notifiable_id); - $this->assertSame('users', $notification->notifiable_type); - $this->assertSame('mention', $notification->data['type']); - $this->assertSame('The first thread', $notification->data['replyable_subject']); + $tested = false; + + foreach (DatabaseNotification::all() as $notification) { + if ($notification->type === MentionNotification::class) { + $this->assertSame($user->id, (int) $notification->notifiable_id); + $this->assertSame('users', $notification->notifiable_type); + $this->assertSame('mention', $notification->data['type']); + $this->assertSame('The first thread', $notification->data['replyable_subject']); + + $tested = true; + } + } + + $this->assertTrue($tested); })->only(); test('users are not notified when mentioned in an edited reply', function () {