Phpunit检查方法调用顺序独立于其他调用
我想确保在其中一个mock中,两个方法按指定顺序调用:methodB()在methodA()之后调用。 我可以通过Phpunit检查方法调用顺序独立于其他调用,php,unit-testing,phpunit,Php,Unit Testing,Phpunit,我想确保在其中一个mock中,两个方法按指定顺序调用:methodB()在methodA()之后调用。 我可以通过->at()实现类似的功能,例如: $service->expects($this->at(0))->method('activate')->with( $this->equalTo($activationKey) )->willReturn(TRUE); $service->expects($this->at(1))->
->at()
实现类似的功能,例如:
$service->expects($this->at(0))->method('activate')->with(
$this->equalTo($activationKey)
)->willReturn(TRUE);
$service->expects($this->at(1))->method('getDetails')->with(
$this->equalTo($activationKey)
)->willReturn($details);
但如果代码后面的部分在activate()
之前添加了一些调用,测试将失败,我需要在at()
中输入幻数
在我的测试中,我不关心在这两种方法之前、之后或之间调用什么。我只是想确保
getDetails()
在activate()
之后被调用,我建议您看看phake,它允许您