[Note: for all code samples on linked sites, follow the links for more detailed explanations.]
Returns different values
The current documentation suggests PHPUnit using a callback or onConsecutiveCalls():
$stub->expects($this->any())
->method('doSomething')
->will($this->returnCallback('str_rot13'));
$stub->expects($this->any())
->method('doSomething')
->will($this->onConsecutiveCalls(2, 3, 5, 7));
Expect a few options
with()may contain several parameters :
$observer->expects($this->once())
->method('reportError')
->with($this->greaterThan(0),
$this->stringContains('Something'),
$this->anything());
Check multiple calls
, ( PHPUnit, ), at() to :
$inputFile->expects($this->at(0))
->method('read')
->will($this->returnValue("3 4"));
$inputFile->expects($this->at(1))
->method('read')
->will($this->returnValue("4 6"));
$inputFile->expects($this->at(2))
->method('read')
->will($this->returnValue(NULL));