From 566ab3fc705f319fc44b959f7a60583b935c3fbe Mon Sep 17 00:00:00 2001 From: Linus Metzler Date: Tue, 3 Oct 2017 21:16:58 +0200 Subject: [PATCH 1/2] Don't run json_encode Guzzle takes care of this thanks to its JSON middleware --- src/Adapter/Guzzle.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/Adapter/Guzzle.php b/src/Adapter/Guzzle.php index 205ff846..bdbddcde 100644 --- a/src/Adapter/Guzzle.php +++ b/src/Adapter/Guzzle.php @@ -67,13 +67,11 @@ public function post(String $uri, array $headers = [], array $body = []): Respon */ public function put(String $uri, array $headers = [], array $body = []): ResponseInterface { - $jsonBody = json_encode($body); - $response = $this->client->put( $uri, [ 'headers' => $headers, - 'json' => $jsonBody + 'json' => $body ] ); @@ -86,13 +84,11 @@ public function put(String $uri, array $headers = [], array $body = []): Respons */ public function patch(String $uri, array $headers = [], array $body = []): ResponseInterface { - $jsonBody = json_encode($body); - $response = $this->client->patch( $uri, [ 'headers' => $headers, - 'json' => $jsonBody + 'json' => $body ] ); From 70ee68f755bcebf1b2ef18a4876183e7b5d857e6 Mon Sep 17 00:00:00 2001 From: Linus Metzler Date: Thu, 5 Oct 2017 14:44:09 +0200 Subject: [PATCH 2/2] fix the test --- tests/Adapter/GuzzleTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Adapter/GuzzleTest.php b/tests/Adapter/GuzzleTest.php index a5e16e00..ba4d58ef 100644 --- a/tests/Adapter/GuzzleTest.php +++ b/tests/Adapter/GuzzleTest.php @@ -58,7 +58,7 @@ public function testPut() $this->assertEquals("application/json", $headers["Content-Type"][0]); $body = json_decode($response->getBody()); - $this->assertEquals("Testing a PUT request.", json_decode($body->json)->{"X-Put-Test"}); + $this->assertEquals("Testing a PUT request.", $body->json->{"X-Put-Test"}); } public function testPatch() @@ -73,7 +73,7 @@ public function testPatch() $this->assertEquals("application/json", $headers["Content-Type"][0]); $body = json_decode($response->getBody()); - $this->assertEquals("Testing a PATCH request.", json_decode($body->json)->{"X-Patch-Test"}); + $this->assertEquals("Testing a PATCH request.", $body->json->{"X-Patch-Test"}); } public function testDelete()