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
This commit is contained in:
DarkAngelBGE 2009-07-22 13:02:31 +00:00
parent ecd001547d
commit d6a12ce5f1
2 changed files with 16 additions and 2 deletions

View file

@ -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.
*

View file

@ -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);
}
}
?>