【发布时间】:2020-08-28 18:46:02
【问题描述】:
帮助我编写单元测试存根,用于发送或不发送松弛通知。在一个批次的执行中,如果发生错误,我会在松弛通道中发送错误。
【问题讨论】:
标签: laravel notifications phpunit slack
帮助我编写单元测试存根,用于发送或不发送松弛通知。在一个批次的执行中,如果发生错误,我会在松弛通道中发送错误。
【问题讨论】:
标签: laravel notifications phpunit slack
在测试中你应该使用 MockApplicationServices trait。它的工作原理与 the documented event mocking.
用法是:
$this->expectsNotification($notifiable, $notification);
// eg.
$this->expectsNotification($user, UpperLimitExceeded::class);
还有 $this->withoutNotifications() 可以跳过任何遇到的通知。
【讨论】: