@@ -198,4 +198,48 @@ public function testGetEavDescriptionsRaisesServerExceptions()
198198
199199 $ this ->client ->app ->getEavDescriptions ();
200200 }
201+
202+ public function testOrder ()
203+ {
204+ $ this ->responses ->append (
205+ new Response (201 , [], null ),
206+ );
207+
208+ $ orderData = [
209+ 'product_code ' => 'FALCON_M_202203 ' ,
210+ 'app_name ' => 'johndoe ' ,
211+ 'initial_app_configuration ' => 'magento_2 ' ,
212+ ];
213+ $ this ->client ->app ->order ($ orderData );
214+
215+ $ request = $ this ->responses ->getLastRequest ();
216+ $ this ->assertEquals ('POST ' , $ request ->getMethod ());
217+ $ this ->assertEquals ('/v2/app/order/ ' , $ request ->getUri ());
218+ $ this ->assertJson ((string )$ request ->getBody ());
219+ $ this ->assertEquals ($ orderData , json_decode ((string )$ request ->getBody (), true ));
220+ }
221+
222+ public function testOrderRaisesClientExceptions ()
223+ {
224+ $ badRequestResponse = new Response (400 , [], json_encode ([
225+ 'non_field_errors ' => ['Your request was invalid. ' ]
226+ ]));
227+ $ this ->responses ->append ($ badRequestResponse );
228+
229+ $ this ->expectExceptionObject (new HypernodeApiClientException ($ badRequestResponse ));
230+
231+ $ this ->client ->app ->order (['product_code ' => 'FALCON_M_202203 ' ]);
232+ }
233+
234+ public function testOrderRaisesServerExceptions ()
235+ {
236+ $ badRequestResponse = new Response (500 , [], json_encode ([
237+ 'non_field_errors ' => ['Something went wrong processing your request. ' ]
238+ ]));
239+ $ this ->responses ->append ($ badRequestResponse );
240+
241+ $ this ->expectExceptionObject (new HypernodeApiServerException ($ badRequestResponse ));
242+
243+ $ this ->client ->app ->order (['product_code ' => 'FALCON_M_202203 ' ]);
244+ }
201245}
0 commit comments