Browse files

Fixing ViewTask so it creates properly cased directories for 2.0.

Fixes #1725
  • Loading branch information...
1 parent 4d76840 commit 1d687214e97edf204f7357fe0200a023f6c78981 @markstory markstory committed May 22, 2011
Showing with 28 additions and 47 deletions.
  1. +2 −14 lib/Cake/Console/Command/Task/ViewTask.php
  2. +26 −33 lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php
View
16 lib/Cake/Console/Command/Task/ViewTask.php
@@ -52,14 +52,6 @@ class ViewTask extends BakeTask {
public $controllerName = null;
/**
- * Path to controller to put views
- *
- * @var string
- * @access public
- */
- public $controllerPath = null;
-
-/**
* The template file to use
*
* @var string
@@ -109,7 +101,6 @@ public function execute() {
}
$action = null;
$this->controllerName = $this->_controllerName($this->args[0]);
- $this->controllerPath = $this->_controllerPath($this->controllerName);
$this->Project->interactive = false;
if (strtolower($this->args[0]) == 'all') {
@@ -189,7 +180,6 @@ public function all() {
foreach ($tables as $table) {
$model = $this->_modelName($table);
$this->controllerName = $this->_controllerName($model);
- $this->controllerPath = Inflector::underscore($this->controllerName);
App::uses($model, 'Model');
if (class_exists($model)) {
$vars = $this->__loadController();
@@ -220,8 +210,6 @@ protected function _interactive() {
$this->Controller->connection = $this->connection;
$this->controllerName = $this->Controller->getName();
- $this->controllerPath = strtolower(Inflector::underscore($this->controllerName));
-
$prompt = __d('cake_console', "Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite %s views if it exist.", $this->controllerName);
$interactive = $this->in($prompt, array('y', 'n'), 'n');
@@ -343,7 +331,7 @@ public function customAction() {
$this->hr();
$this->out(__d('cake_console', 'Controller Name: %s', $this->controllerName));
$this->out(__d('cake_console', 'Action Name: %s', $action));
- $this->out(__d('cake_console', 'Path: %s', $this->params['app'] . DS . $this->controllerPath . DS . Inflector::underscore($action) . ".ctp"));
+ $this->out(__d('cake_console', 'Path: %s', $this->params['app'] . DS . $this->controllerName . DS . Inflector::underscore($action) . ".ctp"));
$this->hr();
$looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y','n'), 'y');
if (strtolower($looksGood) == 'y') {
@@ -370,7 +358,7 @@ public function bake($action, $content = '') {
}
$this->out("\n" . __d('cake_console', 'Baking `%s` view file...', $action), 1, Shell::QUIET);
$path = $this->getPath();
- $filename = $path . $this->controllerPath . DS . Inflector::underscore($action) . '.ctp';
+ $filename = $path . $this->controllerName . DS . Inflector::underscore($action) . '.ctp';
return $this->createFile($filename, $content);
}
View
59 lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php
@@ -326,11 +326,10 @@ public function testGetContentWithAdminAction() {
*/
public function testBakeView() {
$this->Task->controllerName = 'ViewTaskComments';
- $this->Task->controllerPath = 'view_task_comments';
$this->Task->expects($this->at(0))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'view.ctp',
+ TMP . 'ViewTaskComments' . DS . 'view.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/View Task Articles/')
);
@@ -344,11 +343,10 @@ public function testBakeView() {
*/
function testBakeEdit() {
$this->Task->controllerName = 'ViewTaskComments';
- $this->Task->controllerPath = 'view_task_comments';
$this->Task->expects($this->at(0))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'edit.ctp',
+ TMP . 'ViewTaskComments' . DS . 'edit.ctp',
new PHPUnit_Framework_Constraint_IsAnything()
);
$this->Task->bake('edit', true);
@@ -361,11 +359,10 @@ function testBakeEdit() {
*/
function testBakeIndex() {
$this->Task->controllerName = 'ViewTaskComments';
- $this->Task->controllerPath = 'view_task_comments';
$this->Task->expects($this->at(0))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'index.ctp',
+ TMP . 'ViewTaskComments' . DS . 'index.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/\$viewTaskComment\[\'Article\'\]\[\'title\'\]/')
);
$this->Task->bake('index', true);
@@ -378,7 +375,6 @@ function testBakeIndex() {
*/
function testBakeWithNoTemplate() {
$this->Task->controllerName = 'ViewTaskComments';
- $this->Task->controllerPath = 'view_task_comments';
$this->Task->expects($this->never())->method('createFile');
$this->Task->bake('delete', true);
@@ -391,13 +387,12 @@ function testBakeWithNoTemplate() {
*/
public function testBakeWithPlugin() {
$this->Task->controllerName = 'ViewTaskComments';
- $this->Task->controllerPath = 'view_task_comments';
$this->Task->plugin = 'TestTest';
$this->Task->name = 'View';
//fake plugin path
CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS));
- $path = APP . 'Plugin' . DS . 'TestTest' . DS . 'View' . DS . 'view_task_comments' . DS . 'view.ctp';
+ $path = APP . 'Plugin' . DS . 'TestTest' . DS . 'View' . DS . 'ViewTaskComments' . DS . 'view.ctp';
$this->Task->expects($this->once())->method('createFile')
->with($path, new PHPUnit_Framework_Constraint_IsAnything());
@@ -412,21 +407,20 @@ public function testBakeWithPlugin() {
*/
public function testBakeActions() {
$this->Task->controllerName = 'ViewTaskComments';
- $this->Task->controllerPath = 'view_task_comments';
$this->Task->expects($this->at(0))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'view.ctp',
+ TMP . 'ViewTaskComments' . DS . 'view.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/View Task Comments/')
);
$this->Task->expects($this->at(1))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'edit.ctp',
+ TMP . 'ViewTaskComments' . DS . 'edit.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/Edit View Task Comment/')
);
$this->Task->expects($this->at(2))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'index.ctp',
+ TMP . 'ViewTaskComments' . DS . 'index.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/ViewTaskComment/')
);
@@ -440,15 +434,14 @@ public function testBakeActions() {
*/
public function testCustomAction() {
$this->Task->controllerName = 'ViewTaskComments';
- $this->Task->controllerPath = 'view_task_comments';
$this->Task->params['app'] = APP;
$this->Task->expects($this->any())->method('in')
->will($this->onConsecutiveCalls('', 'my_action', 'y'));
$this->Task->expects($this->once())->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'my_action.ctp',
+ TMP . 'ViewTaskComments' . DS . 'my_action.ctp',
new PHPUnit_Framework_Constraint_IsAnything()
);
@@ -468,12 +461,12 @@ public function testExecuteIntoAll() {
$this->Task->expects($this->at(0))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'index.ctp',
+ TMP . 'ViewTaskComments' . DS . 'index.ctp',
new PHPUnit_Framework_Constraint_IsAnything()
);
$this->Task->expects($this->at(1))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'add.ctp',
+ TMP . 'ViewTaskComments' . DS . 'add.ctp',
new PHPUnit_Framework_Constraint_IsAnything()
);
$this->Task->expects($this->exactly(2))->method('createFile');
@@ -494,7 +487,7 @@ public function testExecuteIntoAllWithActionName() {
$this->Task->expects($this->once())->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'index.ctp',
+ TMP . 'ViewTaskComments' . DS . 'index.ctp',
new PHPUnit_Framework_Constraint_IsAnything()
);
@@ -512,7 +505,7 @@ public function testExecuteWithActionParam() {
$this->Task->expects($this->once())->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'view.ctp',
+ TMP . 'ViewTaskComments' . DS . 'view.ctp',
new PHPUnit_Framework_Constraint_IsAnything()
);
$this->Task->execute();
@@ -529,12 +522,12 @@ public function testExecuteWithController() {
$this->Task->expects($this->at(0))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'index.ctp',
+ TMP . 'ViewTaskComments' . DS . 'index.ctp',
new PHPUnit_Framework_Constraint_IsAnything()
);
$this->Task->expects($this->at(1))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'add.ctp',
+ TMP . 'ViewTaskComments' . DS . 'add.ctp',
new PHPUnit_Framework_Constraint_IsAnything()
);
$this->Task->expects($this->exactly(2))->method('createFile');
@@ -562,12 +555,12 @@ public function testExecuteWithControllerVariations($name) {
$this->Task->expects($this->at(0))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'index.ctp',
+ TMP . 'ViewTaskComments' . DS . 'index.ctp',
new PHPUnit_Framework_Constraint_IsAnything()
);
$this->Task->expects($this->at(1))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'add.ctp',
+ TMP . 'ViewTaskComments' . DS . 'add.ctp',
new PHPUnit_Framework_Constraint_IsAnything()
);
$this->Task->execute();
@@ -593,7 +586,7 @@ public function testExecuteWithControllerAndAdminFlag() {
foreach ($views as $i => $view) {
$this->Task->expects($this->at($i))->method('createFile')
->with(
- TMP . 'view_task_articles' . DS . $view,
+ TMP . 'ViewTaskArticles' . DS . $view,
new PHPUnit_Framework_Constraint_IsAnything()
);
}
@@ -620,25 +613,25 @@ public function testExecuteInteractive() {
$this->Task->expects($this->at(3))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'index.ctp',
+ TMP . 'ViewTaskComments' . DS . 'index.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/ViewTaskComment/')
);
$this->Task->expects($this->at(4))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'view.ctp',
+ TMP . 'ViewTaskComments' . DS . 'view.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/ViewTaskComment/')
);
$this->Task->expects($this->at(5))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'add.ctp',
+ TMP . 'ViewTaskComments' . DS . 'add.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/Add View Task Comment/')
);
$this->Task->expects($this->at(6))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'edit.ctp',
+ TMP . 'ViewTaskComments' . DS . 'edit.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/Edit View Task Comment/')
);
@@ -658,7 +651,7 @@ public function testExecuteWithAlternateTemplates() {
$this->Task->expects($this->once())->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'list.ctp',
+ TMP . 'ViewTaskComments' . DS . 'list.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/ViewTaskComment/')
);
$this->Task->execute();
@@ -685,25 +678,25 @@ public function testExecuteInteractiveWithAdmin() {
$this->Task->expects($this->at(3))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'admin_index.ctp',
+ TMP . 'ViewTaskComments' . DS . 'admin_index.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/ViewTaskComment/')
);
$this->Task->expects($this->at(4))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'admin_view.ctp',
+ TMP . 'ViewTaskComments' . DS . 'admin_view.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/ViewTaskComment/')
);
$this->Task->expects($this->at(5))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'admin_add.ctp',
+ TMP . 'ViewTaskComments' . DS . 'admin_add.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/Add View Task Comment/')
);
$this->Task->expects($this->at(6))->method('createFile')
->with(
- TMP . 'view_task_comments' . DS . 'admin_edit.ctp',
+ TMP . 'ViewTaskComments' . DS . 'admin_edit.ctp',
new PHPUnit_Framework_Constraint_PCREMatch('/Edit View Task Comment/')
);

0 comments on commit 1d68721

Please sign in to comment.