Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Send multipart email notification #15016

Merged
merged 2 commits into from
Aug 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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