Fixing Router::reverse() not correctly working with Request objects that

contained query string parameters.
This commit is contained in:
mark_story 2011-01-20 21:20:23 -05:00
parent e64e29964d
commit 1c3e1df305
2 changed files with 7 additions and 2 deletions

View file

@ -1084,11 +1084,14 @@ class Router {
*/
public static function reverse($params) {
if ($params instanceof CakeRequest) {
$url = $params->query;
$params = $params->params;
} else {
$url = $params['url'];
}
$pass = $params['pass'];
$named = $params['named'];
$url = $params['url'];
unset(
$params['pass'], $params['named'], $params['paging'], $params['models'], $params['url'], $url['url'],
$params['autoRender'], $params['bare'], $params['requested'], $params['return']

View file

@ -2309,9 +2309,11 @@ class RouterTest extends CakeTestCase {
'action' => 'view',
'pass' => array(1),
'named' => array(),
'url' => array('url' => 'eng/posts/view/1')
));
$request->query = array('url' => 'eng/posts/view/1', 'test' => 'value');
$result = Router::reverse($request);
$expected = '/eng/posts/view/1?test=value';
$this->assertEquals($expected, $result);
}
/**