在纯 PHPUnit 模拟中,我可以执行以下操作:
$mock->expects($this->at(0))
->method('isReady')
->will($this->returnValue(false));
$mock->expects($this->at(1))
->method('isReady')
->will($this->returnValue(true));
我无法使用 Prophecy 做同样的事情。是否可以?
最佳答案
您可以使用:
$mock->isReady()->willReturn(false, true);
显然它没有记录(见 https://gist.github.com/gquemener/292e7c5a4bbb72fd48a8 )。
关于php - 如何在 Prophecy 中模拟相同的方法,以便它在每次调用中返回不同的响应,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32336511/