Mock in PHPUnit - multiple configuration of the same method with different arguments


Is it possible to configure PHPUnit mock in this way?

$context = $this->getMockBuilder('Context')

   ->will($this->returnValue(new Matcher()));

   ->will($this->returnValue(new Logger()));

I use PHPUnit 3.5.10 and it fails when I ask for Matcher because it expects "Logger" argument. It is like the second expectation is rewriting the first one, but when I dump the mock, everything looks ok.

As of PHPUnit 3.6, there is $this->returnValueMap() which may be used to return different values depending on the given parameters to the method stub.