Permalink
Browse files

Adding PluginShortRoute into default connected routes. Fixes issues w…

…ith the framework having built in 404s.

Adding tests for the default connected routes.
  • Loading branch information...
1 parent 131578c commit 81dc0d42b904f5d90db43fbd2d3345d708c8b66a @markstory markstory committed Apr 8, 2010
Showing with 16 additions and 1 deletion.
  1. +4 −1 cake/libs/router.php
  2. +12 −0 cake/tests/cases/libs/router.test.php
View
@@ -572,14 +572,17 @@ function __connectDefaultRoutes() {
foreach ($plugins as $key => $value) {
$plugins[$key] = Inflector::underscore($value);
}
- $match = array('plugin' => implode('|', $plugins));
+ $pluginPattern = implode('|', $plugins);
+ $match = array('plugin' => $pluginPattern);
foreach ($this->__prefixes as $prefix) {
$params = array('prefix' => $prefix, $prefix => true);
$indexParams = $params + array('action' => 'index');
$this->connect("/{$prefix}/:plugin/:controller", $indexParams, $match);
$this->connect("/{$prefix}/:plugin/:controller/:action/*", $params, $match);
}
+ $shortParams = array('routeClass' => 'PluginShortRoute', 'plugin' => $pluginPattern);
+ $this->connect('/:plugin', array('action' => 'index'), $shortParams);
$this->connect('/:plugin/:controller', array('action' => 'index'), $match);
$this->connect('/:plugin/:controller/:action/*', array(), $match);
}
@@ -1943,6 +1943,7 @@ function testConnectDefaultRoutes() {
)
), true);
App::objects('plugin', null, false);
+ Router::reload();
$plugins = App::objects('plugin');
$plugin = Inflector::underscore($plugins[0]);
@@ -1955,6 +1956,17 @@ function testConnectDefaultRoutes() {
'named' => array(), 'pass' => array()
);
$this->assertEqual($result, $expected);
+
+ $result = Router::url(array('plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index'));
+ $this->assertEqual($result, '/test_plugin');
+
+ $result = Router::parse('/test_plugin');
+ $expected = array(
+ 'plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index',
+ 'named' => array(), 'pass' => array()
+ );
+
+ $this->assertEqual($result, $expected, 'Plugin shortcut route broken. %s');
}
/**

0 comments on commit 81dc0d4

Please sign in to comment.