@@ -70,4 +70,56 @@ public function testGetListRaisesServerExceptions()
7070
7171 $ this ->client ->product ->getList ();
7272 }
73+
74+ public function testGetCurrent ()
75+ {
76+ $ product = [
77+ 'code ' => 'FALCON_S_202203 ' ,
78+ 'name ' => 'Falcon S ' ,
79+ 'backups_enabled ' => true ,
80+ 'is_development ' => false ,
81+ 'varnish_supported ' => true ,
82+ 'supports_sla ' => true ,
83+ 'price ' => 1234 ,
84+ 'currency ' => 'EUR ' ,
85+ 'flavor ' => [
86+ 'name ' => '2CPU/8GB/60GB (Falcon S 202202) ' ,
87+ 'redis_size ' => '1024 ' ,
88+ ],
89+ ];
90+ $ this ->responses ->append (
91+ new Response (200 , [], json_encode ($ product )),
92+ );
93+
94+ $ result = $ this ->client ->product ->getCurrent ('johndoe ' );
95+
96+ $ request = $ this ->responses ->getLastRequest ();
97+ $ this ->assertEquals ('GET ' , $ request ->getMethod ());
98+ $ this ->assertEquals ('/v2/product/app/johndoe/current/ ' , $ request ->getUri ());
99+ $ this ->assertEquals ($ product , $ result );
100+ }
101+
102+ public function testGetCurrentRaisesClientExceptions ()
103+ {
104+ $ badRequestResponse = new Response (400 , [], json_encode ([
105+ 'non_field_errors ' => ['Your request was invalid. ' ]
106+ ]));
107+ $ this ->responses ->append ($ badRequestResponse );
108+
109+ $ this ->expectExceptionObject (new HypernodeApiClientException ($ badRequestResponse ));
110+
111+ $ this ->client ->product ->getCurrent ('johndoe ' );
112+ }
113+
114+ public function testGetCurrentRaisesServerExceptions ()
115+ {
116+ $ badRequestResponse = new Response (500 , [], json_encode ([
117+ 'non_field_errors ' => ['Something went wrong processing your request. ' ]
118+ ]));
119+ $ this ->responses ->append ($ badRequestResponse );
120+
121+ $ this ->expectExceptionObject (new HypernodeApiServerException ($ badRequestResponse ));
122+
123+ $ this ->client ->product ->getCurrent ('johndoe ' );
124+ }
73125}
0 commit comments