Skip to content
This repository
Browse code

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...
commit d6a12ce5f1d7debb29985897028db51615857f05 1 parent ecd0015
Tim Koschuetzki authored July 22, 2009
3  cake/libs/router.php
@@ -1245,7 +1245,7 @@ function currentRoute() {
1245 1245
  * @access public
1246 1246
  * @static
1247 1247
  */
1248  
-	function stripPlugin($base, $plugin) {
  1248
+	function stripPlugin($base, $plugin = null) {
1249 1249
 		if ($plugin != null) {
1250 1250
 			$base = preg_replace('/(?:' . $plugin . ')/', '', $base);
1251 1251
 			$base = str_replace('//', '', $base);
@@ -1258,7 +1258,6 @@ function stripPlugin($base, $plugin) {
1258 1258
 		}
1259 1259
 		return $base;
1260 1260
 	}
1261  
-
1262 1261
 /**
1263 1262
  * Strip escape characters from parameter values.
1264 1263
  *
15  cake/tests/cases/libs/router.test.php
@@ -1655,5 +1655,20 @@ function testRegexRouteMatching() {
1655 1655
 		$expected = '/test/test_another_action/locale:badness';
1656 1656
 		$this->assertEqual($result, $expected);
1657 1657
 	}
  1658
+/**
  1659
+ * testStripPlugin
  1660
+ *
  1661
+ * @return void
  1662
+ * @access public
  1663
+ */
  1664
+	function testStripPlugin() {
  1665
+		$pluginName = 'forums';
  1666
+		$url = 'example.com/' . $pluginName . '/';
  1667
+		$expected = 'example.com';
  1668
+
  1669
+		$this->assertEqual(Router::stripPlugin($url, $pluginName), $expected);
  1670
+		$this->assertEqual(Router::stripPlugin($url), $url);
  1671
+		$this->assertEqual(Router::stripPlugin($url, null), $url);
  1672
+	}
1658 1673
 }
1659 1674
 ?>

0 notes on commit d6a12ce

Please sign in to comment.
Something went wrong with that request. Please try again.