mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing help not getting called
Adding tests
This commit is contained in:
parent
1d8f57d37a
commit
06d3aee348
2 changed files with 25 additions and 1 deletions
|
@ -344,7 +344,7 @@ class ShellDispatcher {
|
|||
}
|
||||
return $Shell->{$task}->execute();
|
||||
}
|
||||
$methods = get_class_methods('Shell');
|
||||
$methods = array_diff(get_class_methods('Shell'), array('help'));
|
||||
}
|
||||
$methods = array_diff(get_class_methods($Shell), $methods);
|
||||
$added = in_array(strtolower($arg), array_map('strtolower', $methods));
|
||||
|
|
|
@ -514,6 +514,17 @@ class ShellDispatcherTest extends CakeTestCase {
|
|||
$this->assertTrue($result);
|
||||
$this->assertEqual($Dispatcher->args, array('initdb'));
|
||||
|
||||
$Shell = new MockWithMainShell();
|
||||
$Shell->setReturnValue('main', true);
|
||||
$Shell->expectOnce('startup');
|
||||
$Shell->expectOnce('help');
|
||||
$Dispatcher->TestShell =& $Shell;
|
||||
|
||||
$Dispatcher->args = array('mock_with_main', 'help');
|
||||
$result = $Dispatcher->dispatch();
|
||||
$this->assertNull($result);
|
||||
$this->assertEqual($Dispatcher->args, array());
|
||||
|
||||
$Shell = new MockWithMainShell();
|
||||
$Shell->setReturnValue('main', true);
|
||||
$Shell->expectNever('hr');
|
||||
|
@ -811,6 +822,19 @@ class ShellDispatcherTest extends CakeTestCase {
|
|||
$result = $Dispatcher->dispatch();
|
||||
$this->assertTrue($result);
|
||||
$this->assertEqual($Dispatcher->args, array());
|
||||
|
||||
$Shell = new MockWeekShell();
|
||||
$Task = new MockOnSundayTask();
|
||||
$Task->expectNever('execute');
|
||||
$Task->expectOnce('help');
|
||||
|
||||
$Shell->MockOnSunday =& $Task;
|
||||
$Shell->taskNames = array('MockOnSunday');
|
||||
$Dispatcher->TestShell =& $Shell;
|
||||
|
||||
$Dispatcher->args = array('mock_week', 'mock_on_sunday', 'help');
|
||||
$result = $Dispatcher->dispatch();
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
/**
|
||||
* Verify shifting of arguments
|
||||
|
|
Loading…
Reference in a new issue