How can I get PHPUnit MockObjects to return different values based on a parameter?
问题 I've got a PHPUnit mock object that returns 'return value' no matter what its arguments: // From inside a test... $mock = $this->getMock('myObject', 'methodToMock'); $mock->expects($this->any)) ->method('methodToMock') ->will($this->returnValue('return value')); What I want to be able to do is return a different value based on the arguments passed to the mock method. I've tried something like: $mock = $this->getMock('myObject', 'methodToMock'); // methodToMock('one') $mock->expects($this->any