Skip to content

Commit

Permalink
[5.3] Send multipart email notification (laravel#15016)
Browse files Browse the repository at this point in the history
* Send multipart email notification

* Updated tests
  • Loading branch information
tillkruss authored and taylorotwell committed Aug 27, 2016
1 parent 15de9a1 commit 8a0879c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/Illuminate/Notifications/Messages/MailMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions src/Illuminate/Notifications/resources/views/email-plain.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{ $level == 'error' ? 'Whoops!' : 'Hello!' }}

<?php
if (! empty($introLines)) {
echo implode("\r\n", $introLines), "\r\n\r\n";
}
if (isset($actionText)) {
echo "{$actionText}: {$actionUrl}\r\n\r\n";
}
if (! empty($outroLines)) {
echo implode("\r\n", $outroLines), "\r\n\r\n";
}
?>
Regards,
{{ config('app.name') }}
24 changes: 18 additions & 6 deletions tests/Notifications/NotificationMailChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 8a0879c

Please sign in to comment.