Permalink
Browse files

2nd param init value for Router::stripPlugin(), improving router's co…

…verage by adding tests for stripPlugin()

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8245 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
1 parent ecd0015 commit d6a12ce5f1d7debb29985897028db51615857f05 @tim-kos tim-kos committed Jul 22, 2009
Showing with 16 additions and 2 deletions.
  1. +1 −2 cake/libs/router.php
  2. +15 −0 cake/tests/cases/libs/router.test.php
View
3 cake/libs/router.php
@@ -1245,7 +1245,7 @@ function currentRoute() {
* @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 @@ function stripPlugin($base, $plugin) {
}
return $base;
}
-
/**
* Strip escape characters from parameter values.
*
View
15 cake/tests/cases/libs/router.test.php
@@ -1655,5 +1655,20 @@ function testRegexRouteMatching() {
$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);
+ }
}
?>

0 comments on commit d6a12ce

Please sign in to comment.