From b8344ecd3389e355eaa41e36afbe52085fd9d2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 8 Dec 2010 23:15:18 -0430 Subject: [PATCH] Replacing some of the App::import by App::uses --- lib/Cake/Console/Command/AclShell.php | 4 +-- lib/Cake/Console/Command/ApiShell.php | 2 +- lib/Cake/Console/Command/BakeShell.php | 9 ++++-- lib/Cake/Console/Command/ConsoleShell.php | 2 +- .../Console/Command/Task/ControllerTask.php | 6 ++-- .../Console/Command/Task/DbConfigTask.php | 2 +- lib/Cake/Console/Command/Task/FixtureTask.php | 6 ++-- lib/Cake/Console/Command/Task/ModelTask.php | 2 +- lib/Cake/Console/Command/Task/PluginTask.php | 3 +- lib/Cake/Console/Command/Task/ViewTask.php | 14 +++++---- lib/Cake/Console/ConsoleErrorHandler.php | 2 +- .../Controller/Component/AclComponent.php | 2 +- .../Controller/Component/EmailComponent.php | 6 ++-- .../Component/RequestHandlerComponent.php | 3 +- lib/Cake/Controller/Controller.php | 4 +-- lib/Cake/Core/App.php | 6 ++-- lib/Cake/Error/ErrorHandler.php | 2 +- lib/Cake/Error/ExceptionRenderer.php | 5 ++-- lib/Cake/I18n/I18n.php | 2 +- lib/Cake/I18n/Multibyte.php | 2 +- lib/Cake/Model/BehaviorCollection.php | 7 +---- lib/Cake/Model/CakeSchema.php | 6 ++-- lib/Cake/Model/Datasource/DboSource.php | 3 +- lib/Cake/Utility/Set.php | 2 +- lib/Cake/View/pages/home.ctp | 2 +- lib/Cake/basics.php | 4 +-- lib/Cake/tests/cases/basics.test.php | 3 +- .../console/libs/task_collection.test.php | 4 +-- .../tests/cases/console/shells/acl.test.php | 6 ++-- .../tests/cases/console/shells/api.test.php | 7 ++--- .../tests/cases/console/shells/bake.test.php | 16 +++++----- .../console/shells/command_list.test.php | 2 +- .../cases/console/shells/schema.test.php | 9 ++---- .../tests/cases/console/shells/shell.test.php | 6 ++-- .../console/shells/tasks/controller.test.php | 30 ++++++++----------- .../console/shells/tasks/db_config.test.php | 7 ++--- .../console/shells/tasks/extract.test.php | 8 ++--- .../console/shells/tasks/fixture.test.php | 12 ++++---- .../cases/console/shells/tasks/model.test.php | 12 ++++---- .../console/shells/tasks/plugin.test.php | 13 ++++---- .../console/shells/tasks/project.test.php | 9 +++--- .../console/shells/tasks/template.test.php | 7 ++--- .../cases/console/shells/tasks/test.test.php | 15 ++++------ 43 files changed, 127 insertions(+), 147 deletions(-) diff --git a/lib/Cake/Console/Command/AclShell.php b/lib/Cake/Console/Command/AclShell.php index e29e4f4ef..04aaa4936 100644 --- a/lib/Cake/Console/Command/AclShell.php +++ b/lib/Cake/Console/Command/AclShell.php @@ -17,8 +17,8 @@ * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'Acl'); -App::import('Model', 'DbAcl'); +App::uses('AclComponent', 'Controller/Component'); +App::uses('DbAcl', 'Model'); /** * Shell for ACL management. This console is known to have issues with zend.ze1_compatibility_mode diff --git a/lib/Cake/Console/Command/ApiShell.php b/lib/Cake/Console/Command/ApiShell.php index 0c036d09d..a9a436a29 100644 --- a/lib/Cake/Console/Command/ApiShell.php +++ b/lib/Cake/Console/Command/ApiShell.php @@ -19,7 +19,7 @@ * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'File'); +App::uses('File', 'Utility'); /** * API shell to show method signatures of CakePHP core classes. diff --git a/lib/Cake/Console/Command/BakeShell.php b/lib/Cake/Console/Command/BakeShell.php index 77dd36201..ed09609f0 100644 --- a/lib/Cake/Console/Command/BakeShell.php +++ b/lib/Cake/Console/Command/BakeShell.php @@ -22,6 +22,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Model', 'Model'); + /** * Bake is a command-line code generation utility for automating programmer chores. * @@ -151,11 +153,11 @@ class BakeShell extends Shell { $modelExists = false; $model = $this->_modelName($name); - if (App::import('Model', $model)) { + App::uses($model, 'Model'); + if (class_exists($model)) { $object = new $model(); $modelExists = true; } else { - App::import('Model', 'Model', false); $object = new Model(array('name' => $name, 'ds' => $this->connection)); } @@ -176,7 +178,8 @@ class BakeShell extends Shell { $this->Controller->bakeTest($controller); } } - if (App::import('Controller', $controller)) { + App::uses($controller . 'Controller', 'Controller') + if (class_exists($controller . 'Controller')) { $this->View->args = array($controller); $this->View->execute(); } diff --git a/lib/Cake/Console/Command/ConsoleShell.php b/lib/Cake/Console/Command/ConsoleShell.php index 404c348ed..5cedf5a97 100644 --- a/lib/Cake/Console/Command/ConsoleShell.php +++ b/lib/Cake/Console/Command/ConsoleShell.php @@ -56,11 +56,11 @@ class ConsoleShell extends Shell { App::uses('Dispatcher', 'Routing'); $this->Dispatcher = new Dispatcher(); $this->models = App::objects('model'); - App::import('Model', $this->models); foreach ($this->models as $model) { $class = Inflector::camelize(str_replace('.php', '', $model)); $this->models[$model] = $class; + App::uses($class, 'Model'); $this->{$class} = new $class(); } $this->out('Model classes:'); diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 46f512365..449a3aa84 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -108,7 +108,8 @@ class ControllerTask extends BakeTask { foreach ($this->__tables as $table) { $model = $this->_modelName($table); $controller = $this->_controllerName($model); - if (App::import('Model', $model)) { + App::uses($model, 'Model'); + if (!class_exists($model)) { $actions = $this->bakeActions($controller); if ($this->bake($controller, $actions) && $unitTestExists) { $this->bakeTest($controller); @@ -273,7 +274,8 @@ class ControllerTask extends BakeTask { if ($plugin) { $modelImport = $plugin . '.' . $modelImport; } - if (!App::import('Model', $modelImport)) { + App::uses($modelImport, '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/Console/Command/Task/DbConfigTask.php b/lib/Cake/Console/Command/Task/DbConfigTask.php index a98b6b053..9f866b1c1 100644 --- a/lib/Cake/Console/Command/Task/DbConfigTask.php +++ b/lib/Cake/Console/Command/Task/DbConfigTask.php @@ -353,7 +353,7 @@ class DbConfigTask extends Shell { * @return void */ public function getConfig() { - App::import('Model', 'ConnectionManager', false); + App::uses('ConnectionManager', 'Model'); $useDbConfig = 'default'; $configs = get_class_vars($this->databaseClassName); diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index cc081c84c..2e0a4c31e 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -19,6 +19,7 @@ */ App::uses('BakeTask', 'Console/Command/Task'); +App::uses('Model', 'Model'); /** * Task class for creating and updating fixtures files. @@ -186,9 +187,7 @@ class FixtureTask extends BakeTask { * @return string Baked fixture content */ public function bake($model, $useTable = false, $importOptions = array()) { - if (!class_exists('CakeSchema')) { - App::import('Model', 'CakeSchema', false); - } + App::uses('CakeSchema', 'Model'); $table = $schema = $records = $import = $modelImport = $recordImport = null; if (!$useTable) { $useTable = Inflector::tableize($model); @@ -394,7 +393,6 @@ class FixtureTask extends BakeTask { } else { $condition = 'WHERE 1=1 LIMIT ' . (isset($this->params['count']) ? $this->params['count'] : 10); } - App::import('Model', 'Model', false); $modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection)); $records = $modelObject->find('all', array( 'conditions' => $condition, diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index c893de33a..e0bc29378 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -20,6 +20,7 @@ App::uses('BakeTask', 'Console/Command/Task'); App::uses('ConnectionManager', 'Model'); +App::uses('Model', 'Model'); /** * Task class for creating and updating model files. @@ -74,7 +75,6 @@ class ModelTask extends BakeTask { * */ public function execute() { - App::import('Model', 'Model', false); parent::execute(); if (empty($this->args)) { diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index 6ae7bd5cb..84c296623 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -17,7 +17,8 @@ * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'File'); + +App::uses('File', 'Utility'); /** * Task class for creating a plugin diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index fc3baa8ae..106ba864a 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -191,7 +191,8 @@ class ViewTask extends BakeTask { $model = $this->_modelName($table); $this->controllerName = $this->_controllerName($model); $this->controllerPath = Inflector::underscore($this->controllerName); - if (App::import('Model', $model)) { + App::uses($model, 'Model'); + if (class_exists($model)) { $vars = $this->__loadController(); if (!$actions) { $actions = $this->_methodsToBake(); @@ -272,17 +273,18 @@ class ViewTask extends BakeTask { $this->err(__('Controller not found')); } - $import = $this->controllerName; + $plugin = null; if ($this->plugin) { - $import = $this->plugin . '.' . $this->controllerName; + $plugin = $this->plugin . '.'; } - if (!App::import('Controller', $import)) { - $file = $this->controllerPath . '_controller.php'; + $controllerClassName = $this->controllerName . 'Controller'; + App::uses($controllerName, $plugin . 'Controller'); + if (!class_exists($controllerClassName)) { + $file = $controllerClassName . '.php'; $this->err(__("The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file)); $this->_stop(); } - $controllerClassName = $this->controllerName . 'Controller'; $controllerObj = new $controllerClassName(); $controllerObj->plugin = $this->plugin; $controllerObj->constructClasses(); diff --git a/lib/Cake/Console/ConsoleErrorHandler.php b/lib/Cake/Console/ConsoleErrorHandler.php index 9eaebb2e5..dbd84aa99 100644 --- a/lib/Cake/Console/ConsoleErrorHandler.php +++ b/lib/Cake/Console/ConsoleErrorHandler.php @@ -19,6 +19,7 @@ */ App::uses('ErrorHandler', 'Error'); App::uses('ConsoleOutput', 'Console'); +App::uses('CakeLog', 'Log'); /** * Error Handler for Cake console. Does simple printing of the @@ -79,7 +80,6 @@ class ConsoleErrorHandler extends ErrorHandler { $stderr->write(__("%s Error: %s\n", $name, $message)); if (Configure::read('debug') == 0) { - App::import('Core', 'CakeLog'); CakeLog::write($log, $message); } } diff --git a/lib/Cake/Controller/Component/AclComponent.php b/lib/Cake/Controller/Component/AclComponent.php index 3a09c590b..7fc8a0a10 100644 --- a/lib/Cake/Controller/Component/AclComponent.php +++ b/lib/Cake/Controller/Component/AclComponent.php @@ -662,7 +662,7 @@ class IniAcl extends Object implements AclInterface { * @return array INI section structure */ public function readConfigFile($filename) { - App::import('Core', 'config/IniReader'); + App::uses('IniReader', 'Configure'); $iniFile = new IniReader(dirname($filename) . DS); return $iniFile->read(basename($filename)); } diff --git a/lib/Cake/Controller/Component/EmailComponent.php b/lib/Cake/Controller/Component/EmailComponent.php index 47ab6775b..9a3aa9f9b 100755 --- a/lib/Cake/Controller/Component/EmailComponent.php +++ b/lib/Cake/Controller/Component/EmailComponent.php @@ -433,9 +433,9 @@ class EmailComponent extends Component { $viewClass = $this->Controller->view; if ($viewClass != 'View') { - list($plugin, $viewClass) = pluginSplit($viewClass); + list($plugin, $viewClass) = pluginSplit($viewClass, true); $viewClass = $viewClass . 'View'; - App::import('View', $this->Controller->view); + App::uses($viewClass, $plugin . 'View'); } $View = new $viewClass($this->Controller, false); @@ -810,7 +810,7 @@ class EmailComponent extends Component { * @access private */ function _smtp() { - App::import('Core', 'CakeSocket'); + App::uses('CakeSocket', 'Network'); $defaults = array( 'host' => 'localhost', diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index 4928c945a..4f5cc3dfe 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -542,7 +542,8 @@ class RequestHandlerComponent extends Component { ); if (!$isAdded) { - if (App::import('Helper', $helper)) { + App::uses($helper . 'Helper', 'Helper'); + if (class_exists($helper . 'Helper')) { $controller->helpers[] = $helper; } } diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index c423a9227..68b255fc7 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -789,9 +789,9 @@ class Controller extends Object { $viewClass = $this->view; if ($this->view != 'View') { - list($plugin, $viewClass) = pluginSplit($viewClass); + list($plugin, $viewClass) = pluginSplit($viewClass, true); $viewClass = $viewClass . 'View'; - App::import('View', $this->view); + App::uses($viewClass, $plugin . 'View'); } $this->request->params['models'] = $this->modelNames; diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index f22d8925d..2e4383ac8 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -23,8 +23,8 @@ * ### Adding paths * * You can add paths to the search indexes App uses to find classes using `App::build()`. Adding - * additional controller paths for example would alter where CakePHP looks for controllers when you - * call App::import('Controller', 'Posts'); This allows you to split your application up across the filesystem. + * additional controller paths for example would alter where CakePHP looks for controllers. + * This allows you to split your application up across the filesystem. * * ### Inspecting loaded paths * @@ -261,7 +261,7 @@ class App { 'View' => array(VIEWS), 'View/Helper' => array(HELPERS), 'locales' => array(APP . 'locale' . DS), - 'shells' => array( + 'Console' => array( APP . 'console' . DS . 'shells' . DS, APP . 'vendors' . DS . 'shells' . DS, VENDORS . 'shells' . DS diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 5124136c2..1af6cc156 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -113,7 +113,7 @@ class ErrorHandler { CakeLog::write(LOG_ERR, '[' . get_class($exception) . '] ' . $exception->getMessage()); } if ($config['renderer'] !== 'ExceptionRenderer') { - App::import('Lib', $config['renderer']); + App::uses($config['renderer'], 'Error'); } $error = new $config['renderer']($exception); $error->render(); diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 1ea26c502..5b5289d29 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -20,6 +20,9 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::import('Sanitize', 'Utility'); + /** * Exception Renderer. * @@ -88,8 +91,6 @@ class ExceptionRenderer { * @param array $messages Error messages */ function __construct(Exception $exception) { - App::import('Core', 'Sanitize'); - $this->controller = $this->_getController($exception); if (method_exists($this->controller, 'apperror')) { diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index b85d9b75b..b899a7cab 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -101,7 +101,7 @@ class I18n { /** * Used by the translation functions in basics.php - * Can also be used like I18n::translate(); but only if the App::import('I18n'); has been used to load the class. + * Returns a translated string based on current language and translation files stored in locale folder * * @param string $singular String to translate * @param string $plural Plural string (if any) diff --git a/lib/Cake/I18n/Multibyte.php b/lib/Cake/I18n/Multibyte.php index 69c23188f..b1045e7b7 100644 --- a/lib/Cake/I18n/Multibyte.php +++ b/lib/Cake/I18n/Multibyte.php @@ -1078,7 +1078,7 @@ class Multibyte { return null; } if (!Configure::configured('_cake_core_')) { - App::import('Core', 'config/PhpReader'); + App::uses('PhpReader', 'Configure'); Configure::config('_cake_core_', new PhpReader(CAKE . 'config' . DS)); } Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_'); diff --git a/lib/Cake/Model/BehaviorCollection.php b/lib/Cake/Model/BehaviorCollection.php index 05fad7db9..064e9a37d 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -94,12 +94,7 @@ class BehaviorCollection extends ObjectCollection { list($plugin, $name) = pluginSplit($behavior); $class = $name . 'Behavior'; - if (!App::import('Behavior', $behavior)) { - throw new MissingBehaviorFileException(array( - 'file' => Inflector::underscore($behavior) . '.php', - 'class' => $class - )); - } + App::uses($class, 'Model/Behavior'); if (!class_exists($class)) { throw new MissingBehaviorClassException(array( 'file' => Inflector::underscore($behavior) . '.php', diff --git a/lib/Cake/Model/CakeSchema.php b/lib/Cake/Model/CakeSchema.php index 17bc19f84..df7601308 100644 --- a/lib/Cake/Model/CakeSchema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -207,9 +207,8 @@ class CakeSchema extends Object { )); $db = ConnectionManager::getDataSource($connection); - App::import('Model', 'AppModel'); if (isset($this->plugin)) { - App::import('Model', Inflector::camelize($this->plugin) . 'AppModel'); + App::uses(Inflector::camelize($this->plugin) . 'AppModel', $this->plugin . '.Model'); } $tables = array(); @@ -234,7 +233,8 @@ class CakeSchema extends Object { if (isset($this->plugin)) { $importModel = $this->plugin . '.' . $model; } - if (!App::import('Model', $importModel)) { + App::uses($importModel, 'Model'); + if (!class_exists($importModel)) { continue; } $vars = get_class_vars($model); diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index a11f4fcd8..83c962a32 100755 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -17,7 +17,9 @@ * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + App::uses('String', 'Utility'); +App::uses('View', 'View'); /** * DboSource @@ -763,7 +765,6 @@ class DboSource extends DataSource { return; } if (PHP_SAPI != 'cli') { - App::import('Core', 'View'); $controller = null; $View = new View($controller, false); $View->set('logs', array($this->configKeyName => $log)); diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index ff2af8519..9fbdc8218 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -585,7 +585,7 @@ class Set { if (is_string($path) && strpos($path, '{') !== false) { $path = String::tokenize($path, '.', '{', '}'); - } else { + } elseif (is_string($path)) { $path = explode('.', $path); } $tmp = array(); diff --git a/lib/Cake/View/pages/home.ctp b/lib/Cake/View/pages/home.ctp index d861c5c12..9beb7b0d0 100644 --- a/lib/Cake/View/pages/home.ctp +++ b/lib/Cake/View/pages/home.ctp @@ -24,7 +24,7 @@ endif; 0): - Debugger::checkSecurityKeys(); + //Debugger::checkSecurityKeys(); endif; ?>

diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 287f0fc20..2d23d220d 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -670,9 +670,7 @@ if (!function_exists('sortByKey')) { * @param string $message Message to write to log */ function LogError($message) { - if (!class_exists('CakeLog')) { - App::import('Core', 'CakeLog'); - } + App::uses('CakeLog', 'Log'); $bad = array("\n", "\r", "\t"); $good = ' '; CakeLog::write('error', str_replace($bad, $good, $message)); diff --git a/lib/Cake/tests/cases/basics.test.php b/lib/Cake/tests/cases/basics.test.php index f6051717b..b3b028cd4 100644 --- a/lib/Cake/tests/cases/basics.test.php +++ b/lib/Cake/tests/cases/basics.test.php @@ -17,8 +17,9 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + require_once CAKE . 'basics.php'; -App::import('Core', 'Folder'); +App::uses('Folder', 'Utility'); /** * BasicsTest class diff --git a/lib/Cake/tests/cases/console/libs/task_collection.test.php b/lib/Cake/tests/cases/console/libs/task_collection.test.php index da7d6eaef..b918469e6 100644 --- a/lib/Cake/tests/cases/console/libs/task_collection.test.php +++ b/lib/Cake/tests/cases/console/libs/task_collection.test.php @@ -18,8 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'TaskCollection', false); -App::import('Shell', 'Shell', false); +App::uses('TaskCollection', 'Console'); +App::uses('Shell', 'Console'); class TaskCollectionTest extends CakeTestCase { /** diff --git a/lib/Cake/tests/cases/console/shells/acl.test.php b/lib/Cake/tests/cases/console/shells/acl.test.php index 0bb6489b1..7a0270084 100644 --- a/lib/Cake/tests/cases/console/shells/acl.test.php +++ b/lib/Cake/tests/cases/console/shells/acl.test.php @@ -17,10 +17,10 @@ * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', 'Acl'); -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('AclShell', 'Console/Command'); /** * AclShellTest class diff --git a/lib/Cake/tests/cases/console/shells/api.test.php b/lib/Cake/tests/cases/console/shells/api.test.php index 82f134552..4c76f4aa8 100644 --- a/lib/Cake/tests/cases/console/shells/api.test.php +++ b/lib/Cake/tests/cases/console/shells/api.test.php @@ -17,11 +17,10 @@ * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', 'Api'); - -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('ApiShell', 'Console/Command'); /** * ApiShellTest class diff --git a/lib/Cake/tests/cases/console/shells/bake.test.php b/lib/Cake/tests/cases/console/shells/bake.test.php index 6f68e8bb3..f627c069a 100644 --- a/lib/Cake/tests/cases/console/shells/bake.test.php +++ b/lib/Cake/tests/cases/console/shells/bake.test.php @@ -18,14 +18,14 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', 'Bake', false); -App::import('Shell', 'tasks/model', false); -App::import('Shell', 'tasks/controller', false); -App::import('Shell', 'tasks/db_config', false); -App::import('Core', 'Controller'); -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('BakeShell', 'Console/Command'); +App::uses('ModelTask', 'Console/Command/Task'); +App::uses('ControllerTask', 'Console/Command/Task'); +App::uses('DbConfigTask', 'Console/Command/Task'); +App::uses('Controller', 'Controller'); if (!class_exists('UsersController')) { class UsersController extends Controller { @@ -76,7 +76,7 @@ class BakeShellTest extends CakeTestCase { * @return void */ public function testAllWithModelName() { - App::import('Model', 'User'); + App::uses('User', 'Model'); $userExists = class_exists('User'); if ($this->skipIf($userExists, 'User class exists, cannot test `bake all [param]`. %s')) { return; diff --git a/lib/Cake/tests/cases/console/shells/command_list.test.php b/lib/Cake/tests/cases/console/shells/command_list.test.php index bdabc2230..48fecaaa8 100644 --- a/lib/Cake/tests/cases/console/shells/command_list.test.php +++ b/lib/Cake/tests/cases/console/shells/command_list.test.php @@ -17,7 +17,7 @@ * @since CakePHP v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'CommandList', false); +App::import('CommandListShell', 'Console/Command'); class TestStringOutput extends ConsoleOutput { diff --git a/lib/Cake/tests/cases/console/shells/schema.test.php b/lib/Cake/tests/cases/console/shells/schema.test.php index 6a7a619a1..d438335e2 100644 --- a/lib/Cake/tests/cases/console/shells/schema.test.php +++ b/lib/Cake/tests/cases/console/shells/schema.test.php @@ -17,13 +17,10 @@ * @since CakePHP v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', 'Schema', false); -App::import('Model', 'CakeSchema', false); - -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; - +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('CakeSchema', 'Model'); /** * Test for Schema database management diff --git a/lib/Cake/tests/cases/console/shells/shell.test.php b/lib/Cake/tests/cases/console/shells/shell.test.php index 91c623cda..fcd8d4dd6 100644 --- a/lib/Cake/tests/cases/console/shells/shell.test.php +++ b/lib/Cake/tests/cases/console/shells/shell.test.php @@ -19,10 +19,10 @@ * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Folder'); -App::import('Shell', 'Shell', false); -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('Folder', 'Utility'); /** * ShellTestShell class 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 f3601376e..ef2bd70e0 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/controller.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/controller.test.php @@ -17,33 +17,27 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'ClassRegistry'); -App::import('View', 'Helper', false); -App::import('Shell', 'Shell', false); -App::import('Shell', array( - 'tasks/project', - 'tasks/controller', - 'tasks/model', - 'tasks/template', - 'tasks/test' -)); -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('CakeSchema', 'Model'); +App::uses('ClassRegistry', 'Utility'); +App::uses('Helper', 'View/Helper'); +App::uses('ProjectTask', 'Console/Command/Task'); +App::uses('ControllerTask', 'Console/Command/Task'); +App::uses('ModelTask', 'Console/Command/Task'); +App::uses('TemplateTask', 'Console/Command/Task'); +App::uses('TestTask', 'Console/Command/Task'); +App::uses('Model', 'Model'); -$imported = App::import('Model', 'BakeArticle'); -$imported = $imported || App::import('Model', 'BakeComment'); -$imported = $imported || App::import('Model', 'BakeTag'); - -if (!$imported) { +if (class_exists('BakeArticle')) { define('ARTICLE_MODEL_CREATED', true); - App::import('Core', 'Model'); class BakeArticle extends Model { public $name = 'BakeArticle'; public $hasMany = array('BakeComment'); public $hasAndBelongsToMany = array('BakeTag'); } - } /** diff --git a/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php b/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php index aca87ac94..50aa43873 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php @@ -17,11 +17,10 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', 'tasks/DbConfig'); - -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('DbConfigTask', 'Console/Command/Task'); class TEST_DATABASE_CONFIG { public $default = array( diff --git a/lib/Cake/tests/cases/console/shells/tasks/extract.test.php b/lib/Cake/tests/cases/console/shells/tasks/extract.test.php index 21993e0d4..6d634e5b4 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/extract.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/extract.test.php @@ -19,11 +19,11 @@ * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Folder'); -App::import('Shell', 'Shell', false); -App::import('Shell', 'tasks/Extract', false); -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('Folder', 'Utility'); +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('ExtractTask', 'Console/Command/Task'); /** * ExtractTaskTest class diff --git a/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php b/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php index 7121f7fd1..c00b4fb94 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php @@ -17,14 +17,12 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', array( - 'tasks/fixture', - 'tasks/template', - 'tasks/db_config' -)); -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('FixtureTask', 'Console/Command/Task'); +App::uses('TemplateTask', 'Console/Command/Task'); +App::uses('DbConfigTask', 'Console/Command/Task'); /** * FixtureTaskTest class diff --git a/lib/Cake/tests/cases/console/shells/tasks/model.test.php b/lib/Cake/tests/cases/console/shells/tasks/model.test.php index ac2a2c7fc..fa48d5921 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/model.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/model.test.php @@ -19,14 +19,12 @@ * @since CakePHP v 1.2.6 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', array( - 'tasks/model', - 'tasks/fixture', - 'tasks/template' -)); -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('FixtureTask', 'Console/Command/Task'); +App::uses('TemplateTask', 'Console/Command/Task'); +App::uses('ModelTask', 'Console/Command/Task'); /** * ModelTaskTest class diff --git a/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php b/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php index 327b258c2..652159880 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php @@ -19,15 +19,12 @@ * @since CakePHP v 1.3.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', array( - 'tasks/plugin', - 'tasks/model' -)); -App::import('Core', array('File')); - -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('PluginTask', 'Console/Command/Task'); +App::uses('ModelTask', 'Console/Command/Task'); +App::import('File', 'Utility'); /** * PluginTaskPlugin class diff --git a/lib/Cake/tests/cases/console/shells/tasks/project.test.php b/lib/Cake/tests/cases/console/shells/tasks/project.test.php index 8e92b7949..63870f4bd 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/project.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/project.test.php @@ -19,12 +19,11 @@ * @since CakePHP v 1.3.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', 'tasks/project'); -App::import('Core', 'File'); - -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('ProjecTask', 'Console/Command/Task'); +App::import('File', 'Utility'); /** * ProjectTask Test class diff --git a/lib/Cake/tests/cases/console/shells/tasks/template.test.php b/lib/Cake/tests/cases/console/shells/tasks/template.test.php index bbd81404d..c2b162dd8 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/template.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/template.test.php @@ -20,11 +20,10 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', 'tasks/template'); - -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('TemplateTask', 'Console/Command/Task'); /** * TemplateTaskTest class * diff --git a/lib/Cake/tests/cases/console/shells/tasks/test.test.php b/lib/Cake/tests/cases/console/shells/tasks/test.test.php index 14b603e54..4a77aaeab 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/test.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/test.test.php @@ -19,16 +19,13 @@ * @since CakePHP v 1.2.0.7726 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', array( - 'tasks/test', - 'tasks/template' -)); -App::import('Controller', 'Controller', false); -App::import('Model', 'Model', false); - -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('TestTask', 'Console/Command/Task'); +App::uses('TemplateTask', 'Console/Command/Task'); +App::uses('Controller', 'Controller'); +App::uses('Model', 'Model'); /** * Test Article model