moving path configuration to App class

This commit is contained in:
gwoo 2009-06-07 15:24:10 -07:00
parent f84ed69780
commit 24d78dd671
28 changed files with 463 additions and 451 deletions

View file

@ -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());
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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('#<h2>Scaffold Mock</h2>#', $result);
$this->assertPattern('#<h2>ScaffoldMock</h2>#', $result);
$this->assertPattern('#<table cellpadding="0" cellspacing="0">#', $result);
//TODO: add testing for table generation
$this->assertPattern('#<a href="/scaffold_users/view/1">1</a>#', $result); //belongsTo links
$this->assertPattern('#<li><a href="/scaffold_mock/add/">New Scaffold Mock</a></li>#', $result);
$this->assertPattern('#<li><a href="/scaffold_mock/add/">New ScaffoldMock</a></li>#', $result);
$this->assertPattern('#<li><a href="/scaffold_users/">List Scaffold Users</a></li>#', $result);
$this->assertPattern('#<li><a href="/scaffold_comments/add/">New Comment</a></li>#', $result);
}
@ -371,12 +371,12 @@ class ScaffoldViewTest extends CakeTestCase {
new Scaffold($this->Controller, $params);
$result = ob_get_clean();
$this->assertPattern('/<h2>View Scaffold Mock<\/h2>/', $result);
$this->assertPattern('/<h2>View ScaffoldMock<\/h2>/', $result);
$this->assertPattern('/<dl>/', $result);
//TODO: add specific tests for fields.
$this->assertPattern('/<a href="\/scaffold_users\/view\/1">1<\/a>/', $result); //belongsTo links
$this->assertPattern('/<li><a href="\/scaffold_mock\/edit\/1">Edit Scaffold Mock<\/a>\s<\/li>/', $result);
$this->assertPattern('/<li><a href="\/scaffold_mock\/delete\/1"[^>]*>Delete Scaffold Mock<\/a>\s*<\/li>/', $result);
$this->assertPattern('/<li><a href="\/scaffold_mock\/edit\/1">Edit ScaffoldMock<\/a>\s<\/li>/', $result);
$this->assertPattern('/<li><a href="\/scaffold_mock\/delete\/1"[^>]*>Delete ScaffoldMock<\/a>\s*<\/li>/', $result);
//check related table
$this->assertPattern('/<div class="related">\s*<h3>Related Scaffold Comments<\/h3>\s*<table cellpadding="0" cellspacing="0">/', $result);
$this->assertPattern('/<li><a href="\/scaffold_comments\/add\/">New Comment<\/a><\/li>/', $result);
@ -459,10 +459,10 @@ class ScaffoldViewTest extends CakeTestCase {
$Scaffold = new Scaffold($this->Controller, $params);
$result = ob_get_clean();
$this->assertPattern('/<h2>Scaffold Mock<\/h2>/', $result);
$this->assertPattern('/<h2>ScaffoldMock<\/h2>/', $result);
$this->assertPattern('/<table cellpadding="0" cellspacing="0">/', $result);
//TODO: add testing for table generation
$this->assertPattern('/<li><a href="\/admin\/scaffold_mock\/add\/">New Scaffold Mock<\/a><\/li>/', $result);
$this->assertPattern('/<li><a href="\/admin\/scaffold_mock\/add\/">New ScaffoldMock<\/a><\/li>/', $result);
Configure::write('Routing.admin', $_backAdmin);
}
@ -580,44 +580,5 @@ class ScaffoldTest extends CakeTestCase {
$result = $Scaffold->getParams();
$this->assertEqual($result['action'], 'admin_edit');
}
/**
* test that the proper names and variable values are set by Scaffold
*
* @return void
**/
function testScaffoldVariableSetting() {
$this->Controller->action = 'admin_edit';
$this->Controller->here = '/admin/scaffold_mock/edit';
$this->Controller->webroot = '/';
$params = array(
'plugin' => null,
'pass' => array(),
'form' => array(),
'named' => array(),
'url' => array('url' =>'admin/scaffold_mock/edit'),
'controller' => 'scaffold_mock',
'action' => 'admin_edit',
'admin' => true,
);
//set router.
Router::setRequestInfo(array($params, array('base' => '/', 'here' => 'admin/scaffold_mock', 'webroot' => '/')));
$this->Controller->params = $params;
$this->Controller->controller = 'scaffold_mock';
$this->Controller->base = '/';
$this->Controller->constructClasses();
$Scaffold =& new TestScaffoldMock($this->Controller, $params);
$result = $this->Controller->viewVars;
$this->assertEqual($result['singularHumanName'], 'Scaffold Mock');
$this->assertEqual($result['pluralHumanName'], 'Scaffold Mock');
$this->assertEqual($result['modelClass'], 'ScaffoldMock');
$this->assertEqual($result['primaryKey'], 'id');
$this->assertEqual($result['displayField'], 'title');
$this->assertEqual($result['singularVar'], 'scaffoldMock');
$this->assertEqual($result['pluralVar'], 'scaffoldMock');
$this->assertEqual($result['scaffoldFields'], array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated'));
}
}
?>

View file

@ -40,7 +40,7 @@ class I18nTest 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'));
}
/**
* tearDown method
@ -49,7 +49,7 @@ class I18nTest extends CakeTestCase {
* @return void
*/
function tearDown() {
Configure::write('localePaths', $this->_localePaths);
App::path('locales', $this->_localePaths);
}
/**
* testDefaultStrings method
@ -2353,8 +2353,8 @@ class I18nTest extends CakeTestCase {
* @return void
*/
function testPluginTranslation() {
$pluginPaths = Configure::read('pluginPaths');
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins'));
$pluginPaths = App::path('plugins');
App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins'));
Configure::write('Config.language', 'po');
$singular = $this->__domainSingular();
@ -2388,7 +2388,7 @@ class I18nTest extends CakeTestCase {
$this->assertTrue(in_array('24 = 0 or > 1 (from plugin)', $plurals));
$this->assertTrue(in_array('25 = 0 or > 1 (from plugin)', $plurals));
Configure::write('pluginPaths', $pluginPaths);
App::path('plugins', $pluginPaths);
}
/**
* testPoMultipleLineTranslation method

View file

@ -424,8 +424,8 @@ class ObjectTest extends CakeTestCase {
$cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Configure::write('modelPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS));
Configure::write('behaviorPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS));
App::path('models', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS));
App::path('behaviors', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS));
$this->assertFalse(class_exists('PersisterOneBehaviorBehavior'));
$this->assertFalse(class_exists('PersisterTwoBehaviorBehavior'));
@ -470,8 +470,8 @@ class ObjectTest extends CakeTestCase {
$this->assertFalse(class_exists('ContainableBehavior'));
Configure::write('modelPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS));
Configure::write('behaviorPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS));
App::path('models', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS));
App::path('behaviors', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS));
$this->assertFalse(class_exists('PersistOneBehaviorBehavior'));
$this->assertFalse(class_exists('PersistTwoBehaviorBehavior'));
@ -617,9 +617,9 @@ class ObjectTest 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));
$result = $this->object->requestAction('/tests_apps/index', array('return'));
$expected = 'This is the TestsAppsController index view';
@ -674,9 +674,9 @@ class ObjectTest extends CakeTestCase {
$result = $this->object->requestAction(array('controller'=>'request_action', 'action'=>'paginate_request_action'), array('pass' => array(5), 'named' => array('param' => 'value')));
$this->assertTrue($result);
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']);
}
/**
* Test that requestAction() is populating $this->params properly

View file

@ -90,8 +90,8 @@ class CacheHelperTest extends CakeTestCase {
* @return void
*/
function startCase() {
$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));
}
/**
* End Case - restore view Paths
@ -100,7 +100,7 @@ class CacheHelperTest extends CakeTestCase {
* @return void
*/
function endCase() {
Configure::write('viewPaths', $this->_viewPaths);
App::path('views', $this->_viewPaths);
}
/**
* tearDown method

View file

@ -143,7 +143,7 @@ class SessionHelperTest extends CakeTestCase {
$result = ob_get_clean();
$this->assertEqual($result, $expected);
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));
$controller = new Controller();
$this->Session->view = new View($controller);

View file

@ -173,8 +173,8 @@ class ThemeViewTest extends CakeTestCase {
$this->Controller->theme = 'test_plugin_theme';
$ThemeView = new TestThemeView($this->Controller);
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
Configure::write('viewPaths', 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));
App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'themed' . DS . 'test_plugin_theme' . DS .'tests' . DS .'index.ctp';
$result = $ThemeView->getViewFileName('index');
@ -200,8 +200,8 @@ class ThemeViewTest extends CakeTestCase {
$ThemeView = new TestThemeView($this->Controller);
$ThemeView->theme = 'test_theme';
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
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('plugins', 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, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS));
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp';
$result = $ThemeView->getViewFileName('home');

View file

@ -236,8 +236,8 @@ class ViewTest extends CakeTestCase {
$this->Controller->action = 'index';
$View = new TestView($this->Controller);
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
Configure::write('viewPaths', 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));
App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS .'tests' . DS .'index.ctp';
$result = $View->getViewFileName('index');
@ -261,8 +261,8 @@ class ViewTest extends CakeTestCase {
$this->Controller->params['pass'] = array('home');
$View = new TestView($this->Controller);
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
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('plugins', 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, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS));
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp';
$result = $View->getViewFileName('home');

View file

@ -744,7 +744,7 @@ class CakeTestCase extends UnitTestCase {
TESTS . 'fixtures',
VENDORS . 'tests' . DS . 'fixtures'
);
$pluginPaths = Configure::read('pluginPaths');
$pluginPaths = App::path('plugins');
foreach ($pluginPaths as $path) {
if (file_exists($path . $pluginName . DS . 'tests' . DS. 'fixtures')) {
$fixturePaths[0] = $path . $pluginName . DS . 'tests' . DS. 'fixtures';

View file

@ -467,8 +467,7 @@ class CodeCoverageManager {
$folderPrefixMap = array(
'behaviors' => 'models',
'components' => 'controllers',
'helpers' => 'views',
'datasources' => 'models'
'helpers' => 'views'
);
foreach ($folderPrefixMap as $dir => $prefix) {
@ -517,7 +516,7 @@ class CodeCoverageManager {
if (!!$manager->pluginTest) {
$path = APP . 'plugins' . DS . $manager->pluginTest . DS . 'tests' . DS . 'groups';
$pluginPaths = Configure::read('pluginPaths');
$pluginPaths = App::path('plugins');
foreach ($pluginPaths as $pluginPath) {
$tmpPath = $pluginPath . $manager->pluginTest . DS . 'tests' . DS. 'groups';
if (file_exists($tmpPath)) {
@ -721,7 +720,7 @@ class CodeCoverageManager {
} elseif (!!$manager->pluginTest) {
$pluginPath = APP . 'plugins' . DS . $manager->pluginTest . DS;
$pluginPaths = Configure::read('pluginPaths');
$pluginPaths = App::path('plugins');
foreach ($pluginPaths as $tmpPath) {
$tmpPath = $tmpPath . $manager->pluginTest . DS;
if (file_exists($tmpPath)) {

View file

@ -335,7 +335,7 @@ class TestManager {
}
} else if (!empty($this->pluginTest)) {
$_pluginBasePath = APP . 'plugins' . DS . $this->pluginTest . DS . 'tests';
$pluginPaths = Configure::read('pluginPaths');
$pluginPaths = App::path('plugins');
foreach ($pluginPaths as $path) {
if (file_exists($path . $this->pluginTest . DS . 'tests')) {
$_pluginBasePath = $path . $this->pluginTest . DS . 'tests';