From d7dd63de82283f5b724cfe10d4848c323c5c6a44 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Tue, 9 Feb 2010 21:13:20 -0500 Subject: [PATCH] Adding the ability to bake all views for one specific action. Tests added. Fixes #251 --- cake/console/libs/tasks/view.php | 11 ++++++++++- .../cases/console/libs/tasks/view.test.php | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php index baf159d4e..62047a3b9 100644 --- a/cake/console/libs/tasks/view.php +++ b/cake/console/libs/tasks/view.php @@ -189,6 +189,10 @@ class ViewTask extends Shell { $this->Controller->interactive = false; $tables = $this->Controller->listAll($this->connection, false); + $actions = null; + if (isset($this->args[1])) { + $actions = array($this->args[1]); + } $this->interactive = false; foreach ($tables as $table) { $model = $this->_modelName($table); @@ -196,7 +200,9 @@ class ViewTask extends Shell { $this->controllerPath = Inflector::underscore($this->controllerName); if (App::import('Model', $model)) { $vars = $this->__loadController(); - $actions = $this->_methodsToBake(); + if (!$actions) { + $actions = $this->_methodsToBake(); + } $this->bakeActions($actions, $vars); } } @@ -441,6 +447,9 @@ class ViewTask extends Shell { $this->out("\tName of the controller views to bake. Can use Plugin.name"); $this->out("\tas a shortcut for plugin baking."); $this->out(); + $this->out(""); + $this->out("\tName of the action view to bake"); + $this->out(); $this->out('Commands:'); $this->out(); $this->out("view "); diff --git a/cake/tests/cases/console/libs/tasks/view.test.php b/cake/tests/cases/console/libs/tasks/view.test.php index fb49c4efa..66fb6b73c 100644 --- a/cake/tests/cases/console/libs/tasks/view.test.php +++ b/cake/tests/cases/console/libs/tasks/view.test.php @@ -453,6 +453,24 @@ class ViewTaskTest extends CakeTestCase { $this->Task->execute(); } +/** + * Test all() with action parameter + * + * @return void + * @access public + */ + function testExecuteIntoAllWithActionName() { + $this->Task->args = array('all', 'index'); + + $this->Task->Controller->setReturnValue('listAll', array('view_task_comments')); + $this->Task->Controller->expectOnce('listAll'); + + $this->Task->expectCallCount('createFile', 1); + $this->Task->expectAt(0, 'createFile', array(TMP . 'view_task_comments' . DS . 'index.ctp', '*')); + + $this->Task->execute(); + } + /** * test `cake bake view $controller view` *