Skip to content
Permalink
Browse files

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.
  • Loading branch information...
markstory committed Oct 19, 2010
1 parent bd156bb commit 6900f470ad90fd16a0212510fe970f3799279c4e
@@ -50,15 +50,6 @@ public function startup() {
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 @@ public function initialize() {
*
*/
public function execute() {
parent::execute();
if (empty($this->args)) {
return $this->_interactive();
}
@@ -95,6 +95,7 @@ public function getOptionParser() {
* @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 @@ public function initialize() {
*
*/
public function execute() {
parent::execute();
if (empty($this->args)) {
$this->_interactive();
}
@@ -75,7 +75,7 @@ public function setUp() {
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 @@ protected function _setupOtherMocks() {
$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 @@ public function setup() {
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 @@ public function testBakeWithPlugin() {
$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')

0 comments on commit 6900f47

Please sign in to comment.
You can’t perform that action at this time.