Navigation Menu

Skip to content

Commit

Permalink
Adding tests to Router::url in order to test url generation with mapR…
Browse files Browse the repository at this point in the history
…esources(). Closes #5951.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7998 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
renan committed Jan 15, 2009
1 parent b9ea171 commit de5cb3c
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion cake/tests/cases/libs/router.test.php
Expand Up @@ -231,6 +231,39 @@ function testMultipleResourceRoute() {
$result = Router::parse('/posts');
$this->assertEqual($result, array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'index', '[method]' => array('GET', 'POST')));
}
/**
* testGenerateUrlResourceRoute method
*
* @access public
* @return void
*/
function testGenerateUrlResourceRoute() {
Router::mapResources('Posts');

$result = Router::url(array('controller' => 'posts', 'action' => 'index', '[method]' => 'GET'));
$expected = '/posts';
$this->assertEqual($result, $expected);

$result = Router::url(array('controller' => 'posts', 'action' => 'view', '[method]' => 'GET', 'id' => 10));
$expected = '/posts/10';
$this->assertEqual($result, $expected);

$result = Router::url(array('controller' => 'posts', 'action' => 'add', '[method]' => 'POST'));
$expected = '/posts';
$this->assertEqual($result, $expected);

$result = Router::url(array('controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'id' => 10));
$expected = '/posts/10';
$this->assertEqual($result, $expected);

$result = Router::url(array('controller' => 'posts', 'action' => 'delete', '[method]' => 'DELETE', 'id' => 10));
$expected = '/posts/10';
$this->assertEqual($result, $expected);

$result = Router::url(array('controller' => 'posts', 'action' => 'edit', '[method]' => 'POST', 'id' => 10));
$expected = '/posts/10';
$this->assertEqual($result, $expected);
}
/**
* testUrlNormalization method
*
Expand Down Expand Up @@ -1059,7 +1092,7 @@ function testQuerystringGeneration() {
$result = Router::url(array('controller' => 'posts', 'action'=>'index', '0', '?' => array('var' => 'test', 'var2' => 'test2', 'more' => 'test data')));
$this->assertEqual($result, $expected);
ini_set('arg_separator.output', $restore);

$result = Router::url(array('controller' => 'posts', 'action'=>'index', '0', '?' => array('var' => 'test', 'var2' => 'test2')), array('escape' => true));
$expected = '/posts/index/0?var=test&var2=test2';
$this->assertEqual($result, $expected);
Expand Down

0 comments on commit de5cb3c

Please sign in to comment.