From bbe05d5ffdd035ef1a6c4a69df4f641f84bf404c Mon Sep 17 00:00:00 2001 From: David Yell Date: Fri, 5 May 2017 10:19:23 +0100 Subject: [PATCH] Added a test for nested array data as a query in the url --- tests/TestCase/Http/Client/RequestTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/TestCase/Http/Client/RequestTest.php b/tests/TestCase/Http/Client/RequestTest.php index c5fe09b6ce0..0ccf86aeb61 100644 --- a/tests/TestCase/Http/Client/RequestTest.php +++ b/tests/TestCase/Http/Client/RequestTest.php @@ -62,6 +62,26 @@ public function testConstructorArrayData() $this->assertEquals('a=b&c=d', $request->body()); } + /** + * test nested array data for encoding of brackets, header and constructor + * + * @return void + */ + public function testConstructorArrayNestedData() + { + $headers = [ + 'Content-Type' => 'application/json', + 'Authorization' => 'Bearer valid-token', + ]; + $data = ['a' => 'b', 'c' => ['foo', 'bar']]; + $request = new Request('http://example.com', 'POST', $headers, $data); + + $this->assertEquals('http://example.com', $request->url()); + $this->assertEquals('POST', $request->getMethod()); + $this->assertEquals('application/x-www-form-urlencoded', $request->getHeaderLine('Content-Type')); + $this->assertEquals('a=b&c%5B0%5D=foo&c%5B1%5D=bar', $request->body()); + } + /** * test url method *