From 540b1052d8235872885fd9dae6f954fe434efe95 Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 20 May 2007 01:40:34 +0000 Subject: [PATCH] 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 --- cake/libs/router.php | 5 ++++- cake/tests/cases/libs/router.test.php | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 668bb748d..3c1187fba 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -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); } diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index b74b92344..cd404dccd 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -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());