mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
adding test to dispatcher, closes #3613
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6023 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
0eed95dda2
commit
31fac597bd
1 changed files with 31 additions and 1 deletions
|
@ -73,6 +73,10 @@ class MyPluginController extends MyPluginAppController {
|
|||
function add() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function admin_add($id = null) {
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
|
||||
class SomePagesController extends AppController {
|
||||
|
@ -638,6 +642,32 @@ class DispatcherTest extends UnitTestCase {
|
|||
$expected = array('param'=>'value', 'param2'=>'value2');
|
||||
$this->assertEqual($controller->params['named'], $expected);
|
||||
|
||||
|
||||
Configure::write('Routing.admin', 'admin');
|
||||
|
||||
Router::reload();
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
$Dispatcher->base = false;
|
||||
|
||||
$url = 'admin/my_plugin/add/5/param:value/param2:value2';
|
||||
|
||||
restore_error_handler();
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
set_error_handler('simpleTestErrorHandler');
|
||||
|
||||
$expected = 'my_plugin';
|
||||
$this->assertIdentical($controller->plugin, $expected);
|
||||
|
||||
$expected = 'MyPlugin';
|
||||
$this->assertIdentical($controller->name, $expected);
|
||||
|
||||
$expected = 'admin_add';
|
||||
$this->assertIdentical($controller->action, $expected);
|
||||
|
||||
$expected = array(0 => 5, 'param'=>'value', 'param2'=>'value2');
|
||||
$this->assertEqual($controller->passedArgs, $expected);
|
||||
|
||||
|
||||
Router::reload();
|
||||
Router::connect('/admin/:controller/:action/*', array('controller' => 'pages', 'action' => 'index', 'admin' => true, 'prefix' => 'admin'));
|
||||
|
||||
|
@ -647,7 +677,7 @@ class DispatcherTest extends UnitTestCase {
|
|||
$url = 'admin/articles_test';
|
||||
|
||||
restore_error_handler();
|
||||
@$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
set_error_handler('simpleTestErrorHandler');
|
||||
|
||||
$expected = 'articles_test';
|
||||
|
|
Loading…
Add table
Reference in a new issue