Replacing almost all remaining uses of App::import

This commit is contained in:
José Lorenzo Rodríguez 2010-12-10 01:53:27 -04:30
parent e57b3d8e74
commit 2907765404
33 changed files with 104 additions and 57 deletions

View file

@ -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)) {

View file

@ -27,7 +27,7 @@
</p>
</div>
<?php
App::import('Core', 'View');
App::uses('View', 'View');
$null = null;
$View = new View($null, false);
echo $View->element('sql_dump');

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,7 +1,7 @@
<?php
App::import('Core', 'route/CakeRoute');
App::import('Core', 'Router');
App::uses('CakeRoute', 'Routing');
App::uses('Router', 'Routing');
/**
* Test case for CakeRoute

View file

@ -1,6 +1,6 @@
<?php
App::import('Core', 'route/PluginShortRoute');
App::import('Core', 'Router');
App::uses('PluginShortRoute', 'Routing/Route');
App::uses('Router', 'Routing');
/**
* test case for PluginShortRoute
*

View file

@ -17,7 +17,7 @@
* @since CakePHP(tm) v 1.2.0.5428
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'Sanitize');
App::uses('Sanitize', 'Utility');
/**
* DataTest class

View file

@ -17,7 +17,7 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'Security');
App::uses('Security', 'Utility');
/**
* SecurityTest class

View file

@ -18,8 +18,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'CakeSession');
App::import('Core', 'session/CacheSession');
App::uses('CakeSession', 'Model/Datasource');
App::uses('CacheSession', 'Model/Datasource/Session');
class CacheSessionTest extends CakeTestCase {

View file

@ -18,9 +18,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'Model');
App::import('Core', 'CakeSession');
App::import('Core', 'session/DatabaseSession');
App::uses('Model', 'Model');
App::uses('CakeSession', 'Model/Session');
App::uses('DatabaseSession', 'Model/Datasource/Session');
class SessionTestModel extends Model {
var $name = 'SessionTestModel';

View file

@ -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', 'Set');
App::uses('Set', 'Utility');
/**
* SetTest class

View file

@ -17,7 +17,7 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'String');
App::uses('String', 'Utility');
/**
* StringTest class

View file

@ -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', 'Validation');
App::uses('Validation', 'Utility');
/**
* CustomValidator class

View file

@ -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('View', 'Helper', 'Router'));
App::uses('View', 'View');
App::uses('Helper', 'View');
App::uses('Router', 'Routing');
/**
* HelperTestPost class

View file

@ -18,8 +18,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', 'HelperCollection');
App::import('View', 'View');
App::uses('HelperCollection', 'View/Helper');
App::uses('View', 'View');
class HelperCollectionTest extends CakeTestCase {
/**

View file

@ -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', array('Controller', 'Model', 'View'));
App::import('Helper', 'Cache');
App::uses('Controller', 'Controller');
App::uses('Model', 'Model');
App::uses('View', 'View');
App::uses('CacheHelper', 'View/Helper');
/**
* CacheTestController class

View file

@ -17,9 +17,14 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', array('ClassRegistry', 'Controller', 'View', 'Model', 'Security', 'CakeRequest'));
App::import('Helper', 'Html');
App::import('Helper', 'Form');
App::uses('ClassRegistry', 'Utility');
App::uses('Controller', 'Controller');
App::uses('View', 'View');
App::uses('Model', 'Model');
App::uses('Security', 'Utility');
App::uses('CakeRequest', 'Network');
App::uses('HtmlHelper', 'View/Helper');
App::uses('FormHelper', 'View/Helper');
/**
* ContactTestController class

View file

@ -18,7 +18,13 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Core', array('Helper', 'AppHelper', 'ClassRegistry', 'Controller'));
App::import('Helper', array('Html', 'Form'));
App::uses('Helper', 'View');
App::uses('AppHelper', 'View/Helper');
App::uses('ClassRegistry', 'Utility');
App::uses('Controller', 'Controller');
App::uses('HtmlHelper', 'View/Helper');
App::uses('FomrHelper', 'View/Helper');
if (!defined('FULL_BASE_URL')) {
define('FULL_BASE_URL', 'http://cakephp.org');
@ -315,7 +321,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 . '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);

View file

@ -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 {
/**

View file

@ -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(

View file

@ -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 {
/**

View file

@ -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

View file

@ -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');

View file

@ -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 {
/**

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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');

View file

@ -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');
/**