@@ -122,4 +122,44 @@ public function testCreateRaisesServerExceptions()
122122
123123 $ this ->client ->whitelist ->create ('johndoe ' , ['ip ' => '1.2.3.4 ' ]);
124124 }
125+
126+ public function testDelete ()
127+ {
128+ $ this ->responses ->append (
129+ new Response (204 , [], null ),
130+ );
131+
132+ $ entryData = ['ip ' => '1.2.3.4 ' , 'type ' => 'waf ' ];
133+ $ this ->client ->whitelist ->delete ('johndoe ' , $ entryData );
134+
135+ $ request = $ this ->responses ->getLastRequest ();
136+ $ this ->assertEquals ('DELETE ' , $ request ->getMethod ());
137+ $ this ->assertEquals ('/v2/whitelist/johndoe/ ' , $ request ->getUri ());
138+ $ this ->assertJson ((string )$ request ->getBody ());
139+ $ this ->assertEquals ($ entryData , json_decode ((string )$ request ->getBody (), true ));
140+ }
141+
142+ public function testDeleteRaisesClientExceptions ()
143+ {
144+ $ badRequestResponse = new Response (400 , [], json_encode ([
145+ 'non_field_errors ' => ['Your request was invalid. ' ]
146+ ]));
147+ $ this ->responses ->append ($ badRequestResponse );
148+
149+ $ this ->expectExceptionObject (new HypernodeApiClientException ($ badRequestResponse ));
150+
151+ $ this ->client ->whitelist ->delete ('johndoe ' , ['ip ' => '1.2.3.4 ' ]);
152+ }
153+
154+ public function testDeleteRaisesServerExceptions ()
155+ {
156+ $ badRequestResponse = new Response (500 , [], json_encode ([
157+ 'non_field_errors ' => ['Something went wrong processing your request. ' ]
158+ ]));
159+ $ this ->responses ->append ($ badRequestResponse );
160+
161+ $ this ->expectExceptionObject (new HypernodeApiServerException ($ badRequestResponse ));
162+
163+ $ this ->client ->whitelist ->delete ('johndoe ' , ['ip ' => '1.2.3.4 ' ]);
164+ }
125165}
0 commit comments