title: PHPUnit and mocking dependencies
body: <p>I'm writing a test for the Service class. As you can see below, my Service class uses the Gateway class. I'd like to mock the output of <code>getSomething()</code> on the Gateway class in one of my tests.</p>
  <p>I tried with stubs (<code>createStub</code>) &amp; mocks (<code>getMockBuilder</code>), but PHPUnit does not produce the desired result.</p>
  <p><em>My classes:</em></p>
  <pre><code>&lt;?php
  
  class GatewayClass
  {
      private $client = null;
  
      public function __construct(Client $client)
      {
          $this-&gt;client = $client-&gt;getClient();
      }
  
      public function getSomething()
      {
          return 'something';
      }
  }
  
  </code></pre>
  <pre><code>&lt;?php
  
  class Service
  {
      private $gateway;
  
      public function __construct(Client $client)
      {
          $this-&gt;gateway = new Gateway($client);
      }
  
      public function getWorkspace()
      {
          return $this-&gt;gateway-&gt;getSomething();
      }
  }
  
  </code></pre>
  <p>(this project does not have a DI container yet)</p>