diff --git a/app/Notifications/Incident/NewIncidentNotification.php b/app/Notifications/Incident/NewIncidentNotification.php index c0f956b2..ab5277dc 100644 --- a/app/Notifications/Incident/NewIncidentNotification.php +++ b/app/Notifications/Incident/NewIncidentNotification.php @@ -72,7 +72,19 @@ class NewIncidentNotification extends Notification $content = trans('notifications.incident.new.mail.content', [ 'name' => $this->incident->name, ]); - + + dd(new MailMessage()) + ->subject(trans('notifications.incident.new.mail.subject')) + ->markdown('notifications.incident.new', [ + 'incident' => $this->incident, + 'content' => $content, + 'actionText' => trans('notifications.incident.new.mail.action'), + 'actionUrl' => cachet_route('incident', [$this->incident]), + 'unsubscribeText' => trans('cachet.subscriber.unsubscribe'), + 'unsubscribeUrl' => cachet_route('subscribe.unsubscribe', $notifiable->verify_code), + 'manageSubscriptionText' => trans('cachet.subscriber.manage_subscription'), + 'manageSubscriptionUrl' => cachet_route('subscribe.manage', $notifiable->verify_code), + ]); return (new MailMessage()) ->subject(trans('notifications.incident.new.mail.subject')) ->markdown('notifications.incident.new', [ diff --git a/tests/Functional/Notifications/MailTest.php b/tests/Functional/Notifications/MailTest.php new file mode 100644 index 00000000..e302180c --- /dev/null +++ b/tests/Functional/Notifications/MailTest.php @@ -0,0 +1,92 @@ +fakerFactory = \Faker\Factory::create(); + $this->appName = 'MailTest'; + } + + /** + * Setup the application. + */ + public function setUp() + { + parent::setUp(); + $this->app->make(SettingsRepository::class)->set('app_name', $this->appName); + $this->app->config->set('setting.app_name', $this->appName); + } + + public function createSubscriber() + { + dispatch(new SubscribeSubscriberCommand( + $this->fakerFactory->safeEmail, + true + )); + } + + /** + * Send a notification to subscribers when a new incident + * is added. + */ + public function testNotificationSentForNewIncident() + { + Mail::fake(); + + $this->signIn(); + $this->createSubscriber(); + + $response = $this->post('dashboard/incidents/create', [ + 'name' => $this->fakerFactory->word, + 'status' => 1, + 'visible' => 1, + 'message' => $this->fakerFactory->paragraph, + 'notify' => 1 + ]); + + Mail::assertSent(NewIncidentNotification::class); + } +} \ No newline at end of file