Permalink
Browse files

Merge remote branch 'origin/1.3' into 1.3

  • Loading branch information...
2 parents 7334fdf + e6664f0 commit 7d81d81176b1bbd882812eedaefc5468315ffb16 @predominant predominant committed Mar 9, 2010
Showing with 423 additions and 226 deletions.
  1. +0 −8 cake/console/libs/bake.php
  2. +60 −0 cake/console/libs/tasks/bake.php
  3. +6 −14 cake/console/libs/tasks/controller.php
  4. +17 −23 cake/console/libs/tasks/fixture.php
  5. +7 −22 cake/console/libs/tasks/model.php
  6. +3 −3 cake/console/libs/tasks/project.php
  7. +4 −19 cake/console/libs/tasks/test.php
  8. +5 −15 cake/console/libs/tasks/view.php
  9. +2 −1 cake/console/templates/default/views/form.ctp
  10. +1 −1 cake/dispatcher.php
  11. +2 −2 cake/libs/cache.php
  12. +1 −1 cake/libs/controller/controller.php
  13. +1 −1 cake/libs/model/connection_manager.php
  14. +7 −6 cake/libs/model/datasources/dbo_source.php
  15. +52 −49 cake/libs/model/model.php
  16. +50 −27 cake/libs/view/helpers/form.php
  17. +6 −5 cake/libs/view/helpers/jquery_engine.php
  18. +4 −4 cake/libs/view/helpers/mootools_engine.php
  19. +5 −5 cake/libs/view/helpers/prototype_engine.php
  20. +57 −1 cake/tests/cases/console/libs/tasks/controller.test.php
  21. +32 −0 cake/tests/cases/console/libs/tasks/fixture.test.php
  22. +34 −0 cake/tests/cases/console/libs/tasks/model.test.php
  23. +1 −0 cake/tests/cases/console/libs/tasks/test.test.php
  24. +21 −0 cake/tests/cases/console/libs/tasks/view.test.php
  25. +1 −1 cake/tests/cases/dispatcher.test.php
  26. +4 −4 cake/tests/cases/libs/debugger.test.php
  27. +1 −1 cake/tests/cases/libs/model/connection_manager.test.php
  28. +23 −4 cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
  29. +5 −5 cake/tests/cases/libs/model/model_behavior.test.php
  30. +1 −1 cake/tests/cases/libs/router.test.php
  31. +1 −1 cake/tests/cases/libs/security.test.php
  32. +7 −0 cake/tests/cases/libs/view/helpers/form.test.php
  33. +1 −1 cake/tests/cases/libs/xml.test.php
  34. +1 −1 cake/tests/lib/code_coverage_manager.php
@@ -48,10 +48,6 @@ function loadTasks() {
parent::loadTasks();
$task = Inflector::classify($this->command);
if (isset($this->{$task}) && !in_array($task, array('Project', 'DbConfig'))) {
- if (empty($this->{$task}->path)) {
- $path = Inflector::underscore(Inflector::pluralize($this->command));
- $this->{$task}->path = $this->params['working'] . DS . $path . DS;
- }
if (isset($this->params['connection'])) {
$this->{$task}->connection = $this->params['connection'];
}
@@ -64,10 +60,6 @@ function loadTasks() {
if (isset($this->params['plugin'])) {
$this->{$task}->plugin = $this->params['plugin'];
}
- if (!is_dir($this->{$task}->path)) {
- $this->err(sprintf(__("%s directory could not be found.\nBe sure you have created %s", true), $task, $this->{$task}->path));
- $this->_stop();
- }
}
}
@@ -0,0 +1,60 @@
+<?php
+/**
+ * Base class for Bake Tasks.
+ *
+ * PHP versions 4 and 5
+ *
+ * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
+ * Copyright 2005-2010, Cake Software Foundation, Inc.
+ *
+ * Licensed under The MIT License
+ * Redistributions of files must retain the above copyright notice.
+ *
+ * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
+ * @link http://cakephp.org CakePHP(tm) Project
+ * @package cake
+ * @subpackage cake.cake.console.libs.tasks
+ * @since CakePHP(tm) v 1.3
+ * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
+ */
+class BakeTask extends Shell {
+
+/**
+ * Name of plugin
+ *
+ * @var string
+ * @access public
+ */
+ var $plugin = null;
+
+/**
+ * The db connection being used for baking
+ *
+ * @var string
+ * @access public
+ */
+ var $connection = null;
+
+/**
+ * Flag for interactive mode
+ *
+ * @var boolean
+ */
+ var $interactive = false;
+
+/**
+ * Gets the path for output. Checks the plugin property
+ * and returns the correct path.
+ *
+ * @return string Path to output.
+ * @access public
+ */
+ function getPath() {
+ $path = $this->path;
+ if (isset($this->plugin)) {
+ $name = substr($this->name, 0, strlen($this->name) - 4);
+ $path = $this->_pluginPath($this->plugin) . Inflector::pluralize(Inflector::underscore($name)) . DS;
+ }
+ return $path;
+ }
+}
@@ -18,21 +18,15 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+include_once dirname(__FILE__) . DS . 'bake.php';
+
/**
* Task class for creating and updating controller files.
*
* @package cake
* @subpackage cake.cake.console.libs.tasks
*/
-class ControllerTask extends Shell {
-
-/**
- * Name of plugin
- *
- * @var string
- * @access public
- */
- var $plugin = null;
+class ControllerTask extends BakeTask {
/**
* Tasks to be loaded by this Task
@@ -76,7 +70,7 @@ function execute() {
return $this->all();
}
- $controller = Inflector::camelize($this->args[0]);
+ $controller = $this->_controllerName($this->args[0]);
$actions = 'scaffold';
if (!empty($this->args[1]) && ($this->args[1] == 'public' || $this->args[1] == 'scaffold')) {
@@ -318,10 +312,7 @@ function bake($controllerName, $actions = '', $helpers = null, $components = nul
$this->Template->set(compact('controllerName', 'actions', 'helpers', 'components', 'isScaffold'));
$contents = $this->Template->generate('classes', 'controller');
- $path = $this->path;
- if (isset($this->plugin)) {
- $path = $this->_pluginPath($this->plugin) . 'controllers' . DS;
- }
+ $path = $this->getPath();
$filename = $path . $this->_controllerPath($controllerName) . '_controller.php';
if ($this->createFile($filename, $contents)) {
return $contents;
@@ -339,6 +330,7 @@ function bake($controllerName, $actions = '', $helpers = null, $components = nul
function bakeTest($className) {
$this->Test->plugin = $this->plugin;
$this->Test->connection = $this->connection;
+ $this->Test->interactive = $this->interactive;
return $this->Test->bake('Controller', $className);
}
@@ -17,22 +17,14 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-
+include_once dirname(__FILE__) . DS . 'bake.php';
/**
* Task class for creating and updating fixtures files.
*
* @package cake
* @subpackage cake.cake.console.libs.tasks
*/
-class FixtureTask extends Shell {
-
-/**
- * Name of plugin
- *
- * @var string
- * @access public
- */
- var $plugin = null;
+class FixtureTask extends BakeTask {
/**
* Tasks to be loaded by this Task
@@ -51,14 +43,6 @@ class FixtureTask extends Shell {
var $path = null;
/**
- * The db connection being used for baking
- *
- * @var string
- * @access public
- */
- var $connection = null;
-
-/**
* Schema instance
*
* @var object
@@ -95,7 +79,7 @@ function execute() {
if (strtolower($this->args[0]) == 'all') {
return $this->all();
}
- $model = Inflector::camelize($this->args[0]);
+ $model = $this->_modelName($this->args[0]);
$this->bake($model);
}
}
@@ -238,10 +222,7 @@ function generateFixtureFile($model, $otherVars) {
$defaults = array('table' => null, 'schema' => null, 'records' => null, 'import' => null, 'fields' => null);
$vars = array_merge($defaults, $otherVars);
- $path = $this->path;
- if (isset($this->plugin)) {
- $path = $this->_pluginPath($this->plugin) . 'tests' . DS . 'fixtures' . DS;
- }
+ $path = $this->getPath();
$filename = Inflector::underscore($model) . '_fixture.php';
$this->Template->set('model', $model);
@@ -254,6 +235,19 @@ function generateFixtureFile($model, $otherVars) {
}
/**
+ * Get the path to the fixtures.
+ *
+ * @return void
+ */
+ function getPath() {
+ $path = $this->path;
+ if (isset($this->plugin)) {
+ $path = $this->_pluginPath($this->plugin) . 'tests' . DS . 'fixtures' . DS;
+ }
+ return $path;
+ }
+
+/**
* Generates a string representation of a schema.
*
* @param array $table Table schema array
@@ -18,29 +18,15 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+include_once dirname(__FILE__) . DS . 'bake.php';
+
/**
* Task class for creating and updating model files.
*
* @package cake
* @subpackage cake.cake.console.libs.tasks
*/
-class ModelTask extends Shell {
-
-/**
- * Name of plugin
- *
- * @var string
- * @access public
- */
- var $plugin = null;
-
-/**
- * Name of the db connection used.
- *
- * @var string
- * @access public
- */
- var $connection = null;
+class ModelTask extends BakeTask {
/**
* path to MODELS directory
@@ -102,7 +88,7 @@ function execute() {
if (strtolower($this->args[0]) == 'all') {
return $this->all();
}
- $model = Inflector::camelize($this->args[0]);
+ $model = $this->_modelName($this->args[0]);
$object = $this->_getModelObject($model);
if ($this->bake($object, false)) {
if ($this->_checkUnitTest()) {
@@ -751,10 +737,7 @@ function bake($name, $data = array()) {
$this->Template->set('plugin', Inflector::camelize($this->plugin));
$out = $this->Template->generate('classes', 'model');
- $path = $this->path;
- if (isset($this->plugin)) {
- $path = $this->_pluginPath($this->plugin) . 'models' . DS;
- }
+ $path = $this->getPath();
$filename = $path . Inflector::underscore($name) . '.php';
$this->out("\nBaking model class for $name...");
$this->createFile($filename, $out);
@@ -769,6 +752,7 @@ function bake($name, $data = array()) {
* @access private
*/
function bakeTest($className) {
+ $this->Test->interactive = $this->interactive;
$this->Test->plugin = $this->plugin;
$this->Test->connection = $this->connection;
return $this->Test->bake('Model', $className);
@@ -928,6 +912,7 @@ function help() {
* @see FixtureTask::bake
*/
function bakeFixture($className, $useTable = null) {
+ $this->Fixture->interactive = $this->interactive;
$this->Fixture->connection = $this->connection;
$this->Fixture->plugin = $this->plugin;
$this->Fixture->bake($className, $useTable);
@@ -314,13 +314,13 @@ function getPrefix() {
$admin = '';
$prefixes = Configure::read('Routing.prefixes');
if (!empty($prefixes)) {
+ if (count($prefixes) == 1) {
+ return $prefixes[0] . '_';
+ }
if ($this->interactive) {
$this->out();
$this->out(__('You have more than one routing prefix configured', true));
}
- if (count($prefixes) == 1) {
- return $prefixes[0] . '_';
- }
$options = array();
foreach ($prefixes as $i => $prefix) {
$options[] = $i + 1;
@@ -18,21 +18,15 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+include_once dirname(__FILE__) . DS . 'bake.php';
+
/**
* Task class for creating and updating test files.
*
* @package cake
* @subpackage cake.cake.console.libs.tasks
*/
-class TestTask extends Shell {
-
-/**
- * Name of plugin
- *
- * @var string
- * @access public
- */
- var $plugin = null;
+class TestTask extends BakeTask {
/**
* path to TESTS directory
@@ -66,12 +60,6 @@ class TestTask extends Shell {
*/
var $_fixtures = array();
-/**
- * Flag for interactive mode
- *
- * @var boolean
- */
- var $interactive = false;
/**
* Execution method always used for tasks
@@ -434,10 +422,7 @@ function generateConstructor($type, $fullClassName) {
* @access public
*/
function testCaseFileName($type, $className) {
- $path = $this->path;
- if (isset($this->plugin)) {
- $path = $this->_pluginPath($this->plugin) . 'tests' . DS;
- }
+ $path = $this->getPath();;
$path .= 'cases' . DS . Inflector::tableize($type) . DS;
if (strtolower($type) == 'controller') {
$className = $this->getRealClassName($type, $className);
Oops, something went wrong.

0 comments on commit 7d81d81

Please sign in to comment.