Skip to content
Browse files

simplified App::path(). Changed App::build() to handle all paths.

tests passing.
  • Loading branch information...
1 parent c364376 commit f9339e3c81978aab45788f38a0a1fa9a48b3bd23 gwoo committed
View
211 cake/libs/configure.php
@@ -461,89 +461,89 @@ class App extends Object {
* @access public
*/
var $types = array(
- 'model' => array('suffix' => '.php', 'extends' => 'AppModel'),
- 'behavior' => array('suffix' => '.php', 'extends' => 'ModelBehavior'),
- 'controller' => array('suffix' => '_controller.php', 'extends' => 'AppController'),
- 'component' => array('suffix' => '.php', 'extends' => null),
- 'view' => array('suffix' => '.php', 'extends' => null),
- 'helper' => array('suffix' => '.php', 'extends' => 'AppHelper'),
- 'plugin' => array('suffix' => '', 'extends' => null),
- 'vendor' => array('suffix' => '', 'extends' => null),
- 'shell' => array('suffix' => '.php', 'extends' => 'Shell'),
- 'class' => array('suffix' => '.php', 'extends' => null),
- 'file' => array('suffix' => '.php', 'extends' => null)
+ 'class' => array('suffix' => '.php', 'extends' => null, 'core' => true),
+ 'file' => array('suffix' => '.php', 'extends' => null, 'core' => true),
+ 'model' => array('suffix' => '.php', 'extends' => 'AppModel', 'core' => false),
+ 'behavior' => array('suffix' => '.php', 'extends' => 'ModelBehavior', 'core' => true),
+ 'controller' => array('suffix' => '_controller.php', 'extends' => 'AppController', 'core' => true),
+ 'component' => array('suffix' => '.php', 'extends' => null, 'core' => true),
+ 'view' => array('suffix' => '.php', 'extends' => null, 'core' => true),
+ 'helper' => array('suffix' => '.php', 'extends' => 'AppHelper', 'core' => true),
+ 'vendor' => array('suffix' => '', 'extends' => null, 'core' => true),
+ 'shell' => array('suffix' => '.php', 'extends' => 'Shell', 'core' => true),
+ 'plugin' => array('suffix' => '', 'extends' => null, 'core' => true)
);
/**
* List of additional path(s) where model files reside.
*
* @var array
- * @access protected
+ * @access public
*/
- var $_models = array();
+ var $models = array();
/**
* List of additional path(s) where behavior files reside.
*
* @var array
- * @access protected
+ * @access public
*/
- var $_behaviors = array();
+ var $behaviors = array();
/**
* List of additional path(s) where controller files reside.
*
* @var array
- * @access protected
+ * @access public
*/
- var $_controllers = array();
+ var $controllers = array();
/**
* List of additional path(s) where component files reside.
*
* @var array
- * @access protected
+ * @access public
*/
- var $_components = array();
+ var $components = array();
/**
* List of additional path(s) where view files reside.
*
* @var array
- * @access protected
+ * @access public
*/
- var $_views = array();
+ var $views = array();
/**
* List of additional path(s) where helper files reside.
*
* @var array
- * @access protected
+ * @access public
*/
- var $_helpers = array();
+ var $helpers = array();
/**
* List of additional path(s) where plugins reside.
*
* @var array
- * @access protected
+ * @access public
*/
- var $_plugins = array();
+ var $plugins = array();
/**
* List of additional path(s) where vendor packages reside.
*
* @var array
- * @access protected
+ * @access public
*/
- var $_vendors = array();
+ var $vendors = array();
/**
* List of additional path(s) where locale files reside.
*
* @var array
- * @access protected
+ * @access public
*/
- var $_locales = array();
+ var $locales = array();
/**
* List of additional path(s) where console shell files reside.
*
* @var array
- * @access protected
+ * @access public
*/
- var $_shells = array();
+ var $shells = array();
/**
* Paths to search for files.
*
@@ -598,79 +598,73 @@ class App extends Object {
*
* Usage
* App::path('models'); will return all paths for models
- * App::path('models', array('/path/to/models')); will set and return all paths for models
- * App::path(array('models' => array('/path/to/models')); will set and return all paths for models
- *
*
* @param string $type type of path
* @return string array
* @access public
*/
- function path($type, $value = array()) {
+ function path($type) {
$_this =& App::getInstance();
- if (empty($value)) {
- if (is_array($type)) {
- foreach ($type as $object => $value) {
- $_this->{"_{$type}"} = (array)$value;
- }
- return $value;
- }
- if (!isset($_this->{"_{$type}"})) {
- return array();
- }
- return $_this->{"_{$type}"};
+ if (!isset($_this->{$type})) {
+ return array();
}
- return $_this->{"_{$type}"} = (array)$value;
+ return $_this->{$type};
}
/**
* 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
+ * @param boolean $reset true will set paths, false merges paths [default] false
* @return void
* @access public
*/
- function build($paths = array()) {
+ function build($paths = array(), $reset = false) {
$_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()
+ $defaults = array(
+ 'models' => array(MODELS),
+ 'behaviors' => array(BEHAVIORS),
+ 'datasources' => array(MODELS . 'datasources'),
+ 'controllers' => array(CONTROLLERS),
+ 'components' => array(COMPONENTS),
+ 'views' => array(VIEWS),
+ 'helpers' => array(HELPERS),
+ 'locales' => array(APP . 'locale' . DS),
+ 'shells' => array(APP . 'vendors' . DS . 'shells', VENDORS . 'shells'),
+ 'vendors' => array(APP . 'vendors' . DS, VENDORS),
+ 'plugins' => array(APP . 'plugins' . DS),
);
- foreach ($basePaths as $type => $default) {
- $pathsVar = "_{$type}s";
+ if ($reset == true) {
+ foreach ($paths as $type => $new) {
+ $_this->{$type} = (array)$new;
+ }
+ return $paths;
+ }
+
+ $core = $_this->core();
+ $app = array('models' => true, 'controllers' => true, 'helpers' => true);
+
+ foreach ($defaults as $type => $default) {
$merge = array();
- if (isset($core[$type])) {
- $merge = $core[$type];
+ if (isset($app[$type])) {
+ $merge = array(APP);
}
- if ($type === 'model' || $type === 'controller' || $type === 'helper') {
- $merge = array_merge(array(APP), $merge);
+ if (isset($core[$type])) {
+ $merge = array_merge($merge, (array)$core[$type]);
}
- if (!is_array($default)) {
- $default = array($default);
- }
- $_this->{$pathsVar} = $default;
+ $_this->{$type} = $default;
- if (isset($paths[$pathsVar]) && !empty($paths[$pathsVar])) {
+ if (!empty($paths[$type])) {
$path = array_flip(array_flip((array_merge(
- $_this->{$pathsVar}, (array)$paths[$pathsVar], $merge
+ $_this->{$type}, (array)$paths[$type], $merge
))));
- $_this->{$pathsVar} = array_values($path);
+ $_this->{$type} = array_values($path);
} else {
- $path = array_flip(array_flip((array_merge($_this->{$pathsVar}, $merge))));
- $_this->{$pathsVar} = array_values($path);
+ $path = array_flip(array_flip((array_merge($_this->{$type}, $merge))));
+ $_this->{$type} = array_values($path);
}
}
}
@@ -705,16 +699,16 @@ function core($type = null) {
$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;
+ $paths['libs'][] = $libs;
+ $paths['models'][] = $libs . 'model' . DS;
+ $paths['behaviors'][] = $libs . 'model' . DS . 'behaviors' . DS;
+ $paths['controllers'][] = $libs . 'controller' . DS;
+ $paths['components'][] = $libs . 'controller' . DS . 'components' . DS;
+ $paths['views'][] = $libs . 'view' . DS;
+ $paths['helpers'][] = $libs . 'view' . DS . 'helpers' . DS;
+ $paths['vendors'][] = $path . DS . 'vendors' . DS;
+ $paths['shells'][] = $cake . 'console' . DS . 'libs' . DS;
break;
}
}
@@ -759,7 +753,7 @@ function objects($type, $path = null, $cache = true) {
$objects = array();
if (empty($path)) {
- $path = $_this->{"_{$type}s"};
+ $path = $_this->{"{$type}s"};
if (isset($types[$type]['core']) && $types[$type]['core'] === false) {
array_pop($path);
}
@@ -806,6 +800,7 @@ function objects($type, $path = null, $cache = true) {
* @access public
*/
function import($type = null, $name = null, $parent = true, $search = array(), $file = null, $return = false) {
+ $_this =& App::getInstance();
$plugin = $directory = null;
if (is_array($type)) {
@@ -854,12 +849,13 @@ function import($type = null, $name = null, $parent = true, $search = array(), $
if ($name != null && strpos($name, '.') !== false) {
list($plugin, $name) = explode('.', $name);
+ $plugin = Inflector::camelize($plugin);
}
- $_this =& App::getInstance();
+
$_this->return = $return;
if (isset($ext)) {
- $file = Inflector::underscore($name) . ".$ext";
+ $file = Inflector::underscore($name) . ".{$ext}";
}
$ext = $_this->__settings($type, $plugin, $parent);
@@ -895,7 +891,6 @@ function import($type = null, $name = null, $parent = true, $search = array(), $
foreach ($paths as $key => $value) {
$_this->search[$key] = $value . $ext['path'];
}
- $plugin = Inflector::camelize($plugin);
}
}
@@ -1012,12 +1007,11 @@ function __load($file) {
* @param string $file full path to file
* @param string $name unique name for this map
* @param string $type type object being mapped
- * @param string $plugin if object is from a plugin, the name of the plugin
+ * @param string $plugin camelized if object is from a plugin, the name of the plugin
* @access private
*/
function __map($file, $name, $type, $plugin) {
if ($plugin) {
- $plugin = Inflector::camelize($plugin);
$this->__map['Plugin'][$plugin][$type][$name] = $file;
} else {
$this->__map[$type][$name] = $file;
@@ -1028,14 +1022,12 @@ function __map($file, $name, $type, $plugin) {
*
* @param string $name unique name
* @param string $type type object
- * @param string $plugin if object is from a plugin, the name of the plugin
+ * @param string $plugin camelized if object is from a plugin, the name of the plugin
* @return mixed, file path if found, false otherwise
* @access private
*/
function __mapped($name, $type, $plugin) {
if ($plugin) {
- $plugin = Inflector::camelize($plugin);
-
if (isset($this->__map['Plugin'][$plugin][$type]) && isset($this->__map['Plugin'][$plugin][$type][$name])) {
return $this->__map['Plugin'][$plugin][$type][$name];
}
@@ -1064,7 +1056,7 @@ function __overload($type, $name) {
* Returns a prefix or suffix needed for loading files.
*
* @param string $type type of object
- * @param string $plugin name of plugin
+ * @param string $plugin camelized name of plugin
* @param boolean $parent false will not attempt to load parent
* @return array
* @access private
@@ -1075,8 +1067,7 @@ function __settings($type, $plugin, $parent) {
}
if ($plugin) {
- $plugin = Inflector::underscore($plugin);
- $name = Inflector::camelize($plugin);
+ $pluginPath = Inflector::underscore($plugin);
}
$path = null;
$load = strtolower($type);
@@ -1084,42 +1075,42 @@ function __settings($type, $plugin, $parent) {
switch ($load) {
case 'model':
if (!class_exists('Model')) {
- App::import('Core', 'Model', false, App::core('model'));
+ App::import('Core', 'Model', false, App::core('models'));
}
if (!class_exists('AppModel')) {
App::import($type, 'AppModel', false, App::path('models'));
}
if ($plugin) {
- if (!class_exists($name . 'AppModel')) {
- App::import($type, $plugin . '.' . $name . 'AppModel', false, array(), $plugin . DS . $plugin . '_app_model.php');
+ if (!class_exists($plugin . 'AppModel')) {
+ App::import($type, $plugin . '.' . $plugin . 'AppModel', false, array(), $pluginPath . DS . $pluginPath . '_app_model.php');
}
- $path = $plugin . DS . 'models' . DS;
+ $path = $pluginPath . DS . 'models' . DS;
}
return array('class' => null, 'suffix' => null, 'path' => $path);
break;
case 'behavior':
if ($plugin) {
- $path = $plugin . DS . 'models' . DS . 'behaviors' . DS;
+ $path = $pluginPath . DS . 'models' . DS . 'behaviors' . DS;
}
return array('class' => $type, 'suffix' => null, 'path' => $path);
break;
case 'controller':
App::import($type, 'AppController', false);
if ($plugin) {
- App::import($type, $plugin . '.' . $name . 'AppController', false, array(), $plugin . DS . $plugin . '_app_controller.php');
- $path = $plugin . DS . 'controllers' . DS;
+ App::import($type, $plugin . '.' . $plugin . 'AppController', false, array(), $pluginPath . DS . $pluginPath . '_app_controller.php');
+ $path = $pluginPath . DS . 'controllers' . DS;
}
return array('class' => $type, 'suffix' => $type, 'path' => $path);
break;
case 'component':
if ($plugin) {
- $path = $plugin . DS . 'controllers' . DS . 'components' . DS;
+ $path = $pluginPath . DS . 'controllers' . DS . 'components' . DS;
}
return array('class' => $type, 'suffix' => null, 'path' => $path);
break;
case 'view':
if ($plugin) {
- $path = $plugin . DS . 'views' . DS;
+ $path = $pluginPath . DS . 'views' . DS;
}
return array('class' => $type, 'suffix' => null, 'path' => $path);
break;
@@ -1128,13 +1119,13 @@ function __settings($type, $plugin, $parent) {
App::import($type, 'AppHelper', false);
}
if ($plugin) {
- $path = $plugin . DS . 'views' . DS . 'helpers' . DS;
+ $path = $pluginPath . DS . 'views' . DS . 'helpers' . DS;
}
return array('class' => $type, 'suffix' => null, 'path' => $path);
break;
case 'vendor':
if ($plugin) {
- $path = $plugin . DS . 'vendors' . DS;
+ $path = $pluginPath . DS . 'vendors' . DS;
}
return array('class' => null, 'suffix' => null, 'path' => $path);
break;
@@ -1166,7 +1157,6 @@ function __paths($type) {
}
return $paths;
}
-
if ($paths = App::path($type .'s')) {
return $paths;
}
@@ -1189,13 +1179,12 @@ function __paths($type) {
*
* @param string $name name of object
* @param string $type type of object
- * @param string $plugin name of plugin
+ * @param string $plugin camelized name of plugin
* @return void
* @access private
*/
function __remove($name, $type, $plugin) {
if ($plugin) {
- $plugin = Inflector::camelize($plugin);
unset($this->__map['Plugin'][$plugin][$type][$name]);
} else {
unset($this->__map[$type][$name]);
View
7 cake/tests/cases/basics.test.php
@@ -40,8 +40,9 @@ class BasicsTest extends CakeTestCase {
* @return void
*/
function setUp() {
- $this->_localePaths = App::path('locales');;
- App::path('locales', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale'));
+ App::build(array(
+ 'locales' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale')
+ ));
$this->_language = Configure::read('Config.language');
}
/**
@@ -51,7 +52,7 @@ function setUp() {
* @return void
*/
function tearDown() {
- App::path('locales', $this->_localePaths);
+ App::build();
Configure::write('Config.language', $this->_language);
}
/**
View
23 cake/tests/cases/console/cake.test.php
@@ -123,16 +123,15 @@ class ShellDispatcherTest extends UnitTestCase {
* @return void
*/
function setUp() {
- $this->_pluginPaths = App::path('plugins');
- $this->_shellPaths = App::path('shells');
-
- App::path('plugins', array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
- ));
- Configure::write('shellPaths', array(
- CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS,
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS
- ));
+ App::build(array(
+ 'plugins' => array(
+ TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
+ ),
+ 'shells' => array(
+ CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS,
+ TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS
+ )
+ ), true);
}
/**
* tearDown method
@@ -141,8 +140,7 @@ function setUp() {
* @return void
*/
function tearDown() {
- App::path('plugins', $this->_pluginPaths);
- Configure::write('shellPaths', $this->_shellPaths);
+ App::build();
}
/**
* testParseParams method
@@ -407,6 +405,7 @@ function testBuildPaths() {
$Dispatcher =& new TestShellDispatcher();
$result = $Dispatcher->shellPaths;
+
$expected = array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'vendors' . DS . 'shells' . DS,
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS . 'vendors' . DS . 'shells' . DS,
View
15 cake/tests/cases/console/libs/shell.test.php
@@ -119,13 +119,11 @@ function testConstruct() {
* @access public
*/
function testInitialize() {
- $_back = array(
- 'modelPaths' => App::path('models'),
- 'pluginPaths' => App::path('plugins'),
- 'viewPaths' => App::path('views'),
- );
- 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));
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS)
+ ), true);
+
$this->Shell->uses = array('TestPlugin.TestPluginPost');
$this->Shell->initialize();
@@ -144,8 +142,7 @@ function testInitialize() {
$this->assertTrue(isset($this->Shell->AppModel));
$this->assertIsA($this->Shell->AppModel, 'AppModel');
- App::path('plugins', $_back['pluginPaths']);
- App::path('models', $_back['modelPaths']);
+ App::build();
}
/**
* testOut method
View
29 cake/tests/cases/dispatcher.test.php
@@ -509,14 +509,9 @@ function startTest() {
$this->_cache = Configure::read('Cache');
Configure::write('Cache.disable', true);
- $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');
- App::path('controllers', Configure::corePaths('controller'));
- App::path('views', Configure::corePaths('view'));
+ App::build(App::core());
}
/**
* tearDown method
@@ -529,12 +524,9 @@ function endTest() {
$_POST = $this->_post;
$_FILES = $this->_files;
$_SERVER = $this->_server;
+ App::build();
Configure::write('App', $this->_app);
Configure::write('Cache', $this->_cache);
- App::path('vendors', $this->_vendorPaths);
- App::path('plugins', $this->_pluginPaths);
- App::path('views', $this->_viewPaths);
- App::path('controllers', $this->_controllerPaths);
Configure::write('debug', $this->_debug);
}
/**
@@ -1623,8 +1615,9 @@ function testPrefixProtection() {
**/
function testTestPluginDispatch() {
$Dispatcher =& new TestDispatcher();
- $_back = App::path('plugins');
- App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
+ App::build(array(
+ '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 +1625,7 @@ function testTestPluginDispatch() {
$this->assertTrue(class_exists('OtherComponentComponent'));
$this->assertTrue(class_exists('PluginsComponentComponent'));
- App::path('plugins', $_back);
+ App::build();
}
/**
* testChangingParamsFromBeforeFilter method
@@ -1678,8 +1671,10 @@ function testStaticAssets() {
$Configure = Configure::getInstance();
$Configure->__objects = null;
- 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));
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS)
+ ));
$Dispatcher =& new TestDispatcher();
@@ -1734,7 +1729,9 @@ function testFullPageCachingDispatch() {
Router::reload();
Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index'));
- App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
+ App::build(array(
+ 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
+ ), true);
$dispatcher =& new Dispatcher();
$dispatcher->base = false;
View
49 cake/tests/cases/libs/cake_test_case.test.php
@@ -94,6 +94,15 @@ function tearDown() {
unset($this->Reporter);
}
/**
+ * endTest
+ *
+ * @access public
+ * @return void
+ */
+ function endTest() {
+ App::build();
+ }
+/**
* testAssertGoodTags
*
* @access public
@@ -238,16 +247,12 @@ function testGetTests() {
* @return void
**/
function testTestAction() {
- $_back = array(
- 'controller' => App::path('controllers'),
- 'view' => App::path('views'),
- 'model' => App::path('models'),
- 'plugin' => App::path('plugins')
- );
- 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));
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
+ 'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)
+ ), true);
$result = $this->Case->testAction('/tests_apps/index', array('return' => 'view'));
$this->assertPattern('/This is the TestsAppsController index view/', $result);
@@ -365,12 +370,6 @@ function testTestAction() {
$db =& ConnectionManager::getDataSource('test_suite');
$db->config['prefix'] = $_backPrefix;
$fixture->drop($db);
-
-
- App::path('models', $_back['model']);
- App::path('controllers', $_back['controller']);
- App::path('views', $_back['view']);
- App::path('plugins', $_back['plugin']);
}
/**
* testSkipIf
@@ -388,14 +387,12 @@ function testSkipIf() {
* @return void
*/
function testTestDispatcher() {
- $_back = array(
- 'controller' => App::path('controllers'),
- 'view' => App::path('views'),
- 'plugin' => App::path('plugins')
- );
- 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));
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
+ 'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)
+ ), true);
$Dispatcher =& new CakeTestDispatcher();
$Case =& new CakeDispatcherMockTestCase();
@@ -407,10 +404,6 @@ function testTestDispatcher() {
$this->assertTrue(isset($Dispatcher->testCase));
$return = $Dispatcher->dispatch('/tests_apps/index', array('autoRender' => 0, 'return' => 1, 'requested' => 1));
-
- App::path('controllers', $_back['controller']);
- App::path('views', $_back['view']);
- App::path('plugins', $_back['plugin']);
}
}
?>
View
2 cake/tests/cases/libs/code_coverage_manager.test.php
@@ -116,7 +116,7 @@ function testGetTestObjectFileNameFromTestCaseFile() {
$expected = $manager->__testObjectFileFromCaseFile('models/some_file.test.php', true);
$this->assertIdentical(APP.'models'.DS.'some_file.php', $expected);
- $expected = $manager->__testObjectFileFromCaseFile('datasources/some_file.test.php', true);
+ $expected = $manager->__testObjectFileFromCaseFile('models/datasources/some_file.test.php', true);
$this->assertIdentical(APP.'models'.DS.'datasources'.DS.'some_file.php', $expected);
$expected = $manager->__testObjectFileFromCaseFile('controllers/some_file.test.php', true);
View
104 cake/tests/cases/libs/configure.test.php
@@ -40,11 +40,20 @@ class ConfigureTest extends CakeTestCase {
*/
function setUp() {
$this->_cacheDisable = Configure::read('Cache.disable');
- Configure::write('Cache.disable', true);
-
$this->_debug = Configure::read('debug');
+
+ Configure::write('Cache.disable', true);
}
/**
+ * endTest
+ *
+ * @access public
+ * @return void
+ */
+ function endTest() {
+ App::build();
+ }
+/**
* tearDown method
*
* @access public
@@ -213,26 +222,81 @@ function testVersion() {
*/
class AppImportTest extends UnitTestCase {
/**
- * testBuildPaths method
+ * testBuild method
*
* @access public
* @return void
*/
function testBuild() {
- App::build();
- $models = App::path('models');
- $this->assertTrue(!empty($models));
+ $old = App::path('models');
+ $expected = array(
+ APP . 'models' . DS,
+ APP,
+ ROOT . DS . LIBS . 'model' . DS
+ );
+ $this->assertEqual($expected, $old);
+
+ App::build(array('models' => array('/path/to/models/')));
+
+ $new = App::path('models');
+
+ $expected = array(
+ APP . 'models' . DS,
+ '/path/to/models/',
+ APP,
+ ROOT . DS . LIBS . 'model' . DS
+ );
+ $this->assertEqual($expected, $new);
+
+ App::build(); //reset defaults
+ $defaults = App::path('models');
+ $this->assertEqual($old, $defaults);
+ }
+/**
+ * testBuildWithReset method
+ *
+ * @access public
+ * @return void
+ */
+ function testBuildWithReset() {
+ $old = App::path('models');
+ $expected = array(
+ APP . 'models' . DS,
+ APP,
+ ROOT . DS . LIBS . 'model' . DS
+ );
+ $this->assertEqual($expected, $old);
+
+ App::build(array('models' => array('/path/to/models/')), true);
+
+ $new = App::path('models');
+
+ $expected = array(
+ '/path/to/models/'
+ );
+ $this->assertEqual($expected, $new);
+
+ App::build(); //reset defaults
+ $defaults = App::path('models');
+ $this->assertEqual($old, $defaults);
}
/**
- * testBuildPaths method
+ * testCore method
*
* @access public
* @return void
*/
function testCore() {
- $model = App::core('model');
- $this->assertTrue(!empty($models));
- }
+ $model = App::core('models');
+ $this->assertEqual(array(ROOT . DS . LIBS . 'model' . DS), $model);
+
+ $view = App::core('views');
+ $this->assertEqual(array(ROOT . DS . LIBS . 'view' . DS), $view);
+
+ $controller = App::core('controllers');
+ $this->assertEqual(array(ROOT . DS . LIBS . 'controller' . DS), $controller);
+
+ }
/**
* testListObjects method
*
@@ -261,8 +325,7 @@ function testListObjects() {
$this->assertTrue(in_array('Html', $result));
$result = App::objects('model');
- $notExpected = array('AppModel', 'Behavior', 'ConnectionManager', 'DbAcl', 'Model', 'Schema');
-
+ $notExpected = array('AppModel', 'ModelBehavior', 'ConnectionManager', 'DbAcl', 'Model', 'CakeSchema');
foreach ($notExpected as $class) {
$this->assertFalse(in_array($class, $result));
}
@@ -276,7 +339,7 @@ function testListObjects() {
$result = App::objects('NonExistingType');
$this->assertFalse($result);
- }
+ }
/**
* testClassLoading method
*
@@ -351,8 +414,9 @@ function testClassLoading() {
$this->assertFalse($file);
}
- $_back = App::path('plugins');
- App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ ));
$result = App::import('Controller', 'TestPlugin.Tests');
$this->assertTrue($result);
@@ -363,7 +427,7 @@ function testClassLoading() {
$this->assertTrue($result);
$this->assertTrue(class_exists('OtherHelperHelper'));
- App::path('plugins', $_back);
+ App::build();
}
/**
* testFileLoading method
@@ -493,9 +557,11 @@ function testMultipleLoadingByType() {
}
*/
function testLoadingVendor() {
- 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));
-
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
+ ), true);
+
ob_start();
$result = App::import('Vendor', 'TestPlugin.TestPluginAsset', array('ext' => 'css'));
$text = ob_get_clean();
View
6 cake/tests/cases/libs/controller/component.test.php
@@ -281,8 +281,8 @@ class ComponentTest extends CakeTestCase {
*/
function setUp() {
$this->_pluginPaths = App::path('plugins');
- App::path('plugins', array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
}
/**
@@ -292,7 +292,7 @@ function setUp() {
* @return void
*/
function tearDown() {
- App::path('plugins', $this->_pluginPaths);
+ App::build();
ClassRegistry::flush();
}
/**
View
2 cake/tests/cases/libs/controller/components/auth.test.php
@@ -1171,7 +1171,7 @@ function testAdminRoute() {
* @return void
*/
function testAjaxLogin() {
- App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
+ App::build(array('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
8 cake/tests/cases/libs/controller/components/email.test.php
@@ -181,9 +181,9 @@ function setUp() {
$this->Controller->EmailTest->initialize($this->Controller, array());
ClassRegistry::addObject('view', new View($this->Controller));
- $this->_viewPaths = App::path('views');
- App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
-
+ App::build(array(
+ 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ ));
}
/**
* tearDown method
@@ -193,7 +193,7 @@ function setUp() {
*/
function tearDown() {
Configure::write('App.encoding', $this->_appEncoding);
- App::path('views', $this->_viewPaths);
+ App::build();
$this->Controller->Session->del('Message');
restore_error_handler();
ClassRegistry::flush();
View
6 cake/tests/cases/libs/controller/components/request_handler.test.php
@@ -144,6 +144,7 @@ function tearDown() {
if (!headers_sent()) {
header('Content-type: text/html'); //reset content type.
}
+ App::build();
}
/**
* testInitializeCallback method
@@ -485,9 +486,7 @@ function testClientProperties() {
function testAjaxRedirectAsRequestAction() {
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$this->_init();
- $_paths = App::path('views');
- $testDir = array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS);
- App::path('views', array_merge($testDir, $_paths));
+ App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)));
$this->Controller->RequestHandler = new NoStopRequestHandler($this);
$this->Controller->RequestHandler->expectOnce('_stop');
@@ -499,7 +498,6 @@ function testAjaxRedirectAsRequestAction() {
$result = ob_get_clean();
$this->assertPattern('/posts index/', $result, 'RequestAction redirect failed.');
- App::path('views', $_paths);
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
}
/**
View
17 cake/tests/cases/libs/controller/controller.test.php
@@ -369,6 +369,15 @@ class ControllerTest extends CakeTestCase {
*/
var $fixtures = array('core.post', 'core.comment', 'core.name');
/**
+ * endTest
+ *
+ * @access public
+ * @return void
+ */
+ function endTest() {
+ App::build();
+ }
+/**
* testConstructClasses method
*
* @access public
@@ -394,10 +403,7 @@ function testConstructClasses() {
unset($Controller);
- $_back = array(
- 'pluginPaths' => App::path('plugins'),
- );
- App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
+ App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)));
$Controller =& new Controller();
$Controller->uses = array('TestPlugin.TestPluginPost');
@@ -407,7 +413,6 @@ function testConstructClasses() {
$this->assertTrue(isset($Controller->TestPluginPost));
$this->assertTrue(is_a($Controller->TestPluginPost, 'TestPluginPost'));
- App::path('plugins', $_back['pluginPaths']);
unset($Controller);
}
/**
@@ -706,7 +711,7 @@ function testControllerSet() {
* @return void
*/
function testRender() {
- 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));
+ App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)));
$Controller =& new Controller();
$Controller->viewPath = 'posts';
View
17 cake/tests/cases/libs/controller/pages_controller.test.php
@@ -38,22 +38,13 @@
*/
class PagesControllerTest extends CakeTestCase {
/**
- * setUp method
+ * endTest method
*
* @access public
* @return void
*/
- function setUp() {
- $this->_viewPaths = App::path('views');
- }
-/**
- * tearDown method
- *
- * @access public
- * @return void
- */
- function tearDown() {
- App::path('views', $this->_viewPaths);
+ function endTest() {
+ App::build();
}
/**
* testDisplay method
@@ -66,7 +57,7 @@ function testDisplay() {
return;
}
- 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));
+ App::build(array('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
37 cake/tests/cases/libs/controller/scaffold.test.php
@@ -215,6 +215,15 @@ function tearDown() {
unset($this->Controller);
}
/**
+ * endTest
+ *
+ * @access public
+ * @return void
+ */
+ function endTest() {
+ App::build();
+ }
+/**
* testGetViewFilename method
*
* @access public
@@ -262,13 +271,11 @@ function testGetViewFilename() {
$expected = 'cake' . DS . 'libs' . DS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp';
$this->assertEqual($result, $expected);
- $_back = array(
- 'viewPaths' => App::path('views'),
- 'pluginPaths' => App::path('plugins'),
- );
- 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));
-
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)
+ ));
+
$Controller =& new ScaffoldMockController();
$Controller->scaffold = 'admin';
$Controller->viewPath = 'posts';
@@ -298,8 +305,6 @@ function testGetViewFilename() {
. DS .'test_plugin' . DS . 'views' . DS . 'tests' . DS . 'scaffold.edit.ctp';
$this->assertEqual($result, $expected);
- App::path('views', $_back['viewPaths']);
- App::path('plugins', $_back['pluginPaths']);
Configure::write('Routing.admin', $_admin);
}
/**
@@ -332,11 +337,11 @@ function testIndexScaffold() {
new Scaffold($this->Controller, $params);
$result = ob_get_clean();
- $this->assertPattern('#<h2>ScaffoldMock</h2>#', $result);
+ $this->assertPattern('#<h2>Scaffold Mock</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 ScaffoldMock</a></li>#', $result);
+ $this->assertPattern('#<li><a href="/scaffold_mock/add/">New Scaffold Mock</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 +376,12 @@ function testViewScaffold() {
new Scaffold($this->Controller, $params);
$result = ob_get_clean();
- $this->assertPattern('/<h2>View ScaffoldMock<\/h2>/', $result);
+ $this->assertPattern('/<h2>View Scaffold Mock<\/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 ScaffoldMock<\/a>\s<\/li>/', $result);
- $this->assertPattern('/<li><a href="\/scaffold_mock\/delete\/1"[^>]*>Delete ScaffoldMock<\/a>\s*<\/li>/', $result);
+ $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);
//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 +464,10 @@ function testAdminIndexScaffold() {
$Scaffold = new Scaffold($this->Controller, $params);
$result = ob_get_clean();
- $this->assertPattern('/<h2>ScaffoldMock<\/h2>/', $result);
+ $this->assertPattern('/<h2>Scaffold Mock<\/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 ScaffoldMock<\/a><\/li>/', $result);
+ $this->assertPattern('/<li><a href="\/admin\/scaffold_mock\/add\/">New Scaffold Mock<\/a><\/li>/', $result);
Configure::write('Routing.admin', $_backAdmin);
}
View
13 cake/tests/cases/libs/i18n.test.php
@@ -40,7 +40,9 @@ class I18nTest extends CakeTestCase {
*/
function setUp() {
$this->_localePaths = App::path('locales');;
- App::path('locales', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale'));
+ App::build(array(
+ 'locales' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale')
+ ));
}
/**
* tearDown method
@@ -49,7 +51,7 @@ function setUp() {
* @return void
*/
function tearDown() {
- App::path('locales', $this->_localePaths);
+ App::build();
}
/**
* testDefaultStrings method
@@ -2353,8 +2355,9 @@ function testNoCoreTranslation () {
* @return void
*/
function testPluginTranslation() {
- $pluginPaths = App::path('plugins');
- App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins'));
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins')
+ ));
Configure::write('Config.language', 'po');
$singular = $this->__domainSingular();
@@ -2388,7 +2391,7 @@ function testPluginTranslation() {
$this->assertTrue(in_array('24 = 0 or > 1 (from plugin)', $plurals));
$this->assertTrue(in_array('25 = 0 or > 1 (from plugin)', $plurals));
- App::path('plugins', $pluginPaths);
+ App::build();
}
/**
* testPoMultipleLineTranslation method
View
39 cake/tests/cases/libs/object.test.php
@@ -322,6 +322,15 @@ function tearDown() {
unset($this->object);
}
/**
+ * endTest
+ *
+ * @access public
+ * @return void
+ */
+ function endTest() {
+ App::build();
+ }
+/**
* testLog method
*
* @access public
@@ -424,8 +433,10 @@ function testPersistWithBehavior() {
$cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
- 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));
+ App::build(array(
+ 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'behaviors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS),
+ ), true);
$this->assertFalse(class_exists('PersisterOneBehaviorBehavior'));
$this->assertFalse(class_exists('PersisterTwoBehaviorBehavior'));
@@ -470,8 +481,10 @@ function testPersistWithBehaviorAndRequestAction() {
$this->assertFalse(class_exists('ContainableBehavior'));
- 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));
+ App::build(array(
+ 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'behaviors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS),
+ ), true);
$this->assertFalse(class_exists('PersistOneBehaviorBehavior'));
$this->assertFalse(class_exists('PersistTwoBehaviorBehavior'));
@@ -612,14 +625,12 @@ function testRequestAction() {
$expected = 12;
$this->assertEqual($result, $expected);
- $_back = array(
- 'controller' => App::path('controllers'),
- 'view' => App::path('views'),
- 'plugin' => App::path('plugins')
- );
- 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));
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
+ 'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)
+ ), true);
$result = $this->object->requestAction('/tests_apps/index', array('return'));
$expected = 'This is the TestsAppsController index view';
@@ -673,10 +684,6 @@ function testRequestAction() {
$result = $this->object->requestAction(array('controller'=>'request_action', 'action'=>'paginate_request_action'), array('pass' => array(5), 'named' => array('param' => 'value')));
$this->assertTrue($result);
-
- App::path('controllers', $_back['controller']);
- App::path('views', $_back['view']);
- App::path('plugins', $_back['plugin']);
}
/**
* Test that requestAction() is populating $this->params properly
View
7 cake/tests/cases/libs/view/helpers/cache.test.php
@@ -90,8 +90,9 @@ function setUp() {
* @return void
*/
function startCase() {
- $this->_viewPaths = App::path('views');
- App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
+ App::build(array(
+ 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ ));
}
/**
* End Case - restore view Paths
@@ -100,7 +101,7 @@ function startCase() {
* @return void
*/
function endCase() {
- App::path('views', $this->_viewPaths);
+ App::build();
}
/**
* tearDown method
View
13 cake/tests/cases/libs/view/helpers/session.test.php
@@ -84,6 +84,15 @@ function tearDown() {
unset($this->Session);
}
/**
+ * endTest
+ *
+ * @access public
+ * @return void
+ */
+ function endTest() {
+ App::build();
+ }
+/**
* testRead method
*
* @access public
@@ -143,7 +152,9 @@ function testFlash() {
$result = ob_get_clean();
$this->assertEqual($result, $expected);
- App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
+ App::build(array(
+ 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ ));
$controller = new Controller();
$this->Session->view = new View($controller);
View
21 cake/tests/cases/libs/view/theme.test.php
@@ -160,6 +160,15 @@ function tearDown() {
unset($this->Controller);
}
/**
+ * endTest
+ *
+ * @access public
+ * @return void
+ */
+ function endTest() {
+ App::build();
+ }
+/**
* testPluginGetTemplate method
*
* @access public
@@ -173,8 +182,10 @@ function testPluginGetTemplate() {
$this->Controller->theme = 'test_plugin_theme';
$ThemeView = new TestThemeView($this->Controller);
- 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));
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ '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 +211,10 @@ function testGetTemplate() {
$ThemeView = new TestThemeView($this->Controller);
$ThemeView->theme = 'test_theme';
- 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));
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ '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 . 'views' . DS .'pages' . DS .'home.ctp';
$result = $ThemeView->getViewFileName('home');
View
27 cake/tests/cases/libs/view/view.test.php
@@ -224,6 +224,27 @@ function tearDown() {
unset($this->Controller);
}
/**
+ * endTest
+ *
+ * @access public
+ * @return void
+ */
+ function startTest() {
+ App::build(array(
+ 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ ));
+ }
+/**
+ * endTest
+ *
+ * @access public
+ * @return void
+ */
+ function endTest() {
+ App::build();
+ }
+/**
* testPluginGetTemplate method
*
* @access public
@@ -236,8 +257,6 @@ function testPluginGetTemplate() {
$this->Controller->action = 'index';
$View = new TestView($this->Controller);
- 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,9 +280,7 @@ function testGetTemplate() {
$this->Controller->params['pass'] = array('home');
$View = new TestView($this->Controller);
- 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');
$this->assertEqual($result, $expected);

0 comments on commit f9339e3

Please sign in to comment.
Something went wrong with that request. Please try again.