Permalink
Browse files

Fixing issue in Router where generating plugin shortcut controller ro…

…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...
1 parent 76d5855 commit 74fd4849ba8e37ed7974a02bf7b9b40761ea7531 @markstory markstory committed Jul 17, 2009
Showing with 23 additions and 1 deletion.
  1. +1 −1 cake/libs/router.php
  2. +22 −0 cake/tests/cases/libs/router.test.php
View
2 cake/libs/router.php
@@ -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);
View
22 cake/tests/cases/libs/router.test.php
@@ -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

0 comments on commit 74fd484

Please sign in to comment.