Laravel 5.3 - 避免在phpunit测试中发送松弛通知

Pis*_*hio 6 php laravel laravel-5 laravel-5.3

所以我有一个测试设置,访问注册页面并提交表单.然后,测试通过令牌验证帐户.

帐户验证后,会通过帐户发送通知 SlackMessage.

我想知道的是我如何拦截这一点,并阻止实际发送的松弛消息 - 仅在运行测试时,但获得某种确认通知实际上被调用的确认.

whe*_*ler 9

我在Laravel 5.3 MockApplicationServices特性中找到了一个未记录的方法expectedNotifications().它的工作原理与记录的事件模拟非常相似.

用法是:

$this->expectsNotification($notifiable, $notification);

// eg.
$this->expectsNotification($user, UpperLimitExceeded::class);
Run Code Online (Sandbox Code Playgroud)

还有$ this-> withoutNotifications()来跳过任何遇到的通知.