@@ -131,4 +131,42 @@ public function testGetListRaisesServerExceptions()
131131
132132 $ this ->client ->backup ->getList ('johndoe ' );
133133 }
134+
135+ public function testCreate ()
136+ {
137+ $ this ->responses ->append (
138+ new Response (200 , [], json_encode ('Backup creation initiated ' )),
139+ );
140+
141+ $ result = $ this ->client ->backup ->create ('johndoe ' );
142+
143+ $ request = $ this ->responses ->getLastRequest ();
144+ $ this ->assertEquals ('POST ' , $ request ->getMethod ());
145+ $ this ->assertEquals ('/v2/app/johndoe/backup/ ' , $ request ->getUri ());
146+ $ this ->assertEquals ('Backup creation initiated ' , $ result );
147+ }
148+
149+ public function testCreateRaisesClientExceptions ()
150+ {
151+ $ badRequestResponse = new Response (400 , [], json_encode (
152+ 'Creating backups requires sla-standard to be enabled. '
153+ ));
154+ $ this ->responses ->append ($ badRequestResponse );
155+
156+ $ this ->expectExceptionObject (new HypernodeApiClientException ($ badRequestResponse ));
157+
158+ $ this ->client ->backup ->create ('johndoe ' );
159+ }
160+
161+ public function testCreateRaisesServerExceptions ()
162+ {
163+ $ badRequestResponse = new Response (500 , [], json_encode ([
164+ 'non_field_errors ' => ['Something went wrong processing your request. ' ]
165+ ]));
166+ $ this ->responses ->append ($ badRequestResponse );
167+
168+ $ this ->expectExceptionObject (new HypernodeApiServerException ($ badRequestResponse ));
169+
170+ $ this ->client ->backup ->create ('johndoe ' );
171+ }
134172}
0 commit comments