mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Moving code from BakeShell to BakeTask.
Adding a base execute method to contain common code shared amongst all the bake tasks. Updating test cases as $name attributes value has changed.
This commit is contained in:
parent
bd156bb601
commit
6900f470ad
11 changed files with 29 additions and 15 deletions
|
@ -50,15 +50,6 @@ class BakeShell extends Shell {
|
|||
if (isset($this->params['connection'])) {
|
||||
$this->{$task}->connection = $this->params['connection'];
|
||||
}
|
||||
foreach($this->args as $i => $arg) {
|
||||
if (strpos($arg, '.')) {
|
||||
list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($this->params['plugin'])) {
|
||||
$this->{$task}->plugin = $this->params['plugin'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,9 +51,27 @@ class BakeTask extends Shell {
|
|||
public function getPath() {
|
||||
$path = $this->path;
|
||||
if (isset($this->plugin)) {
|
||||
$name = substr($this->name, 0, strlen($this->name) - 4);
|
||||
$path = $this->_pluginPath($this->plugin) . Inflector::pluralize(Inflector::underscore($name)) . DS;
|
||||
$path = $this->_pluginPath($this->plugin) . Inflector::pluralize(Inflector::underscore($this->name)) . DS;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base execute method parses some parameters and sets some properties on the bake tasks.
|
||||
* call when overriding execute()
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute() {
|
||||
foreach($this->args as $i => $arg) {
|
||||
if (strpos($arg, '.')) {
|
||||
list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isset($this->params['plugin'])) {
|
||||
$this->plugin = $this->params['plugin'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ class ControllerTask extends BakeTask {
|
|||
*
|
||||
*/
|
||||
public function execute() {
|
||||
parent::execute();
|
||||
if (empty($this->args)) {
|
||||
return $this->_interactive();
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ class FixtureTask extends BakeTask {
|
|||
* @return void
|
||||
*/
|
||||
public function execute() {
|
||||
parent::execute();
|
||||
if (empty($this->args)) {
|
||||
$this->_interactive();
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ class ModelTask extends BakeTask {
|
|||
*/
|
||||
public function execute() {
|
||||
App::import('Model', 'Model', false);
|
||||
parent::execute();
|
||||
|
||||
if (empty($this->args)) {
|
||||
$this->_interactive();
|
||||
|
|
|
@ -65,6 +65,7 @@ class TestTask extends BakeTask {
|
|||
*
|
||||
*/
|
||||
public function execute() {
|
||||
parent::execute();
|
||||
if (empty($this->args)) {
|
||||
$this->_interactive();
|
||||
}
|
||||
|
|
|
@ -97,6 +97,7 @@ class ViewTask extends BakeTask {
|
|||
*
|
||||
*/
|
||||
public function execute() {
|
||||
parent::execute();
|
||||
if (empty($this->args)) {
|
||||
$this->_interactive();
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class ControllerTaskTest extends CakeTestCase {
|
|||
array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'),
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$this->Task->name = 'ControllerTask';
|
||||
$this->Task->name = 'Controller';
|
||||
$this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in);
|
||||
$this->Task->Template->params['theme'] = 'default';
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class ModelTaskTest extends CakeTestCase {
|
|||
$this->Task->Test = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||
$this->Task->Template = new TemplateTask($this->Task->Dispatch, $out, $out, $in);
|
||||
|
||||
$this->Task->name = 'ModelTask';
|
||||
$this->Task->name = 'Model';
|
||||
$this->Task->interactive = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ class TestTaskTest extends CakeTestCase {
|
|||
array('in', 'err', 'createFile', '_stop', 'isLoadableClass'),
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$this->Task->name = 'TestTask';
|
||||
$this->Task->name = 'Test';
|
||||
$this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in);
|
||||
}
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ class ViewTaskTest extends CakeTestCase {
|
|||
$this->Task->controllerName = 'ViewTaskComments';
|
||||
$this->Task->controllerPath = 'view_task_comments';
|
||||
$this->Task->plugin = 'TestTest';
|
||||
$this->Task->name = 'ViewTask';
|
||||
$this->Task->name = 'View';
|
||||
|
||||
$path = APP . 'plugins' . DS . 'test_test' . DS . 'views' . DS . 'view_task_comments' . DS . 'view.ctp';
|
||||
$this->Task->expects($this->once())->method('createFile')
|
||||
|
|
Loading…
Add table
Reference in a new issue