我有一个有趣的问题。执行时...
$lenderMailer->shouldReceive('sendDonationMail')->once();我的测试通过了,没有问题。但是,如果我尝试:
$lenderMailer->shouldReceive('sendDonationMail')->once()->with(\Mockery::on(function(){
return true;
}));我要买一台NoMatchingExpectationException。sendDonationMail方法的签名是
public function sendDonationMail(Lender $lender, Money $donationAmount)你知道为什么会抛出异常吗?
发布于 2016-08-21 11:40:20
您必须为所有参数设置期望,目前您仅使用闭包验证$lender参数。
例如,这应该是可行的:
$lenderMailer->shouldReceive('sendDonationMail')->once()->with(\Mockery::on(function(){ return true; }), \Mockery::any());https://stackoverflow.com/questions/39041295
复制相似问题