Skip to content

Commit

Permalink
Updating view and controller tasks to use (_singluar|_plural)HumanNam…
Browse files Browse the repository at this point in the history
…e functions

Modifying the test case to expect humanized forms
  • Loading branch information
AD7six committed Aug 19, 2009
1 parent ce8dd03 commit 7c4dfed
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions cake/console/libs/tasks/controller.php
Expand Up @@ -92,7 +92,7 @@ function execute() {
$actions= $this->bakeActions($controller, $admin);
}
}

if (!empty($this->args[2]) && $this->args[2] == 'admin') {
$admin = $this->Project->getAdmin();
if ($admin) {
Expand Down Expand Up @@ -294,8 +294,8 @@ function bakeActions($controllerName, $admin = null, $wannaUseSession = true) {
$controllerPath = $this->_controllerPath($controllerName);
$pluralName = $this->_pluralName($currentModelName);
$singularName = Inflector::variable($currentModelName);
$singularHumanName = Inflector::humanize($currentModelName);
$pluralHumanName = Inflector::humanize($controllerName);
$singularHumanName = $this->_singularHumanName($currentModelName);
$pluralHumanName = $this->_pluralName($controllerName);

$this->Template->set(compact('admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName',
'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName'));
Expand Down
10 changes: 4 additions & 6 deletions cake/console/libs/tasks/view.php
Expand Up @@ -284,23 +284,21 @@ function __loadController() {
$primaryKey = $modelObj->primaryKey;
$displayField = $modelObj->displayField;
$singularVar = Inflector::variable($modelClass);
$pluralVar = Inflector::variable($this->controllerName);
$singularHumanName = Inflector::humanize($modelClass);
$pluralHumanName = Inflector::humanize($this->controllerName);
$singularHumanName = $this->_singularHumanName($modelClass);
$schema = $modelObj->schema();
$fields = array_keys($schema);
$associations = $this->__associations($modelObj);
} else {
$primaryKey = null;
$displayField = null;
$singularVar = Inflector::variable(Inflector::singularize($this->controllerName));
$pluralVar = Inflector::variable($this->controllerName);
$singularHumanName = Inflector::humanize(Inflector::singularize($this->controllerName));
$pluralHumanName = Inflector::humanize($this->controllerName);
$singularHumanName = $this->_singularHumanName($this->controllerName);
$fields = array();
$schema = array();
$associations = array();
}
$pluralVar = Inflector::variable($this->controllerName);
$pluralHumanName = $this->_pluralHumanName($this->controllerName);

return compact('modelClass', 'schema', 'primaryKey', 'displayField', 'singularVar', 'pluralVar',
'singularHumanName', 'pluralHumanName', 'fields','associations');
Expand Down
12 changes: 6 additions & 6 deletions cake/tests/cases/console/libs/tasks/view.test.php
Expand Up @@ -260,11 +260,11 @@ function testBakeActions() {

$this->Task->expectAt(0, 'createFile', array(
TMP . 'view_task_comments' . DS . 'view.ctp',
new PatternExpectation('/ViewTaskComments/')
new PatternExpectation('/View Task Comments/')
));
$this->Task->expectAt(1, 'createFile', array(
TMP . 'view_task_comments' . DS . 'edit.ctp',
new PatternExpectation('/Edit ViewTaskComment/')
new PatternExpectation('/Edit View Task Comment/')
));
$this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'index.ctp',
Expand Down Expand Up @@ -389,11 +389,11 @@ function testExecuteInteractive() {
));
$this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'add.ctp',
new PatternExpectation('/Add ViewTaskComment/')
new PatternExpectation('/Add View Task Comment/')
));
$this->Task->expectAt(3, 'createFile', array(
TMP . 'view_task_comments' . DS . 'edit.ctp',
new PatternExpectation('/Edit ViewTaskComment/')
new PatternExpectation('/Edit View Task Comment/')
));

$this->Task->execute();
Expand Down Expand Up @@ -426,11 +426,11 @@ function testExecuteInteractiveWithAdmin() {
));
$this->Task->expectAt(2, 'createFile', array(
TMP . 'view_task_comments' . DS . 'admin_add.ctp',
new PatternExpectation('/Add ViewTaskComment/')
new PatternExpectation('/Add View Task Comment/')
));
$this->Task->expectAt(3, 'createFile', array(
TMP . 'view_task_comments' . DS . 'admin_edit.ctp',
new PatternExpectation('/Edit ViewTaskComment/')
new PatternExpectation('/Edit View Task Comment/')
));

$this->Task->execute();
Expand Down

0 comments on commit 7c4dfed

Please sign in to comment.