With PHPUnit, I test the sequence of method calls using β at (), for example:
$mock->expects($this->at(0))->method('execute')->will($this->returnValue('foo')); $mock->expects($this->at(1))->method('execute')->will($this->returnValue('bar')); $mock->expects($this->at(2))->method('execute')->will($this->returnValue('baz'));
How can I customize the layout, so that in the case described above, if execute () is called four or more times, it will immediately fail? I tried this:
$mock->expects($this->at(3))->method('execute')->will($this->throwException(new Exception('Called too many times.')));
But this also fails if execute () is not called four times. He must immediately otherwise, the system under test will create its own errors, which will lead to an unclear error message.
source share