mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 10:36:16 +00:00
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:
parent
ecd001547d
commit
d6a12ce5f1
2 changed files with 16 additions and 2 deletions
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue