mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fixing issue where ViewTask would make empty view files for actions that did not have templates. Test case added. Fixes #1040
This commit is contained in:
parent
ece055eefe
commit
c48c0d6295
2 changed files with 16 additions and 0 deletions
|
@ -366,6 +366,9 @@ class ViewTask extends BakeTask {
|
|||
if ($content === true) {
|
||||
$content = $this->getContent($action);
|
||||
}
|
||||
if (empty($content)) {
|
||||
return false;
|
||||
}
|
||||
$path = $this->getPath();
|
||||
$filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp';
|
||||
return $this->createFile($filename, $content);
|
||||
|
|
|
@ -374,6 +374,19 @@ class ViewTaskTest extends CakeTestCase {
|
|||
$this->Task->bake('index', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that baking a view with no template doesn't make a file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testBakeWithNoTemplate() {
|
||||
$this->Task->controllerName = 'ViewTaskComments';
|
||||
$this->Task->controllerPath = 'view_task_comments';
|
||||
|
||||
$this->Task->expectNever('createFile');
|
||||
$this->Task->bake('delete', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* test bake() with a -plugin param
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue