Browse files

Adding support for -plugin parameter to TestTask

Test cases for plugin path generation added.
  • Loading branch information...
1 parent 2181846 commit 44bffc5baebcf23a71f1554f85929ee6e52f8723 @markstory markstory committed Jun 6, 2009
View
25 cake/console/libs/tasks/test.php
@@ -156,16 +156,13 @@ function bake($type, $className) {
$this->Template->set(compact('className', 'methods', 'type', 'fullClassName', 'mock', 'construction'));
$out = $this->Template->generate('objects', 'test');
- if (strpos($this->path, $type) === false) {
- $this->filePath = $this->path . 'cases' . DS . Inflector::tableize($type) . DS;
- }
- $made = $this->createFile($this->filePath . Inflector::underscore($fullClassName) . '.test.php', $out);
+ $filename = $this->testCaseFileName($type, $className);
+ $made = $this->createFile($filename, $out);
if ($made) {
return $out;
}
return false;
}
-
/**
* Interact with the user and get their chosen type. Can exit the script.
*
@@ -400,5 +397,23 @@ function generateConstructor($type, $fullClassName) {
}
return "new $fullClassName()\n";
}
+
+/**
+ * make the filename for the test case. resolve the suffixes for controllers
+ * and get the plugin path if needed.
+ *
+ * @return string filename the test should be created on
+ **/
+ function testCaseFileName($type, $className) {
+ $path = $this->path;
+ if (isset($this->plugin)) {
+ $path = $this->_pluginPath($this->plugin) . 'tests' . DS;
+ }
+ $path .= 'cases' . DS . Inflector::tableize($type) . DS;
+ if (strtolower($type) == 'controller') {
+ $className = $this->getRealClassName($type, $className);
+ }
+ return $path . Inflector::underscore($className) . '.test.php';
+ }
}
?>
View
1 cake/tests/cases/console/libs/tasks/controller.test.php
@@ -256,6 +256,7 @@ function testBakeWithPlugin() {
$this->Task->expectAt(0, 'createFile', array($path, '*'));
$this->Task->bake('Articles', '--actions--', array(), array(), array());
}
+
/**
* test that bakeActions is creating the correct controller Code. (Using sessions)
*
View
13 cake/tests/cases/console/libs/tasks/test.test.php
@@ -392,6 +392,19 @@ function testMockClassGeneration() {
}
/**
+ * test bake() with a -plugin param
+ *
+ * @return void
+ **/
+ function testBakeWithPlugin() {
+ $this->Task->plugin = 'TestTest';
+
+ $path = APP . 'plugins' . DS . 'test_test' . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'form.test.php';
+ $this->Task->expectAt(0, 'createFile', array($path, '*'));
+ $this->Task->bake('Helper', 'Form');
+ }
+
+/**
* test execute with a type defined
*
* @return void

0 comments on commit 44bffc5

Please sign in to comment.