Skip to content
Permalink
Browse files

Added a test for nested array data as a query in the url

  • Loading branch information...
davidyell committed May 5, 2017
1 parent e85bfda commit bbe05d5ffdd035ef1a6c4a69df4f641f84bf404c
Showing with 20 additions and 0 deletions.
  1. +20 −0 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
*

0 comments on commit bbe05d5

Please sign in to comment.
You can’t perform that action at this time.