From d6a12ce5f1d7debb29985897028db51615857f05 Mon Sep 17 00:00:00 2001 From: DarkAngelBGE Date: Wed, 22 Jul 2009 13:02:31 +0000 Subject: [PATCH] 2nd param init value for Router::stripPlugin(), improving router's coverage by adding tests for stripPlugin() git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8245 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/router.php | 3 +-- cake/tests/cases/libs/router.test.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 3707a56d7..f0cf13e50 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -1245,7 +1245,7 @@ class Router extends Object { * @access public * @static */ - function stripPlugin($base, $plugin) { + function stripPlugin($base, $plugin = null) { if ($plugin != null) { $base = preg_replace('/(?:' . $plugin . ')/', '', $base); $base = str_replace('//', '', $base); @@ -1258,7 +1258,6 @@ class Router extends Object { } return $base; } - /** * Strip escape characters from parameter values. * diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 08739db83..99d0e220d 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1655,5 +1655,20 @@ class RouterTest extends CakeTestCase { $expected = '/test/test_another_action/locale:badness'; $this->assertEqual($result, $expected); } +/** + * testStripPlugin + * + * @return void + * @access public + */ + function testStripPlugin() { + $pluginName = 'forums'; + $url = 'example.com/' . $pluginName . '/'; + $expected = 'example.com'; + + $this->assertEqual(Router::stripPlugin($url, $pluginName), $expected); + $this->assertEqual(Router::stripPlugin($url), $url); + $this->assertEqual(Router::stripPlugin($url, null), $url); + } } ?> \ No newline at end of file