Skip to content
Permalink
Browse files

Fix missing query arguments in array urls.

Adding documented features that previously wasn't implemented.

Fixes #3328
  • Loading branch information...
markstory committed Nov 2, 2012
1 parent 093275a commit 9ce70044b0d73e1a9fe52c28b8df454f0d3bebe7
Showing with 25 additions and 3 deletions.
  1. +7 −2 lib/Cake/Core/Object.php
  2. +18 −1 lib/Cake/Test/Case/Core/ObjectTest.php
@@ -73,9 +73,13 @@ public function requestAction($url, $extra = array()) {
$extra['autoRender'] = 1;
unset($extra[$index]);
}
if (is_array($url) && !isset($extra['url'])) {
$arrayUrl = is_array($url);
if ($arrayUrl && !isset($extra['url'])) {
$extra['url'] = array();
}
if ($arrayUrl && !isset($extra['data'])) {
$extra['data'] = array();
}
$extra = array_merge(array('autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1), $extra);
$data = isset($extra['data']) ? $extra['data'] : null;
unset($extra['data']);
@@ -88,11 +92,12 @@ public function requestAction($url, $extra = array()) {
} elseif (is_array($url)) {
$params = $url + array('pass' => array(), 'named' => array(), 'base' => false);
$params = array_merge($params, $extra);
$request = new CakeRequest(Router::reverse($params), false);
$request = new CakeRequest(Router::reverse($params));
}
if (isset($data)) {
$request->data = $data;
}
$dispatcher = new Dispatcher();
$result = $dispatcher->dispatch($request, new CakeResponse(), $extra);
Router::popRequest();
@@ -619,6 +619,24 @@ public function testRequestActionParamParseAndPass() {
$this->assertEquals($expected, $result['named']);
}
/**
* Test that requestAction handles get parameters correctly.
*
* @return void
*/
public function testRequestActionGetParameters() {
$result = $this->object->requestAction(
'/request_action/params_pass?get=value&limit=5'
);
$this->assertEquals('value', $result->query['get']);
$result = $this->object->requestAction(
array('controller' => 'request_action', 'action' => 'params_pass'),
array('url' => array('get' => 'value', 'limit' => 5))
);
$this->assertEquals('value', $result->query['get']);
}
/**
* test that requestAction does not fish data out of the POST
* superglobal.
@@ -632,7 +650,6 @@ public function testRequestActionNoPostPassing() {
'item' => 'value'
));
$result = $this->object->requestAction(array('controller' => 'request_action', 'action' => 'post_pass'));
$expected = null;
$this->assertEmpty($result);
$result = $this->object->requestAction(

0 comments on commit 9ce7004

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