问题描述
我正在尝试测试发送验证电子邮件。该API工作正常,并且电子邮件已成功发送,但是问题出在测试中。
我正在模拟通知,并试图断言该通知已发送。
这是我的测试功能:
public function a_verification_email_is_sent_upon_registration()
{
Notification::fake();
$userData = factory('App\Models\User')->make(['email_verified_at' => null]);
$this->post(route('api.register'),$userData);
Notification::assertSentTo(User::latest()->first(),VerifyEmail::class);
}
我得到的错误是:
预期的[Illuminate \ Auth \ Notifications \ VerifyEmail]通知未发送。
一切正常,用户注册成功,并且我测试了Registered事件正在分派并且确实可以。因此,它应该发送通知,因为根据EventServiceProvider.php中的此映射,SendEmailVerificationNotification是Registered事件的侦听器。
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
Registered::class => [
SendEmailVerificationNotification::class,],];
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)