title: How to mock chain of methods with PHPUnit test
body: <p>I'm trying to mock a chain (nested) of methods to return the desired value , this is the code : </p>
  
  <pre><code>public function __construct($db)
  {
  $this-&gt;db = $db;
  }
  
  public function getResults()
  {
  return $this-&gt;db-&gt;getFinder()-&gt;find($this-&gt;DBTable);
  }
  </code></pre>
  
  <p>I tried this mock but it does not work : </p>
  
  <pre><code>$dbMock = $this-&gt;createMock(DB::class);
          $dbMock = $dbMock
              -&gt;expects(self::any())
              -&gt;method('getFinder')
              -&gt;method('find')
              -&gt;with('questions')
              -&gt;will($this-&gt;returnValue('7'));
  </code></pre>
  
  <p>Any solutions how to solve such a problem ?</p>
  
  <p>Thank you .</p>