Skip to content

Commit

Permalink
Remove empty files for test and plugin bakes
Browse files Browse the repository at this point in the history
  • Loading branch information
bcrowe committed Sep 26, 2014
1 parent 42d4921 commit bf4c69a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Shell/Task/PluginTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ public function bake($plugin) {
$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);
Expand Down
18 changes: 18 additions & 0 deletions src/Shell/Task/TestTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ public function bake($type, $className) {
$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;
}
Expand Down Expand Up @@ -272,6 +274,22 @@ public function getRealClassName($type, $class) {
return $namespace . '\\' . $subSpace . '\\' . $class;
}

/**
* 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.
*
Expand Down

0 comments on commit bf4c69a

Please sign in to comment.