Skip to content

Commit

Permalink
Adding additional test for plugin shortcut routes including prefixed …
Browse files Browse the repository at this point in the history
…shortcut routes.
  • Loading branch information
markstory committed Apr 4, 2010
1 parent 781af4a commit e57e8f3
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions cake/tests/cases/libs/router.test.php
Expand Up @@ -751,6 +751,15 @@ function testUrlGenerationPlugins() {
* @return void
*/
function testPluginShortcutRoutes() {
App::build(array(
'plugins' => array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
)
), true);
App::objects('plugin', null, false);
Configure::write('Routing.prefixes', array('admin'));
Router::reload();

$result = Router::url(array('plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index'));
$this->assertEqual($result, '/test_plugin', 'Plugin shortcut index action failed.');

Expand All @@ -764,6 +773,29 @@ function testPluginShortcutRoutes() {
$this->assertEqual(
$result, '/test_plugin/view/1/sort:title/dir:asc', 'Plugin shortcut with passed + named args failed.'
);

$result = Router::parse('/test_plugin');
$this->assertEqual($result['plugin'], 'test_plugin');
$this->assertEqual($result['controller'], 'test_plugin');
$this->assertEqual($result['action'], 'index');

$result = Router::parse('/test_plugin/add');
$this->assertEqual($result['plugin'], 'test_plugin');
$this->assertEqual($result['controller'], 'test_plugin');
$this->assertEqual($result['action'], 'add');

$result = Router::parse('/admin/test_plugin');
$this->assertEqual($result['plugin'], 'test_plugin');
$this->assertEqual($result['controller'], 'test_plugin');
$this->assertEqual($result['action'], 'index');
$this->assertEqual($result['prefix'], 'admin');

$result = Router::parse('/admin/test_plugin/add/1');
$this->assertEqual($result['plugin'], 'test_plugin');
$this->assertEqual($result['controller'], 'test_plugin');
$this->assertEqual($result['action'], 'add');
$this->assertEqual($result['prefix'], 'admin');
$this->assertEqual($result['pass'], array(1));
}

/**
Expand Down Expand Up @@ -2436,8 +2468,6 @@ function testParse() {
$this->assertEqual($result['action'], 'index');
}
}
//SimpleTest::ignore('RouterTest');
//SimpleTest::ignore('CakeRouteTestCase');

/**
* Test case for PluginShortRoute
Expand Down

0 comments on commit e57e8f3

Please sign in to comment.