diff --git a/src/SeatsioClient.php b/src/SeatsioClient.php index 3b5eea3..fbe6729 100644 --- a/src/SeatsioClient.php +++ b/src/SeatsioClient.php @@ -109,6 +109,7 @@ function ($numRetries) { 'auth' => [$secretKey, null], 'http_errors' => false, 'handler' => $stack, + 'timeout' => 10, 'headers' => [ 'Accept-Encoding' => 'gzip', 'X-Client-Lib' => 'php' diff --git a/tests/SeatsioExceptionTest.php b/tests/SeatsioExceptionTest.php index 32e9757..47ea646 100644 --- a/tests/SeatsioExceptionTest.php +++ b/tests/SeatsioExceptionTest.php @@ -2,6 +2,10 @@ namespace Seatsio; +use GuzzleHttp\Client; +use GuzzleHttp\Handler\MockHandler; +use GuzzleHttp\Exception\ConnectException; +use GuzzleHttp\HandlerStack; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; @@ -23,4 +27,14 @@ public function testCanInstantiateSeatsioExceptionWithoutRequestId() self::assertNull($exception->requestId); self::assertStringStartsWith("GET http://dummy.uri resulted in a `400 Bad Request` response.", $exception->getMessage()); } + + public function testTimeoutThrowsSeatsioException() + { + $this->expectException(SeatsioException::class); + $this->expectExceptionMessage("Connection timed out"); + + $request = new Request("GET", "http://dummy.uri/charts"); + $connectException = new ConnectException("Connection timed out", $request); + throw SeatsioException::fromException($request, $connectException); + } }