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

[6.x] Expose Notification Id within Message Data #31632

Merged
merged 5 commits into from
Feb 28, 2020
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
1 change: 1 addition & 0 deletions src/Illuminate/Notifications/Channels/MailChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ protected function buildView($message)
protected function additionalMessageData($notification)
{
return [
'__laravel_notification_id' => $notification->id,
'__laravel_notification' => get_class($notification),
'__laravel_notification_queued' => in_array(
ShouldQueue::class, class_implements($notification)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Notifications\Notifiable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use Mockery as m;
use Orchestra\Testbench\TestCase;

Expand Down Expand Up @@ -69,6 +70,7 @@ protected function setUp(): void
public function testMailIsSent()
{
$notification = new TestMailNotification;
$notification->id = Str::uuid()->toString();

$user = NotifiableUser::forceCreate([
'email' => '[email protected]',
Expand All @@ -80,6 +82,7 @@ public function testMailIsSent()
$this->mailer->shouldReceive('send')->once()->with(
['html' => 'htmlContent', 'text' => 'textContent'],
array_merge($notification->toMail($user)->toArray(), [
'__laravel_notification_id' => $notification->id,
'__laravel_notification' => get_class($notification),
'__laravel_notification_queued' => false,
]),
Expand Down Expand Up @@ -112,6 +115,7 @@ public function testMailIsSent()
public function testMailIsSentToNamedAddress()
{
$notification = new TestMailNotification;
$notification->id = Str::uuid()->toString();

$user = NotifiableUserWithNamedAddress::forceCreate([
'email' => '[email protected]',
Expand All @@ -124,6 +128,7 @@ public function testMailIsSentToNamedAddress()
$this->mailer->shouldReceive('send')->once()->with(
['html' => 'htmlContent', 'text' => 'textContent'],
array_merge($notification->toMail($user)->toArray(), [
'__laravel_notification_id' => $notification->id,
'__laravel_notification' => get_class($notification),
'__laravel_notification_queued' => false,
]),
Expand Down Expand Up @@ -156,6 +161,7 @@ public function testMailIsSentToNamedAddress()
public function testMailIsSentWithSubject()
{
$notification = new TestMailNotificationWithSubject;
$notification->id = Str::uuid()->toString();

$user = NotifiableUser::forceCreate([
'email' => '[email protected]',
Expand All @@ -167,6 +173,7 @@ public function testMailIsSentWithSubject()
$this->mailer->shouldReceive('send')->once()->with(
['html' => 'htmlContent', 'text' => 'textContent'],
array_merge($notification->toMail($user)->toArray(), [
'__laravel_notification_id' => $notification->id,
'__laravel_notification' => get_class($notification),
'__laravel_notification_queued' => false,
]),
Expand All @@ -189,6 +196,7 @@ public function testMailIsSentWithSubject()
public function testMailIsSentToMultipleAdresses()
{
$notification = new TestMailNotificationWithSubject;
$notification->id = Str::uuid()->toString();

$user = NotifiableUserWithMultipleAddreses::forceCreate([
'email' => '[email protected]',
Expand All @@ -200,6 +208,7 @@ public function testMailIsSentToMultipleAdresses()
$this->mailer->shouldReceive('send')->once()->with(
['html' => 'htmlContent', 'text' => 'textContent'],
array_merge($notification->toMail($user)->toArray(), [
'__laravel_notification_id' => $notification->id,
'__laravel_notification' => get_class($notification),
'__laravel_notification_queued' => false,
]),
Expand Down