From 701d93c61c65c6a1cceddb58b722bf29e025fbac Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 10 Jun 2009 23:21:42 -0400 Subject: [PATCH] Adding test cases for execute() Adding more i18n Fixing issues with folders being left behind by tests. --- cake/console/libs/tasks/plugin.php | 16 +++++------ .../cases/console/libs/tasks/plugin.test.php | 27 ++++++++++++++++++- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/cake/console/libs/tasks/plugin.php b/cake/console/libs/tasks/plugin.php index 2868fb1ffdb..7be18e37af0 100644 --- a/cake/console/libs/tasks/plugin.php +++ b/cake/console/libs/tasks/plugin.php @@ -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); } } @@ -98,7 +97,6 @@ function execute() { return $this->{$task}->execute(); } } - $this->help(); } /** @@ -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'); diff --git a/cake/tests/cases/console/libs/tasks/plugin.test.php b/cake/tests/cases/console/libs/tasks/plugin.test.php index 4cb8b3d2a4f..b5f639d65af 100644 --- a/cake/tests/cases/console/libs/tasks/plugin.test.php +++ b/cake/tests/cases/console/libs/tasks/plugin.test.php @@ -83,6 +83,7 @@ function startCase() { $this->_paths = $paths = Configure::read('pluginPaths'); $this->_testPath = array_push($paths, TMP); Configure::write('pluginPaths', $paths); + clearstatcache(); } /** @@ -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(); } }