我似乎不能让邮件门面接受一个 ->with()
命令进行测试。
这是有效的:
Mail::shouldReceive('send')->once();
但是这个并不起作用:
Mail::shouldReceive('send')->with('emails.welcome')->once();
而这个也不行:
Mail::shouldReceive('send')->with('emails.welcome', array(), function(){})->once();
这个也不行:
Mail::shouldReceive('send')->with('emails.welcome', array(), function($message){})->once();
所有的都会给出以下错误:
"No matching handler found for Illuminate\Mail\Mailer::send("emails.welcome", Array, Closure)"
那么我如何测试邮件以检查它接收到了什么?
另外 - 对于额外的加分 - 是否有可能测试邮件在闭包内部执行的内容?也就是说,我可以检查$message->to()
设置为什么吗?
编辑:我的邮件代码:
Mail::send("emails.welcome", $data, function($message)
{
$message->to($data['email'], $data['name'])->subject('Welcome!');
});
m::mock('Illuminate\Mail\Message')
,否则不需要任何更改就可以工作! - MightyPork