Removing unused variables and properly testing more methods in App class

This commit is contained in:
Jose Lorenzo Rodriguez 2011-03-09 23:33:03 -04:30
parent 21286cb8c2
commit 472257c347
3 changed files with 26 additions and 96 deletions

View file

@ -66,90 +66,6 @@ class App {
'plugin' => array('suffix' => '', 'extends' => null, 'core' => true)
);
/**
* List of additional path(s) where model files reside.
*
* @var array
*/
public static $models = array();
/**
* List of additional path(s) where behavior files reside.
*
* @var array
*/
public static $behaviors = array();
/**
* List of additional path(s) where controller files reside.
*
* @var array
*/
public static $controllers = array();
/**
* List of additional path(s) where component files reside.
*
* @var array
*/
public static $components = array();
/**
* List of additional path(s) where datasource files reside.
*
* @var array
*/
public static $datasources = array();
/**
* List of additional path(s) where libs files reside.
*
* @var array
*/
public static $libs = array();
/**
* List of additional path(s) where view files reside.
*
* @var array
*/
public static $views = array();
/**
* List of additional path(s) where helper files reside.
*
* @var array
*/
public static $helpers = array();
/**
* List of additional path(s) where plugins reside.
*
* @var array
*/
public static $plugins = array();
/**
* List of additional path(s) where vendor packages reside.
*
* @var array
*/
public static $vendors = array();
/**
* List of additional path(s) where locale files reside.
*
* @var array
*/
public static $locales = array();
/**
* List of additional path(s) where console shell files reside.
*
* @var array
*/
public static $shells = array();
/**
* Paths to search for files.
*
@ -218,7 +134,7 @@ class App {
private static $__packageFormat = array();
/**
* Maps an old style cakephp class type to the corresponding package
* Maps an old style CakePHP class type to the corresponding package
*
*/
public static $legacy = array(
@ -445,10 +361,6 @@ class App {
$includeDirectories = false;
$name = $type;
if (isset(self::$legacy[$type . 's'])) {
$type = self::$legacy[$type . 's'];
}
if ($type === 'plugin') {
$type = 'plugins';
}
@ -460,6 +372,10 @@ class App {
list($plugin, $type) = pluginSplit($type);
if (isset(self::$legacy[$type . 's'])) {
$type = self::$legacy[$type . 's'];
}
if ($type === 'file' && !$path) {
return false;
} elseif ($type === 'file') {
@ -479,6 +395,7 @@ class App {
if (empty($path)) {
$path = self::path($type, $plugin);
}
$items = array();
foreach ((array)$path as $dir) {

View file

@ -24,7 +24,7 @@ App::import('Core', 'Debugger');
<a href="http://cakephp.org/changelogs/1.3.6"><?php __('Read the changelog'); ?> </a>
<?php
if (Configure::read('debug') > 0):
//Debugger::checkSecurityKeys();
Debugger::checkSecurityKeys();
endif;
?>
<p>

View file

@ -260,32 +260,45 @@ class AppImportTest extends CakeTestCase {
*/
function testListObjectsInPlugin() {
App::build(array(
'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$oldCache = App::$models;
$result = App::objects('TestPlugin.model');
$this->assertTrue(in_array('TestPluginPost', $result));
$this->assertEquals($oldCache, App::$models);
$result = App::objects('TestPlugin.Model');
$this->assertTrue(in_array('TestPluginPost', $result));
$result = App::objects('TestPlugin.behavior');
$this->assertTrue(in_array('TestPluginPersisterOne', $result));
$result = App::objects('TestPlugin.Model/Behavior');
$this->assertTrue(in_array('TestPluginPersisterOne', $result));
$result = App::objects('TestPlugin.helper');
$expected = array('OtherHelper', 'PluggedHelper', 'TestPluginApp');
$expected = array('OtherHelperHelper', 'PluggedHelper', 'TestPluginApp');
$this->assertEquals($result, $expected);
$result = App::objects('TestPlugin.View/Helper');
$expected = array('OtherHelperHelper', 'PluggedHelper', 'TestPluginApp');
$this->assertEquals($result, $expected);
$result = App::objects('TestPlugin.component');
$this->assertTrue(in_array('OtherComponent', $result));
$result = App::objects('TestPlugin.Controller/Component');
$this->assertTrue(in_array('OtherComponent', $result));
$result = App::objects('TestPluginTwo.behavior');
$this->assertEquals($result, array());
$result = App::objects('TestPluginTwo.Model/Behavior');
$this->assertEquals($result, array());
$result = App::objects('model', null, false);
$this->assertTrue(in_array('Comment', $result));
$this->assertTrue(in_array('Post', $result));
$result = App::objects('Model', null, false);
$this->assertTrue(in_array('Comment', $result));
$this->assertTrue(in_array('Post', $result));
App::build();
}
@ -319,7 +332,7 @@ class AppImportTest extends CakeTestCase {
*/
function testThemePath() {
App::build(array(
'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS)
));
$path = App::themePath('test_theme');
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;