title: PHPUnit - creating Mock objects to act as stubs for properties
body: <p>I'm trying to configure a Mock object in PHPunit to return values for different properties (that are accessed using the __get function)</p>
  
  <p>Example:</p>
  
  <pre><code>class OriginalObject {
   public function __get($name){
  switch($name)
   case "ParameterA":
    return "ValueA";
   case "ParameterB":
    return "ValueB";
   }
  }
  </code></pre>
  
  <p>I'm trying to mock this using:</p>
  
  <pre><code>$mockObject = $this-&gt;getMock("OrigionalObject");
  
  $mockObject    -&gt;expects($this-&gt;once())
      -&gt;method('__get')
      -&gt;with($this-&gt;equalTo('ParameterA'))
      -&gt;will($this-&gt;returnValue("ValueA"));
  
  $mockObject    -&gt;expects($this-&gt;once())
      -&gt;method('__get')
      -&gt;with($this-&gt;equalTo('ParameterB'))
      -&gt;will($this-&gt;returnValue("ValueB"));
  </code></pre>
  
  <p>but this fails horribly :-(</p>