我一定遗漏了一些东西,但我遵循了本教程:http ://www.phpunit.de/manual/current/en/test-doubles.html
 <?php
    class SomeClass
    {
      public function doSomething()
      {
         // Do something.
         return 'bar';
      }
    }
 ?>
我的 StubTest 课程
class StubTest extends PHPUnit_Framework_TestCase
{
  public function testStub()
  {
    // Create a stub for the SomeClass class.
    $stub = $this->getMock('SomeClass');
    // Configure the stub.
    $stub->expects($this->any())
         ->method('doSomething')
         ->will($this->returnValue('foo'));
    // Calling $stub->doSomething() will now return
   $this->assertEquals('foo', $stub->doSomething());
  }
 }
 ?>
好吧,也许我遗漏了一些东西,但调用 doSomething 的预期价值不是吧?
如果我这样做$this->assertEquals('bar', $stub->doSomething());,它将失败。  
它似乎是基于->will($this->returnValue('foo'));