title: Is it possible, using PHPUnit mock objects, to expect a call to a magic __call() method?
body: <p>I've got a mock object in a test. The real object, PageRepository, implements a magic method using __call(), so if you call $pageRepository->findOneByXXXX($value_of_field_XXXX), it will search the database for records matching that parameter. </p>
  
  <p>Is there a way to mock that method?</p>
  
  <p>The real method call would look something like this:</p>
  
  <pre><code>$homepage = $pageRepository-&gt;findOneBySlug('homepage');
  </code></pre>
  
  <p>The test would look like this:</p>
  
  <pre><code>$mockPageRepository-&gt;expects($this-&gt;any())
      -&gt;method('findOneBySlug')
      -&gt;will($this-&gt;returnValue(new Page()));
  </code></pre>
  
  <p>But it doesn't work -- PHPUnit doesn't spot the method call. The only way to get it to see the method is to define the method explicitly in PageRepository.</p>