updating paths in controller and model tasks for test cases

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6528 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-03-09 04:09:37 +00:00
parent 10bdc235ee
commit ce4ea52136
2 changed files with 27 additions and 14 deletions

View file

@ -38,7 +38,7 @@ class ControllerTask extends Shell {
*
* @var string
* @access public
*/
*/
var $plugin = null;
/**
* Tasks to be loaded by this Task
@ -121,7 +121,7 @@ class ControllerTask extends Shell {
$this->hr();
$this->out("Baking {$controllerName}Controller");
$this->hr();
$controllerFile = low(Inflector::underscore($controllerName));
$question[] = __("Would you like to build your controller interactively?", true);
@ -478,9 +478,9 @@ class ControllerTask extends Shell {
$path = CONTROLLER_TESTS;
if (isset($this->plugin)) {
$pluginPath = 'plugins' . DS . Inflector::underscore($this->plugin) . DS;
$path = APP . $pluginPath . 'tests' . DS . 'controllers' . DS;
}
$path = APP . $pluginPath . 'tests' . DS . 'cases' . DS . 'controllers' . DS;
}
$filename = Inflector::underscore($className).'_controller.test.php';
$this->out("\nBaking unit test for $className...");

View file

@ -38,7 +38,7 @@ class ModelTask extends Shell {
*
* @var string
* @access public
*/
*/
var $plugin = null;
/**
* path to MODELS directory
@ -658,7 +658,12 @@ class ModelTask extends Shell {
$results = $this->fixture($className, $useTable);
if ($results) {
$fixture[] = "'app." . Inflector::underscore($className) ."'";
$fixtureInc = 'app';
if ($this->plugin) {
$fixtureInc = 'plugin.'.Inflector::underscore($this->plugin);
}
$fixture[] = "'{$fixtureInc}." . Inflector::underscore($className) ."'";
if (!empty($associations)) {
$assoc[] = Set::extract($associations, 'belongsTo.{n}.className');
@ -667,18 +672,18 @@ class ModelTask extends Shell {
foreach ($assoc as $key => $value) {
if (is_array($value)) {
foreach ($value as $class) {
$fixture[] = "'app." . Inflector::underscore($class) ."'";
$fixture[] = "'{$fixtureInc}" . Inflector::underscore($class) ."'";
}
}
}
}
$fixture = join(", ", $fixture);
$import = $className;
if (isset($this->plugin)) {
$import = $this->plugin . '.' . $className;
}
$out = "App::import('Model', '$import');\n\n";
$out .= "class Test{$className} extends {$className} {\n";
$out .= "\tvar \$cacheSources = false;\n}\n\n";
@ -697,9 +702,9 @@ class ModelTask extends Shell {
$path = MODEL_TESTS;
if (isset($this->plugin)) {
$pluginPath = 'plugins' . DS . Inflector::underscore($this->plugin) . DS;
$path = APP . $pluginPath . 'tests' . DS . 'models' . DS;
$path = APP . $pluginPath . 'tests' . DS . 'cases' . DS . 'models' . DS;
}
$filename = Inflector::underscore($className).'.test.php';
$this->out("\nBaking unit test for $className...");
@ -753,12 +758,12 @@ class ModelTask extends Shell {
while ($enteredModel == '') {
$enteredModel = $this->in(__("Enter a number from the list above, type in the name of another model, or 'q' to exit", true), null, 'q');
if ($enteredModel === 'q') {
$this->out(__("Exit", true));
exit();
}
if ($enteredModel == '' || intval($enteredModel) > count($this->_modelNames)) {
$this->err(__("The model name you supplied was empty, or the number you selected was not an option. Please try again.", true));
$enteredModel = '';
@ -845,6 +850,14 @@ class ModelTask extends Shell {
$ts = date('Y-m-d H:i:s');
$insert = "'$ts'";
break;
case 'date':
$ts = date('Y-m-d');
$insert = "'$ts'";
break;
case 'time':
$ts = date('H:i:s');
$insert = "'$ts'";
break;
case 'boolean':
$insert = 1;
break;