Skip to content
Permalink
Browse files

Fix plugin scopes not correctly setting their params.

The `+` operator was not working as plugin = null had already happened.
  • Loading branch information...
markstory committed Jun 30, 2014
1 parent b50ef5f commit 9d17b3897e953abf5bcb63329eea1898bcf00087
Showing with 12 additions and 7 deletions.
  1. +2 −1 src/Routing/ScopedRouteCollection.php
  2. +10 −6 tests/TestCase/Routing/ScopedRouteCollectionTest.php
@@ -343,7 +343,6 @@ public function resources($name, $options = [], $callback = null) {
* @throws \Cake\Error\Exception
*/
public function connect($route, array $defaults = [], $options = []) {
$defaults += ['plugin' => null];
if (empty($options['action'])) {
$defaults += array('action' => 'index');
}
@@ -403,6 +402,8 @@ protected function _makeRoute($route, $defaults, $options) {
}
}
$defaults += $this->_params;
$defaults += ['plugin' => null];
$route = new $routeClass($route, $defaults, $options);
}
@@ -237,6 +237,13 @@ public function testNestedPlugin() {
$res = $routes->plugin('Contacts', function($r) {
$this->assertEquals('/b/contacts', $r->path());
$this->assertEquals(['plugin' => 'Contacts', 'key' => 'value'], $r->params());
$r->connect('/:controller');
$route = $r->routes()[0];
$this->assertEquals(
['key' => 'value', 'plugin' => 'Contacts', 'action' => 'index'],
$route->defaults
);
});
$this->assertNull($res);
}
@@ -331,14 +338,11 @@ public function testMatchPlugin() {
$routes = new ScopedRouteCollection('/contacts', ['plugin' => 'Contacts']);
$routes->connect('/', ['controller' => 'Contacts']);
$result = $routes->match(
['plugin' => 'Contacts', 'controller' => 'Contacts', 'action' => 'index'],
$context
);
$this->assertFalse($result);
$result = $routes->match(['controller' => 'Contacts', 'action' => 'index'], $context);
$this->assertFalse($result);
$result = $routes->match(['plugin' => 'Contacts', 'controller' => 'Contacts', 'action' => 'index'], $context);
$this->assertEquals('contacts', $result);
}
/**

0 comments on commit 9d17b38

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