diff --git a/cake/console/libs/tasks/view.php b/cake/console/libs/tasks/view.php index 67f5a1e12ab..700008a68df 100644 --- a/cake/console/libs/tasks/view.php +++ b/cake/console/libs/tasks/view.php @@ -339,17 +339,12 @@ function bake($action, $content = '') { if ($content === true) { $content = $this->getContent($action); } - $filename = $this->path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp'; - $Folder =& new Folder($this->path . $this->controllerPath, true); - $errors = $Folder->errors(); - if (empty($errors)) { - return $this->createFile($filename, $content); - } else { - foreach ($errors as $error) { - $this->err($error); - } + $path = $this->path; + if (isset($this->plugin)) { + $path = $this->_pluginPath($this->plugin) . 'views' . DS; } - return false; + $filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp'; + return $this->createFile($filename, $content); } /** diff --git a/cake/tests/cases/console/libs/tasks/view.test.php b/cake/tests/cases/console/libs/tasks/view.test.php index aaae32239b4..f76229d7ca8 100644 --- a/cake/tests/cases/console/libs/tasks/view.test.php +++ b/cake/tests/cases/console/libs/tasks/view.test.php @@ -176,6 +176,22 @@ function testBake() { @rmdir(TMP . 'view_task_comments'); } +/** + * test bake() with a -plugin param + * + * @return void + **/ + function testBakeWithPlugin() { + $this->Task->path = TMP; + $this->Task->controllerName = 'ViewTaskComments'; + $this->Task->controllerPath = 'view_task_comments'; + $this->Task->plugin = 'TestTest'; + + $path = APP . 'plugins' . DS . 'test_test' . DS . 'views' . DS . 'view_task_comments' . DS . 'view.ctp'; + $this->Task->expectAt(0, 'createFile', array($path, '*')); + $this->Task->bake('view', true); + } + /** * test bake actions baking multiple actions. *