Permalink
Browse files

Making -plugin function with ViewTask

Adding tests for -plugin parameter
Removing extra Folder calls.
  • Loading branch information...
1 parent 4141158 commit 4d7f00504a6acc848d493349b1b3380658b95caa @markstory markstory committed Jun 7, 2009
Showing with 21 additions and 10 deletions.
  1. +5 −10 cake/console/libs/tasks/view.php
  2. +16 −0 cake/tests/cases/console/libs/tasks/view.test.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);
}
/**
@@ -177,6 +177,22 @@ function testBake() {
}
/**
+ * 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.
*
* @return void

0 comments on commit 4d7f005

Please sign in to comment.