From 5eae9fcba5653b907c0f9142e3484e2d24d14a25 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 10 Jun 2009 22:19:14 -0400 Subject: [PATCH] Adding test case for PluginTask::bake() --- cake/console/libs/tasks/plugin.php | 10 ++++------ .../cases/console/libs/tasks/plugin.test.php | 20 ++++++++++++++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/cake/console/libs/tasks/plugin.php b/cake/console/libs/tasks/plugin.php index 935d773f9..187b12971 100644 --- a/cake/console/libs/tasks/plugin.php +++ b/cake/console/libs/tasks/plugin.php @@ -123,18 +123,16 @@ class PluginTask extends Shell { * @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 @@ class PluginTask extends Shell { $Folder->create($this->path . $pluginPath . DS . $directory); } - if (low($verbose) == 'y') { + if (strtolower($verbose) == 'y') { foreach ($Folder->messages() as $message) { $this->out($message); } diff --git a/cake/tests/cases/console/libs/tasks/plugin.test.php b/cake/tests/cases/console/libs/tasks/plugin.test.php index af5150f76..8b10d109e 100644 --- a/cake/tests/cases/console/libs/tasks/plugin.test.php +++ b/cake/tests/cases/console/libs/tasks/plugin.test.php @@ -71,6 +71,7 @@ class PluginTaskTest extends CakeTestCase { $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 @@ class PluginTaskTest extends CakeTestCase { * * @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'); } } ?> \ No newline at end of file