I’m wondering how to go about testing this. Say I have a getter method, and I change the value in the process of a method. Here’s a simple example:
public function foo($model)
{
var_dump($model->state());
$model->state('saved');
var_dump($model->state());
}
I mock the model like so:
$model = $this->getMock('Model');
$model->expects($this->any))
->method('state')
->will($this->returnValue('new'));
How should I setup the mock so that the second call returns a different value (saved)?
http://www.phpunit.de/manual/3.6/en/test-doubles.html#test-doubles.mock-objects
Plus you can additionally check with
with()that the parameter passed equals tosavedPS: this will work for
For your code you need to set up 3 mock calls, not 2