Skip to content
Browse files

Making plugin task find plugins on $pluginPaths

Fixing i18n.
Adding tests for execute with 2 params.
  • Loading branch information...
1 parent 701d93c commit 88f95bc0c4c14f2884ad3faa84bc3335112e41a6 @markstory markstory committed
Showing with 32 additions and 11 deletions.
  1. +8 −7 cake/console/libs/tasks/plugin.php
  2. +24 −4 cake/tests/cases/console/libs/tasks/plugin.test.php
View
15 cake/console/libs/tasks/plugin.php
@@ -68,15 +68,16 @@ function execute() {
}
}
$plugin = null;
+
if (isset($this->args[0])) {
$plugin = Inflector::camelize($this->args[0]);
- $pluginPath = Inflector::underscore($plugin) . DS;
+ $pluginPath = $this->_pluginPath($plugin);
$this->Dispatch->shiftArgs();
- if (is_dir($this->path . $pluginPath)) {
+ if (is_dir($pluginPath)) {
$this->out(sprintf(__('Plugin: %s', true), $plugin));
- $this->out(sprintf(__('Path: %s', true), $this->path . $pluginPath));
+ $this->out(sprintf(__('Path: %s', true), $pluginPath));
} elseif (isset($this->args[0])) {
- $this->err(sprintf(__('%s in path %s not found.', true), $plugin, $this->path . $pluginPath));
+ $this->err(sprintf(__('%s in path %s not found.', true), $plugin, $pluginPath));
$this->_stop();
} else {
$this->__interactive($plugin);
@@ -88,7 +89,7 @@ function execute() {
$this->Dispatch->shiftArgs();
if (in_array($task, $this->tasks)) {
$this->{$task}->plugin = $plugin;
- $this->{$task}->path = $this->path . $pluginPath . Inflector::underscore(Inflector::pluralize($task)) . DS;
+ $this->{$task}->path = $pluginPath . Inflector::underscore(Inflector::pluralize($task)) . DS;
if (!is_dir($this->{$task}->path)) {
$this->err(sprintf(__("%s directory could not be found.\nBe sure you have created %s", true), $task, $this->{$task}->path));
@@ -131,8 +132,8 @@ function bake($plugin) {
}
$this->hr();
- $this->out(sprintf(__("Plugin Name: %s", true) . $plugin));
- $this->out(sprintf(__("Plugin Directory: %s", true) . $this->path . $pluginPath));
+ $this->out(sprintf(__("Plugin Name: %s", true), $plugin));
+ $this->out(sprintf(__("Plugin Directory: %s", true), $this->path . $pluginPath));
$this->hr();
$looksGood = $this->in(__('Look okay?', true), array('y', 'n', 'q'), 'y');
View
28 cake/tests/cases/console/libs/tasks/plugin.test.php
@@ -39,7 +39,7 @@
if (!class_exists('PluginTask')) {
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'plugin.php';
- require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';
+ require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'model.php';
}
Mock::generatePartial(
@@ -48,9 +48,11 @@
);
Mock::generatePartial(
'PluginTask', 'MockPluginTask',
- array('in', '_stop', 'err', 'out', 'createFile', 'isLoadableClass')
+ array('in', '_stop', 'err', 'out', 'createFile')
);
+Mock::generate('ModelTask', 'PluginTestMockModelTask');
+
/**
* PluginTaskPlugin class
*
@@ -59,7 +61,6 @@
*/
class PluginTaskTest extends CakeTestCase {
- var $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag');
/**
* setUp method
*
@@ -83,7 +84,6 @@ function startCase() {
$this->_paths = $paths = Configure::read('pluginPaths');
$this->_testPath = array_push($paths, TMP);
Configure::write('pluginPaths', $paths);
- clearstatcache();
}
/**
@@ -160,5 +160,25 @@ function testExecuteWithOneArg() {
$Folder->delete();
}
+/**
+ * test execute chaining into MVC parts
+ *
+ * @return void
+ **/
+ function testExecuteWithTwoArgs() {
+ $this->Task->Model =& new PluginTestMockModelTask();
+ $this->Task->setReturnValueAt(0, 'in', $this->_testPath);
+ $this->Task->setReturnValueAt(1, 'in', 'y');
+
+ $Folder =& new Folder(TMP . 'bake_test_plugin', true);
+
+ $this->Task->Dispatch->args = array('BakeTestPlugin', 'model');
+ $this->Task->args =& $this->Task->Dispatch->args;
+
+ $this->Task->Model->expectOnce('loadTasks');
+ $this->Task->Model->expectOnce('execute');
+ $this->Task->execute();
+ $Folder->delete();
+ }
}
?>

0 comments on commit 88f95bc

Please sign in to comment.
Something went wrong with that request. Please try again.