title: PHPUnit Mock Change the expectations later
body: <p>I have a simple use case.  I want to have a setUp method which will cause my mock object to return a default value:</p>
  
  <pre><code>$this-&gt;myservice
          -&gt;expects($this-&gt;any())
          -&gt;method('checkUniqueness')
          -&gt;will($this-&gt;returnValue(true));
  </code></pre>
  
  <p>But then in <strong>some</strong> tests, I want to return a different value:</p>
  
  <pre><code>$this-&gt;myservice
          -&gt;expects($this-&gt;exactly(1))
          -&gt;method('checkUniqueness')
          -&gt;will($this-&gt;returnValue(false));
  </code></pre>
  
  <p>I've used GoogleMock for C++ in the past and it had "returnByDefault" or something to handle that.  I couldn't figure out if this is possible in PHPUnit (there is no api documentation and the code is difficult to read through to find what I want).</p>
  
  <p>Now I can't just change <code>$this-&gt;myservice</code> to a new mock, because in setup, I pass it into other things that need to be mocked or tested.</p>
  
  <p>My only other solution is that I lose the benefit of the setup and instead have to build up all of my mocks for every test.</p>