title: PHPUnit: stub methods undefined
body: <p>I must be missing something. I'm trying to stub methods on a class in PHPUnit, but when I invoke the method on the mock object, it tells me that method is undefined.</p>
  
  <p>Example class to stub:</p>
  
  <pre><code>namespace MyApp;
  
  class MyStubClass 
  {
     public function mrMethod()
     {
       // doing stuff
     }   
  }
  </code></pre>
  
  <p>To stub it, I write:</p>
  
  <pre><code>// specifying all getMock() args to disable calling of class __construct()
  $stub = $this-&gt;getMock('MyStubClass', array(), array(), 'MockMyStubClass', false, false, false);
  $stub-&gt;expects($this-&gt;any())
       -&gt;method('mrMethod')
       -&gt;will($this-&gt;returnValue('doing stuff'));
  </code></pre>
  
  <p>But upon invoking the stubbed method, I get an exception:</p>
  
  <pre><code>$stub-&gt;mrMethod();
  //PHP Fatal error:  Call to undefined method MockMyStubClass::mrMethod()
  </code></pre>
  
  <p>I'm using PHPUnit 3.4.3 with PHP 5.3.0. </p>
  
  <p>Another small thing I noticed was that if specifying a namespace in the <code>getMock()</code> method results in a class loading exception because of a double namespace:</p>
  
  <pre><code>$stub = $this-&gt;getMock('MyApp\MyStubClass');
  // Fatal error:  Class 'MyApp\MyApp\MyStubClass' not found
  </code></pre>
  
  <p>That strikes me as rather odd (and getmock() will not accept a namespace with a leading backslash). The only thing I could think to cause that would may be because this class is
  registered with an autoloader?</p>
  
  <p>Any thoughts?</p>