diff --git a/src/Watchers/NotificationWatcher.php b/src/Watchers/NotificationWatcher.php index 372fccf05..39b2faef0 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); diff --git a/tests/Watchers/NotificationWatcherTest.php b/tests/Watchers/NotificationWatcherTest.php index a7cfa3c97..df0dadf91 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']); } }