我想模拟一个方法,该方法A在第一次调用B时返回,第二次调用时返回,所有后续调用都将返回C。我假设我可以使用$this->any()并$this->at()获得期望的期望,但它似乎$this->any()总是优先。
// calls to foo() will always return 'C' even after the following setup
$this->expects($this->any())->method('foo')->will($this->returnValue('C'));
$this->expects($this->at(0))->method('foo')->will($this->returnValue('A'));
$this->expects($this->at(1))->method('foo')->will($this->returnValue('B'));
有没有办法做到这一点?