I'm trying to create a mock instance in setUp with default values for all of the overridden methods and then in several different tests change the return value for some of the methods depending on what I'm testing without having to set up the entire Mock. Is there a way to do this?
This is what I tried, but the naive approach doesn't work. The method still returns the value from the original expectation setup.
First setup:
$my_mock->expects($this->any())
->method('one_of_many_methods')
->will($this->returnValue(true));
In another test before a different assert:
$my_mock->expects($this->any())
->method('one_of_many_methods')
->will($this->returnValue(false));
Duplicate to this question: PHPUnit Mock Change the expectations later, but that one got no responses and I thought a new question might bring the issue to the fore.