Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moving addition of plugin and controller keys to Router instead of Ro…

…uterRoute.
  • Loading branch information...
commit de0b90db4a7e1d24906ebee3def8c4b1b566a608 1 parent 9e9559b
@markstory markstory authored
Showing with 7 additions and 14 deletions.
  1. +1 −6 cake/libs/router.php
  2. +6 −8 cake/tests/cases/libs/router.test.php
View
7 cake/libs/router.php
@@ -274,9 +274,7 @@ function connect($route, $default = array(), $params = array()) {
$self->__prefixes[] = $default['prefix'];
$self->__prefixes = array_keys(array_flip($self->__prefixes));
}
- if (!isset($default['action'])) {
- $default['action'] = 'index';
- }
+ $default += array('action' => 'index', 'plugin' => null, 'controller' => null);
$self->routes[] =& new RouterRoute($route, $default, $params);
return $self->routes;
}
@@ -1222,7 +1220,6 @@ function compile() {
return $this->_compiledRoute;
}
$this->_writeRoute($this->template, $this->defaults, $this->params);
- $this->defaults += array('plugin' => null, 'controller' => null);
return $this->_compiledRoute;
}
/**
@@ -1407,8 +1404,6 @@ function match($url) {
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
//*/
-
- $url += array('controller' => null, 'plugin' => null);
$defaults = $this->defaults;
if (isset($defaults['prefix'])) {
View
14 cake/tests/cases/libs/router.test.php
@@ -1949,7 +1949,7 @@ function testRouterConnectDefaults() {
}
}
-// SimpleTest::ignore('RouterTest');
+//SimpleTest::ignore('RouterTest');
/**
* Test case for RouterRoute
*
@@ -2117,10 +2117,9 @@ function testComplexRouteCompilingAndParsing() {
$this->assertPattern($result, '/posts/08/01/2007/title-of-post');
$result = $route->parse('/posts/08/01/2007/title-of-post');
- $this->assertEqual(count($result), 9);
+ $this->assertEqual(count($result), 8);
$this->assertEqual($result['controller'], 'posts');
$this->assertEqual($result['action'], 'view');
- $this->assertEqual($result['plugin'], null);
$this->assertEqual($result['year'], '2007');
$this->assertEqual($result['month'], '08');
$this->assertEqual($result['day'], '01');
@@ -2140,7 +2139,6 @@ function testComplexRouteCompilingAndParsing() {
'controller' => 'pages',
'action' => 'view',
'extra' => null,
- 'plugin' => null
);
$this->assertEqual($route->defaults, $expected);
}
@@ -2200,7 +2198,7 @@ function testMatchBasic() {
'controller' => 'subscribe', 'admin' => true, 'prefix' => 'admin'
));
- $url = array('plugin' => null, 'controller' => 'subscribe', 'admin' => true, 'action' => 'edit', 1);
+ $url = array('controller' => 'subscribe', 'admin' => true, 'action' => 'edit', 1);
$result = $route->match($url);
$expected = '/admin/subscriptions/edit/1';
$this->assertEqual($result, $expected);
@@ -2212,14 +2210,14 @@ function testMatchBasic() {
* @return void
*/
function testMatchWithPatterns() {
- $route =& new RouterRoute('/:controller/:action/:id', array(), array('id' => '[0-9]+'));
+ $route =& new RouterRoute('/:controller/:action/:id', array('plugin' => null), array('id' => '[0-9]+'));
$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => 'foo'));
$this->assertFalse($result);
- $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => '9'));
+ $result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => '9'));
$this->assertEqual($result, '/posts/view/9');
- $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => '922'));
+ $result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => '922'));
$this->assertEqual($result, '/posts/view/922');
}
Please sign in to comment.
Something went wrong with that request. Please try again.