diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index b4a493b3f..859b73a11 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -290,7 +290,8 @@ class ControllerTask extends BakeTask { $displayField = $modelObj->displayField; $primaryKey = $modelObj->primaryKey; - $this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName', + $this->Template->set(compact( + 'plugin', 'admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName', 'displayField', 'primaryKey' )); @@ -312,7 +313,10 @@ class ControllerTask extends BakeTask { $isScaffold = ($actions === 'scaffold') ? true : false; - $this->Template->set('plugin', $this->plugin); + $this->Template->set(array( + 'plugin' => $this->plugin, + 'pluginPath' => empty($this->plugin) ? '' : $this->plugin . '.' + )); $this->Template->set(compact('controllerName', 'actions', 'helpers', 'components', 'isScaffold')); $contents = $this->Template->generate('classes', 'controller'); diff --git a/lib/Cake/Console/Templates/default/classes/controller.ctp b/lib/Cake/Console/Templates/default/classes/controller.ctp index d476bb783..ba3c343f7 100644 --- a/lib/Cake/Console/Templates/default/classes/controller.ctp +++ b/lib/Cake/Console/Templates/default/classes/controller.ctp @@ -20,6 +20,7 @@ */ echo " /** * Controller diff --git a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php index 37e856ad6..c0126d279 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php @@ -315,15 +315,18 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->expects($this->at(3))->method('createFile')->with( $path, new PHPUnit_Framework_Constraint_PCREMatch('/ArticlesController extends ControllerTestAppController/') - ); + )->will($this->returnValue(true)); $this->Task->bake('Articles', '--actions--', array(), array(), array()); $this->Task->plugin = 'ControllerTest'; $path = APP . 'Plugin' . DS . 'ControllerTest' . DS . 'Controller' . DS . 'ArticlesController.php'; - $this->Task->bake('Articles', '--actions--', array(), array(), array()); + $result = $this->Task->bake('Articles', '--actions--', array(), array(), array()); + + $this->assertContains("App::uses('ControllerTestAppController', 'ControllerTest.Controller');", $result); + $this->assertEquals('ControllerTest', $this->Task->Template->templateVars['plugin']); + $this->assertEquals('ControllerTest.', $this->Task->Template->templateVars['pluginPath']); - $this->assertEqual($this->Task->Template->templateVars['plugin'], 'ControllerTest'); CakePlugin::unload(); }