So I've got a test set up that visits the sign up page and submits the form. Then the test verifies the account by token.
Once the account has been verified, a notification is sent through a SlackMessage
.
What I was wondering is how can I intercept this, and stop the slack message from actually sending - only when running a test, but get some kind of confirmation that the notification did in fact get called.
I found an undocumented method expectsNotifications() in the Laravel 5.3 MockApplicationServices trait. It works pretty much the same as the documented event mocking.
Usage is:
$this->expectsNotification($notifiable, $notification);
// eg.
$this->expectsNotification($user, UpperLimitExceeded::class);
There is also $this->withoutNotifications() to skip over any encountered notifications.
If you need to skip sending all notifications, put the following line at the beginning of your test method:
$this->withoutNotifications();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With