Permalink
Browse files

Removing $uses as part of bake.

  • Loading branch information...
1 parent 9d405fa commit 0d7b86fc8b169e513e618c4fc0491ee668c39b8b @markstory markstory committed May 19, 2009
@@ -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';
@@ -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'
@@ -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);
}
@@ -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:');
@@ -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) {
@@ -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';
@@ -508,18 +506,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.
*
* @param string $prompt A yes/no question to precede the list
@@ -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)):
@@ -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);
}
/**
@@ -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);
@@ -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.