From de0b90db4a7e1d24906ebee3def8c4b1b566a608 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 29 Nov 2009 16:21:33 -0500 Subject: [PATCH] Moving addition of plugin and controller keys to Router instead of RouterRoute. --- cake/libs/router.php | 7 +------ cake/tests/cases/libs/router.test.php | 14 ++++++-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index e00e98dd6..686b71485 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -274,9 +274,7 @@ class Router { $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 @@ class RouterRoute { 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 @@ class RouterRoute { return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix'))); //*/ - - $url += array('controller' => null, 'plugin' => null); $defaults = $this->defaults; if (isset($defaults['prefix'])) { diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 4ac957f5c..9a828cd0a 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1949,7 +1949,7 @@ class RouterTest extends CakeTestCase { } } -// SimpleTest::ignore('RouterTest'); +//SimpleTest::ignore('RouterTest'); /** * Test case for RouterRoute * @@ -2117,10 +2117,9 @@ class RouterRouteTestCase extends CakeTestCase { $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 @@ class RouterRouteTestCase extends CakeTestCase { 'controller' => 'pages', 'action' => 'view', 'extra' => null, - 'plugin' => null ); $this->assertEqual($route->defaults, $expected); } @@ -2200,7 +2198,7 @@ class RouterRouteTestCase extends CakeTestCase { '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 @@ class RouterRouteTestCase extends CakeTestCase { * @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'); }