mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
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:
parent
2baa585437
commit
d861587960
2 changed files with 13 additions and 1 deletions
|
@ -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]];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Reference in a new issue