Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure that the core required routing parameters are set. #7108

Merged
merged 1 commit into from Jul 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Routing/RequestActionTrait.php
Expand Up @@ -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)
];
Expand Down
16 changes: 16 additions & 0 deletions tests/TestCase/Routing/RequestActionTraitTest.php
Expand Up @@ -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.
*
Expand Down
Expand Up @@ -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,
Expand Down