Permalink
Browse files

Make sure that the core required routing parameters are set.

requestAction() should set the default routing parameters when the array
form is used.

Refs #7045
  • Loading branch information...
markstory committed Jul 24, 2015
1 parent 123ee79 commit 8de4c014d2b4c9301474284231b510ed1d2e92c9
@@ -118,8 +118,9 @@ public function requestAction($url, array $extra = [])
'url' => $url
];
} elseif (is_array($url)) {
$defaultParams = ['plugin' => null, 'controller' => null, 'action' => null];
$params = [
'params' => $url,
'params' => $url + $defaultParams,
'base' => false,
'url' => Router::reverse($url)
];
@@ -194,6 +194,22 @@ public function testRequestActionArray()
$this->assertNull($result);
}
/**
* Test that the required parameter names are seeded by requestAction.
*
* @return void
*/
public function testRequestActionArraySetParamNames()
{
$result = $this->object->requestAction(
['controller' => 'RequestAction', 'action' => 'params_pass']
);
$result = json_decode($result, true);
$this->assertArrayHasKey('action', $result['params']);
$this->assertArrayHasKey('controller', $result['params']);
$this->assertArrayHasKey('plugin', $result['params']);
}
/**
* Test that requestAction() does not forward the 0 => return value.
*
@@ -116,6 +116,7 @@ public function query_pass()
public function params_pass()
{
$this->response->body(json_encode([
'params' => $this->request->params,
'base' => $this->request->base,
'webroot' => $this->request->webroot,
'params' => $this->request->params,

0 comments on commit 8de4c01

Please sign in to comment.