Phpunit检查方法独立于其他呼叫调用命令

时间:2015-10-05 15:38:04

标签: php unit-testing phpunit

我想确保,在其中一个模拟中,按指定的顺序调用两个方法:methodB()在 methodA()之后被称为。 我可以用->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()之后被称为

0 个答案:

没有答案