This commit is contained in:
Data-Kiss 2019-10-09 19:04:58 +01:00
parent 74b840a6cc
commit 87d4e33632
2 changed files with 105 additions and 1 deletions

View File

@ -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', [

View File

@ -0,0 +1,92 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Tests\Cachet\Functional\Notifications;
use CachetHQ\Tests\Cachet\AbstractTestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use CachetHQ\Cachet\Settings\Repository as SettingsRepository;
use CachetHQ\Cachet\Bus\Commands\Subscriber\SubscribeSubscriberCommand;
use Mail;
class MailTest extends AbstractTestCase
{
use DatabaseMigrations;
/**
* @var \Faker\Generator
*/
protected $fakerFactory;
/**
* @var string
*/
protected $appName;
/**
* @var string
*/
protected $subscriber;
/**
* MailTest constructor.
*
* @param null $name
* @param array $data
* @param string $dataName
*/
public function __construct($name = null, array $data = [], $dataName = '')
{
parent::__construct($name, $data, $dataName);
$this->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);
}
}