From fd8a7ed6d629b7a37a0073409930ed5ba72a4ea0 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 01:25:01 -0430 Subject: [PATCH] Fixing ControllerTask tests --- lib/Cake/Console/Command/Task/ControllerTask.php | 6 +++--- .../tests/cases/console/shells/tasks/controller.test.php | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 318f68681..e7d7995b2 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -107,7 +107,7 @@ class ControllerTask extends BakeTask { $model = $this->_modelName($table); $controller = $this->_controllerName($model); App::uses($model, 'Model'); - if (!class_exists($model)) { + if (class_exists($model)) { $actions = $this->bakeActions($controller); if ($this->bake($controller, $actions) && $unitTestExists) { $this->bakeTest($controller); @@ -270,9 +270,9 @@ class ControllerTask extends BakeTask { $currentModelName = $modelImport = $this->_modelName($controllerName); $plugin = $this->plugin; if ($plugin) { - $modelImport = $plugin . '.' . $modelImport; + $plugin .= '.'; } - App::uses($modelImport, 'Model'); + App::uses($modelImport, $plugin . 'Model'); if (!class_exists($modelImport)) { $this->err(__('You must have a model for this class to build basic methods. Please try again.')); $this->_stop(); diff --git a/lib/Cake/tests/cases/console/shells/tasks/controller.test.php b/lib/Cake/tests/cases/console/shells/tasks/controller.test.php index cd92ba2c8..19b16df02 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/controller.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/controller.test.php @@ -29,7 +29,12 @@ App::uses('TemplateTask', 'Console/Command/Task'); App::uses('TestTask', 'Console/Command/Task'); App::uses('Model', 'Model'); -if (class_exists('BakeArticle')) { +App::uses('BakeArticle', 'Model'); +App::uses('BakeComment', 'Model'); +App::uses('BakeTags', 'Model'); +$imported = class_exists('BakeArticle') || class_exists('BakeComment') || class_exists('BakeTag'); + +if (!$imported) { define('ARTICLE_MODEL_CREATED', true); class BakeArticle extends Model {