Skip to content

Commit

Permalink
Moving addition of plugin and controller keys to Router instead of Ro…
Browse files Browse the repository at this point in the history
…uterRoute.
  • Loading branch information
markstory committed Nov 29, 2009
1 parent 9e9559b commit de0b90d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
7 changes: 1 addition & 6 deletions cake/libs/router.php
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
/**
Expand Down Expand Up @@ -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'])) {
Expand Down
14 changes: 6 additions & 8 deletions cake/tests/cases/libs/router.test.php
Expand Up @@ -1949,7 +1949,7 @@ function testRouterConnectDefaults() {
}
}

// SimpleTest::ignore('RouterTest');
//SimpleTest::ignore('RouterTest');
/**
* Test case for RouterRoute
*
Expand Down Expand Up @@ -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');
Expand All @@ -2140,7 +2139,6 @@ function testComplexRouteCompilingAndParsing() {
'controller' => 'pages',
'action' => 'view',
'extra' => null,
'plugin' => null
);
$this->assertEqual($route->defaults, $expected);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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');
}

Expand Down

0 comments on commit de0b90d

Please sign in to comment.