Skip to content

Commit

Permalink
Adding test cases for execute()
Browse files Browse the repository at this point in the history
Adding more i18n
Fixing issues with folders being left behind by tests.
  • Loading branch information
markstory committed Jun 11, 2009
1 parent 22c5755 commit 701d93c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
16 changes: 7 additions & 9 deletions cake/console/libs/tasks/plugin.php
Expand Up @@ -73,14 +73,13 @@ function execute() {
$pluginPath = Inflector::underscore($plugin) . DS;
$this->Dispatch->shiftArgs();
if (is_dir($this->path . $pluginPath)) {
$this->out(sprintf('Plugin: %s', $plugin));
$this->out(sprintf('Path: %s', $this->path . $pluginPath));
$this->hr();
$this->out(sprintf(__('Plugin: %s', true), $plugin));
$this->out(sprintf(__('Path: %s', true), $this->path . $pluginPath));
} elseif (isset($this->args[0])) {
$this->err(sprintf('%s in path %s not found.', $plugin, $this->path . $pluginPath));
$this->err(sprintf(__('%s in path %s not found.', true), $plugin, $this->path . $pluginPath));
$this->_stop();
} else {
return $this->__interactive($plugin);
$this->__interactive($plugin);
}
}

Expand All @@ -98,7 +97,6 @@ function execute() {
return $this->{$task}->execute();
}
}
$this->help();
}

/**
Expand Down Expand Up @@ -133,11 +131,11 @@ function bake($plugin) {
}

$this->hr();
$this->out(__("Plugin Name: ", true) . $plugin);
$this->out(__("Plugin Directory: ", 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?', array('y', 'n', 'q'), 'y');
$looksGood = $this->in(__('Look okay?', true), array('y', 'n', 'q'), 'y');

if (strtolower($looksGood) == 'y') {
$verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');
Expand Down
27 changes: 26 additions & 1 deletion cake/tests/cases/console/libs/tasks/plugin.test.php
Expand Up @@ -83,6 +83,7 @@ function startCase() {
$this->_paths = $paths = Configure::read('pluginPaths');
$this->_testPath = array_push($paths, TMP);
Configure::write('pluginPaths', $paths);
clearstatcache();
}

/**
Expand Down Expand Up @@ -132,7 +133,31 @@ function testBakeFoldersAndFiles() {
$file = $path . DS . 'bake_test_plugin_app_model.php';
$this->Task->expectAt(1, 'createFile', array($file, '*'), 'No AppModel %s');

@rmdir(TMP . 'bake_test_plugin');
$Folder =& new Folder(TMP . 'bake_test_plugin');
$Folder->delete();
}

/**
* Test Execute
*
* @return void
**/
function testExecuteWithOneArg() {
$this->Task->setReturnValueAt(0, 'in', $this->_testPath);
$this->Task->setReturnValueAt(1, 'in', 'y');
$this->Task->Dispatch->args = array('BakeTestPlugin');
$this->Task->args =& $this->Task->Dispatch->args;

$path = TMP . 'bake_test_plugin';
$file = $path . DS . 'bake_test_plugin_app_controller.php';
$this->Task->expectAt(0, 'createFile', array($file, '*'), 'No AppController %s');

$file = $path . DS . 'bake_test_plugin_app_model.php';
$this->Task->expectAt(1, 'createFile', array($file, '*'), 'No AppModel %s');

$this->Task->execute();
$Folder =& new Folder(TMP . 'bake_test_plugin');
$Folder->delete();
}

}
Expand Down

0 comments on commit 701d93c

Please sign in to comment.