diff --git a/cake/console/cake.php b/cake/console/cake.php index 823e6fc00..0a88cccaa 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -198,7 +198,7 @@ class ShellDispatcher { */ function __buildPaths() { $paths = array(); - $pluginPaths = Configure::read('pluginPaths'); + $pluginPaths = App::path('plugins'); if (!class_exists('Folder')) { require LIBS . 'folder.php'; } @@ -259,7 +259,7 @@ class ShellDispatcher { Configure::getInstance(file_exists(CONFIGS . 'bootstrap.php')); if (!file_exists(APP_PATH . 'config' . DS . 'core.php')) { - include_once CORE_PATH . 'cake' . DS . 'console' . DS . 'libs' . DS . 'templates' . DS . 'skel' . DS . 'config' . DS . 'core.php'; + include_once CORE_PATH . 'cake' . DS . 'console' . DS . 'templates' . DS . 'skel' . DS . 'config' . DS . 'core.php'; Configure::buildPaths(array()); } diff --git a/cake/console/libs/testsuite.php b/cake/console/libs/testsuite.php index b11a7ea11..99b34d82e 100644 --- a/cake/console/libs/testsuite.php +++ b/cake/console/libs/testsuite.php @@ -316,7 +316,7 @@ class TestSuiteShell extends Shell { } else { $scoredCategory = Inflector::underscore($category); $folder = APP . 'plugins' . DS . $scoredCategory . DS; - $pluginPaths = Configure::read('pluginPaths'); + $pluginPaths = App::path('plugins'); foreach ($pluginPaths as $path) { if (file_exists($path . $scoredCategory . DS . 'tests')) { $folder = $path . $scoredCategory . DS . 'tests'; diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 9756c841a..581db44aa 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -620,7 +620,7 @@ class Dispatcher extends Object { if ($pos > 0) { $plugin = substr($url, 0, $pos - 1); $url = str_replace($plugin . '/', '', $url); - $pluginPaths = Configure::read('pluginPaths'); + $pluginPaths = App::path('plugins'); $count = count($pluginPaths); for ($i = 0; $i < $count; $i++) { $paths[] = $pluginPaths[$i] . $plugin . DS . 'vendors' . DS; diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 753549478..5a5545027 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -32,76 +32,6 @@ * @link http://book.cakephp.org/view/42/The-Configuration-Class */ class Configure extends Object { -/** - * List of additional path(s) where model files reside. - * - * @var array - * @access public - */ - var $modelPaths = array(); -/** - * List of additional path(s) where behavior files reside. - * - * @var array - * @access public - */ - var $behaviorPaths = array(); -/** - * List of additional path(s) where controller files reside. - * - * @var array - * @access public - */ - var $controllerPaths = array(); -/** - * List of additional path(s) where component files reside. - * - * @var array - * @access public - */ - var $componentPaths = array(); -/** - * List of additional path(s) where view files reside. - * - * @var array - * @access public - */ - var $viewPaths = array(); -/** - * List of additional path(s) where helper files reside. - * - * @var array - * @access public - */ - var $helperPaths = array(); -/** - * List of additional path(s) where plugins reside. - * - * @var array - * @access public - */ - var $pluginPaths = array(); -/** - * List of additional path(s) where vendor packages reside. - * - * @var array - * @access public - */ - var $vendorPaths = array(); -/** - * List of additional path(s) where locale files reside. - * - * @var array - * @access public - */ - var $localePaths = array(); -/** - * List of additional path(s) where console shell files reside. - * - * @var array - * @access public - */ - var $shellPaths = array(); /** * Current debug level. * @@ -117,13 +47,6 @@ class Configure extends Object { * @access private */ var $__cache = false; -/** - * Holds and key => value array of objects' types. - * - * @var array - * @access private - */ - var $__objects = array(); /** * Returns a singleton instance of the Configure class. * @@ -138,111 +61,6 @@ class Configure extends Object { } return $instance[0]; } -/** - * Returns an index of objects of the given type, with the physical path to each object. - * - * @param string $type Type of object, i.e. 'model', 'controller', 'helper', or 'plugin' - * @param mixed $path Optional - * @return Configure instance - * @access public - */ - function listObjects($type, $path = null, $cache = true) { - $objects = array(); - $extension = false; - $name = $type; - - if ($type === 'file' && !$path) { - return false; - } elseif ($type === 'file') { - $extension = true; - $name = $type . str_replace(DS, '', $path); - } - $_this =& Configure::getInstance(); - - if (empty($_this->__objects) && $cache === true) { - $_this->__objects = Cache::read('object_map', '_cake_core_'); - } - - if (empty($_this->__objects) || !isset($_this->__objects[$type]) || $cache !== true) { - $types = array( - 'model' => array('suffix' => '.php', 'base' => 'AppModel', 'core' => false), - 'behavior' => array('suffix' => '.php', 'base' => 'ModelBehavior'), - 'controller' => array('suffix' => '_controller.php', 'base' => 'AppController'), - 'component' => array('suffix' => '.php', 'base' => null), - 'view' => array('suffix' => '.php', 'base' => null), - 'helper' => array('suffix' => '.php', 'base' => 'AppHelper'), - 'plugin' => array('suffix' => '', 'base' => null), - 'vendor' => array('suffix' => '', 'base' => null), - 'class' => array('suffix' => '.php', 'base' => null), - 'file' => array('suffix' => '.php', 'base' => null) - ); - - if (!isset($types[$type])) { - return false; - } - $objects = array(); - - if (empty($path)) { - $path = $_this->{$type . 'Paths'}; - if (isset($types[$type]['core']) && $types[$type]['core'] === false) { - array_pop($path); - } - } - $items = array(); - - foreach ((array)$path as $dir) { - if ($type === 'file' || $type === 'class' || strpos($dir, $type) !== false) { - $items = $_this->__list($dir, $types[$type]['suffix'], $extension); - $objects = array_merge($items, array_diff($objects, $items)); - } - } - - if ($type !== 'file') { - foreach ($objects as $key => $value) { - $objects[$key] = Inflector::camelize($value); - } - } - if ($cache === true && !empty($objects)) { - $_this->__objects[$name] = $objects; - $_this->__cache = true; - } else { - return $objects; - } - } - return $_this->__objects[$name]; - } -/** - * Returns an array of filenames of PHP files in the given directory. - * - * @param string $path Path to scan for files - * @param string $suffix if false, return only directories. if string, match and return files - * @return array List of directories or files in directory - */ - function __list($path, $suffix = false, $extension = false) { - if (!class_exists('Folder')) { - require LIBS . 'folder.php'; - } - $items = array(); - $Folder =& new Folder($path); - $contents = $Folder->read(false, true); - - if (is_array($contents)) { - if (!$suffix) { - return $contents[0]; - } else { - foreach ($contents[1] as $item) { - if (substr($item, - strlen($suffix)) === $suffix) { - if ($extension) { - $items[] = $item; - } else { - $items[] = substr($item, 0, strlen($item) - strlen($suffix)); - } - } - } - } - } - return $items; - } /** * Used to store a dynamic variable in the Configure instance. * @@ -254,7 +72,7 @@ class Configure extends Object { * 'key1' => 'value of the Configure::One[key1]', * 'key2' => 'value of the Configure::One[key2]' * ); - * + * * Configure::write(array( * 'One.key1' => 'value of the Configure::One[key1]', * 'One.key2' => 'value of the Configure::One[key2]' @@ -403,7 +221,7 @@ class Configure extends Object { include(CACHE . 'persistent' . DS . $fileName . '.php'); $found = true; } else { - foreach (Configure::corePaths('cake') as $key => $path) { + foreach (App::core('cake') as $key => $path) { if (file_exists($path . DS . 'config' . DS . $fileName . '.php')) { include($path . DS . 'config' . DS . $fileName . '.php'); $found = true; @@ -479,57 +297,6 @@ class Configure extends Object { } Configure::__writeConfig($content, $name, $write); } -/** - * Returns a key/value list of all paths where core libs are found. - * Passing $type only returns the values for a given value of $key. - * - * @param string $type valid values are: 'model', 'behavior', 'controller', 'component', - * 'view', 'helper', 'datasource', 'libs', and 'cake' - * @return array numeric keyed array of core lib paths - * @access public - */ - function corePaths($type = null) { - $paths = Cache::read('core_paths', '_cake_core_'); - if (!$paths) { - $paths = array(); - $openBasedir = ini_get('open_basedir'); - if ($openBasedir) { - $all = explode(PATH_SEPARATOR, $openBasedir); - $all = array_flip(array_flip((array_merge(array(CAKE_CORE_INCLUDE_PATH), $all)))); - } else { - $all = explode(PATH_SEPARATOR, ini_get('include_path')); - $all = array_flip(array_flip((array_merge(array(CAKE_CORE_INCLUDE_PATH), $all)))); - } - foreach ($all as $path) { - if ($path !== DS) { - $path = rtrim($path, DS); - } - if (empty($path) || $path === '.') { - continue; - } - $cake = $path . DS . 'cake' . DS; - $libs = $cake . 'libs' . DS; - if (is_dir($libs)) { - $paths['libs'][] = $libs; - $paths['model'][] = $libs . 'model' . DS; - $paths['behavior'][] = $libs . 'model' . DS . 'behaviors' . DS; - $paths['controller'][] = $libs . 'controller' . DS; - $paths['component'][] = $libs . 'controller' . DS . 'components' . DS; - $paths['view'][] = $libs . 'view' . DS; - $paths['helper'][] = $libs . 'view' . DS . 'helpers' . DS; - $paths['cake'][] = $cake; - $paths['vendor'][] = $path . DS . 'vendors' . DS; - $paths['shell'][] = $cake . 'console' . DS . 'libs' . DS; - break; - } - } - Cache::write('core_paths', array_filter($paths), '_cake_core_'); - } - if ($type && isset($paths[$type])) { - return $paths[$type]; - } - return $paths; - } /** * Creates a cached version of a configuration file. * Appends values passed from Configure::store() to the cached file @@ -582,56 +349,25 @@ class Configure extends Object { return $name; } /** - * Build path references. Merges the supplied $paths - * with the base paths and the default core paths. - * - * @param array $paths paths defines in config/bootstrap.php - * @return void - * @access public + * @deprecated + * @see App::objects() + */ + function listObjects($type, $path = null, $cache = true) { + return App::objects($type, $path, $cache); + } +/** + * @deprecated + * @see App::core() + */ + function corePaths($type = null) { + return App::core($type); + } +/** + * @deprecated + * @see App::build() */ function buildPaths($paths) { - $_this =& Configure::getInstance(); - $core = $_this->corePaths(); - $basePaths = array( - 'model' => array(MODELS), - 'behavior' => array(BEHAVIORS), - 'controller' => array(CONTROLLERS), - 'component' => array(COMPONENTS), - 'view' => array(VIEWS), - 'helper' => array(HELPERS), - 'plugin' => array(APP . 'plugins' . DS), - 'vendor' => array(APP . 'vendors' . DS, VENDORS), - 'locale' => array(APP . 'locale' . DS), - 'shell' => array(), - 'datasource' => array(MODELS . 'datasources') - ); - - foreach ($basePaths as $type => $default) { - $pathsVar = $type . 'Paths'; - $merge = array(); - - if (isset($core[$type])) { - $merge = $core[$type]; - } - if ($type === 'model' || $type === 'controller' || $type === 'helper') { - $merge = array_merge(array(APP), $merge); - } - - if (!is_array($default)) { - $default = array($default); - } - $_this->{$pathsVar} = $default; - - if (isset($paths[$pathsVar]) && !empty($paths[$pathsVar])) { - $path = array_flip(array_flip((array_merge( - $_this->{$pathsVar}, (array)$paths[$pathsVar], $merge - )))); - $_this->{$pathsVar} = array_values($path); - } else { - $path = array_flip(array_flip((array_merge($_this->{$pathsVar}, $merge)))); - $_this->{$pathsVar} = array_values($path); - } - } + return App::build($paths); } /** * Loads app/config/bootstrap.php. @@ -692,9 +428,9 @@ class Configure extends Object { } Cache::config('default'); } - Configure::buildPaths(compact( - 'modelPaths', 'viewPaths', 'controllerPaths', 'helperPaths', 'componentPaths', - 'behaviorPaths', 'pluginPaths', 'vendorPaths', 'localePaths', 'shellPaths' + App::build(compact( + 'models', 'views', 'controllers', 'helpers', 'components', + 'behaviors', 'plugins', 'vendors', 'locales', 'shells' )); } } @@ -718,6 +454,96 @@ class Configure extends Object { * @subpackage cake.cake.libs */ class App extends Object { +/** + * List of object types and their properties + * + * @var array + * @access public + */ + var $objects = array( + 'model' => array('suffix' => '.php', 'base' => 'AppModel', 'core' => false), + 'behavior' => array('suffix' => '.php', 'base' => 'ModelBehavior'), + 'controller' => array('suffix' => '_controller.php', 'base' => 'AppController'), + 'component' => array('suffix' => '.php', 'base' => null), + 'view' => array('suffix' => '.php', 'base' => null), + 'helper' => array('suffix' => '.php', 'base' => 'AppHelper'), + 'plugin' => array('suffix' => '', 'base' => null), + 'vendor' => array('suffix' => '', 'base' => null), + 'shell' => array('suffix' => 'Shell', 'base' => 'Shell'), + 'class' => array('suffix' => '.php', 'base' => null), + 'file' => array('suffix' => '.php', 'base' => null) + ); + +/** + * List of additional path(s) where model files reside. + * + * @var array + * @access protected + */ + var $_models = array(); +/** + * List of additional path(s) where behavior files reside. + * + * @var array + * @access protected + */ + var $_behaviors = array(); +/** + * List of additional path(s) where controller files reside. + * + * @var array + * @access protected + */ + var $_controllers = array(); +/** + * List of additional path(s) where component files reside. + * + * @var array + * @access protected + */ + var $_components = array(); +/** + * List of additional path(s) where view files reside. + * + * @var array + * @access protected + */ + var $_views = array(); +/** + * List of additional path(s) where helper files reside. + * + * @var array + * @access protected + */ + var $_helpers = array(); +/** + * List of additional path(s) where plugins reside. + * + * @var array + * @access protected + */ + var $_plugins = array(); +/** + * List of additional path(s) where vendor packages reside. + * + * @var array + * @access protected + */ + var $_vendors = array(); +/** + * List of additional path(s) where locale files reside. + * + * @var array + * @access protected + */ + var $_locales = array(); +/** + * List of additional path(s) where console shell files reside. + * + * @var array + * @access protected + */ + var $_shells = array(); /** * Paths to search for files. * @@ -760,6 +586,200 @@ class App extends Object { * @access private */ var $__loaded = array(); +/** + * Holds and key => value array of object types. + * + * @var array + * @access private + */ + var $__objects = array(); +/** + * Used to read information stored path + * + * Usage + * App::path('models'); will return all paths for models + * + * @param string $type type of path + * @return string array + * @access public + */ + function path($type, $value = array()) { + $_this =& App::getInstance(); + if (!isset($_this->{"_{$type}"})) { + return array(); + } + if (empty($value)) { + return $_this->{"_{$type}"}; + } + if (!empty($value)) { + return $_this->{"_{$type}"} = (array)$value; + } + } +/** + * Build path references. Merges the supplied $paths + * with the base paths and the default core paths. + * + * @param array $paths paths defines in config/bootstrap.php + * @return void + * @access public + */ + function build($paths = array()) { + $_this =& App::getInstance(); + $core = $_this->core(); + $basePaths = array( + 'model' => array(MODELS), + 'behavior' => array(BEHAVIORS), + 'datasource' => array(MODELS . 'datasources'), + 'controller' => array(CONTROLLERS), + 'component' => array(COMPONENTS), + 'view' => array(VIEWS), + 'helper' => array(HELPERS), + 'plugin' => array(APP . 'plugins' . DS), + 'vendor' => array(APP . 'vendors' . DS, VENDORS), + 'locale' => array(APP . 'locale' . DS), + 'shell' => array() + ); + + foreach ($basePaths as $type => $default) { + $pathsVar = "_{$type}s"; + $merge = array(); + + if (isset($core[$type])) { + $merge = $core[$type]; + } + if ($type === 'model' || $type === 'controller' || $type === 'helper') { + $merge = array_merge(array(APP), $merge); + } + + if (!is_array($default)) { + $default = array($default); + } + $_this->{$pathsVar} = $default; + + if (isset($paths[$pathsVar]) && !empty($paths[$pathsVar])) { + $path = array_flip(array_flip((array_merge( + $_this->{$pathsVar}, (array)$paths[$pathsVar], $merge + )))); + $_this->{$pathsVar} = array_values($path); + } else { + $path = array_flip(array_flip((array_merge($_this->{$pathsVar}, $merge)))); + $_this->{$pathsVar} = array_values($path); + } + } + } +/** + * Returns a key/value list of all paths where core libs are found. + * Passing $type only returns the values for a given value of $key. + * + * @param string $type valid values are: 'model', 'behavior', 'controller', 'component', + * 'view', 'helper', 'datasource', 'libs', and 'cake' + * @return array numeric keyed array of core lib paths + * @access public + */ + function core($type = null) { + $paths = Cache::read('core_paths', '_cake_core_'); + if (!$paths) { + $paths = array(); + $openBasedir = ini_get('open_basedir'); + if ($openBasedir) { + $all = explode(PATH_SEPARATOR, $openBasedir); + $all = array_flip(array_flip((array_merge(array(CAKE_CORE_INCLUDE_PATH), $all)))); + } else { + $all = explode(PATH_SEPARATOR, ini_get('include_path')); + $all = array_flip(array_flip((array_merge(array(CAKE_CORE_INCLUDE_PATH), $all)))); + } + foreach ($all as $path) { + if ($path !== DS) { + $path = rtrim($path, DS); + } + if (empty($path) || $path === '.') { + continue; + } + $cake = $path . DS . 'cake' . DS; + $libs = $cake . 'libs' . DS; + if (is_dir($libs)) { + $paths['libs'][] = $libs; + $paths['model'][] = $libs . 'model' . DS; + $paths['behavior'][] = $libs . 'model' . DS . 'behaviors' . DS; + $paths['controller'][] = $libs . 'controller' . DS; + $paths['component'][] = $libs . 'controller' . DS . 'components' . DS; + $paths['view'][] = $libs . 'view' . DS; + $paths['helper'][] = $libs . 'view' . DS . 'helpers' . DS; + $paths['cake'][] = $cake; + $paths['vendor'][] = $path . DS . 'vendors' . DS; + $paths['shell'][] = $cake . 'console' . DS . 'libs' . DS; + break; + } + } + Cache::write('core_paths', array_filter($paths), '_cake_core_'); + } + if ($type && isset($paths[$type])) { + return $paths[$type]; + } + return $paths; + } +/** + * Returns an index of objects of the given type, with the physical path to each object. + * + * @param string $type Type of object, i.e. 'model', 'controller', 'helper', or 'plugin' + * @param mixed $path Optional + * @return Configure instance + * @access public + */ + function objects($type, $path = null, $cache = true) { + $objects = array(); + $extension = false; + $name = $type; + + if ($type === 'file' && !$path) { + return false; + } elseif ($type === 'file') { + $extension = true; + $name = $type . str_replace(DS, '', $path); + } + $_this =& App::getInstance(); + + if (empty($_this->__objects) && $cache === true) { + $_this->__objects = Cache::read('object_map', '_cake_core_'); + } + + if (empty($_this->__objects) || !isset($_this->__objects[$type]) || $cache !== true) { + $types = $_this->objects; + + if (!isset($types[$type])) { + return false; + } + $objects = array(); + + if (empty($path)) { + $path = $_this->{"_{$type}s"}; + if (isset($types[$type]['core']) && $types[$type]['core'] === false) { + array_pop($path); + } + } + $items = array(); + + foreach ((array)$path as $dir) { + if ($type === 'file' || $type === 'class' || strpos($dir, $type) !== false) { + $items = $_this->__list($dir, $types[$type]['suffix'], $extension); + $objects = array_merge($items, array_diff($objects, $items)); + } + } + + if ($type !== 'file') { + foreach ($objects as $key => $value) { + $objects[$key] = Inflector::camelize($value); + } + } + if ($cache === true && !empty($objects)) { + $_this->__objects[$name] = $objects; + $_this->__cache = true; + } else { + return $objects; + } + } + return $_this->__objects[$name]; + } /** * Finds classes based on $name or specific file(s) to search. * @@ -1057,10 +1077,10 @@ class App extends Object { switch ($load) { case 'model': if (!class_exists('Model')) { - App::import('Core', 'Model', false, Configure::corePaths('model')); + App::import('Core', 'Model', false, App::core('model')); } if (!class_exists('AppModel')) { - App::import($type, 'AppModel', false, Configure::read('modelPaths')); + App::import($type, 'AppModel', false, App::path('models')); } if ($plugin) { if (!class_exists($name . 'AppModel')) { @@ -1128,7 +1148,7 @@ class App extends Object { $type = strtolower($type); if ($type === 'core') { - $path = Configure::corePaths(); + $path = App::core(); $paths = array(); foreach ($path as $key => $value) { @@ -1140,7 +1160,7 @@ class App extends Object { return $paths; } - if ($paths = Configure::read($type . 'Paths')) { + if ($paths = App::path($type .'s')) { return $paths; } @@ -1174,6 +1194,38 @@ class App extends Object { unset($this->__map[$type][$name]); } } +/** + * Returns an array of filenames of PHP files in the given directory. + * + * @param string $path Path to scan for files + * @param string $suffix if false, return only directories. if string, match and return files + * @return array List of directories or files in directory + */ + function __list($path, $suffix = false, $extension = false) { + if (!class_exists('Folder')) { + require LIBS . 'folder.php'; + } + $items = array(); + $Folder =& new Folder($path); + $contents = $Folder->read(false, true); + + if (is_array($contents)) { + if (!$suffix) { + return $contents[0]; + } else { + foreach ($contents[1] as $item) { + if (substr($item, - strlen($suffix)) === $suffix) { + if ($extension) { + $items[] = $item; + } else { + $items[] = substr($item, 0, strlen($item) - strlen($suffix)); + } + } + } + } + } + return $items; + } /** * Object destructor. * @@ -1184,7 +1236,7 @@ class App extends Object { */ function __destruct() { if ($this->__cache) { - $core = Configure::corePaths('cake'); + $core = App::core('cake'); unset($this->__paths[rtrim($core[0], DS)]); Cache::write('dir_map', array_filter($this->__paths), '_cake_core_'); Cache::write('file_map', array_filter($this->__map), '_cake_core_'); diff --git a/cake/libs/i18n.php b/cake/libs/i18n.php index 850ac5782..eb7cf2e44 100644 --- a/cake/libs/i18n.php +++ b/cake/libs/i18n.php @@ -255,7 +255,7 @@ class I18n extends Object { $plugins = Configure::listObjects('plugin'); if (!empty($plugins)) { - $pluginPaths = Configure::read('pluginPaths'); + $pluginPaths = App::path('plugins'); foreach ($plugins as $plugin) { $plugin = Inflector::underscore($plugin); diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index a3c27b308..0dc2a02df 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -814,7 +814,7 @@ class View extends Object { $defaultPath = $paths[0]; if ($this->plugin) { - $pluginPaths = Configure::read('pluginPaths'); + $pluginPaths = App::path('plugins'); foreach ($paths as $path) { if (strpos($path, $pluginPaths[0]) === 0) { $defaultPath = $path; @@ -890,14 +890,14 @@ class View extends Object { return $this->__paths; } $paths = array(); - $viewPaths = Configure::read('viewPaths'); + $viewPaths = App::path('views'); if ($plugin !== null) { $count = count($viewPaths); for ($i = 0; $i < $count; $i++) { $paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS; } - $pluginPaths = Configure::read('pluginPaths'); + $pluginPaths = App::path('plugins'); $count = count($pluginPaths); for ($i = 0; $i < $count; $i++) { diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php index 3526a7ca2..69ec59752 100644 --- a/cake/tests/cases/basics.test.php +++ b/cake/tests/cases/basics.test.php @@ -41,7 +41,7 @@ class BasicsTest extends CakeTestCase { */ function setUp() { $this->_localePaths = Configure::read('localePaths'); - Configure::write('localePaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale')); + App::path('locales', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale')); $this->_language = Configure::read('Config.language'); } /** @@ -51,7 +51,7 @@ class BasicsTest extends CakeTestCase { * @return void */ function tearDown() { - Configure::write('localePaths', $this->_localePaths); + App::path('locales', $this->_localePaths); Configure::write('Config.language', $this->_language); } /** diff --git a/cake/tests/cases/console/cake.test.php b/cake/tests/cases/console/cake.test.php index 9ec2e57dd..7beeb1e4b 100644 --- a/cake/tests/cases/console/cake.test.php +++ b/cake/tests/cases/console/cake.test.php @@ -123,10 +123,10 @@ class ShellDispatcherTest extends UnitTestCase { * @return void */ function setUp() { - $this->_pluginPaths = Configure::read('pluginPaths'); + $this->_pluginPaths = App::path('plugins'); $this->_shellPaths = Configure::read('shellPaths'); - Configure::write('pluginPaths', array( + App::path('plugins', array( TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS )); Configure::write('shellPaths', array( @@ -141,7 +141,7 @@ class ShellDispatcherTest extends UnitTestCase { * @return void */ function tearDown() { - Configure::write('pluginPaths', $this->_pluginPaths); + App::path('plugins', $this->_pluginPaths); Configure::write('shellPaths', $this->_shellPaths); } /** diff --git a/cake/tests/cases/console/libs/shell.test.php b/cake/tests/cases/console/libs/shell.test.php index bfd15a95b..76bfe3c22 100644 --- a/cake/tests/cases/console/libs/shell.test.php +++ b/cake/tests/cases/console/libs/shell.test.php @@ -124,8 +124,8 @@ class ShellTest extends CakeTestCase { 'pluginPaths' => Configure::read('pluginPaths'), 'viewPaths' => Configure::read('viewPaths'), ); - Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); - Configure::write('modelPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS)); + App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + App::path('models', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS)); $this->Shell->uses = array('TestPlugin.TestPluginPost'); $this->Shell->initialize(); @@ -144,8 +144,8 @@ class ShellTest extends CakeTestCase { $this->assertTrue(isset($this->Shell->AppModel)); $this->assertIsA($this->Shell->AppModel, 'AppModel'); - Configure::write('pluginPaths', $_back['pluginPaths']); - Configure::write('modelPaths', $_back['modelPaths']); + App::path('plugins', $_back['pluginPaths']); + App::path('models', $_back['modelPaths']); } /** * testOut method diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index fd0fff3b9..fdc6491b6 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -509,14 +509,14 @@ class DispatcherTest extends CakeTestCase { $this->_cache = Configure::read('Cache'); Configure::write('Cache.disable', true); - $this->_vendorPaths = Configure::read('vendorPaths'); - $this->_pluginPaths = Configure::read('pluginPaths'); - $this->_viewPaths = Configure::read('viewPaths'); - $this->_controllerPaths = Configure::read('controllerPaths'); + $this->_vendorPaths = App::path('vendors'); + $this->_pluginPaths = App::path('plugins'); + $this->_viewPaths = App::path('views'); + $this->_controllerPaths = App::path('controllers'); $this->_debug = Configure::read('debug'); - Configure::write('controllerPaths', Configure::corePaths('controller')); - Configure::write('viewPaths', Configure::corePaths('view')); + App::path('controllers', Configure::corePaths('controller')); + App::path('views', Configure::corePaths('view')); } /** * tearDown method @@ -532,9 +532,9 @@ class DispatcherTest extends CakeTestCase { Configure::write('App', $this->_app); Configure::write('Cache', $this->_cache); Configure::write('vendorPaths', $this->_vendorPaths); - Configure::write('pluginPaths', $this->_pluginPaths); - Configure::write('viewPaths', $this->_viewPaths); - Configure::write('controllerPaths', $this->_controllerPaths); + App::path('plugins', $this->_pluginPaths); + App::path('views', $this->_viewPaths); + App::path('controllers', $this->_controllerPaths); Configure::write('debug', $this->_debug); } /** @@ -1623,8 +1623,8 @@ class DispatcherTest extends CakeTestCase { **/ function testTestPluginDispatch() { $Dispatcher =& new TestDispatcher(); - $_back = Configure::read('pluginPaths'); - Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + $_back = App::path('plugins'); + App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); $url = '/test_plugin/tests/index'; $result = $Dispatcher->dispatch($url, array('return' => 1)); $this->assertTrue(class_exists('TestsController')); @@ -1632,7 +1632,7 @@ class DispatcherTest extends CakeTestCase { $this->assertTrue(class_exists('OtherComponentComponent')); $this->assertTrue(class_exists('PluginsComponentComponent')); - Configure::write('pluginPaths', $_back); + App::path('plugins', $_back); } /** * testChangingParamsFromBeforeFilter method @@ -1678,7 +1678,7 @@ class DispatcherTest extends CakeTestCase { $Configure = Configure::getInstance(); $Configure->__objects = null; - Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); Configure::write('vendorPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS)); $Dispatcher =& new TestDispatcher(); @@ -1734,7 +1734,7 @@ class DispatcherTest extends CakeTestCase { Router::reload(); Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index')); - Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)); + App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)); $dispatcher =& new Dispatcher(); $dispatcher->base = false; diff --git a/cake/tests/cases/libs/cake_test_case.test.php b/cake/tests/cases/libs/cake_test_case.test.php index 399106bc6..6b8dce1f3 100644 --- a/cake/tests/cases/libs/cake_test_case.test.php +++ b/cake/tests/cases/libs/cake_test_case.test.php @@ -244,10 +244,10 @@ class CakeTestCaseTest extends CakeTestCase { 'model' => Configure::read('modelPaths'), 'plugin' => Configure::read('pluginPaths') ); - Configure::write('controllerPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)); - Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)); - Configure::write('modelPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS)); - Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + App::path('controllers', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)); + App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)); + App::path('models', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS)); + App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); $result = $this->Case->testAction('/tests_apps/index', array('return' => 'view')); $this->assertPattern('/This is the TestsAppsController index view/', $result); @@ -367,10 +367,10 @@ class CakeTestCaseTest extends CakeTestCase { $fixture->drop($db); - Configure::write('modelPaths', $_back['model']); - Configure::write('controllerPaths', $_back['controller']); - Configure::write('viewPaths', $_back['view']); - Configure::write('pluginPaths', $_back['plugin']); + App::path('models', $_back['model']); + App::path('controllers', $_back['controller']); + App::path('views', $_back['view']); + App::path('plugins', $_back['plugin']); } /** * testSkipIf @@ -393,9 +393,9 @@ class CakeTestCaseTest extends CakeTestCase { 'view' => Configure::read('viewPaths'), 'plugin' => Configure::read('pluginPaths') ); - Configure::write('controllerPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)); - Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)); - Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + App::path('controllers', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)); + App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)); + App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); $Dispatcher =& new CakeTestDispatcher(); $Case =& new CakeDispatcherMockTestCase(); @@ -408,9 +408,9 @@ class CakeTestCaseTest extends CakeTestCase { $return = $Dispatcher->dispatch('/tests_apps/index', array('autoRender' => 0, 'return' => 1, 'requested' => 1)); - Configure::write('controllerPaths', $_back['controller']); - Configure::write('viewPaths', $_back['view']); - Configure::write('pluginPaths', $_back['plugin']); + App::path('controllers', $_back['controller']); + App::path('views', $_back['view']); + App::path('plugins', $_back['plugin']); } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/configure.test.php b/cake/tests/cases/libs/configure.test.php index 10eea816a..63fd1e87f 100644 --- a/cake/tests/cases/libs/configure.test.php +++ b/cake/tests/cases/libs/configure.test.php @@ -248,17 +248,6 @@ class ConfigureTest extends CakeTestCase { $result = Configure::version(); $this->assertTrue(version_compare($result, '1.2', '>=')); } -/** - * testBuildPaths method - * - * @access public - * @return void - */ - function testBuildPaths() { - Configure::buildPaths(array()); - $models = Configure::read('modelPaths'); - $this->assertTrue(!empty($models)); - } } /** * AppImportTest class @@ -267,6 +256,17 @@ class ConfigureTest extends CakeTestCase { * @subpackage cake.tests.cases.libs */ class AppImportTest extends UnitTestCase { +/** + * testBuildPaths method + * + * @access public + * @return void + */ + function testBuild() { + App::build(); + $models = App::path('models'); + $this->assertTrue(!empty($models)); + } /** * testClassLoading method * @@ -341,8 +341,8 @@ class AppImportTest extends UnitTestCase { $this->assertFalse($file); } - $_back = Configure::read('pluginPaths'); - Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + $_back = App::path('plugins'); + App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); $result = App::import('Controller', 'TestPlugin.Tests'); $this->assertTrue($result); @@ -353,7 +353,7 @@ class AppImportTest extends UnitTestCase { $this->assertTrue($result); $this->assertTrue(class_exists('OtherHelperHelper')); - Configure::write('pluginPaths', $_back); + App::path('plugins', $_back); } /** * testFileLoading method @@ -483,8 +483,8 @@ class AppImportTest extends UnitTestCase { } */ function testLoadingVendor() { - Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); - Configure::write('vendorPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS)); + App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + App::path('vendors', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS)); ob_start(); $result = App::import('Vendor', 'TestPlugin.TestPluginAsset', array('ext' => 'css')); diff --git a/cake/tests/cases/libs/controller/component.test.php b/cake/tests/cases/libs/controller/component.test.php index cd99ec02c..e893c92a6 100644 --- a/cake/tests/cases/libs/controller/component.test.php +++ b/cake/tests/cases/libs/controller/component.test.php @@ -280,8 +280,8 @@ class ComponentTest extends CakeTestCase { * @return void */ function setUp() { - $this->_pluginPaths = Configure::read('pluginPaths'); - Configure::write('pluginPaths', array( + $this->_pluginPaths = App::path('plugins'); + App::path('plugins', array( TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS )); } @@ -292,7 +292,7 @@ class ComponentTest extends CakeTestCase { * @return void */ function tearDown() { - Configure::write('pluginPaths', $this->_pluginPaths); + App::path('plugins', $this->_pluginPaths); ClassRegistry::flush(); } /** diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 00bf8a9c6..101900096 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -1171,7 +1171,7 @@ class AuthTest extends CakeTestCase { * @return void */ function testAjaxLogin() { - Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)); + App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)); $_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest"; if (!class_exists('dispatcher')) { diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 08f033aac..ba779dc02 100644 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -181,8 +181,8 @@ class EmailComponentTest extends CakeTestCase { $this->Controller->EmailTest->initialize($this->Controller, array()); ClassRegistry::addObject('view', new View($this->Controller)); - $this->_viewPaths = Configure::read('viewPaths'); - Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)); + $this->_viewPaths = App::path('views'); + App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)); } /** @@ -193,7 +193,7 @@ class EmailComponentTest extends CakeTestCase { */ function tearDown() { Configure::write('App.encoding', $this->_appEncoding); - Configure::write('viewPaths', $this->_viewPaths); + App::path('views', $this->_viewPaths); $this->Controller->Session->del('Message'); restore_error_handler(); ClassRegistry::flush(); diff --git a/cake/tests/cases/libs/controller/components/request_handler.test.php b/cake/tests/cases/libs/controller/components/request_handler.test.php index 0af25da9c..68c30bd00 100644 --- a/cake/tests/cases/libs/controller/components/request_handler.test.php +++ b/cake/tests/cases/libs/controller/components/request_handler.test.php @@ -485,9 +485,9 @@ class RequestHandlerComponentTest extends CakeTestCase { function testAjaxRedirectAsRequestAction() { $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $this->_init(); - $_paths = Configure::read('viewPaths'); + $_paths = App::path('views'); $testDir = array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS); - Configure::write('viewPaths', array_merge($testDir, $_paths)); + App::path('views', array_merge($testDir, $_paths)); $this->Controller->RequestHandler = new NoStopRequestHandler($this); $this->Controller->RequestHandler->expectOnce('_stop'); @@ -499,7 +499,7 @@ class RequestHandlerComponentTest extends CakeTestCase { $result = ob_get_clean(); $this->assertPattern('/posts index/', $result, 'RequestAction redirect failed.'); - Configure::write('viewPaths', $_paths); + App::path('views', $_paths); unset($_SERVER['HTTP_X_REQUESTED_WITH']); } /** diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 27ef1da67..4ea98cbc7 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -397,7 +397,7 @@ class ControllerTest extends CakeTestCase { $_back = array( 'pluginPaths' => Configure::read('pluginPaths'), ); - Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); $Controller =& new Controller(); $Controller->uses = array('TestPlugin.TestPluginPost'); @@ -407,7 +407,7 @@ class ControllerTest extends CakeTestCase { $this->assertTrue(isset($Controller->TestPluginPost)); $this->assertTrue(is_a($Controller->TestPluginPost, 'TestPluginPost')); - Configure::write('pluginPaths', $_back['pluginPaths']); + App::path('plugins', $_back['pluginPaths']); unset($Controller); } /** @@ -706,7 +706,7 @@ class ControllerTest extends CakeTestCase { * @return void */ function testRender() { - Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)); + App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)); $Controller =& new Controller(); $Controller->viewPath = 'posts'; diff --git a/cake/tests/cases/libs/controller/pages_controller.test.php b/cake/tests/cases/libs/controller/pages_controller.test.php index 66980e744..fd92a4651 100644 --- a/cake/tests/cases/libs/controller/pages_controller.test.php +++ b/cake/tests/cases/libs/controller/pages_controller.test.php @@ -44,7 +44,7 @@ class PagesControllerTest extends CakeTestCase { * @return void */ function setUp() { - $this->_viewPaths = Configure::read('viewPaths'); + $this->_viewPaths = App::path('views'); } /** * tearDown method @@ -53,7 +53,7 @@ class PagesControllerTest extends CakeTestCase { * @return void */ function tearDown() { - Configure::write('viewPaths', $this->_viewPaths); + App::path('views', $this->_viewPaths); } /** * testDisplay method @@ -66,7 +66,7 @@ class PagesControllerTest extends CakeTestCase { return; } - Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)); + App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)); $Pages =& new PagesController(); $Pages->viewPath = 'posts'; diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index 78dca4ee3..07a4d35b8 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -266,8 +266,8 @@ class ScaffoldViewTest extends CakeTestCase { 'viewPaths' => Configure::read('viewPaths'), 'pluginPaths' => Configure::read('pluginPaths'), ); - Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)); - Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); + App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)); + App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)); $Controller =& new ScaffoldMockController(); $Controller->scaffold = 'admin'; @@ -298,8 +298,8 @@ class ScaffoldViewTest extends CakeTestCase { . DS .'test_plugin' . DS . 'views' . DS . 'tests' . DS . 'scaffold.edit.ctp'; $this->assertEqual($result, $expected); - Configure::write('viewPaths', $_back['viewPaths']); - Configure::write('pluginPaths', $_back['pluginPaths']); + App::path('views', $_back['viewPaths']); + App::path('plugins', $_back['pluginPaths']); Configure::write('Routing.admin', $_admin); } /** @@ -332,11 +332,11 @@ class ScaffoldViewTest extends CakeTestCase { new Scaffold($this->Controller, $params); $result = ob_get_clean(); - $this->assertPattern('#