title: How to deep mock a class which support chaining methods
body: <p>I'm trying to unit test a controller where I have <code>$this-&gt;library-&gt;client-&gt;changeLog-&gt;create()</code> and I'm wondering if I need to mock each of these properties or if I can just somehow deep mock <code>$this-&gt;library</code> so I don't have to have a long chain of objects being mocked and have to worry about their constructor parameters as well.  I'm trying to mock a chain right now and it's very ugly and not working very well.</p>
  
  <p>I also tried <code>$this-&gt;library-&gt;shouldReceive('client-&gt;changeLog-&gt;create')-&gt;once()-&gt;andReturn(true);</code> but it leads to a "trying to get property of a non-object.</p>
  
  <p>Is there a simple way to test the output the output of a method that's a few properties deep?</p>