title: Unit test: Simulate a timeout with Guzzle 5
body: <p>I am using <strong>Guzzle 5.3</strong> and want to test that my client throws a <code>TimeOutException</code>. </p>
  
  <p>Then, how can I do a mock of Guzzle Client that throw a <code>GuzzleHttp\Exception\ConnectException</code>?</p>
  
  <p>Code to test.</p>
  
  <pre><code>public function request($namedRoute, $data = [])
  {
      try {
          /** @noinspection PhpVoidFunctionResultUsedInspection */
          /** @var \GuzzleHttp\Message\ResponseInterface $response */
          $response =  $this-&gt;httpClient-&gt;post($path, ['body' =&gt; $requestData]);
      } catch (ConnectException $e) {
          throw new \Vendor\Client\TimeOutException();
      }
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>The right question was: how to throw a Exception with Guzzle 5? or, how to test a catch block with Guzzle 5?</p>