Skip to content
Permalink
Browse files

Add test for added cases in RouteCollection::_getNames()

The additional prefix names are needed for cases like this test.
Uncomment accidentally commented out test case.
  • Loading branch information...
markstory committed Jul 7, 2014
1 parent 7cb51d7 commit f981c7c8ec97daab3d829501f705101c9b66051f
Showing with 39 additions and 3 deletions.
  1. +36 −0 tests/TestCase/Routing/RouteCollectionTest.php
  2. +3 −3 tests/TestCase/Routing/RouterTest.php
@@ -178,6 +178,42 @@ public function testMatchPlugin() {
$this->assertEquals('contacts', $result);
}
/**
* Test that prefixes increase the specificity of a route match.
*
* Connect the admin route after the non prefixed version, this means
* the non-prefix route would have a more specific name (users:index)
*
* @return void
*/
public function testMatchPrefixSpecificity() {
$context = [
'_base' => '/',
'_scheme' => 'http',
'_host' => 'example.org',
];
$routes = new RouteBuilder($this->collection, '/');
$routes->connect('/:action/*', ['controller' => 'Users']);
$routes->connect('/admin/:controller', ['prefix' => 'admin', 'action' => 'index']);
$url = [
'plugin' => null,
'prefix' => 'admin',
'controller' => 'Users',
'action' => 'index'
];
$result = $this->collection->match($url, $context);
$this->assertEquals('admin/Users', $result);
$url = [
'plugin' => null,
'controller' => 'Users',
'action' => 'index'
];
$result = $this->collection->match($url, $context);
$this->assertEquals('index', $result);
}
/**
* Test getting named routes.
*
@@ -1880,9 +1880,9 @@ public function testPagesUrlParsing() {
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
// $result = Router::parse('/');
// $expected = array('pass' => array('home'), 'plugin' => null, 'controller' => 'pages', 'action' => 'display');
// $this->assertEquals($expected, $result);
$result = Router::parse('/');
$expected = array('pass' => array('home'), 'plugin' => null, 'controller' => 'pages', 'action' => 'display');
$this->assertEquals($expected, $result);
$result = Router::parse('/pages/home/');
$expected = array('pass' => array('home'), 'plugin' => null, 'controller' => 'pages', 'action' => 'display');

0 comments on commit f981c7c

Please sign in to comment.
You can’t perform that action at this time.