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.8] Notification fake accepts custom channels #28969

merged 1 commit into from Jun 27, 2019


None yet
2 participants
Copy link

commented Jun 27, 2019

When dispatching notifications now you have the option to pass in the channels you want to deliver that notification - overriding the channels returned from the notification's via method.

Unfortunately the NotificationFake doesn't support this use case - and it records the notifications having been sent over their default channels instead. This means that you cannot test that the notification was sent over the given channel instead.

This change is simply reflecting the implementation in NotificationSender into the fake.


$user->notify(new MessageReceived($message), [NexmoVoiceChannel::class]);

Notification::assertSentTo($user, MessageReceived::class, function ($notification, $channels) {
    return $channels[0] === NexmoVoiceChannel::class;

For some additional context, my use-case is that the notification is usually delivered by email/text however a user might want to receive it via a phone call instead. An alternative approach might be to pass that in through the notification's constructor instead but that felt a little odd.

@dwightwatson dwightwatson changed the title Notification fake accepts custom channels [5.8] Notification fake accepts custom channels Jun 27, 2019

@taylorotwell taylorotwell merged commit 896906b into laravel:5.8 Jun 27, 2019

2 checks passed

continuous-integration/styleci/pr The analysis has passed
continuous-integration/travis-ci/pr The Travis CI build passed

@dwightwatson dwightwatson deleted the dwightwatson:notification-fake branch Jun 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.