Skip to content

Commit

Permalink
Removing $uses as part of bake.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 19, 2009
1 parent 9d405fa commit 0d7b86f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 31 deletions.
26 changes: 6 additions & 20 deletions cake/console/libs/tasks/controller.php
Expand Up @@ -143,7 +143,7 @@ function __interactive() {
$this->out("Baking {$controllerName}Controller");
$this->hr();

$helpers = $components = $uses = array();
$helpers = $components = array();
$actions = '';
$wannaUseSession = 'y';
$wannaBakeAdminCrud = 'n';
Expand Down Expand Up @@ -172,7 +172,6 @@ function __interactive() {

$helpers = $this->doHelpers();
$components = $this->doComponents();
$uses = $this->doUses();

$wannaUseSession = $this->in(
__("Would you like to use Session flash messages?", true), array('y','n'), 'y'
Expand All @@ -195,13 +194,13 @@ function __interactive() {
$looksGood = $this->in(__('Look okay?', true), array('y','n'), 'y');

if (strtolower($looksGood) == 'y') {
$baked = $this->bake($controllerName, $actions, $helpers, $components, $uses);
$baked = $this->bake($controllerName, $actions, $helpers, $components);
if ($baked && $this->_checkUnitTest()) {
$this->bakeTest($controllerName);
}
}
} else {
$baked = $this->bake($controllerName, $actions, $helpers, $components, $uses);
$baked = $this->bake($controllerName, $actions, $helpers, $components);
if ($baked && $this->_checkUnitTest()) {
$this->bakeTest($controllerName);
}
Expand All @@ -213,7 +212,7 @@ function __interactive() {
*
* @return void
**/
function confirmController($controllerName, $useDynamicScaffold, $uses, $helpers, $components) {
function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) {
$this->out('');
$this->hr();
$this->out('The following controller will be created:');
Expand All @@ -227,7 +226,6 @@ function confirmController($controllerName, $useDynamicScaffold, $uses, $helpers
$properties = array(
'helpers' => __("Helpers:", true),
'components' => __('Components:', true),
'uses' => __('Uses:', true)
);

foreach ($properties as $var => $title) {
Expand Down Expand Up @@ -432,11 +430,11 @@ function bakeActions($controllerName, $admin = null, $wannaUseSession = true) {
* @return string Baked controller
* @access private
*/
function bake($controllerName, $actions = '', $helpers = null, $components = null, $uses = null) {
function bake($controllerName, $actions = '', $helpers = null, $components = null) {
$isScaffold = ($actions === 'scaffold') ? true : false;

$this->Template->set('plugin', $this->plugin);
$this->Template->set(compact('controllerName', 'actions', 'helpers', 'components', 'uses', 'isScaffold'));
$this->Template->set(compact('controllerName', 'actions', 'helpers', 'components', 'isScaffold'));
$contents = $this->Template->generate('objects', 'controller');

$filename = $this->path . $this->_controllerPath($controllerName) . '_controller.php';
Expand Down Expand Up @@ -507,18 +505,6 @@ function doComponents() {
);
}

/**
* Interact with the user and get a list of additional models to use
*
* @return array Models the user wants to use.
**/
function doUses() {
return $this->_doPropertyChoices(
__("Would you like this controller to use any additional models?", true),
__("Please provide a comma separated list of the model names you'd like to use.\nExample: 'Post, Comment, User'", true)
);
}

/**
* Common code for property choice handling.
*
Expand Down
7 changes: 0 additions & 7 deletions cake/console/libs/templates/objects/controller.ctp
Expand Up @@ -29,13 +29,6 @@ class <?php echo $controllerName; ?>Controller extends <?php echo $plugin; ?>App
var $scaffold;
<?php else: ?>
<?php
if (count($uses)):
echo "\tvar \$uses = array('" . $this->_modelName($controllerName) . "'";
foreach ($uses as $use):
echo ", '" . $this->_modelName($use) . "'";
endforeach;
echo ");\n";
endif;

echo "\tvar \$helpers = array('Html', 'Form'";
if (count($helpers)):
Expand Down
30 changes: 26 additions & 4 deletions cake/tests/cases/console/libs/tasks/controller.test.php
Expand Up @@ -196,8 +196,7 @@ function testConfirmController() {
$this->Task->expectAt(2, 'out', array("Controller Name:\n\t$controller"));
$this->Task->expectAt(3, 'out', array("Helpers:\n\tAjax, Time"));
$this->Task->expectAt(4, 'out', array("Components:\n\tAcl, Auth"));
$this->Task->expectAt(5, 'out', array("Uses:\n\tComment, User"));
$this->Task->confirmController($controller, $scaffold, $uses, $helpers, $components);
$this->Task->confirmController($controller, $scaffold, $helpers, $components);
}

/**
Expand All @@ -214,7 +213,6 @@ function testBake() {
$result = $this->Task->bake('Articles', '--actions--', $helpers, $components, $uses);
$this->assertPattern('/class ArticlesController extends AppController/', $result);
$this->assertPattern('/\$components \= array\(\'Acl\', \'Auth\'\)/', $result);
$this->assertPattern('/\$uses \= array\(\'Article\', \'Comment\', \'User\'\)/', $result);
$this->assertPattern('/\$helpers \= array\(\'Html\', \'Form\', \'Ajax\', \'Time\'\)/', $result);
$this->assertPattern('/\-\-actions\-\-/', $result);

Expand All @@ -223,7 +221,31 @@ function testBake() {
$this->assertPattern('/var \$scaffold/', $result);
$this->assertNoPattern('/helpers/', $result);
$this->assertNoPattern('/components/', $result);
$this->assertNoPattern('/uses/', $result);
}

/**
* test that execute runs all when the first arg == all
*
* @return void
**/
function testExecuteIntoAll() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');

$filename = '/my/path/articles_controller.php';
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class ArticlesController/')));

$filename = '/my/path/articles_tags_contoller.php';
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class ArticlesTagsController/')));

$filename = '/my/path/comments_controller.php';
$this->Task->expectAt(2, 'createFile', array($filename, new PatternExpectation('/class CommentsController/')));

$filename = '/my/path/tags_controller.php';
$this->Task->expectAt(4, 'createFile', array($filename, new PatternExpectation('/class TagsController/')));

$this->Task->execute();
}
}
?>

0 comments on commit 0d7b86f

Please sign in to comment.