Permalink
Browse files

Adding tests to Router::url in order to test url generation with mapR…

…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...
1 parent b9ea171 commit de5cb3cabfe321566ba9b38452a03ea4a7f5aee7 @renan renan committed Jan 15, 2009
Showing with 34 additions and 1 deletion.
  1. +34 −1 cake/tests/cases/libs/router.test.php
@@ -232,6 +232,39 @@ function testMultipleResourceRoute() {
$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
*
* @access public
@@ -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);

0 comments on commit de5cb3c

Please sign in to comment.