File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 33
44namespace TK \Test \Unit ;
55
6+ use TK \SDK \Exception \RequestException ;
7+ use TK \SDK \Client ;
68use TK \SDK \ValueObject \Factory \RetrieveReservationDetailParametersFactory ;
79use TK \SDK \ClientBuilder ;
10+ use TK \Test \Unit \Resources \ExampleEndpoint ;
811use Dotenv ;
12+ use ReflectionMethod ;
913
1014class ClientTest extends \Codeception \Test \Unit
1115{
@@ -14,6 +18,9 @@ class ClientTest extends \Codeception\Test\Unit
1418 */
1519 protected $ tester ;
1620
21+ /**
22+ * @var Client
23+ */
1724 private $ client ;
1825
1926 protected function _before ()
@@ -67,4 +74,17 @@ public function shouldThrowExceptionForInvalidArgument() : void
6774 {
6875 $ this ->client ->retrieveReservationDetail ([]);
6976 }
77+
78+ /**
79+ * @test
80+ * @expectedException \TK\SDK\Exception\RequestException
81+ */
82+ public function shouldThrowExceptionForGuzzleRequestError () : void
83+ {
84+ $ endpoint = new ExampleEndpoint ();
85+
86+ $ httpRequest = new ReflectionMethod ($ this ->client , 'httpRequest ' );
87+ $ httpRequest ->setAccessible (true );
88+ $ httpRequest ->invoke ($ this ->client , $ endpoint );
89+ }
7090}
Original file line number Diff line number Diff line change 1+ <?php
2+ declare (strict_types=1 );
3+
4+ namespace TK \Test \Unit \Resources ;
5+
6+ use TK \SDK \Endpoint \EndpointAbstract ;
7+ use TK \SDK \Endpoint \EndpointInterface ;
8+
9+ class ExampleEndpoint extends EndpointAbstract implements EndpointInterface
10+ {
11+ public function __construct ()
12+ {
13+ $ this ->endpoint = '/nonExistedEndpoint ' ;
14+ $ this ->responseRoot = 'none ' ;
15+ $ this ->queryParameters = [];
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments