diff --git a/src/Illuminate/Notifications/Messages/MailMessage.php b/src/Illuminate/Notifications/Messages/MailMessage.php index ea4ae07cbbe4..914498f87e6d 100644 --- a/src/Illuminate/Notifications/Messages/MailMessage.php +++ b/src/Illuminate/Notifications/Messages/MailMessage.php @@ -9,7 +9,10 @@ class MailMessage extends SimpleMessage * * @var string */ - public $view = 'notifications::email'; + public $view = [ + 'notifications::email', + 'notifications::email-plain', + ]; /** * The view data for the message. diff --git a/src/Illuminate/Notifications/resources/views/email-plain.blade.php b/src/Illuminate/Notifications/resources/views/email-plain.blade.php new file mode 100644 index 000000000000..f5b35c0115bf --- /dev/null +++ b/src/Illuminate/Notifications/resources/views/email-plain.blade.php @@ -0,0 +1,19 @@ +{{ $level == 'error' ? 'Whoops!' : 'Hello!' }} + + +Regards, +{{ config('app.name') }} diff --git a/tests/Notifications/NotificationMailChannelTest.php b/tests/Notifications/NotificationMailChannelTest.php index 7e18db7c0ef0..bd15f211f12c 100644 --- a/tests/Notifications/NotificationMailChannelTest.php +++ b/tests/Notifications/NotificationMailChannelTest.php @@ -22,7 +22,9 @@ public function testMailIsSentByChannel() $mailer = Mockery::mock(Illuminate\Contracts\Mail\Mailer::class) ); - $mailer->shouldReceive('send')->with('notifications::email', $data, Mockery::type('Closure')); + $views = ['notifications::email', 'notifications::email-plain']; + + $mailer->shouldReceive('send')->with($views, $data, Mockery::type('Closure')); $channel->send($notifiable, $notification); } @@ -39,7 +41,9 @@ public function testMessageWithSubject() $mailer = Mockery::mock(Illuminate\Contracts\Mail\Mailer::class) ); - $mailer->shouldReceive('send')->with('notifications::email', $data, Mockery::on(function ($closure) { + $views = ['notifications::email', 'notifications::email-plain']; + + $mailer->shouldReceive('send')->with($views, $data, Mockery::on(function ($closure) { $mock = Mockery::mock('Illuminate\Mailer\Message'); $mock->shouldReceive('subject')->once()->with('test subject'); @@ -68,7 +72,9 @@ public function testMessageWithoutSubjectAutogeneratesSubjectFromClassName() $mailer = Mockery::mock(Illuminate\Contracts\Mail\Mailer::class) ); - $mailer->shouldReceive('send')->with('notifications::email', $data, Mockery::on(function ($closure) { + $views = ['notifications::email', 'notifications::email-plain']; + + $mailer->shouldReceive('send')->with($views, $data, Mockery::on(function ($closure) { $mock = Mockery::mock('Illuminate\Mailer\Message'); $mock->shouldReceive('subject')->once()->with('Notification Mail Channel Test Notification No Subject'); @@ -95,7 +101,9 @@ public function testMessageWithMultipleSenders() $mailer = Mockery::mock(Illuminate\Contracts\Mail\Mailer::class) ); - $mailer->shouldReceive('send')->with('notifications::email', $data, Mockery::on(function ($closure) { + $views = ['notifications::email', 'notifications::email-plain']; + + $mailer->shouldReceive('send')->with($views, $data, Mockery::on(function ($closure) { $mock = Mockery::mock('Illuminate\Mailer\Message'); $mock->shouldReceive('subject')->once(); @@ -124,7 +132,9 @@ public function testMessageWithFromAddress() $mailer = Mockery::mock(Illuminate\Contracts\Mail\Mailer::class) ); - $mailer->shouldReceive('send')->with('notifications::email', $data, Mockery::on(function ($closure) { + $views = ['notifications::email', 'notifications::email-plain']; + + $mailer->shouldReceive('send')->with($views, $data, Mockery::on(function ($closure) { $mock = Mockery::mock('Illuminate\Mailer\Message'); $mock->shouldReceive('subject')->once(); @@ -153,7 +163,9 @@ public function testMessageWithFromAddressAndNoName() $mailer = Mockery::mock(Illuminate\Contracts\Mail\Mailer::class) ); - $mailer->shouldReceive('send')->with('notifications::email', $data, Mockery::on(function ($closure) { + $views = ['notifications::email', 'notifications::email-plain']; + + $mailer->shouldReceive('send')->with($views, $data, Mockery::on(function ($closure) { $mock = Mockery::mock('Illuminate\Mailer\Message'); $mock->shouldReceive('subject')->once();