Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding test case for PluginTask::bake()

  • Loading branch information...
commit 5eae9fcba5653b907c0f9142e3484e2d24d14a25 1 parent 2f5711c
@markstory markstory authored
View
10 cake/console/libs/tasks/plugin.php
@@ -123,18 +123,16 @@ function __interactive($plugin = null) {
* @return bool
*/
function bake($plugin) {
-
$pluginPath = Inflector::underscore($plugin);
$this->hr();
- $this->out("Plugin Name: $plugin");
- $this->out("Plugin Directory: {$this->path}{$pluginPath}");
+ $this->out(__("Plugin Name: ", true) . $plugin);
+ $this->out(__("Plugin Directory: ", true) . $this->path . $pluginPath);
$this->hr();
-
$looksGood = $this->in('Look okay?', array('y', 'n', 'q'), 'y');
- if (low($looksGood) == 'y') {
+ if (strtolower($looksGood) == 'y') {
$verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');
$Folder = new Folder($this->path . $pluginPath);
@@ -144,7 +142,7 @@ function bake($plugin) {
$Folder->create($this->path . $pluginPath . DS . $directory);
}
- if (low($verbose) == 'y') {
+ if (strtolower($verbose) == 'y') {
foreach ($Folder->messages() as $message) {
$this->out($message);
}
View
20 cake/tests/cases/console/libs/tasks/plugin.test.php
@@ -71,6 +71,7 @@ function startTest() {
$this->Dispatcher->shellPaths = Configure::read('shellPaths');
$this->Task =& new MockPluginTask($this->Dispatcher);
$this->Task->Dispatch =& $this->Dispatcher;
+ $this->Task->path = TMP;
}
/**
@@ -88,8 +89,25 @@ function endTest() {
*
* @return void
**/
- function testBake() {
+ function testBakeFoldersAndFiles() {
+ $this->Task->setReturnValueAt(0, 'in', 'y');
+ $this->Task->bake('BakeTestPlugin');
+ $path = TMP . 'bake_test_plugin';
+ $this->assertTrue(is_dir($path), 'No plugin dir %s');
+ $this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s');
+ $this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s');
+ $this->assertTrue(is_dir($path . DS . 'models'), 'No models dir %s');
+ $this->assertTrue(is_dir($path . DS . 'views'), 'No views dir %s');
+ $this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s');
+
+ $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');
+
+ @rmdir(TMP . 'bake_test_plugin');
}
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.