Browse Source

Merge pull request #4736 from bcrowe/3.0-empty-files

3.0 - Remove empty files for test and plugin bakes
José Lorenzo Rodríguez 11 years ago
parent
commit
5b3dc054d2
2 changed files with 20 additions and 0 deletions
  1. 2 0
      src/Shell/Task/PluginTask.php
  2. 18 0
      src/Shell/Task/TestTask.php

+ 2 - 0
src/Shell/Task/PluginTask.php

@@ -138,6 +138,8 @@ class PluginTask extends BakeTask {
 			$out .= "class AppController extends BaseController {\n\n";
 			$out .= "}\n";
 			$this->createFile($this->path . $plugin . DS . $classBase . DS . 'Controller' . DS . $controllerFileName, $out);
+			$emptyFile = $this->path  . 'empty';
+			$this->_deleteEmptyFile($emptyFile);
 
 			$hasAutoloader = $this->_modifyAutoloader($plugin, $this->path);
 			$this->_generateRoutes($plugin, $this->path);

+ 18 - 0
src/Shell/Task/TestTask.php

@@ -209,6 +209,8 @@ class TestTask extends BakeTask {
 		$out = $this->Template->generate('classes', 'test');
 
 		$filename = $this->testCaseFileName($type, $fullClassName);
+		$emptyFile = $this->getPath() . $this->getSubspacePath($type) . DS . 'empty';
+		$this->_deleteEmptyFile($emptyFile);
 		if ($this->createFile($filename, $out)) {
 			return $out;
 		}
@@ -273,6 +275,22 @@ class TestTask extends BakeTask {
 	}
 
 /**
+ * Gets the subspace path for a test.
+ *
+ * @param string $type The Type of object you are generating tests for eg. controller.
+ * @return string Path of the subspace.
+ */
+	public function getSubspacePath($type) {
+		$namespace = Configure::read('App.namespace');
+		if ($this->plugin) {
+			$namespace = $this->plugin;
+		}
+		$suffix = $this->classSuffixes[strtolower($type)];
+		$subspace = $this->mapType($type);
+		return str_replace('\\', DS, $subspace);
+	}
+
+/**
  * Map the types that TestTask uses to concrete types that App::className can use.
  *
  * @param string $type The type of thing having a test generated.