From 29077654040ae4074558725a50342a9f85f18632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 10 Dec 2010 01:53:27 -0430 Subject: [PATCH] Replacing almost all remaining uses of App::import --- lib/Cake/TestSuite/Fixture/CakeTestFixture.php | 12 ++++++++---- lib/Cake/TestSuite/templates/footer.php | 2 +- lib/Cake/tests/cases/libs/folder.test.php | 2 +- lib/Cake/tests/cases/libs/multibyte.test.php | 2 +- lib/Cake/tests/cases/libs/object.test.php | 5 ++++- lib/Cake/tests/cases/libs/object_collection.test.php | 2 +- lib/Cake/tests/cases/libs/route/cake_route.test.php | 4 ++-- .../cases/libs/route/plugin_short_route.test.php | 4 ++-- lib/Cake/tests/cases/libs/sanitize.test.php | 2 +- lib/Cake/tests/cases/libs/security.test.php | 2 +- .../tests/cases/libs/session/cache_session.test.php | 4 ++-- .../cases/libs/session/database_session.test.php | 6 +++--- lib/Cake/tests/cases/libs/set.test.php | 2 +- lib/Cake/tests/cases/libs/string.test.php | 2 +- lib/Cake/tests/cases/libs/validation.test.php | 2 +- lib/Cake/tests/cases/libs/view/helper.test.php | 5 ++++- .../tests/cases/libs/view/helper_collection.test.php | 4 ++-- .../tests/cases/libs/view/helpers/cache.test.php | 7 +++++-- lib/Cake/tests/cases/libs/view/helpers/form.test.php | 11 ++++++++--- lib/Cake/tests/cases/libs/view/helpers/html.test.php | 12 +++++++++--- .../cases/libs/view/helpers/jquery_engine.test.php | 7 +++++-- lib/Cake/tests/cases/libs/view/helpers/js.test.php | 7 +++++-- .../cases/libs/view/helpers/mootools_engine.test.php | 5 ++++- .../tests/cases/libs/view/helpers/number.test.php | 2 +- .../tests/cases/libs/view/helpers/paginator.test.php | 7 +++++-- .../libs/view/helpers/prototype_engine.test.php | 5 ++++- lib/Cake/tests/cases/libs/view/helpers/rss.test.php | 5 +++-- .../tests/cases/libs/view/helpers/session.test.php | 6 ++++-- lib/Cake/tests/cases/libs/view/helpers/text.test.php | 4 ++-- lib/Cake/tests/cases/libs/view/helpers/time.test.php | 4 ++-- lib/Cake/tests/cases/libs/view/media.test.php | 5 ++++- lib/Cake/tests/cases/libs/view/theme.test.php | 4 ++-- lib/Cake/tests/cases/libs/view/view.test.php | 8 +++++--- 33 files changed, 104 insertions(+), 57 deletions(-) diff --git a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php index b7676cf5c..db66430c9 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php @@ -20,6 +20,8 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); +App::uses('CakeSchema', 'Model'); + /** * Short description for class. * @@ -52,7 +54,6 @@ class CakeTestFixture { * */ public function __construct() { - App::import('Model', 'CakeSchema'); $this->Schema = new CakeSchema(array('name' => 'TestSuite', 'connection' => 'test')); $this->init(); } @@ -68,9 +69,12 @@ class CakeTestFixture { is_array($this->import) ? $this->import : array('model' => $this->import) ); - if (isset($import['model']) && App::import('Model', $import['model'])) { - App::import('Model', $import['model']); - list(, $modelClass) = pluginSplit($import['model']); + if (isset($import['model'])) { + list($plugin, $modelClass) = pluginSplit($import['model'], true); + App::uses($modelClass, $plugin . 'Model'); + if (!class_exists($modelClass)) { + throw new MissingModelException(array('class' => $modelClass)); + } $model = new $modelClass(null, null, $import['connection']); $db = $model->getDataSource(); if (empty($model->tablePrefix)) { diff --git a/lib/Cake/TestSuite/templates/footer.php b/lib/Cake/TestSuite/templates/footer.php index e9b6c6746..172195f02 100644 --- a/lib/Cake/TestSuite/templates/footer.php +++ b/lib/Cake/TestSuite/templates/footer.php @@ -27,7 +27,7 @@

element('sql_dump'); diff --git a/lib/Cake/tests/cases/libs/folder.test.php b/lib/Cake/tests/cases/libs/folder.test.php index 428520610..739047e57 100644 --- a/lib/Cake/tests/cases/libs/folder.test.php +++ b/lib/Cake/tests/cases/libs/folder.test.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'File'); +App::uses('File', 'Utility'); /** * FolderTest class diff --git a/lib/Cake/tests/cases/libs/multibyte.test.php b/lib/Cake/tests/cases/libs/multibyte.test.php index 7da643c34..6eb0068b5 100644 --- a/lib/Cake/tests/cases/libs/multibyte.test.php +++ b/lib/Cake/tests/cases/libs/multibyte.test.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0.6833 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Multibyte', 'I18n'); +App::uses('Multibyte', 'I18n'); /** * MultibyteTest class diff --git a/lib/Cake/tests/cases/libs/object.test.php b/lib/Cake/tests/cases/libs/object.test.php index a371cf9f2..f5ad44cad 100644 --- a/lib/Cake/tests/cases/libs/object.test.php +++ b/lib/Cake/tests/cases/libs/object.test.php @@ -17,7 +17,10 @@ * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', array('Object', 'Controller', 'Model')); + +App::uses('Object', 'Core'); +App::uses('Controller', 'Controller'); +App::uses('Model', 'Model'); /** * RequestActionPost class diff --git a/lib/Cake/tests/cases/libs/object_collection.test.php b/lib/Cake/tests/cases/libs/object_collection.test.php index 9d0861861..ffc061cd2 100644 --- a/lib/Cake/tests/cases/libs/object_collection.test.php +++ b/lib/Cake/tests/cases/libs/object_collection.test.php @@ -18,7 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'ObjectCollection'); +App::uses('ObjectCollection', 'Utility'); /** * A generic object class diff --git a/lib/Cake/tests/cases/libs/route/cake_route.test.php b/lib/Cake/tests/cases/libs/route/cake_route.test.php index dae305b23..76f76f336 100644 --- a/lib/Cake/tests/cases/libs/route/cake_route.test.php +++ b/lib/Cake/tests/cases/libs/route/cake_route.test.php @@ -1,7 +1,7 @@ skipIf(!is_writable(WWW_ROOT . 'theme'), 'Cannot write to webroot/theme')) { return; } - App::import('Core', 'File'); + App::uses('File', 'Utility'); $testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'img' . DS . '__cake_test_image.gif'; $file = new File($testfile, true); @@ -596,7 +602,7 @@ class HtmlHelperTest extends CakeTestCase { if ($this->skipIf(!is_writable(WWW_ROOT . 'theme'), 'Cannot write to webroot/theme')) { return; } - App::import('Core', 'File'); + App::uses('File', 'Utility'); $testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'js' . DS . '__test_js.js'; $file = new File($testfile, true); diff --git a/lib/Cake/tests/cases/libs/view/helpers/jquery_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/jquery_engine.test.php index 87c2b8b2b..ecbff4bb8 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/jquery_engine.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/jquery_engine.test.php @@ -18,8 +18,11 @@ * @subpackage cake.tests.cases.views.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', array('Html', 'Js', 'JqueryEngine')); -App::import('Core', 'View'); + +App::uses('HtmlHelper', 'View/Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('JqueryEngineHelper', 'View/Helper'); +App::uses('View', 'View'); class JqueryEngineHelperTest extends CakeTestCase { /** diff --git a/lib/Cake/tests/cases/libs/view/helpers/js.test.php b/lib/Cake/tests/cases/libs/view/helpers/js.test.php index 1fd1602a7..1b03d5648 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/js.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/js.test.php @@ -19,8 +19,11 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', array('Js', 'Html', 'Form')); -App::import('Core', array('View', 'ClassRegistry')); +App::uses('HtmlHelper', 'View/Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('FormHelper', 'View/Helper'); +App::uses('View', 'View'); +App::uses('ClassRegistry', 'Utility'); class OptionEngineHelper extends JsBaseEngineHelper { protected $_optionMap = array( diff --git a/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php index 53af75a80..fa4253842 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php @@ -20,7 +20,10 @@ * @subpackage cake.tests.cases.views.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', array('Html', 'Js', 'MootoolsEngine')); + +App::uses('HtmlHelper', 'View/Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('MooToolsEngineHelper', 'View/Helper'); class MooEngineHelperTest extends CakeTestCase { /** diff --git a/lib/Cake/tests/cases/libs/view/helpers/number.test.php b/lib/Cake/tests/cases/libs/view/helpers/number.test.php index 1d1d04c4c..9919416fb 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/number.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/number.test.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Number'); +App::uses('NumberHelper', 'View/Helper'); /** * NumberHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/helpers/paginator.test.php b/lib/Cake/tests/cases/libs/view/helpers/paginator.test.php index 2d0bda4a9..ef720ccc8 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/paginator.test.php @@ -17,8 +17,11 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'View'); -App::import('Helper', array('Html', 'Paginator', 'Form', 'Js')); +App::uses('View', 'View'); +App::uses('HtmlHelper', 'View/Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('PaginatorHelper', 'View/Helper'); +App::uses('FormHelper', 'View/Helper'); if (!defined('FULL_BASE_URL')) { define('FULL_BASE_URL', 'http://cakephp.org'); diff --git a/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php index 395b25cd7..77c2b1b87 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php @@ -18,7 +18,10 @@ * @subpackage cake.tests.cases.views.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', array('Html', 'Js', 'PrototypeEngine')); + +App::uses('HtmlHelper', 'View/Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('PrototypeEngineHelper', 'View/Helper'); class PrototypeEngineHelperTest extends CakeTestCase { /** diff --git a/lib/Cake/tests/cases/libs/view/helpers/rss.test.php b/lib/Cake/tests/cases/libs/view/helpers/rss.test.php index afc3e54e9..0e6e18474 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/rss.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/rss.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) */ -App::import('View', 'View'); -App::import('Helper', array('Rss', 'Time')); +App::uses('View', 'View'); +App::uses('RssHelper', 'View/Helper'); +App::uses('TimeHelper', 'View/Helper'); /** * RssHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/helpers/session.test.php b/lib/Cake/tests/cases/libs/view/helpers/session.test.php index c61421bd1..2fa1dad0a 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/session.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/session.test.php @@ -17,8 +17,10 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', array('Controller', 'View')); -App::import('Helper', array('Session')); + +App::uses('Controller', 'Controller'); +App::uses('View', 'View'); +App::uses('SessionHelper', 'View/Helper'); /** * SessionHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/helpers/text.test.php b/lib/Cake/tests/cases/libs/view/helpers/text.test.php index cdb5dcecb..2ac412374 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/text.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/text.test.php @@ -17,8 +17,8 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'View'); -App::import('Helper', 'Text'); +App::uses('View', 'View'); +App::uses('TextHelper', 'Helper'); /** * TextHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/helpers/time.test.php b/lib/Cake/tests/cases/libs/view/helpers/time.test.php index 668467296..d5ba62b61 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/time.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/time.test.php @@ -17,8 +17,8 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Time'); -App::import('Core', 'View'); +App::uses('TimeHelper', 'View/Helper'); +App::uses('View', 'View'); /** * TimeHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/media.test.php b/lib/Cake/tests/cases/libs/view/media.test.php index 39b9d190d..a9352f5d9 100644 --- a/lib/Cake/tests/cases/libs/view/media.test.php +++ b/lib/Cake/tests/cases/libs/view/media.test.php @@ -17,7 +17,10 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', array('Media', 'Controller', 'CakeResponse')); + +App::uses('Controller', 'Controller'); +App::uses('MediaView', 'View'); +App::uses('CakeResponse', 'Network'); /** * MediaViewTest class diff --git a/lib/Cake/tests/cases/libs/view/theme.test.php b/lib/Cake/tests/cases/libs/view/theme.test.php index ffc8ee045..69a986ad7 100644 --- a/lib/Cake/tests/cases/libs/view/theme.test.php +++ b/lib/Cake/tests/cases/libs/view/theme.test.php @@ -17,8 +17,8 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('View', 'View'); -App::import('View', 'Theme'); +App::uses('View', 'View'); +App::uses('ThemeView', 'View'); App::uses('Controller', 'Controller'); diff --git a/lib/Cake/tests/cases/libs/view/view.test.php b/lib/Cake/tests/cases/libs/view/view.test.php index 8038ff010..9824b125a 100644 --- a/lib/Cake/tests/cases/libs/view/view.test.php +++ b/lib/Cake/tests/cases/libs/view/view.test.php @@ -17,9 +17,11 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', array('View', 'Controller')); -App::import('Helper', 'Cache'); -App::import('Core', array('ErrorHandler')); + +App::uses('View', 'View'); +App::uses('Controller', 'Controller'); +App::uses('CacheHelper', 'View/Helper'); +App::uses('ErrorHandler', 'Error'); /**