Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a test for nested array data as a query in the url
  • Loading branch information
David Yell committed May 5, 2017
1 parent e85bfda commit bbe05d5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/TestCase/Http/Client/RequestTest.php
Expand Up @@ -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
*
Expand Down

0 comments on commit bbe05d5

Please sign in to comment.