Skip to content

Commit

Permalink
Merge pull request #694 from hkdobrev/test-query-params-subrequest
Browse files Browse the repository at this point in the history
Test query params are parsed correctly in both initial and subrequests
  • Loading branch information
acoulton committed Jul 23, 2016
2 parents 91b3ec5 + 2ce9e93 commit 0505301
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions tests/kohana/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ public function provider_query_parameter_parsing()
{
return array(
array(
new Request('foo/bar'),
'foo/bar',
array(
'foo' => 'bar',
'sna' => 'fu'
Expand All @@ -631,7 +631,7 @@ public function provider_query_parameter_parsing()
),
),
array(
new Request('foo/bar?john=wayne&peggy=sue'),
'foo/bar?john=wayne&peggy=sue',
array(
'foo' => 'bar',
'sna' => 'fu'
Expand All @@ -644,7 +644,7 @@ public function provider_query_parameter_parsing()
),
),
array(
new Request('http://host.tld/foo/bar?john=wayne&peggy=sue'),
'http://host.tld/foo/bar?john=wayne&peggy=sue',
array(
'foo' => 'bar',
'sna' => 'fu'
Expand All @@ -664,13 +664,41 @@ public function provider_query_parameter_parsing()
*
* @dataProvider provider_query_parameter_parsing
*
* @param Request request
* @param string url
* @param array query
* @param array expected
* @return void
*/
public function test_query_parameter_parsing(Request $request, $query, $expected)
public function test_query_parameter_parsing($url, $query, $expected)
{
Request::$initial = NULL;

$request = new Request($url);

foreach ($query as $key => $value)
{
$request->query($key, $value);
}

$this->assertSame($expected, $request->query());
}

/**
* Tests that query parameters are parsed correctly
*
* @dataProvider provider_query_parameter_parsing
*
* @param string url
* @param array query
* @param array expected
* @return void
*/
public function test_query_parameter_parsing_in_subrequest($url, $query, $expected)
{
Request::$initial = new Request(TRUE);

$request = new Request($url);

foreach ($query as $key => $value)
{
$request->query($key, $value);
Expand Down

0 comments on commit 0505301

Please sign in to comment.