title: PHPUnit and mock request from Guzzle
body: <p>I have a class with the following function :</p>
  
  <pre><code>public function get(string $uri) : stdClass
  {
      $this-&gt;client = new Client;
      $response = $this-&gt;client-&gt;request(
          'GET',
          $uri,
          $this-&gt;headers
      );
  
      return json_decode($response-&gt;getBody());
  }
  </code></pre>
  
  <p>How can I mock the request method from PHPUnit? I tried different ways but it always tries to connect to the uri specified.</p>
  
  <p>I tried with :</p>
  
  <pre><code>    $clientMock = $this-&gt;getMockBuilder('GuzzleHttp\Client')
          -&gt;setMethods('request')
          -&gt;getMock();
  
      $clientMock-&gt;expects($this-&gt;once())
          -&gt;method('request')
          -&gt;willReturn('{}');
  </code></pre>
  
  <p>But this didn't work. What can I do? I just need to mock the response to be empty.</p>
  
  <p>Thanks</p>
  
  <p>PD : Client comes from (use GuzzleHttp\Client)</p>