title: Can I change a method on a PHPUnit Mock after I've set it?
body: <p>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?</p>
  
  <p>This is what I tried, but the naive approach doesn't work. The method still returns the value from the original expectation setup.</p>
  
  <p>First setup:</p>
  
  <pre><code>$my_mock-&gt;expects($this-&gt;any())
          -&gt;method('one_of_many_methods')
          -&gt;will($this-&gt;returnValue(true));
  </code></pre>
  
  <p>In another test before a different assert:</p>
  
  <pre><code>$my_mock-&gt;expects($this-&gt;any())
          -&gt;method('one_of_many_methods')
          -&gt;will($this-&gt;returnValue(false));
  </code></pre>
  
  <p>Duplicate to this question: <a href="https://stackoverflow.com/questions/10165831/phpunit-mock-change-the-expectations-later">PHPUnit Mock Change the expectations later</a>, but that one got no responses and I thought a new question might bring the issue to the fore.</p>