I am using Guzzle 5.3 and want to test that my client throws a TimeOutException
.
Then, How can I do a mock of Guzzle Client that throw a GuzzleHttp\Exception\ConnectException
?
Code to test.
try {
/** @noinspection PhpVoidFunctionResultUsedInspection */
/** @var \GuzzleHttp\Message\ResponseInterface $response */
$response = $this->httpClient->post($path, ['body' => $requestData]);
} catch (ConnectException $e) {
throw new Vendor\Client\TimeOutException();
}
Aucun commentaire:
Enregistrer un commentaire