Updating fix for empty parameter passing in Router; adding test case

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5470 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-07-27 13:32:26 +00:00
parent 1e141a567f
commit dee2ea4f68
2 changed files with 15 additions and 4 deletions

View file

@ -333,10 +333,10 @@ class Router extends Object {
break; //leave the default values;
} else {
// unnamed elements go in as 'pass'
$search = explode('/', $found);
foreach (Set::filter($search, true) as $k => $value) {
$out['pass'][$k] = $_this->stripEscape($value);
}
$out['pass'] = am($out['pass'], array_map(
array(&$_this, 'stripEscape'),
Set::filter(explode('/', $found), true)
));
}
}
break;

View file

@ -249,6 +249,17 @@ class RouterTest extends UnitTestCase {
$result = $this->router->parse('/posts/2007/08/01/title-of-post-here');
$expected = array('year' => '2007', 'month' => '08', 'day' => '01', 'controller' => 'posts', 'action' => 'view', 'plugin' =>'', 'pass' => array('0' => 'title-of-post-here'));
$this->assertEqual($result, $expected);
$this->router->routes = array();
$result = $this->router->parse('/pages/display/home');
$expected = array('pass' => array ('home'), 'controller' => 'pages', 'action' => 'display');
$this->assertEqual($result, $expected);
$result = $this->router->parse('pages/display/home/');
$this->assertEqual($result, $expected);
$result = $this->router->parse('pages/display/home');
$this->assertEqual($result, $expected);
}
function testAdminRouting() {