Skip to content
Permalink
Browse files

Fix for query parameters in integration test

  • Loading branch information...
Robbert Noordzij
Robbert Noordzij committed May 4, 2015
1 parent 62ad00c commit d59ac1bcc2b7b8ceb56f94dd6c95eead7a712108
Showing with 34 additions and 1 deletion.
  1. +22 −1 src/TestSuite/IntegrationTestCase.php
  2. +12 −0 tests/TestCase/TestSuite/IntegrationTestCaseTest.php
@@ -350,11 +350,13 @@ protected function _buildRequest($url, $method, $data)
$session = Session::create($sessionConfig);
$session->write($this->_session);
list ($url, $query) = $this->_url($url);
$props = [
'url' => Router::url($url),
'url' => $url,
'post' => $data,
'cookies' => $this->_cookie,
'session' => $session,
'query' => $query
];
$env = [];
if (isset($this->_request['headers'])) {
@@ -369,6 +371,25 @@ protected function _buildRequest($url, $method, $data)
return new Request($props);
}
/**
* Creates a valid request url and parameter array more like Request::_url()
*
* @param string|array $url The URL
* @return array Qualified URL and the query parameters
*/
protected function _url($url)
{
$url = Router::url($url);
$query = [];
if (strpos($url, '?') !== false) {
list($url, $parameters) = explode('?', $url, 2);
parse_str($parameters, $query);
}
return [$url, $query];
}
/**
* Fetches a view variable by name.
*
@@ -72,6 +72,18 @@ public function testRequestBuilding()
$this->assertEquals('bar', $request->env('PHP_AUTH_PW'));
}
/**
* Test building a request, with query parameters
*
* @return void
*/
public function testRequestBuildingQueryParameters()
{
$request = $this->_buildRequest('/tasks/view?archived=yes', 'GET', []);
$this->assertEquals('/tasks/view?archived=yes', $request->here());
$this->assertEquals('yes', $request->query('archived'));
}
/**
* Test sending get requests.
*

0 comments on commit d59ac1b

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