From 05ee21da4bf2acfa896348f6c2087049cabedb4a Mon Sep 17 00:00:00 2001 From: root Date: Fri, 22 Nov 2019 21:19:13 -0500 Subject: [PATCH 1/3] properly implode nested notification routes --- src/Watchers/NotificationWatcher.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Watchers/NotificationWatcher.php b/src/Watchers/NotificationWatcher.php index 372fccf05..54b74cdae 100644 --- a/src/Watchers/NotificationWatcher.php +++ b/src/Watchers/NotificationWatcher.php @@ -69,7 +69,11 @@ private function formatNotifiable($notifiable) if ($notifiable instanceof Model) { return FormatModel::given($notifiable); } elseif ($notifiable instanceof AnonymousNotifiable) { - return 'Anonymous:'.implode(',', $notifiable->routes); + $routes = array_map(function ($route){ + return is_array( $route ) ? implode(',', $route) : $route; + }, $notifiable->routes); + + return 'Anonymous:'.implode(',', $routes); } return get_class($notifiable); From 0da5f936b8aaa31986b97f925f5835422c449500 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 22 Nov 2019 21:34:56 -0500 Subject: [PATCH 2/3] adding tests for array routes in notification watcher test --- tests/Watchers/NotificationWatcherTest.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/Watchers/NotificationWatcherTest.php b/tests/Watchers/NotificationWatcherTest.php index a7cfa3c97..ccc7e7f04 100644 --- a/tests/Watchers/NotificationWatcherTest.php +++ b/tests/Watchers/NotificationWatcherTest.php @@ -24,16 +24,26 @@ protected function getEnvironmentSetUp($app) public function test_notification_watcher_registers_entry() { - Notification::route('mail', 'telescope@laravel.com') - ->notify(new BoomerangNotification); + $this->performNotificationAssertions('mail', 'telescope@laravel.com'); + } + + public function test_notification_watcher_registers_array_routes() + { + $this->performNotificationAssertions('mail', ['telescope@laravel.com','nestedroute@laravel.com']); + } + + private function performNotificationAssertions($channel, $route) + { + Notification::route($channel, $route) + ->notify(new BoomerangNotification); $entry = $this->loadTelescopeEntries()->first(); $this->assertSame(EntryType::NOTIFICATION, $entry->type); $this->assertSame(BoomerangNotification::class, $entry->content['notification']); $this->assertSame(false, $entry->content['queued']); - $this->assertStringContainsString('telescope@laravel.com', $entry->content['notifiable']); - $this->assertSame('mail', $entry->content['channel']); + $this->assertStringContainsString(is_array($route) ? implode(',', $route) : $route, $entry->content['notifiable']); + $this->assertSame($channel, $entry->content['channel']); $this->assertNull($entry->content['response']); } } From 7a4ad5fc13c1e66e573c645853cf156f0f66eff5 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 22 Nov 2019 22:06:07 -0500 Subject: [PATCH 3/3] fixing styleci tests --- src/Watchers/NotificationWatcher.php | 4 ++-- tests/Watchers/NotificationWatcherTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Watchers/NotificationWatcher.php b/src/Watchers/NotificationWatcher.php index 54b74cdae..39b2faef0 100644 --- a/src/Watchers/NotificationWatcher.php +++ b/src/Watchers/NotificationWatcher.php @@ -69,8 +69,8 @@ private function formatNotifiable($notifiable) if ($notifiable instanceof Model) { return FormatModel::given($notifiable); } elseif ($notifiable instanceof AnonymousNotifiable) { - $routes = array_map(function ($route){ - return is_array( $route ) ? implode(',', $route) : $route; + $routes = array_map(function ($route) { + return is_array($route) ? implode(',', $route) : $route; }, $notifiable->routes); return 'Anonymous:'.implode(',', $routes); diff --git a/tests/Watchers/NotificationWatcherTest.php b/tests/Watchers/NotificationWatcherTest.php index ccc7e7f04..df0dadf91 100644 --- a/tests/Watchers/NotificationWatcherTest.php +++ b/tests/Watchers/NotificationWatcherTest.php @@ -29,7 +29,7 @@ public function test_notification_watcher_registers_entry() public function test_notification_watcher_registers_array_routes() { - $this->performNotificationAssertions('mail', ['telescope@laravel.com','nestedroute@laravel.com']); + $this->performNotificationAssertions('mail', ['telescope@laravel.com', 'nestedroute@laravel.com']); } private function performNotificationAssertions($channel, $route)