Assert own tasks are loaded before trying to access taskNames.

This commit is contained in:
euromark 2013-09-27 12:53:18 +02:00
parent ad1b80645d
commit c23531e806
4 changed files with 3 additions and 5 deletions

View file

@ -201,6 +201,7 @@ class Shell extends Object {
*/
public function initialize() {
$this->_loadModels();
$this->loadTasks();
}
/**

View file

@ -206,7 +206,6 @@ class ShellDispatcher {
if ($Shell instanceof Shell) {
$Shell->initialize();
$Shell->loadTasks();
return $Shell->runCommand($command, $this->args);
}
$methods = array_diff(get_class_methods($Shell), get_class_methods('Shell'));

View file

@ -441,7 +441,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Mock = $this->getMock('Shell', array(), array(), 'MockWithMainShell');
$Mock->expects($this->once())->method('initialize');
$Mock->expects($this->once())->method('loadTasks');
$Mock->expects($this->once())->method('runCommand')
->with(null, array())
->will($this->returnValue(true));
@ -467,7 +466,6 @@ class ShellDispatcherTest extends CakeTestCase {
$this->mockObjects[] = $Shell;
$Shell->expects($this->once())->method('initialize');
$Shell->expects($this->once())->method('loadTasks');
$Shell->expects($this->once())->method('runCommand')
->with('initdb', array('initdb'))
->will($this->returnValue(true));
@ -491,7 +489,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Shell = $this->getMock('Object', $methods, array(), 'MockWithMainNotAShell');
$Shell->expects($this->never())->method('initialize');
$Shell->expects($this->never())->method('loadTasks');
$Shell->expects($this->once())->method('startup');
$Shell->expects($this->once())->method('main')->will($this->returnValue(true));
$Dispatcher->TestShell = $Shell;
@ -524,7 +521,6 @@ class ShellDispatcherTest extends CakeTestCase {
$Shell = $this->getMock('Object', $methods, array(&$Dispatcher), 'MockWithoutMainNotAShell');
$Shell->expects($this->never())->method('initialize');
$Shell->expects($this->never())->method('loadTasks');
$Shell->expects($this->once())->method('startup');
$Shell->expects($this->once())->method('main')->will($this->returnValue(true));
$Dispatcher->TestShell = $Shell;

View file

@ -195,6 +195,7 @@ class ShellTest extends CakeTestCase {
), App::RESET);
CakePlugin::load('TestPlugin');
$this->Shell->tasks = array('DbConfig' => array('one', 'two'));
$this->Shell->uses = array('TestPlugin.TestPluginPost');
$this->Shell->initialize();
@ -208,6 +209,7 @@ class ShellTest extends CakeTestCase {
$this->assertTrue(isset($this->Shell->Comment));
$this->assertInstanceOf('Comment', $this->Shell->Comment);
$this->assertEquals('Comment', $this->Shell->modelClass);
$this->assertInstanceOf('DbConfigTask', $this->Shell->DbConfig);
App::build();
}