From 4b25239298fe53742d24cefe53bc0654ad3e4051 Mon Sep 17 00:00:00 2001 From: "mariano.iglesias" Date: Sat, 5 Apr 2008 14:21:33 +0000 Subject: [PATCH] Adding router test case for URL generation with prefixes git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6635 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/tests/cases/libs/router.test.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index a2c4d69c7..f55780c19 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -35,7 +35,6 @@ uses('router', 'debugger'); * @subpackage cake.tests.cases.libs */ class RouterTest extends UnitTestCase { - function setUp() { $this->router =& Router::getInstance(); } @@ -427,7 +426,6 @@ class RouterTest extends UnitTestCase { $this->assertEqual($result, $expected); $this->router->reload(); - //Configure::write('Routing.admin', false); $this->router->setRequestInfo(array( array( @@ -510,6 +508,28 @@ class RouterTest extends UnitTestCase { $expected = '/admin/shows/show_tickets/edit/6'; $this->assertEqual($result, $expected); } + + function testUrlGenerationWithPrefix() { + Configure::write('Routing.admin', 'admin'); + $this->router->reload(); + + $this->router->connectNamed(array('event', 'lang')); + $this->router->connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); + $this->router->connect('/pages/contact_us', array('controller' => 'pages', 'action' => 'contact_us')); + $this->router->connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); + $this->router->connect('/reset/*', array('admin' => true, 'controller' => 'users', 'action' => 'reset')); + $this->router->connect('/tests', array('controller' => 'tests', 'action' => 'index')); + $this->router->parseExtensions('rss'); + + $this->router->setRequestInfo(array( + array('pass' => array(), 'named' => array(), 'controller' => 'registrations', 'action' => 'admin_index', 'plugin' => '', 'prefix' => 'admin', 'admin' => true, 'url' => array('ext' => 'html', 'url' => 'admin/registrations/index'), 'form' => array()), + array('base' => '', 'here' => '/admin/registrations/index', 'webroot' => '/') + )); + + $result = $this->router->url(array('page' => 2)); + $expected = '/admin/registrations/index/page:2'; + $this->assertEqual($result, $expected); + } function testUrlGenerationWithExtensions() { $this->router->reload();