Adding test case to explain how route prefix matching functions (Ticket )

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5924 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-10-30 14:49:03 +00:00
parent d913e88ef5
commit 1ab95d703f

View file

@ -778,6 +778,31 @@ class RouterTest extends UnitTestCase {
$this->assertEqual($result, $expected);
}
function testUrlGenerationWithPrefixes() {
$this->router->reload();
$this->router->connect('/protected/:controller/:action/*', array(
'controller' => 'users',
'action' => 'index',
'prefix' => 'protected',
'protected' => true
));
$this->router->parse('/');
$this->router->setRequestInfo(array(
array('plugin' => null, 'controller' => 'images', 'action' => 'index', 'pass' => array(), 'prefix' => null, 'admin' => false, 'form' => array(), 'url' => array('url' => 'images/index'), 'bare' => 0, 'webservices' => null),
array('plugin' => null, 'controller' => null, 'action' => null, 'base' => '', 'here' => '/images/index', 'webroot' => '/')
));
$result = $this->router->url(array('controller' => 'images', 'action' => 'add'));
$expected = '/images/add';
$this->assertEqual($result, $expected);
$result = $this->router->url(array('controller' => 'images', 'action' => 'add', 'protected' => true));
$expected = '/protected/images/add';
$this->assertEqual($result, $expected);
}
function testParamsUrlParsing() {
$this->router->reload();
$this->router->connect('/', array('controller' => 'posts', 'action' => 'index'));