mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing ViewTask so it creates properly cased directories for 2.0.
Fixes #1725
This commit is contained in:
parent
4d76840d44
commit
1d687214e9
2 changed files with 28 additions and 47 deletions
|
@ -51,14 +51,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
|
||||
*
|
||||
|
@ -109,7 +101,6 @@ class ViewTask extends BakeTask {
|
|||
}
|
||||
$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 @@ class ViewTask extends BakeTask {
|
|||
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 @@ class ViewTask extends BakeTask {
|
|||
$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 @@ class ViewTask extends BakeTask {
|
|||
$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 @@ class ViewTask extends BakeTask {
|
|||
}
|
||||
$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);
|
||||
}
|
||||
|
||||
|
|
|
@ -326,11 +326,10 @@ class ViewTaskTest extends CakeTestCase {
|
|||
*/
|
||||
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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
*/
|
||||
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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
*/
|
||||
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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
*/
|
||||
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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
*/
|
||||
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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
*/
|
||||
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,7 +434,6 @@ class ViewTaskTest extends CakeTestCase {
|
|||
*/
|
||||
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')
|
||||
|
@ -448,7 +441,7 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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 @@ class ViewTaskTest extends CakeTestCase {
|
|||
|
||||
$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/')
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue