Skip to content

Commit

Permalink
Fixing issue in Router where generating plugin shortcut controller ro…
Browse files Browse the repository at this point in the history
…utes with admin prefixes left a :controller param behind. Fixes #6252

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8235 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
markstory committed Jul 17, 2009
1 parent 76d5855 commit 74fd484
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/router.php
Expand Up @@ -1082,7 +1082,7 @@ function __mapRoute($route, $params = array()) {
if (isset($params[$key])) {
$string = $params[$key];
unset($params[$key]);
} else {
} elseif (strpos($out, $key) != strlen($out) - strlen($key)) {
$key = $key . '/';
}
$out = str_replace(':' . $key, $string, $out);
Expand Down
22 changes: 22 additions & 0 deletions cake/tests/cases/libs/router.test.php
Expand Up @@ -1036,6 +1036,28 @@ function testAdminRouting() {
$result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => 'var=test&var2=test2'));
$expected = '/beheer/posts/index/0?var=test&var2=test2';
$this->assertEqual($result, $expected);

Configure::write('Routing.admin', 'admin');
$paths = Configure::read('pluginPaths');
Configure::write('pluginPaths', array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
));
Configure::write('__objects.plugin', array('test_plugin'));

Router::reload();
Router::setRequestInfo(array(
array('admin' => true, 'controller' => 'controller', 'action' => 'action',
'form' => array(), 'url' => array(), 'plugin' => null),
array('base' => '/', 'here' => '/', 'webroot' => '/base/', 'passedArgs' => array(),
'argSeparator' => ':', 'namedArgs' => array())
));
Router::parse('/');

$result = Router::url(array('plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index'));
$expected = '/admin/test_plugin';
$this->assertEqual($result, $expected);

Configure::write('pluginPaths', $paths);
}
/**
* testExtensionParsingSetting method
Expand Down

0 comments on commit 74fd484

Please sign in to comment.