diff --git a/tests/unit/ClientTest.php b/tests/unit/ClientTest.php index c1df3f4..654ece1 100644 --- a/tests/unit/ClientTest.php +++ b/tests/unit/ClientTest.php @@ -3,9 +3,13 @@ namespace TK\Test\Unit; +use TK\SDK\Exception\RequestException; +use TK\SDK\Client; use TK\SDK\ValueObject\Factory\RetrieveReservationDetailParametersFactory; use TK\SDK\ClientBuilder; +use TK\Test\Unit\Resources\ExampleEndpoint; use Dotenv; +use ReflectionMethod; class ClientTest extends \Codeception\Test\Unit { @@ -14,6 +18,9 @@ class ClientTest extends \Codeception\Test\Unit */ protected $tester; + /** + * @var Client + */ private $client; protected function _before() @@ -67,4 +74,17 @@ public function shouldThrowExceptionForInvalidArgument() : void { $this->client->retrieveReservationDetail([]); } + + /** + * @test + * @expectedException \TK\SDK\Exception\RequestException + */ + public function shouldThrowExceptionForGuzzleRequestError() : void + { + $endpoint = new ExampleEndpoint(); + + $httpRequest = new ReflectionMethod($this->client, 'httpRequest'); + $httpRequest->setAccessible(true); + $httpRequest->invoke($this->client, $endpoint); + } } diff --git a/tests/unit/Resources/ExampleEndpoint.php b/tests/unit/Resources/ExampleEndpoint.php new file mode 100644 index 0000000..08070e1 --- /dev/null +++ b/tests/unit/Resources/ExampleEndpoint.php @@ -0,0 +1,17 @@ +endpoint = '/nonExistedEndpoint'; + $this->responseRoot = 'none'; + $this->queryParameters = []; + } +}