title: Mock objects which support chaining methods
body: <p>I'm wondering if there's a fairly concise way of mocking objects which support chaining of methods... so for example, a database query object might have a method call that looks like this:</p>
  
  <pre><code>$result = $database-&gt;select('my_table')-&gt;where(array('my_field'=&gt;'a_value'))-&gt;limit(1)-&gt;execute();
  </code></pre>
  
  <p>The problem comes if I have to mock two different select queries so that they return different results. Any ideas?</p>
  
  <p>This is specifically about PHPUnit, but experiences from other unit testing frameworks will help.</p>