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'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
App::uses('CakeSchema', 'Model');
/** /**
* Short description for class. * Short description for class.
* *
@ -52,7 +54,6 @@ class CakeTestFixture {
* *
*/ */
public function __construct() { public function __construct() {
App::import('Model', 'CakeSchema');
$this->Schema = new CakeSchema(array('name' => 'TestSuite', 'connection' => 'test')); $this->Schema = new CakeSchema(array('name' => 'TestSuite', 'connection' => 'test'));
$this->init(); $this->init();
} }
@ -68,9 +69,12 @@ class CakeTestFixture {
is_array($this->import) ? $this->import : array('model' => $this->import) is_array($this->import) ? $this->import : array('model' => $this->import)
); );
if (isset($import['model']) && App::import('Model', $import['model'])) { if (isset($import['model'])) {
App::import('Model', $import['model']); list($plugin, $modelClass) = pluginSplit($import['model'], true);
list(, $modelClass) = pluginSplit($import['model']); App::uses($modelClass, $plugin . 'Model');
if (!class_exists($modelClass)) {
throw new MissingModelException(array('class' => $modelClass));
}
$model = new $modelClass(null, null, $import['connection']); $model = new $modelClass(null, null, $import['connection']);
$db = $model->getDataSource(); $db = $model->getDataSource();
if (empty($model->tablePrefix)) { if (empty($model->tablePrefix)) {

View file

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

View file

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

View file

@ -17,7 +17,7 @@
* @since CakePHP(tm) v 1.2.0.6833 * @since CakePHP(tm) v 1.2.0.6833
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('Multibyte', 'I18n'); App::uses('Multibyte', 'I18n');
/** /**
* MultibyteTest class * MultibyteTest class

View file

@ -17,7 +17,10 @@
* @since CakePHP(tm) v 1.2.0.5432 * @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @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 * RequestActionPost class

View file

@ -18,7 +18,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('Core', 'ObjectCollection'); App::uses('ObjectCollection', 'Utility');
/** /**
* A generic object class * A generic object class

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,7 +17,10 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @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 * HelperTestPost class

View file

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

View file

@ -17,8 +17,11 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @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 * CacheTestController class

View file

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

View file

@ -18,7 +18,13 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('Core', array('Helper', 'AppHelper', 'ClassRegistry', 'Controller')); 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')) { if (!defined('FULL_BASE_URL')) {
define('FULL_BASE_URL', 'http://cakephp.org'); 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')) { if ($this->skipIf(!is_writable(WWW_ROOT . 'theme'), 'Cannot write to webroot/theme')) {
return; return;
} }
App::import('Core', 'File'); App::uses('File', 'Utility');
$testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'img' . DS . '__cake_test_image.gif'; $testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'img' . DS . '__cake_test_image.gif';
$file = new File($testfile, true); $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')) { if ($this->skipIf(!is_writable(WWW_ROOT . 'theme'), 'Cannot write to webroot/theme')) {
return; return;
} }
App::import('Core', 'File'); App::uses('File', 'Utility');
$testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'js' . DS . '__test_js.js'; $testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'js' . DS . '__test_js.js';
$file = new File($testfile, true); $file = new File($testfile, true);

View file

@ -18,8 +18,11 @@
* @subpackage cake.tests.cases.views.helpers * @subpackage cake.tests.cases.views.helpers
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @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 { class JqueryEngineHelperTest extends CakeTestCase {
/** /**

View file

@ -19,8 +19,11 @@
* @since CakePHP(tm) v 1.3 * @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('Helper', array('Js', 'Html', 'Form')); App::uses('HtmlHelper', 'View/Helper');
App::import('Core', array('View', 'ClassRegistry')); App::uses('JsHelper', 'View/Helper');
App::uses('FormHelper', 'View/Helper');
App::uses('View', 'View');
App::uses('ClassRegistry', 'Utility');
class OptionEngineHelper extends JsBaseEngineHelper { class OptionEngineHelper extends JsBaseEngineHelper {
protected $_optionMap = array( protected $_optionMap = array(

View file

@ -20,7 +20,10 @@
* @subpackage cake.tests.cases.views.helpers * @subpackage cake.tests.cases.views.helpers
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @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 { class MooEngineHelperTest extends CakeTestCase {
/** /**

View file

@ -17,7 +17,7 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('Helper', 'Number'); App::uses('NumberHelper', 'View/Helper');
/** /**
* NumberHelperTest class * NumberHelperTest class

View file

@ -17,8 +17,11 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('Core', 'View'); App::uses('View', 'View');
App::import('Helper', array('Html', 'Paginator', 'Form', 'Js')); 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')) { if (!defined('FULL_BASE_URL')) {
define('FULL_BASE_URL', 'http://cakephp.org'); define('FULL_BASE_URL', 'http://cakephp.org');

View file

@ -18,7 +18,10 @@
* @subpackage cake.tests.cases.views.helpers * @subpackage cake.tests.cases.views.helpers
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @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 { class PrototypeEngineHelperTest extends CakeTestCase {
/** /**

View file

@ -17,8 +17,9 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('View', 'View'); App::uses('View', 'View');
App::import('Helper', array('Rss', 'Time')); App::uses('RssHelper', 'View/Helper');
App::uses('TimeHelper', 'View/Helper');
/** /**
* RssHelperTest class * RssHelperTest class

View file

@ -17,8 +17,10 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @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 * SessionHelperTest class

View file

@ -17,8 +17,8 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('Core', 'View'); App::uses('View', 'View');
App::import('Helper', 'Text'); App::uses('TextHelper', 'Helper');
/** /**
* TextHelperTest class * TextHelperTest class

View file

@ -17,8 +17,8 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('Helper', 'Time'); App::uses('TimeHelper', 'View/Helper');
App::import('Core', 'View'); App::uses('View', 'View');
/** /**
* TimeHelperTest class * TimeHelperTest class

View file

@ -17,7 +17,10 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @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 * MediaViewTest class

View file

@ -17,8 +17,8 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('View', 'View'); App::uses('View', 'View');
App::import('View', 'Theme'); App::uses('ThemeView', 'View');
App::uses('Controller', 'Controller'); App::uses('Controller', 'Controller');

View file

@ -17,9 +17,11 @@
* @since CakePHP(tm) v 1.2.0.4206 * @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::import('Core', array('View', 'Controller'));
App::import('Helper', 'Cache'); App::uses('View', 'View');
App::import('Core', array('ErrorHandler')); App::uses('Controller', 'Controller');
App::uses('CacheHelper', 'View/Helper');
App::uses('ErrorHandler', 'Error');
/** /**