mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 20:46:24 +00:00
Merge pull request #1684 from dereuromark/master-shell
Bugfix: Assert own tasks are loaded before trying to access taskNames.
This commit is contained in:
commit
066e0b6677
4 changed files with 3 additions and 5 deletions
|
@ -201,6 +201,7 @@ class Shell extends Object {
|
||||||
*/
|
*/
|
||||||
public function initialize() {
|
public function initialize() {
|
||||||
$this->_loadModels();
|
$this->_loadModels();
|
||||||
|
$this->loadTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -206,7 +206,6 @@ class ShellDispatcher {
|
||||||
|
|
||||||
if ($Shell instanceof Shell) {
|
if ($Shell instanceof Shell) {
|
||||||
$Shell->initialize();
|
$Shell->initialize();
|
||||||
$Shell->loadTasks();
|
|
||||||
return $Shell->runCommand($command, $this->args);
|
return $Shell->runCommand($command, $this->args);
|
||||||
}
|
}
|
||||||
$methods = array_diff(get_class_methods($Shell), get_class_methods('Shell'));
|
$methods = array_diff(get_class_methods($Shell), get_class_methods('Shell'));
|
||||||
|
|
|
@ -441,7 +441,6 @@ class ShellDispatcherTest extends CakeTestCase {
|
||||||
$Mock = $this->getMock('Shell', array(), array(), 'MockWithMainShell');
|
$Mock = $this->getMock('Shell', array(), array(), 'MockWithMainShell');
|
||||||
|
|
||||||
$Mock->expects($this->once())->method('initialize');
|
$Mock->expects($this->once())->method('initialize');
|
||||||
$Mock->expects($this->once())->method('loadTasks');
|
|
||||||
$Mock->expects($this->once())->method('runCommand')
|
$Mock->expects($this->once())->method('runCommand')
|
||||||
->with(null, array())
|
->with(null, array())
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
@ -467,7 +466,6 @@ class ShellDispatcherTest extends CakeTestCase {
|
||||||
$this->mockObjects[] = $Shell;
|
$this->mockObjects[] = $Shell;
|
||||||
|
|
||||||
$Shell->expects($this->once())->method('initialize');
|
$Shell->expects($this->once())->method('initialize');
|
||||||
$Shell->expects($this->once())->method('loadTasks');
|
|
||||||
$Shell->expects($this->once())->method('runCommand')
|
$Shell->expects($this->once())->method('runCommand')
|
||||||
->with('initdb', array('initdb'))
|
->with('initdb', array('initdb'))
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
@ -491,7 +489,6 @@ class ShellDispatcherTest extends CakeTestCase {
|
||||||
$Shell = $this->getMock('Object', $methods, array(), 'MockWithMainNotAShell');
|
$Shell = $this->getMock('Object', $methods, array(), 'MockWithMainNotAShell');
|
||||||
|
|
||||||
$Shell->expects($this->never())->method('initialize');
|
$Shell->expects($this->never())->method('initialize');
|
||||||
$Shell->expects($this->never())->method('loadTasks');
|
|
||||||
$Shell->expects($this->once())->method('startup');
|
$Shell->expects($this->once())->method('startup');
|
||||||
$Shell->expects($this->once())->method('main')->will($this->returnValue(true));
|
$Shell->expects($this->once())->method('main')->will($this->returnValue(true));
|
||||||
$Dispatcher->TestShell = $Shell;
|
$Dispatcher->TestShell = $Shell;
|
||||||
|
@ -524,7 +521,6 @@ class ShellDispatcherTest extends CakeTestCase {
|
||||||
$Shell = $this->getMock('Object', $methods, array(&$Dispatcher), 'MockWithoutMainNotAShell');
|
$Shell = $this->getMock('Object', $methods, array(&$Dispatcher), 'MockWithoutMainNotAShell');
|
||||||
|
|
||||||
$Shell->expects($this->never())->method('initialize');
|
$Shell->expects($this->never())->method('initialize');
|
||||||
$Shell->expects($this->never())->method('loadTasks');
|
|
||||||
$Shell->expects($this->once())->method('startup');
|
$Shell->expects($this->once())->method('startup');
|
||||||
$Shell->expects($this->once())->method('main')->will($this->returnValue(true));
|
$Shell->expects($this->once())->method('main')->will($this->returnValue(true));
|
||||||
$Dispatcher->TestShell = $Shell;
|
$Dispatcher->TestShell = $Shell;
|
||||||
|
|
|
@ -195,6 +195,7 @@ class ShellTest extends CakeTestCase {
|
||||||
), App::RESET);
|
), App::RESET);
|
||||||
|
|
||||||
CakePlugin::load('TestPlugin');
|
CakePlugin::load('TestPlugin');
|
||||||
|
$this->Shell->tasks = array('DbConfig' => array('one', 'two'));
|
||||||
$this->Shell->uses = array('TestPlugin.TestPluginPost');
|
$this->Shell->uses = array('TestPlugin.TestPluginPost');
|
||||||
$this->Shell->initialize();
|
$this->Shell->initialize();
|
||||||
|
|
||||||
|
@ -208,6 +209,7 @@ class ShellTest extends CakeTestCase {
|
||||||
$this->assertTrue(isset($this->Shell->Comment));
|
$this->assertTrue(isset($this->Shell->Comment));
|
||||||
$this->assertInstanceOf('Comment', $this->Shell->Comment);
|
$this->assertInstanceOf('Comment', $this->Shell->Comment);
|
||||||
$this->assertEquals('Comment', $this->Shell->modelClass);
|
$this->assertEquals('Comment', $this->Shell->modelClass);
|
||||||
|
$this->assertInstanceOf('DbConfigTask', $this->Shell->DbConfig);
|
||||||
|
|
||||||
App::build();
|
App::build();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue