Skip to content
This repository
Browse code

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

…uterRoute.
  • Loading branch information...
commit de0b90db4a7e1d24906ebee3def8c4b1b566a608 1 parent 9e9559b
Mark Story authored November 29, 2009
7  cake/libs/router.php
@@ -274,9 +274,7 @@ function connect($route, $default = array(), $params = array()) {
274 274
 			$self->__prefixes[] = $default['prefix'];
275 275
 			$self->__prefixes = array_keys(array_flip($self->__prefixes));
276 276
 		}
277  
-		if (!isset($default['action'])) {
278  
-			$default['action'] = 'index';
279  
-		}
  277
+		$default += array('action' => 'index', 'plugin' => null, 'controller' => null);
280 278
 		$self->routes[] =& new RouterRoute($route, $default, $params);
281 279
 		return $self->routes;
282 280
 	}
@@ -1222,7 +1220,6 @@ function compile() {
1222 1220
 			return $this->_compiledRoute;
1223 1221
 		}
1224 1222
 		$this->_writeRoute($this->template, $this->defaults, $this->params);
1225  
-		$this->defaults += array('plugin' => null, 'controller' => null);
1226 1223
 		return $this->_compiledRoute;
1227 1224
 	}
1228 1225
 /**
@@ -1407,8 +1404,6 @@ function match($url) {
1407 1404
 		return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
1408 1405
 
1409 1406
 //*/
1410  
-
1411  
-		$url += array('controller' => null, 'plugin' => null);
1412 1407
 		$defaults = $this->defaults;
1413 1408
 
1414 1409
 		if (isset($defaults['prefix'])) {
14  cake/tests/cases/libs/router.test.php
@@ -1949,7 +1949,7 @@ function testRouterConnectDefaults() {
1949 1949
 	}
1950 1950
 }
1951 1951
 
1952  
-// SimpleTest::ignore('RouterTest');
  1952
+//SimpleTest::ignore('RouterTest');
1953 1953
 /**
1954 1954
  * Test case for RouterRoute
1955 1955
  *
@@ -2117,10 +2117,9 @@ function testComplexRouteCompilingAndParsing() {
2117 2117
 		$this->assertPattern($result, '/posts/08/01/2007/title-of-post');
2118 2118
 		$result = $route->parse('/posts/08/01/2007/title-of-post');
2119 2119
 
2120  
-		$this->assertEqual(count($result), 9);
  2120
+		$this->assertEqual(count($result), 8);
2121 2121
 		$this->assertEqual($result['controller'], 'posts');
2122 2122
 		$this->assertEqual($result['action'], 'view');
2123  
-		$this->assertEqual($result['plugin'], null);
2124 2123
 		$this->assertEqual($result['year'], '2007');
2125 2124
 		$this->assertEqual($result['month'], '08');
2126 2125
 		$this->assertEqual($result['day'], '01');
@@ -2140,7 +2139,6 @@ function testComplexRouteCompilingAndParsing() {
2140 2139
 			'controller' => 'pages',
2141 2140
 			'action' => 'view',
2142 2141
 			'extra' => null,
2143  
-			'plugin' => null
2144 2142
 		);
2145 2143
 		$this->assertEqual($route->defaults, $expected);
2146 2144
 	}
@@ -2200,7 +2198,7 @@ function testMatchBasic() {
2200 2198
 			'controller' => 'subscribe', 'admin' => true, 'prefix' => 'admin'
2201 2199
 		));
2202 2200
 
2203  
-		$url = array('plugin' => null, 'controller' => 'subscribe', 'admin' => true, 'action' => 'edit', 1);
  2201
+		$url = array('controller' => 'subscribe', 'admin' => true, 'action' => 'edit', 1);
2204 2202
 		$result = $route->match($url);
2205 2203
 		$expected = '/admin/subscriptions/edit/1';
2206 2204
 		$this->assertEqual($result, $expected);
@@ -2212,14 +2210,14 @@ function testMatchBasic() {
2212 2210
  * @return void
2213 2211
  */
2214 2212
 	function testMatchWithPatterns() {
2215  
-		$route =& new RouterRoute('/:controller/:action/:id', array(), array('id' => '[0-9]+'));
  2213
+		$route =& new RouterRoute('/:controller/:action/:id', array('plugin' => null), array('id' => '[0-9]+'));
2216 2214
 		$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => 'foo'));
2217 2215
 		$this->assertFalse($result);
2218 2216
 
2219  
-		$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => '9'));
  2217
+		$result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => '9'));
2220 2218
 		$this->assertEqual($result, '/posts/view/9');
2221 2219
 
2222  
-		$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => '922'));
  2220
+		$result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => '922'));
2223 2221
 		$this->assertEqual($result, '/posts/view/922');
2224 2222
 	}
2225 2223
 

0 notes on commit de0b90d

Please sign in to comment.
Something went wrong with that request. Please try again.