Adding fix for #2452 (patch from #2476).

Added tests for ticket #2452

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4927 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-04-29 11:10:11 +00:00
parent 2baa585437
commit d861587960
2 changed files with 13 additions and 1 deletions

View file

@ -503,7 +503,7 @@ class Router extends Object {
$args[] = $url[$keys[$i]];
} else if(!empty($path['namedArgs']) && in_array($keys[$i], array_keys($path['namedArgs'])) && !empty($url[$keys[$i]])) {
$named[] = $keys[$i] . $path['argSeparator'] . $url[$keys[$i]];
} else if(!empty($url[$keys[$i]])){
} elseif(!empty($url[$keys[$i]]) || is_numeric($url[$keys[$i]])) {
$named[] = $keys[$i] . $path['argSeparator'] . $url[$keys[$i]];
}
}

View file

@ -251,6 +251,18 @@ class RouterTest extends UnitTestCase {
$result = $this->router->url(array('controller' => 'posts', 'action'=>'index', '0', '?' => array('var' => 'test', 'var2' => 'test2', 'more' => 'test data')));
$this->assertEqual($result, $expected);
}
function testNamedArgsUrlGeneration() {
Router::setRequestInfo(array(null, array('base' => '/', 'argSeparator' => ':')));
$result = $this->router->url(array('controller' => 'posts', 'action' => 'index', 'published' => 1, 'deleted' => 1));
$expected = '/posts/index/published:1/deleted:1';
$this->assertEqual($result, $expected);
$result = $this->router->url(array('controller' => 'posts', 'action' => 'index', 'published' => 0, 'deleted' => 0));
$expected = '/posts/index/published:0/deleted:0';
$this->assertEqual($result, $expected);
}
}
?>