@@ -286,6 +286,25 @@ public function delete()
286286 $ this ->assertSame (['Content-Type ' => ['application/json ' ]], $ response ->getResponseHeaders ());
287287 }
288288
289+ /**
290+ * Verify behavior of startDelete when no id is given.
291+ *
292+ * @test
293+ * @covers ::startDelete
294+ *
295+ * @return void
296+ */
297+ public function deleteWithoutId ()
298+ {
299+ $ adapter = new DeleteAdapter ();
300+ $ authentication = Authentication::createClientCredentials ('not under test ' , 'not under test ' );
301+ $ client = new Client ($ adapter , $ authentication , 'baseUrl/v1 ' );
302+ $ client ->startDelete ('resource ' , null , ['foo ' => 'bar ' ]);
303+ $ this ->assertSame ('baseUrl/v1/resource ' , $ adapter ->request ->getUrl ());
304+ $ this ->assertSame ('DELETE ' , $ adapter ->request ->getMethod ());
305+ $ this ->assertSame (json_encode (['foo ' => 'bar ' ]), $ adapter ->request ->getBody ());
306+ }
307+
289308 /**
290309 * Verfiy delete creates the request body properly
291310 *
@@ -715,29 +734,29 @@ public function end($handle)
715734
716735final class DeleteAdapter implements Adapter
717736{
718- private $ _request ;
737+ public $ request ;
719738
720739 public function start (Request $ request )
721740 {
722- $ this ->_request = $ request ;
741+ $ this ->request = $ request ;
723742 }
724743
725744 public function end ($ handle )
726745 {
727- if (substr ($ this ->_request ->getUrl (), -5 ) === 'token ' ) {
746+ if (substr ($ this ->request ->getUrl (), -5 ) === 'token ' ) {
728747 return new Response (200 , ['Content-Type ' => ['application/json ' ]], ['access_token ' => 'a token ' , 'expires_in ' => 1 ]);
729748 }
730749
731750 if (
732- $ this ->_request ->getMethod () === 'DELETE ' &&
733- $ this ->_request ->getUrl () === 'baseUrl/v1/resource+name/the+id ' &&
734- $ this ->_request ->getHeaders () === [
751+ $ this ->request ->getMethod () === 'DELETE ' &&
752+ $ this ->request ->getUrl () === 'baseUrl/v1/resource+name/the+id ' &&
753+ $ this ->request ->getHeaders () === [
735754 'Content-Type ' => 'application/json ' ,
736755 'Accept-Encoding ' => 'gzip ' ,
737756 'Authorization ' => 'Bearer a token ' ,
738757 ]
739758 ) {
740- $ body = $ this ->_request ->getBody ();
759+ $ body = $ this ->request ->getBody ();
741760
742761 if ($ body === null || $ body === '{"the key":"the value"} ' ) {
743762 return new Response (204 , ['Content-Type ' => ['application/json ' ]]);
0 commit comments