Fixing string-based URL generation inside plugins (Ticket #2588)

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5123 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-05-20 01:40:34 +00:00
parent d2fb7d89ed
commit 540b1052d8
2 changed files with 20 additions and 1 deletions

View file

@ -555,7 +555,10 @@ class Router extends Object {
if (defined('CAKE_ADMIN') && isset($params[CAKE_ADMIN])) {
$output .= CAKE_ADMIN . '/';
}
$output .= strtolower($params['controller']) . '/' . $url;
if (!empty($params['plugin'])) {
$output .= Inflector::underscore($params['plugin']) . '/';
}
$output .= Inflector::underscore($params['controller']) . '/' . $url;
}
$output = str_replace('//', '/', $output);
}

View file

@ -158,6 +158,22 @@ class RouterTest extends UnitTestCase {
$this->assertEqual($result, $expected);
}
function testPluginUrlGeneration() {
$this->router->setRequestInfo(array(
array(
'controller' => 'controller', 'action' => 'index', 'form' => array(),
'url' => array (), 'bare' => 0, 'webservices' => null, 'plugin' => 'test'
),
array (
'base' => '/base', 'here' => '/clients/sage/portal/donations', 'webroot' => '/base/',
'passedArgs' => array (), 'argSeparator' => ':', 'namedArgs' => array (), 'webservices' => null
)
));
$this->assertEqual($this->router->url('read/1'), '/base/test/controller/read/1');
$this->router->reload();
}
function testUrlParsing() {
extract($this->router->getNamedExpressions());