diff --git a/app/config/database.php.default b/app/config/database.php.default
index 9fb8e9e98..b7eb4bba2 100644
--- a/app/config/database.php.default
+++ b/app/config/database.php.default
@@ -28,15 +28,15 @@
* You can specify multiple configurations for production, development and testing.
*
* driver => The name of a supported driver; valid options are as follows:
- * mysql - MySQL 4 & 5,
- * sqlite - SQLite (PHP5 only),
- * postgres - PostgreSQL 7 and higher,
- * mssql - Microsoft SQL Server 2000 and higher,
- * oracle - Oracle 8 and higher
+ * Datasabe/Mysql - MySQL 4 & 5,
+ * Datasabe/Sqlite - SQLite (PHP5 only),
+ * Datasabe/Postgres - PostgreSQL 7 and higher,
+ * Datasabe/Mssql - Microsoft SQL Server 2000 and higher,
+ * Datasabe/Oracle - Oracle 8 and higher
*
* You can add custom database drivers (or override existing drivers) by adding the
- * appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php',
- * where 'x' is the name of the database.
+ * appropriate file to app/models/datasources/database. Drivers should be named 'MyDriver.php',
+ *
*
* persistent => true / false
* Determines whether or not the database should use a persistent connection
@@ -59,7 +59,7 @@
class DATABASE_CONFIG {
public $default = array(
- 'driver' => 'mysql',
+ 'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
@@ -69,7 +69,7 @@ class DATABASE_CONFIG {
);
public $test = array(
- 'driver' => 'mysql',
+ 'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
diff --git a/app/console/cake.php b/app/console/cake.php
index 9200fd36b..ef5e26816 100755
--- a/app/console/cake.php
+++ b/app/console/cake.php
@@ -19,6 +19,6 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-require_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'cake' . DIRECTORY_SEPARATOR . 'console' . DIRECTORY_SEPARATOR . 'shell_dispatcher.php');
+require_once(dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'lib'. DIRECTORY_SEPARATOR . 'Cake' . DIRECTORY_SEPARATOR . 'Console' . DIRECTORY_SEPARATOR . 'ShellDispatcher.php');
return ShellDispatcher::run($argv);
diff --git a/app/console/shells/templates/empty b/app/console/templates/empty
similarity index 100%
rename from app/console/shells/templates/empty
rename to app/console/templates/empty
diff --git a/app/webroot/index.php b/app/webroot/index.php
index f1ff8d197..3c5e71589 100644
--- a/app/webroot/index.php
+++ b/app/webroot/index.php
@@ -49,7 +49,7 @@
*
*/
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
- define('CAKE_CORE_INCLUDE_PATH', ROOT);
+ define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
}
/**
@@ -67,7 +67,7 @@
define('APP_PATH', ROOT . DS . APP_DIR . DS);
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
}
- if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
+ if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) {
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}
@@ -75,6 +75,6 @@
return;
}
- require LIBS . 'dispatcher.php';
+ App::uses('Dispatcher', 'Routing');
$Dispatcher = new Dispatcher();
$Dispatcher->dispatch(new CakeRequest());
diff --git a/app/webroot/test.php b/app/webroot/test.php
index c11aaac99..c7b718ca7 100644
--- a/app/webroot/test.php
+++ b/app/webroot/test.php
@@ -45,11 +45,11 @@ ini_set('display_errors', 1);
define('APP_DIR', basename(dirname(dirname(__FILE__))));
}
/**
- * The absolute path to the "cake" directory, WITHOUT a trailing DS.
+ * The absolute path to the "Cake" directory, WITHOUT a trailing DS.
*
*/
if (!defined('CAKE_CORE_INCLUDE_PATH')) {
- define('CAKE_CORE_INCLUDE_PATH', ROOT);
+ define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib');
}
/**
@@ -67,21 +67,14 @@ if (!defined('CORE_PATH')) {
define('APP_PATH', ROOT . DS . APP_DIR . DS);
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
}
-if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
+if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) {
trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}
-$corePath = App::core('cake');
-if (isset($corePath[0])) {
- define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS);
-} else {
- define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH);
-}
-
if (Configure::read('debug') < 1) {
die(__('Debug setting does not allow access to this url.'));
}
-require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php';
+require_once CAKE_TESTS_LIB . 'CakeTestSuiteDispatcher.php';
CakeTestSuiteDispatcher::run();
diff --git a/cake/bootstrap.php b/cake/bootstrap.php
deleted file mode 100644
index aa30770fc..000000000
--- a/cake/bootstrap.php
+++ /dev/null
@@ -1,39 +0,0 @@
- 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),
- 'lib' => 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
- */
- public static $models = array();
-
-/**
- * List of additional path(s) where behavior files reside.
- *
- * @var array
- */
- public static $behaviors = array();
-
-/**
- * List of additional path(s) where controller files reside.
- *
- * @var array
- */
- public static $controllers = array();
-
-/**
- * List of additional path(s) where component files reside.
- *
- * @var array
- */
- public static $components = array();
-
-/**
- * List of additional path(s) where datasource files reside.
- *
- * @var array
- */
- public static $datasources = array();
-
-/**
- * List of additional path(s) where libs files reside.
- *
- * @var array
- */
- public static $libs = array();
-
-/**
- * List of additional path(s) where view files reside.
- *
- * @var array
- */
- public static $views = array();
-
-/**
- * List of additional path(s) where helper files reside.
- *
- * @var array
- */
- public static $helpers = array();
-
-/**
- * List of additional path(s) where plugins reside.
- *
- * @var array
- */
- public static $plugins = array();
-
-/**
- * List of additional path(s) where vendor packages reside.
- *
- * @var array
- */
- public static $vendors = array();
-
-/**
- * List of additional path(s) where locale files reside.
- *
- * @var array
- */
- public static $locales = array();
-
-/**
- * List of additional path(s) where console shell files reside.
- *
- * @var array
- */
- public static $shells = array();
-
-/**
- * Paths to search for files.
- *
- * @var array
- */
- public static $search = array();
-
-/**
- * Whether or not to return the file that is loaded.
- *
- * @var boolean
- */
- public static $return = false;
-
-/**
- * Determines if $__maps and $__paths cache should be written.
- *
- * @var boolean
- */
- private static $__cache = false;
-
-/**
- * Holds key/value pairs of $type => file path.
- *
- * @var array
- */
- private static $__map = array();
-
-/**
- * Holds paths for deep searching of files.
- *
- * @var array
- */
- private static $__paths = array();
-
-/**
- * Holds loaded files.
- *
- * @var array
- */
- private static $__loaded = array();
-
-/**
- * Holds and key => value array of object types.
- *
- * @var array
- */
- private static $__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
- */
- public static function path($type) {
- if (!isset(self::${$type})) {
- return array();
- }
- return self::${$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
- */
- public static function build($paths = array(), $reset = false) {
- $defaults = array(
- 'models' => array(MODELS),
- 'behaviors' => array(BEHAVIORS),
- 'datasources' => array(MODELS . 'datasources'),
- 'controllers' => array(CONTROLLERS),
- 'components' => array(COMPONENTS),
- 'libs' => array(APPLIBS),
- 'views' => array(VIEWS),
- 'helpers' => array(HELPERS),
- 'locales' => array(APP . 'locale' . DS),
- 'shells' => array(
- APP . 'console' . DS . 'shells' . DS,
- APP . 'vendors' . DS . 'shells' . DS,
- VENDORS . 'shells' . DS
- ),
- 'vendors' => array(APP . 'vendors' . DS, VENDORS),
- 'plugins' => array(APP . 'plugins' . DS)
- );
-
- if ($reset == true) {
- foreach ($paths as $type => $new) {
- self::${$type} = (array)$new;
- }
- return $paths;
- }
-
- $core = self::core();
- $app = array('models' => true, 'controllers' => true, 'helpers' => true);
-
- foreach ($defaults as $type => $default) {
- $merge = array();
-
- if (isset($app[$type])) {
- $merge = array(APP);
- }
- if (isset($core[$type])) {
- $merge = array_merge($merge, (array)$core[$type]);
- }
-
- if (empty(self::${$type}) || empty($paths)) {
- self::${$type} = $default;
- }
-
- if (!empty($paths[$type])) {
- $path = array_flip(array_flip(array_merge(
- (array)$paths[$type], self::${$type}, $merge
- )));
- } else {
- $path = array_flip(array_flip(array_merge(self::${$type}, $merge)));
- }
- self::${$type} = array_values($path);
- }
- }
-
-/**
- * Get the path that a plugin is on. Searches through the defined plugin paths.
- *
- * @param string $plugin CamelCased/lower_cased plugin name to find the path of.
- * @return string full path to the plugin.
- */
- public static function pluginPath($plugin) {
- $pluginDir = Inflector::underscore($plugin);
- for ($i = 0, $length = count(self::$plugins); $i < $length; $i++) {
- if (is_dir(self::$plugins[$i] . $pluginDir)) {
- return self::$plugins[$i] . $pluginDir . DS ;
- }
- }
- return self::$plugins[0] . $pluginDir . DS;
- }
-
-/**
- * Find the path that a theme is on. Search through the defined theme paths.
- *
- * @param string $theme lower_cased theme name to find the path of.
- * @return string full path to the theme.
- */
- public static function themePath($theme) {
- $themeDir = 'themed' . DS . Inflector::underscore($theme);
- for ($i = 0, $length = count(self::$views); $i < $length; $i++) {
- if (is_dir(self::$views[$i] . $themeDir)) {
- return self::$views[$i] . $themeDir . DS ;
- }
- }
- return self::$views[0] . $themeDir . DS;
- }
-
-/**
- * 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
- */
- public static function core($type = null) {
- static $paths = false;
- if (!$paths) {
- $paths = array();
- $libs = dirname(__FILE__) . DS;
- $cake = dirname($libs) . DS;
- $path = dirname($cake) . DS;
-
- $paths['cake'][] = $cake;
- $paths['libs'][] = $libs;
- $paths['models'][] = $libs . 'model' . DS;
- $paths['datasources'][] = $libs . 'model' . DS . 'datasources' . 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['plugins'][] = $path . 'plugins' . DS;
- $paths['vendors'][] = $path . 'vendors' . DS;
- $paths['shells'][] = $cake . 'console' . DS . 'shells' . DS;
- // Provide BC path to vendors/shells
- $paths['shells'][] = $path . 'vendors' . DS . 'shells' . DS;
- }
- if ($type && isset($paths[$type])) {
- return $paths[$type];
- }
- return $paths;
- }
-
-/**
- * Returns an array of objects of the given type.
- *
- * Example usage:
- *
- * `App::objects('plugin');` returns `array('DebugKit', 'Blog', 'User');`
- *
- * You can also search only within a plugin's objects by using the plugin dot
- * syntax (these objects are not cached):
- *
- * `App::objects('MyPlugin.model');` returns `array('Post', 'Comment');`
- *
- * @param string $type Type of object, i.e. 'model', 'controller', 'helper', or 'plugin'
- * @param mixed $path Optional Scan only the path given. If null, paths for the chosen
- * type will be used.
- * @param boolean $cache Set to false to rescan objects of the chosen type. Defaults to true.
- * @return mixed Either false on incorrect / miss. Or an array of found objects.
- */
- public static function objects($type, $path = null, $cache = true) {
- $objects = array();
- $extension = false;
- list($plugin, $type) = pluginSplit($type);
- $name = $type;
-
- if ($plugin) {
- $path = Inflector::pluralize($type);
- if ($path == 'helpers') {
- $path = 'views' . DS .$path;
- } elseif ($path == 'behaviors') {
- $path = 'models' . DS .$path;
- } elseif ($path == 'components') {
- $path = 'controllers' . DS .$path;
- }
- $path = self::pluginPath($plugin) . $path;
- $cache = false;
- }
-
- if ($type === 'file' && !$path) {
- return false;
- } elseif ($type === 'file') {
- $extension = true;
- $name = $type . str_replace(DS, '', $path);
- }
-
- if (empty(self::$__objects) && $cache === true) {
- self::$__objects = Cache::read('object_map', '_cake_core_');
- }
-
- if (!isset(self::$__objects[$name]) || $cache !== true) {
- $types = self::$types;
-
- if (!isset($types[$type])) {
- return false;
- }
- $objects = array();
-
- if (empty($path)) {
- $path = self::${"{$type}s"};
- if (isset($types[$type]['core']) && $types[$type]['core'] === false) {
- array_pop($path);
- }
- }
- $items = array();
-
- foreach ((array)$path as $dir) {
- if ($dir != APP) {
- $items = self::__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) {
- self::$__cache = true;
- }
- if ($plugin) {
- return $objects;
- }
- self::$__objects[$name] = $objects;
- }
-
- return self::$__objects[$name];
- }
-
-/**
- * Allows you to modify the object listings that App maintains inside of it
- * Useful for testing
- *
- * @param string $type Type of object listing you are changing
- * @param array $values The values $type should be set to.
- * @return void
- */
- public static function setObjects($type, $values) {
- self::$__objects[$type] = $values;
- }
-
-/**
- * Finds classes based on $name or specific file(s) to search. Calling App::import() will
- * not construct any classes contained in the files. It will only find and require() the file.
- *
- * @link http://book.cakephp.org/view/934/Using-App-import
- * @param mixed $type The type of Class if passed as a string, or all params can be passed as
- * an single array to $type,
- * @param string $name Name of the Class or a unique name for the file
- * @param mixed $parent boolean true if Class Parent should be searched, accepts key => value
- * array('parent' => $parent ,'file' => $file, 'search' => $search, 'ext' => '$ext');
- * $ext allows setting the extension of the file name
- * based on Inflector::underscore($name) . ".$ext";
- * @param array $search paths to search for files, array('path 1', 'path 2', 'path 3');
- * @param string $file full name of the file to search for including extension
- * @param boolean $return, return the loaded file, the file must have a return
- * statement in it to work: return $variable;
- * @return boolean true if Class is already in memory or if file is found and loaded, false if not
- */
- public static function import($type = null, $name = null, $parent = true, $search = array(), $file = null, $return = false) {
- $plugin = $directory = null;
-
- if (is_array($type)) {
- extract($type, EXTR_OVERWRITE);
- }
-
- if (is_array($parent)) {
- extract($parent, EXTR_OVERWRITE);
- }
-
- if ($name === null && $file === null) {
- $name = $type;
- $type = 'Core';
- } elseif ($name === null) {
- $type = 'File';
- }
-
- if (is_array($name)) {
- foreach ($name as $class) {
- $tempType = $type;
- $plugin = null;
-
- if (strpos($class, '.') !== false) {
- $value = explode('.', $class);
- $count = count($value);
-
- if ($count > 2) {
- $tempType = $value[0];
- $plugin = $value[1] . '.';
- $class = $value[2];
- } elseif ($count === 2 && ($type === 'Core' || $type === 'File')) {
- $tempType = $value[0];
- $class = $value[1];
- } else {
- $plugin = $value[0] . '.';
- $class = $value[1];
- }
- }
-
- if (!App::import($tempType, $plugin . $class, $parent)) {
- return false;
- }
- }
- return true;
- }
-
- if ($name != null && strpos($name, '.') !== false) {
- list($plugin, $name) = explode('.', $name);
- $plugin = Inflector::camelize($plugin);
- }
- self::$return = $return;
-
- if (isset($ext)) {
- $file = Inflector::underscore($name) . ".{$ext}";
- }
- $ext = self::__settings($type, $plugin, $parent);
- $className = $name;
- if (strpos($className, '/') !== false) {
- $className = substr($className, strrpos($className, '/') + 1);
- }
- if ($name != null && !class_exists($className . $ext['class'])) {
- if ($load = self::__mapped($name . $ext['class'], $type, $plugin)) {
- if (self::__load($load)) {
- if (self::$return) {
- return include($load);
- }
- return true;
- } else {
- self::__remove($name . $ext['class'], $type, $plugin);
- self::$__cache = true;
- }
- }
- if (!empty($search)) {
- self::$search = $search;
- } elseif ($plugin) {
- self::$search = self::__paths('plugin');
- } else {
- self::$search = self::__paths($type);
- }
- $find = $file;
-
- if ($find === null) {
- $find = Inflector::underscore($name . $ext['suffix']).'.php';
-
- if ($plugin) {
- $paths = self::$search;
- foreach ($paths as $key => $value) {
- self::$search[$key] = $value . $ext['path'];
- }
- }
- }
-
- if (strtolower($type) !== 'vendor' && empty($search) && self::__load($file)) {
- $directory = false;
- } else {
- $file = $find;
- $directory = self::__find($find, true);
- }
-
- if ($directory !== null) {
- self::$__cache = true;
- self::__map($directory . $file, $name . $ext['class'], $type, $plugin);
-
- if (self::$return) {
- return include($directory . $file);
- }
- return true;
- }
- return false;
- }
- return true;
- }
-
-/**
- * Initializes the cache for App, registers a shutdown function.
- *
- * @return void
- */
- public static function init() {
- self::$__map = (array)Cache::read('file_map', '_cake_core_');
- register_shutdown_function(array('App', 'shutdown'));
- }
-
-/**
- * Locates the $file in $__paths, searches recursively.
- *
- * @param string $file full file name
- * @param boolean $recursive search $__paths recursively
- * @return mixed boolean on fail, $file directory path on success
- */
- private static function __find($file, $recursive = true) {
- static $appPath = false;
-
- if (empty(self::$search)) {
- return null;
- } elseif (is_string(self::$search)) {
- self::$search = array(self::$search);
- }
-
- if (empty(self::$__paths)) {
- self::$__paths = Cache::read('dir_map', '_cake_core_');
- }
-
- foreach (self::$search as $path) {
- if ($appPath === false) {
- $appPath = rtrim(APP, DS);
- }
- $path = rtrim($path, DS);
-
- if ($path === $appPath) {
- $recursive = false;
- }
- if ($recursive === false) {
- if (self::__load($path . DS . $file)) {
- return $path . DS;
- }
- continue;
- }
-
- if (!isset(self::$__paths[$path])) {
- if (!class_exists('Folder')) {
- require LIBS . 'folder.php';
- }
- $Folder = new Folder();
- $directories = $Folder->tree($path, array('.svn', '.git', 'CVS', 'tests', 'templates'), 'dir');
- sort($directories);
- self::$__paths[$path] = $directories;
- }
-
- foreach (self::$__paths[$path] as $directory) {
- if (self::__load($directory . DS . $file)) {
- return $directory . DS;
- }
- }
- }
- return null;
- }
-
-/**
- * Attempts to load $file.
- *
- * @param string $file full path to file including file name
- * @return boolean
- * @access private
- */
- private static function __load($file) {
- if (empty($file)) {
- return false;
- }
- if (!self::$return && isset(self::$__loaded[$file])) {
- return true;
- }
- if (file_exists($file)) {
- if (!self::$return) {
- require($file);
- self::$__loaded[$file] = true;
- }
- return true;
- }
- return false;
- }
-
-/**
- * Maps the $name to the $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 camelized if object is from a plugin, the name of the plugin
- * @return void
- * @access private
- */
- private static function __map($file, $name, $type, $plugin) {
- if ($plugin) {
- self::$__map['Plugin'][$plugin][$type][$name] = $file;
- } else {
- self::$__map[$type][$name] = $file;
- }
- }
-
-/**
- * Returns a file's complete path.
- *
- * @param string $name unique name
- * @param string $type type object
- * @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
- */
- private static function __mapped($name, $type, $plugin) {
- if ($plugin) {
- if (isset(self::$__map['Plugin'][$plugin][$type]) && isset(self::$__map['Plugin'][$plugin][$type][$name])) {
- return self::$__map['Plugin'][$plugin][$type][$name];
- }
- return false;
- }
-
- if (isset(self::$__map[$type]) && isset(self::$__map[$type][$name])) {
- return self::$__map[$type][$name];
- }
- return false;
- }
-
-/**
- * Loads parent classes based on $type.
- * Returns a prefix or suffix needed for loading files.
- *
- * @param string $type type of object
- * @param string $plugin camelized name of plugin
- * @param boolean $parent false will not attempt to load parent
- * @return array
- * @access private
- */
- private static function __settings($type, $plugin, $parent) {
- if (!$parent) {
- return array('class' => null, 'suffix' => null, 'path' => null);
- }
-
- if ($plugin) {
- $pluginPath = Inflector::underscore($plugin);
- }
- $path = null;
- $load = strtolower($type);
-
- switch ($load) {
- case 'model':
- if (!class_exists('Model')) {
- require LIBS . 'model' . DS . 'model.php';
- }
- if (!class_exists('AppModel')) {
- App::import($type, 'AppModel', false);
- }
- if ($plugin) {
- if (!class_exists($plugin . 'AppModel')) {
- App::import($type, $plugin . '.' . $plugin . 'AppModel', false, array(), $pluginPath . DS . $pluginPath . '_app_model.php');
- }
- $path = $pluginPath . DS . 'models' . DS;
- }
- return array('class' => null, 'suffix' => null, 'path' => $path);
- break;
- case 'behavior':
- if ($plugin) {
- $path = $pluginPath . DS . 'models' . DS . 'behaviors' . DS;
- }
- return array('class' => $type, 'suffix' => null, 'path' => $path);
- break;
- case 'datasource':
- if ($plugin) {
- $path = $pluginPath . DS . 'models' . DS . 'datasources' . DS;
- }
- return array('class' => $type, 'suffix' => null, 'path' => $path);
- case 'controller':
- App::import($type, 'AppController', false);
- if ($plugin) {
- 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':
- App::import('Core', 'Component', false);
- if ($plugin) {
- $path = $pluginPath . DS . 'controllers' . DS . 'components' . DS;
- }
- return array('class' => $type, 'suffix' => null, 'path' => $path);
- break;
- case 'lib':
- if ($plugin) {
- $path = $pluginPath . DS . 'libs' . DS;
- }
- return array('class' => null, 'suffix' => null, 'path' => $path);
- break;
- case 'view':
- App::import('View', 'View', false);
- if ($plugin) {
- $path = $pluginPath . DS . 'views' . DS;
- }
- return array('class' => $type, 'suffix' => null, 'path' => $path);
- break;
- case 'helper':
- if (!class_exists('AppHelper')) {
- App::import($type, 'AppHelper', false);
- }
- if ($plugin) {
- $path = $pluginPath . DS . 'views' . DS . 'helpers' . DS;
- }
- return array('class' => $type, 'suffix' => null, 'path' => $path);
- break;
- case 'shell':
- if (!class_exists('Shell')) {
- App::import($type, 'Shell', false);
- }
- if (!class_exists('AppShell')) {
- App::import($type, 'AppShell', false);
- }
- if ($plugin) {
- $path = $pluginPath . DS . 'console' . DS . 'shells' . DS;
- }
- return array('class' => $type, 'suffix' => null, 'path' => $path);
- break;
- case 'vendor':
- if ($plugin) {
- $path = $pluginPath . DS . 'vendors' . DS;
- }
- return array('class' => null, 'suffix' => null, 'path' => $path);
- break;
- default:
- $type = $suffix = $path = null;
- break;
- }
- return array('class' => null, 'suffix' => null, 'path' => null);
- }
-
-/**
- * Returns default search paths.
- *
- * @param string $type type of object to be searched
- * @return array list of paths
- */
- private static function __paths($type) {
- $type = strtolower($type);
- $paths = array();
-
- if ($type === 'core') {
- return App::core('libs');
- }
- if (isset(self::${$type . 's'})) {
- return self::${$type . 's'};
- }
- return $paths;
- }
-
-/**
- * Removes file location from map if the file has been deleted.
- *
- * @param string $name name of object
- * @param string $type type of object
- * @param string $plugin camelized name of plugin
- * @return void
- */
- private static function __remove($name, $type, $plugin) {
- if ($plugin) {
- unset(self::$__map['Plugin'][$plugin][$type][$name]);
- } else {
- unset(self::$__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
- */
- private static 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.
- *
- * Writes cache file if changes have been made to the $__map or $__paths
- *
- * @return void
- */
- public static function shutdown() {
- if (self::$__cache) {
- $core = App::core('cake');
- unset(self::$__paths[rtrim($core[0], DS)]);
- Cache::write('dir_map', array_filter(self::$__paths), '_cake_core_');
- Cache::write('file_map', array_filter(self::$__map), '_cake_core_');
- Cache::write('object_map', self::$__objects, '_cake_core_');
- }
- }
-}
diff --git a/cake/tests/cases/libs/app.test.php b/cake/tests/cases/libs/app.test.php
deleted file mode 100644
index 701f32f60..000000000
--- a/cake/tests/cases/libs/app.test.php
+++ /dev/null
@@ -1,568 +0,0 @@
-assertEqual($expected, $old);
-
- App::build(array('models' => array('/path/to/models/')));
-
- $new = App::path('models');
-
- $expected = array(
- '/path/to/models/',
- APP . 'models' . DS,
- APP,
- 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,
- 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);
- }
-
-/**
- * testCore method
- *
- * @access public
- * @return void
- */
- function testCore() {
- $model = App::core('models');
- $this->assertEqual(array(LIBS . 'model' . DS), $model);
-
- $view = App::core('views');
- $this->assertEqual(array(LIBS . 'view' . DS), $view);
-
- $controller = App::core('controllers');
- $this->assertEqual(array(LIBS . 'controller' . DS), $controller);
-
- }
-
-/**
- * testListObjects method
- *
- * @access public
- * @return void
- */
- function testListObjects() {
- $result = App::objects('class', TEST_CAKE_CORE_INCLUDE_PATH . 'libs', false);
- $this->assertTrue(in_array('Xml', $result));
- $this->assertTrue(in_array('Cache', $result));
- $this->assertTrue(in_array('HttpSocket', $result));
-
- $result = App::objects('behavior', null, false);
- $this->assertTrue(in_array('Tree', $result));
-
- $result = App::objects('controller', null, false);
- $this->assertTrue(in_array('Pages', $result));
-
- $result = App::objects('component', null, false);
- $this->assertTrue(in_array('Auth', $result));
-
- $result = App::objects('view', null, false);
- $this->assertTrue(in_array('Media', $result));
-
- $result = App::objects('helper', null, false);
- $this->assertTrue(in_array('Html', $result));
-
- $result = App::objects('model', null, false);
- $notExpected = array('AppModel', 'ModelBehavior', 'ConnectionManager', 'DbAcl', 'Model', 'CakeSchema');
- foreach ($notExpected as $class) {
- $this->assertFalse(in_array($class, $result));
- }
-
- $result = App::objects('file');
- $this->assertFalse($result);
-
- $result = App::objects('file', 'non_existing_configure');
- $expected = array();
- $this->assertEqual($result, $expected);
-
- $result = App::objects('NonExistingType');
- $this->assertFalse($result);
-
- App::build(array(
- 'plugins' => array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS
- )
- ));
- $result = App::objects('plugin', null, false);
- $this->assertTrue(in_array('Cache', $result));
- $this->assertTrue(in_array('Log', $result));
-
- App::build();
- }
-
-/**
- * Tests listing objects within a plugin
- *
- * @return void
- */
- function testListObjectsInPlugin() {
- App::build(array(
- 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
- ));
-
- $oldCache = App::$models;
- $result = App::objects('TestPlugin.model');
- $this->assertTrue(in_array('TestPluginPost', $result));
- $this->assertEquals($oldCache, App::$models);
-
- $result = App::objects('TestPlugin.behavior');
- $this->assertTrue(in_array('TestPluginPersisterOne', $result));
-
- $result = App::objects('TestPlugin.helper');
- $expected = array('OtherHelper', 'PluggedHelper', 'TestPluginApp');
- $this->assertEquals($result, $expected);
-
- $result = App::objects('TestPlugin.component');
- $this->assertTrue(in_array('OtherComponent', $result));
-
- $result = App::objects('TestPluginTwo.behavior');
- $this->assertEquals($result, array());
-
- $result = App::objects('model', null, false);
- $this->assertTrue(in_array('Comment', $result));
- $this->assertTrue(in_array('Post', $result));
-
- App::build();
- }
-
-/**
- * test that pluginPath can find paths for plugins.
- *
- * @return void
- */
- function testPluginPath() {
- App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
- ));
- $path = App::pluginPath('test_plugin');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
- $this->assertEqual($path, $expected);
-
- $path = App::pluginPath('TestPlugin');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
- $this->assertEqual($path, $expected);
-
- $path = App::pluginPath('TestPluginTwo');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS;
- $this->assertEqual($path, $expected);
- App::build();
- }
-
-/**
- * test that pluginPath can find paths for plugins.
- *
- * @return void
- */
- function testThemePath() {
- App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS)
- ));
- $path = App::themePath('test_theme');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;
- $this->assertEqual($path, $expected);
-
- $path = App::themePath('TestTheme');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;
- $this->assertEqual($path, $expected);
-
- App::build();
- }
-
-/**
- * testClassLoading method
- *
- * @access public
- * @return void
- */
- function testClassLoading() {
- $file = App::import();
- $this->assertTrue($file);
-
- $file = App::import('Model', 'Model', false);
- $this->assertTrue($file);
- $this->assertTrue(class_exists('Model'));
-
- $file = App::import('Controller', 'Controller', false);
- $this->assertTrue($file);
- $this->assertTrue(class_exists('Controller'));
-
- $file = App::import('Component', 'Component', false);
- $this->assertTrue($file);
- $this->assertTrue(class_exists('Component'));
-
- $file = App::import('Shell', 'Shell', false);
- $this->assertTrue($file);
- $this->assertTrue(class_exists('Shell'));
-
- $file = App::import('Lib', 'config/PhpReader');
- $this->assertTrue($file);
- $this->assertTrue(class_exists('PhpReader'));
-
- $file = App::import('Model', 'SomeRandomModelThatDoesNotExist', false);
- $this->assertFalse($file);
-
- $file = App::import('Model', 'AppModel', false);
- $this->assertTrue($file);
- $this->assertTrue(class_exists('AppModel'));
-
- $file = App::import('WrongType', null, true, array(), '');
- $this->assertTrue($file);
-
- $file = App::import('Model', 'NonExistingPlugin.NonExistingModel', false);
- $this->assertFalse($file);
-
- $file = App::import('Core', 'NonExistingPlugin.NonExistingModel', false);
- $this->assertFalse($file);
-
- $file = App::import('Model', array('NonExistingPlugin.NonExistingModel'), false);
- $this->assertFalse($file);
-
- $file = App::import('Core', array('NonExistingPlugin.NonExistingModel'), false);
- $this->assertFalse($file);
-
- $file = App::import('Core', array('NonExistingPlugin.NonExistingModel.AnotherChild'), false);
- $this->assertFalse($file);
-
- if (!class_exists('AppController')) {
- $classes = array_flip(get_declared_classes());
-
- $this->assertFalse(isset($classes['PagesController']));
- $this->assertFalse(isset($classes['AppController']));
-
- $file = App::import('Controller', 'Pages');
- $this->assertTrue($file);
- $this->assertTrue(class_exists('PagesController'));
-
- $classes = array_flip(get_declared_classes());
-
- $this->assertTrue(isset($classes['PagesController']));
- $this->assertTrue(isset($classes['AppController']));
-
- $file = App::import('Behavior', 'Containable');
- $this->assertTrue($file);
- $this->assertTrue(class_exists('ContainableBehavior'));
-
- $file = App::import('Component', 'RequestHandler');
- $this->assertTrue($file);
- $this->assertTrue(class_exists('RequestHandlerComponent'));
-
- $file = App::import('Helper', 'Form');
- $this->assertTrue($file);
- $this->assertTrue(class_exists('FormHelper'));
-
- $file = App::import('Model', 'NonExistingModel');
- $this->assertFalse($file);
-
- $file = App::import('Datasource', 'DboSource');
- $this->assertTrue($file);
- $this->assertTrue(class_exists('DboSource'));
- }
- App::build();
- }
-
-/**
- * test import() with plugins
- *
- * @return void
- */
- function testPluginImporting() {
- App::build(array(
- 'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
- ));
-
- $result = App::import('Controller', 'TestPlugin.Tests');
- $this->assertTrue($result);
- $this->assertTrue(class_exists('TestPluginAppController'));
- $this->assertTrue(class_exists('TestsController'));
-
- $result = App::import('Lib', 'TestPlugin.TestPluginLibrary');
- $this->assertTrue($result);
- $this->assertTrue(class_exists('TestPluginLibrary'));
-
- $result = App::import('Lib', 'Library');
- $this->assertTrue($result);
- $this->assertTrue(class_exists('Library'));
-
- $result = App::import('Helper', 'TestPlugin.OtherHelper');
- $this->assertTrue($result);
- $this->assertTrue(class_exists('OtherHelperHelper'));
-
- $result = App::import('Helper', 'TestPlugin.TestPluginApp');
- $this->assertTrue($result);
- $this->assertTrue(class_exists('TestPluginAppHelper'));
-
- $result = App::import('Datasource', 'TestPlugin.TestSource');
- $this->assertTrue($result);
- $this->assertTrue(class_exists('TestSource'));
-
- App::build();
- }
-
-/**
- * test that building helper paths actually works.
- *
- * @return void
- * @link http://cakephp.lighthouseapp.com/projects/42648/tickets/410
- */
- function testImportingHelpersFromAlternatePaths() {
- App::build();
- $this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.');
- App::import('Helper', 'Banana');
- $this->assertFalse(class_exists('BananaHelper'), 'BananaHelper was not found because the path does not exist.');
-
- App::build(array(
- 'helpers' => array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS
- )
- ));
- App::build(array('vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH)));
- $this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.');
- App::import('Helper', 'Banana');
- $this->assertTrue(class_exists('BananaHelper'), 'BananaHelper was not loaded.');
-
- App::build();
- }
-
-/**
- * testFileLoading method
- *
- * @access public
- * @return void
- */
- function testFileLoading () {
- $file = App::import('File', 'RealFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php');
- $this->assertTrue($file);
-
- $file = App::import('File', 'NoFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'cake' . DS . 'config.php');
- $this->assertFalse($file);
- }
-
-/**
- * testFileLoadingWithArray method
- *
- * @access public
- * @return void
- */
- function testFileLoadingWithArray() {
- $type = array('type' => 'File', 'name' => 'SomeName', 'parent' => false,
- 'file' => TEST_CAKE_CORE_INCLUDE_PATH . DS . 'config' . DS . 'config.php');
- $file = App::import($type);
- $this->assertTrue($file);
-
- $type = array('type' => 'File', 'name' => 'NoFile', 'parent' => false,
- 'file' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'cake' . DS . 'config.php');
- $file = App::import($type);
- $this->assertFalse($file);
- }
-
-/**
- * testFileLoadingReturnValue method
- *
- * @access public
- * @return void
- */
- function testFileLoadingReturnValue () {
- $file = App::import('File', 'Name', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', true);
- $this->assertTrue(!empty($file));
-
- $this->assertTrue(isset($file['Cake.version']));
-
- $type = array('type' => 'File', 'name' => 'OtherName', 'parent' => false,
- 'file' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', 'return' => true);
- $file = App::import($type);
- $this->assertTrue(!empty($file));
-
- $this->assertTrue(isset($file['Cake.version']));
- }
-
-/**
- * testLoadingWithSearch method
- *
- * @access public
- * @return void
- */
- function testLoadingWithSearch () {
- $file = App::import('File', 'NewName', false, array(TEST_CAKE_CORE_INCLUDE_PATH ), 'config.php');
- $this->assertTrue($file);
-
- $file = App::import('File', 'AnotherNewName', false, array(LIBS), 'config.php');
- $this->assertFalse($file);
- }
-
-/**
- * testLoadingWithSearchArray method
- *
- * @access public
- * @return void
- */
- function testLoadingWithSearchArray () {
- $type = array('type' => 'File', 'name' => 'RandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(TEST_CAKE_CORE_INCLUDE_PATH ));
- $file = App::import($type);
- $this->assertTrue($file);
-
- $type = array('type' => 'File', 'name' => 'AnotherRandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(LIBS));
- $file = App::import($type);
- $this->assertFalse($file);
- }
-
-/**
- * testMultipleLoading method
- *
- * @access public
- * @return void
- */
- function testMultipleLoading() {
- if (class_exists('I18n', false) || class_exists('CakeSocket', false)) {
- $this->markTestSkipped('Cannot test loading of classes that exist.');
- }
- $toLoad = array('I18n', 'CakeSocket');
-
- $classes = array_flip(get_declared_classes());
- $this->assertFalse(isset($classes['i18n']));
- $this->assertFalse(isset($classes['CakeSocket']));
-
- $load = App::import($toLoad);
- $this->assertTrue($load);
-
- $classes = array_flip(get_declared_classes());
-
-
- $this->assertTrue(isset($classes['I18n']));
-
- $load = App::import(array('I18n', 'SomeNotFoundClass', 'CakeSocket'));
- $this->assertFalse($load);
-
- $load = App::import($toLoad);
- $this->assertTrue($load);
- }
-
-/**
- * This test only works if you have plugins/my_plugin set up.
- * plugins/my_plugin/models/my_plugin.php and other_model.php
- */
-
-/*
- function testMultipleLoadingByType() {
- $classes = array_flip(get_declared_classes());
- $this->assertFalse(isset($classes['OtherPlugin']));
- $this->assertFalse(isset($classes['MyPlugin']));
-
-
- $load = App::import('Model', array('MyPlugin.OtherPlugin', 'MyPlugin.MyPlugin'));
- $this->assertTrue($load);
-
- $classes = array_flip(get_declared_classes());
- $this->assertTrue(isset($classes['OtherPlugin']));
- $this->assertTrue(isset($classes['MyPlugin']));
- }
-*/
- function testLoadingVendor() {
- 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();
- $this->assertTrue($result);
- $this->assertEqual($text, 'this is the test plugin asset css file');
-
- ob_start();
- $result = App::import('Vendor', 'TestAsset', array('ext' => 'css'));
- $text = ob_get_clean();
- $this->assertTrue($result);
- $this->assertEqual($text, 'this is the test asset css file');
-
- $result = App::import('Vendor', 'TestPlugin.SamplePlugin');
- $this->assertTrue($result);
- $this->assertTrue(class_exists('SamplePluginClassTestName'));
-
- $result = App::import('Vendor', 'ConfigureTestVendorSample');
- $this->assertTrue($result);
- $this->assertTrue(class_exists('ConfigureTestVendorSample'));
-
- ob_start();
- $result = App::import('Vendor', 'SomeName', array('file' => 'some.name.php'));
- $text = ob_get_clean();
- $this->assertTrue($result);
- $this->assertEqual($text, 'This is a file with dot in file name');
-
- ob_start();
- $result = App::import('Vendor', 'TestHello', array('file' => 'Test'.DS.'hello.php'));
- $text = ob_get_clean();
- $this->assertTrue($result);
- $this->assertEqual($text, 'This is the hello.php file in Test directory');
-
- ob_start();
- $result = App::import('Vendor', 'MyTest', array('file' => 'Test'.DS.'MyTest.php'));
- $text = ob_get_clean();
- $this->assertTrue($result);
- $this->assertEqual($text, 'This is the MyTest.php file');
-
- ob_start();
- $result = App::import('Vendor', 'Welcome');
- $text = ob_get_clean();
- $this->assertTrue($result);
- $this->assertEqual($text, 'This is the welcome.php file in vendors directory');
-
- ob_start();
- $result = App::import('Vendor', 'TestPlugin.Welcome');
- $text = ob_get_clean();
- $this->assertTrue($result);
- $this->assertEqual($text, 'This is the welcome.php file in test_plugin/vendors directory');
- }
-}
diff --git a/cake/tests/test_app/models/datasources/test/test_local_driver.php b/cake/tests/test_app/models/datasources/test/test_local_driver.php
deleted file mode 100644
index e483cb303..000000000
--- a/cake/tests/test_app/models/datasources/test/test_local_driver.php
+++ /dev/null
@@ -1,5 +0,0 @@
-paths = array_merge($this->paths, array(
- 'behavior' => LIBS . 'model' . DS . 'behaviors' . DS,
- 'cache' => LIBS . 'cache' . DS,
- 'controller' => LIBS . 'controller' . DS,
- 'component' => LIBS . 'controller' . DS . 'components' . DS,
- 'helper' => LIBS . 'view' . DS . 'helpers' . DS,
- 'model' => LIBS . 'model' . DS,
- 'view' => LIBS . 'view' . DS,
+ 'behavior' => LIBS . 'Model' . DS . 'Behavior' . DS,
+ 'cache' => LIBS . 'Cache' . DS,
+ 'controller' => LIBS . 'Controller' . DS,
+ 'component' => LIBS . 'Controller' . DS . 'Component' . DS,
+ 'helper' => LIBS . 'View' . DS . 'Helper' . DS,
+ 'model' => LIBS . 'Model' . DS,
+ 'view' => LIBS . 'View' . DS,
'core' => LIBS
));
}
@@ -74,7 +74,7 @@ class ApiShell extends Shell {
$class = Inflector::camelize($type);
} elseif (count($this->args) > 1) {
$file = Inflector::underscore($this->args[1]);
- $class = Inflector::camelize($file);
+ $class = Inflector::camelize($this->args[1]);
}
$objects = App::objects('class', $path);
if (in_array($class, $objects)) {
@@ -88,7 +88,7 @@ class ApiShell extends Shell {
$this->error(__('%s not found', $class));
}
- $parsed = $this->__parseClass($path . $file .'.php', $class);
+ $parsed = $this->__parseClass($path . $class .'.php', $class);
if (!empty($parsed)) {
if (isset($this->params['method'])) {
@@ -197,9 +197,12 @@ class ApiShell extends Shell {
function __parseClass($path, $class) {
$parsed = array();
- if (!include_once($path)) {
- $this->err(__('%s could not be found', $path));
+ if (!class_exists($class)) {
+ if (!include_once($path)) {
+ $this->err(__('%s could not be found', $path));
+ }
}
+
$reflection = new ReflectionClass($class);
foreach ($reflection->getMethods() as $method) {
diff --git a/cake/console/shells/bake.php b/lib/Cake/Console/Command/BakeShell.php
similarity index 97%
rename from cake/console/shells/bake.php
rename to lib/Cake/Console/Command/BakeShell.php
index ec741ed3a..718f8d8ff 100644
--- a/cake/console/shells/bake.php
+++ b/lib/Cake/Console/Command/BakeShell.php
@@ -21,6 +21,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+App::uses('Model', 'Model');
+
/**
* Bake is a command-line code generation utility for automating programmer chores.
*
@@ -149,11 +151,11 @@ class BakeShell extends Shell {
$modelExists = false;
$model = $this->_modelName($name);
- if (App::import('Model', $model)) {
+ App::uses($model, 'Model');
+ if (class_exists($model)) {
$object = new $model();
$modelExists = true;
} else {
- App::import('Model', 'Model', false);
$object = new Model(array('name' => $name, 'ds' => $this->connection));
}
@@ -174,7 +176,8 @@ class BakeShell extends Shell {
$this->Controller->bakeTest($controller);
}
}
- if (App::import('Controller', $controller)) {
+ App::uses($controller . 'Controller', 'Controller');
+ if (class_exists($controller . 'Controller')) {
$this->View->args = array($controller);
$this->View->execute();
}
diff --git a/cake/console/shells/command_list.php b/lib/Cake/Console/Command/CommandListShell.php
similarity index 86%
rename from cake/console/shells/command_list.php
rename to lib/Cake/Console/Command/CommandListShell.php
index e9323c6f7..bce1d0a75 100644
--- a/cake/console/shells/command_list.php
+++ b/lib/Cake/Console/Command/CommandListShell.php
@@ -16,6 +16,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+App::uses('Inflector', 'Utility');
+
/**
* Shows a list of commands available from the console.
*
@@ -79,17 +81,18 @@ class CommandListShell extends Shell {
protected function _getShellList() {
$shellList = array();
- $corePaths = App::core('shells');
- $shellList = $this->_appendShells('CORE', $corePaths, $shellList);
+ $shells = App::objects('file', App::core('Console/Command'));
+ $shellList = $this->_appendShells('CORE', $shells, $shellList);
- $appPaths = array_diff(App::path('shells'), $corePaths);
- $shellList = $this->_appendShells('app', $appPaths, $shellList);
+ $appShells = App::objects('Console/Command', null, false);
+ $shellList = $this->_appendShells('app', $appShells, $shellList);
$plugins = App::objects('plugin');
foreach ($plugins as $plugin) {
- $pluginPath = App::pluginPath($plugin) . 'console' . DS . 'shells' . DS;
- $shellList = $this->_appendShells($plugin, array($pluginPath), $shellList);
+ $pluginShells = App::objects($plugin . '.Console/Command');
+ $shellList = $this->_appendShells($plugin, $pluginShells, $shellList);
}
+
return $shellList;
}
@@ -98,22 +101,10 @@ class CommandListShell extends Shell {
*
* @return array
*/
- protected function _appendShells($type, $paths, $shellList) {
- foreach ($paths as $path) {
- if (!is_dir($path)) {
- continue;
- }
- $shells = App::objects('file', $path);
-
- if (empty($shells)) {
- continue;
- }
- foreach ($shells as $shell) {
- if ($shell !== 'shell.php' && $shell !== 'app_shell.php') {
- $shell = str_replace('.php', '', $shell);
- $shellList[$shell][$type] = $type;
- }
- }
+ protected function _appendShells($type, $shells, $shellList) {
+ foreach ($shells as $shell) {
+ $shell = Inflector::underscore(str_replace('Shell', '', $shell));
+ $shellList[$shell][$type] = $type;
}
return $shellList;
}
diff --git a/cake/console/shells/console.php b/lib/Cake/Console/Command/ConsoleShell.php
similarity index 96%
rename from cake/console/shells/console.php
rename to lib/Cake/Console/Command/ConsoleShell.php
index 44cc13d45..1e00d7dd7 100644
--- a/cake/console/shells/console.php
+++ b/lib/Cake/Console/Command/ConsoleShell.php
@@ -51,14 +51,14 @@ class ConsoleShell extends Shell {
*
*/
public function initialize() {
- require_once CAKE . 'dispatcher.php';
+ App::uses('Dispatcher', 'Routing');
$this->Dispatcher = new Dispatcher();
$this->models = App::objects('model');
- App::import('Model', $this->models);
foreach ($this->models as $model) {
$class = Inflector::camelize(str_replace('.php', '', $model));
$this->models[$model] = $class;
+ App::uses($class, 'Model');
$this->{$class} = new $class();
}
$this->out('Model classes:');
@@ -333,21 +333,20 @@ class ConsoleShell extends Shell {
* @return boolean True if config reload was a success, otherwise false
*/
protected function _loadRoutes() {
- $router = Router::getInstance();
-
- $router->reload();
- extract($router->getNamedExpressions());
+ Router::reload();
+ extract(Router::getNamedExpressions());
if (!@include(CONFIGS . 'routes.php')) {
return false;
}
- $router->parse('/');
+ Router::parse('/');
- foreach (array_keys($router->getNamedExpressions()) as $var) {
+ foreach (array_keys(Router::getNamedExpressions()) as $var) {
unset(${$var});
}
- for ($i = 0, $len = count($router->routes); $i < $len; $i++) {
- $router->routes[$i]->compile();
+
+ foreach (Router::$routes as $route) {
+ $route->compile();
}
return true;
}
diff --git a/cake/console/shells/i18n.php b/lib/Cake/Console/Command/I18nShell.php
similarity index 100%
rename from cake/console/shells/i18n.php
rename to lib/Cake/Console/Command/I18nShell.php
diff --git a/cake/console/shells/schema.php b/lib/Cake/Console/Command/SchemaShell.php
similarity index 99%
rename from cake/console/shells/schema.php
rename to lib/Cake/Console/Command/SchemaShell.php
index 3c16edd81..8282c4ce7 100644
--- a/cake/console/shells/schema.php
+++ b/lib/Cake/Console/Command/SchemaShell.php
@@ -19,8 +19,8 @@
* @since CakePHP(tm) v 1.2.0.5550
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'File', false);
-App::import('Model', 'CakeSchema', false);
+App::uses('File', 'Utility');
+App::uses('CakeSchema', 'Model');
/**
* Schema is a command-line database management utility for automating programmer chores.
diff --git a/cake/console/shells/tasks/bake.php b/lib/Cake/Console/Command/Task/BakeTask.php
similarity index 100%
rename from cake/console/shells/tasks/bake.php
rename to lib/Cake/Console/Command/Task/BakeTask.php
diff --git a/cake/console/shells/tasks/controller.php b/lib/Cake/Console/Command/Task/ControllerTask.php
similarity index 97%
rename from cake/console/shells/tasks/controller.php
rename to lib/Cake/Console/Command/Task/ControllerTask.php
index c3c4e2ea4..cdea1e1d5 100644
--- a/cake/console/shells/tasks/controller.php
+++ b/lib/Cake/Console/Command/Task/ControllerTask.php
@@ -17,7 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-include_once dirname(__FILE__) . DS . 'bake.php';
+App::uses('BakeTask', 'Console/Command/Task');
/**
* Task class for creating and updating controller files.
@@ -106,7 +106,8 @@ class ControllerTask extends BakeTask {
foreach ($this->__tables as $table) {
$model = $this->_modelName($table);
$controller = $this->_controllerName($model);
- if (App::import('Model', $model)) {
+ App::uses($model, 'Model');
+ if (class_exists($model)) {
$actions = $this->bakeActions($controller);
if ($this->bake($controller, $actions) && $unitTestExists) {
$this->bakeTest($controller);
@@ -142,10 +143,9 @@ class ControllerTask extends BakeTask {
$useDynamicScaffold = 'n';
$wannaBakeCrud = 'y';
- $controllerFile = strtolower(Inflector::underscore($controllerName));
$question[] = __("Would you like to build your controller interactively?");
- if (file_exists($this->path . $controllerFile .'_controller.php')) {
+ if (file_exists($this->path . $controllerName .'Controller.php')) {
$question[] = __("Warning: Choosing no will overwrite the %sController.", $controllerName);
}
$doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y');
@@ -269,9 +269,10 @@ class ControllerTask extends BakeTask {
$currentModelName = $modelImport = $this->_modelName($controllerName);
$plugin = $this->plugin;
if ($plugin) {
- $modelImport = $plugin . '.' . $modelImport;
+ $plugin .= '.';
}
- if (!App::import('Model', $modelImport)) {
+ App::uses($modelImport, $plugin . 'Model');
+ if (!class_exists($modelImport)) {
$this->err(__('You must have a model for this class to build basic methods. Please try again.'));
$this->_stop();
}
@@ -313,7 +314,7 @@ class ControllerTask extends BakeTask {
$contents = $this->Template->generate('classes', 'controller');
$path = $this->getPath();
- $filename = $path . $this->_controllerPath($controllerName) . '_controller.php';
+ $filename = $path . $this->_controllerNames($controllerName) . 'Controller.php';
if ($this->createFile($filename, $contents)) {
return $contents;
}
diff --git a/cake/console/shells/tasks/db_config.php b/lib/Cake/Console/Command/Task/DbConfigTask.php
similarity index 99%
rename from cake/console/shells/tasks/db_config.php
rename to lib/Cake/Console/Command/Task/DbConfigTask.php
index 6aaa9bf5e..e33850bbc 100644
--- a/cake/console/shells/tasks/db_config.php
+++ b/lib/Cake/Console/Command/Task/DbConfigTask.php
@@ -351,7 +351,7 @@ class DbConfigTask extends Shell {
* @return void
*/
public function getConfig() {
- App::import('Model', 'ConnectionManager', false);
+ App::uses('ConnectionManager', 'Model');
$useDbConfig = 'default';
$configs = get_class_vars($this->databaseClassName);
diff --git a/cake/console/shells/tasks/extract.php b/lib/Cake/Console/Command/Task/ExtractTask.php
similarity index 99%
rename from cake/console/shells/tasks/extract.php
rename to lib/Cake/Console/Command/Task/ExtractTask.php
index 9965876e2..a5ece60c7 100644
--- a/cake/console/shells/tasks/extract.php
+++ b/lib/Cake/Console/Command/Task/ExtractTask.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5012
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'File');
+App::uses('File', 'Utility');
/**
* Language string extractor
*
@@ -112,7 +112,7 @@ class ExtractTask extends Shell {
$this->__paths = explode(',', $this->params['paths']);
} else {
$defaultPath = APP_PATH;
- $message = __("What is the full path you would like to extract?\nExample: %s\n[Q]uit [D]one", $this->Dispatch->params['root'] . DS . 'myapp');
+ $message = __("What is the full path you would like to extract?\nExample: %s\n[Q]uit [D]one", $defaultPath);
while (true) {
$response = $this->in($message, null, $defaultPath);
if (strtoupper($response) === 'Q') {
diff --git a/cake/console/shells/tasks/fixture.php b/lib/Cake/Console/Command/Task/FixtureTask.php
similarity index 98%
rename from cake/console/shells/tasks/fixture.php
rename to lib/Cake/Console/Command/Task/FixtureTask.php
index 6a527672c..9352e539d 100644
--- a/cake/console/shells/tasks/fixture.php
+++ b/lib/Cake/Console/Command/Task/FixtureTask.php
@@ -16,7 +16,10 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-include_once dirname(__FILE__) . DS . 'bake.php';
+
+App::uses('BakeTask', 'Console/Command/Task');
+App::uses('Model', 'Model');
+
/**
* Task class for creating and updating fixtures files.
*
@@ -182,9 +185,7 @@ class FixtureTask extends BakeTask {
* @return string Baked fixture content
*/
public function bake($model, $useTable = false, $importOptions = array()) {
- if (!class_exists('CakeSchema')) {
- App::import('Model', 'CakeSchema', false);
- }
+ App::uses('CakeSchema', 'Model');
$table = $schema = $records = $import = $modelImport = null;
$importBits = array();
@@ -393,7 +394,6 @@ class FixtureTask extends BakeTask {
} else {
$condition = 'WHERE 1=1 LIMIT ' . (isset($this->params['count']) ? $this->params['count'] : 10);
}
- App::import('Model', 'Model', false);
$modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
$records = $modelObject->find('all', array(
'conditions' => $condition,
diff --git a/cake/console/shells/tasks/model.php b/lib/Cake/Console/Command/Task/ModelTask.php
similarity index 99%
rename from cake/console/shells/tasks/model.php
rename to lib/Cake/Console/Command/Task/ModelTask.php
index 5ac132dd1..7725519c7 100644
--- a/cake/console/shells/tasks/model.php
+++ b/lib/Cake/Console/Command/Task/ModelTask.php
@@ -17,7 +17,10 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-include_once dirname(__FILE__) . DS . 'bake.php';
+App::uses('BakeTask', 'Console/Command/Task');
+App::uses('ConnectionManager', 'Model');
+App::uses('Model', 'Model');
+App::uses('Validation', 'Utility');
/**
* Task class for creating and updating model files.
@@ -71,7 +74,6 @@ class ModelTask extends BakeTask {
*
*/
public function execute() {
- App::import('Model', 'Model', false);
parent::execute();
if (empty($this->args)) {
@@ -739,7 +741,7 @@ class ModelTask extends BakeTask {
$out = $this->Template->generate('classes', 'model');
$path = $this->getPath();
- $filename = $path . Inflector::underscore($name) . '.php';
+ $filename = $path . $name . '.php';
$this->out("\nBaking model class for $name...", 1, Shell::QUIET);
$this->createFile($filename, $out);
ClassRegistry::flush();
@@ -789,7 +791,6 @@ class ModelTask extends BakeTask {
if (!isset($useDbConfig)) {
$useDbConfig = $this->connection;
}
- App::import('Model', 'ConnectionManager', false);
$db = ConnectionManager::getDataSource($useDbConfig);
$useTable = Inflector::tableize($modelName);
@@ -818,7 +819,6 @@ class ModelTask extends BakeTask {
if (!isset($useDbConfig)) {
$useDbConfig = $this->connection;
}
- App::import('Model', 'ConnectionManager', false);
$tables = array();
$db = ConnectionManager::getDataSource($useDbConfig);
diff --git a/cake/console/shells/tasks/plugin.php b/lib/Cake/Console/Command/Task/PluginTask.php
similarity index 98%
rename from cake/console/shells/tasks/plugin.php
rename to lib/Cake/Console/Command/Task/PluginTask.php
index 118273d45..a08212423 100644
--- a/cake/console/shells/tasks/plugin.php
+++ b/lib/Cake/Console/Command/Task/PluginTask.php
@@ -16,7 +16,9 @@
* @since CakePHP(tm) v 1.2
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'File');
+
+App::uses('File', 'Utility');
+App::uses('Folder', 'Utility');
/**
* Task class for creating a plugin
diff --git a/cake/console/shells/tasks/project.php b/lib/Cake/Console/Command/Task/ProjectTask.php
similarity index 97%
rename from cake/console/shells/tasks/project.php
rename to lib/Cake/Console/Command/Task/ProjectTask.php
index eb59cc7c2..19bd4ac01 100644
--- a/cake/console/shells/tasks/project.php
+++ b/lib/Cake/Console/Command/Task/ProjectTask.php
@@ -17,7 +17,10 @@
* @since CakePHP(tm) v 1.2
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'File');
+
+App::uses('File', 'Utility');
+App::uses('String', 'Utility');
+App::uses('Security', 'Utility');
/**
* Task class for creating new project apps and plugins
@@ -49,14 +52,6 @@ class ProjectTask extends Shell {
$project = $_SERVER['PWD'] . DS . $project;
}
- if (empty($this->params['skel'])) {
- $core = App::core('shells');
- $skelPath = dirname($core[0]) . DS . 'templates' . DS . 'skel';
- if (is_dir($skelPath) === true) {
- $this->params['skel'] = $skelPath;
- }
- }
-
while (!$project) {
$prompt = __("What is the full path for this app including the app directory name?\n Example:");
$default = APP_PATH . 'myapp';
@@ -236,9 +231,6 @@ class ProjectTask extends Shell {
$File = new File($path . 'config' . DS . 'core.php');
$contents = $File->read();
if (preg_match('/([\s]*Configure::write\(\'Security.salt\',[\s\'A-z0-9]*\);)/', $contents, $match)) {
- if (!class_exists('Security')) {
- require LIBS . 'security.php';
- }
$string = Security::generateAuthKey();
$result = str_replace($match[0], "\t" . 'Configure::write(\'Security.salt\', \''.$string.'\');', $contents);
if ($File->write($result)) {
@@ -387,6 +379,7 @@ class ProjectTask extends Shell {
))->addOption('empty', array(
'help' => __('Create empty files in each of the directories. Good if you are using git')
))->addOption('skel', array(
+ 'default' => current(App::core('Console')) . DS . 'templates' . DS . 'skel',
'help' => __('The directory layout to use for the new application skeleton. Defaults to cake/console/templates/skel of CakePHP used to create the project.')
));
}
diff --git a/cake/console/shells/tasks/template.php b/lib/Cake/Console/Command/Task/TemplateTask.php
similarity index 98%
rename from cake/console/shells/tasks/template.php
rename to lib/Cake/Console/Command/Task/TemplateTask.php
index d23fc21d1..34c122ed9 100644
--- a/cake/console/shells/tasks/template.php
+++ b/lib/Cake/Console/Command/Task/TemplateTask.php
@@ -16,7 +16,8 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Folder');
+
+App::uses('Folder', 'Utility');
class TemplateTask extends Shell {
@@ -53,8 +54,8 @@ class TemplateTask extends Shell {
* @return array Array of bake themes that are installed.
*/
protected function _findThemes() {
- $paths = App::path('shells');
- $core = array_pop($paths);
+ $paths = App::path('Console');
+ $core = current(App::core('Console'));
$separator = DS === '/' ? '/' : '\\\\';
$core = preg_replace('#shells' . $separator . '$#', '', $core);
diff --git a/cake/console/shells/tasks/test.php b/lib/Cake/Console/Command/Task/TestTask.php
similarity index 99%
rename from cake/console/shells/tasks/test.php
rename to lib/Cake/Console/Command/Task/TestTask.php
index e62286e77..1fdab02d6 100644
--- a/cake/console/shells/tasks/test.php
+++ b/lib/Cake/Console/Command/Task/TestTask.php
@@ -17,8 +17,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-include_once dirname(__FILE__) . DS . 'bake.php';
-App::import('Model', 'ClassRegistry');
+App::uses('BakeTask', 'Console/Command/Task');
+App::uses('ClassRegistry', 'Utility');
/**
* Task class for creating and updating test files.
diff --git a/cake/console/shells/tasks/view.php b/lib/Cake/Console/Command/Task/ViewTask.php
similarity index 97%
rename from cake/console/shells/tasks/view.php
rename to lib/Cake/Console/Command/Task/ViewTask.php
index 51c84f2f3..c69813320 100644
--- a/cake/console/shells/tasks/view.php
+++ b/lib/Cake/Console/Command/Task/ViewTask.php
@@ -16,8 +16,9 @@
* @since CakePHP(tm) v 1.2
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Controller', 'Controller', false);
-include_once dirname(__FILE__) . DS . 'bake.php';
+
+App::uses('Controller', 'Controller');
+App::uses('BakeTask', 'Console/Command/Task');
/**
* Task class for creating and updating view files.
@@ -146,7 +147,7 @@ class ViewTask extends BakeTask {
protected function _methodsToBake() {
$methods = array_diff(
array_map('strtolower', get_class_methods($this->controllerName . 'Controller')),
- array_map('strtolower', get_class_methods('appcontroller'))
+ array_map('strtolower', get_class_methods('AppController'))
);
$scaffoldActions = false;
if (empty($methods)) {
@@ -188,7 +189,8 @@ class ViewTask extends BakeTask {
$model = $this->_modelName($table);
$this->controllerName = $this->_controllerName($model);
$this->controllerPath = Inflector::underscore($this->controllerName);
- if (App::import('Model', $model)) {
+ App::uses($model, 'Model');
+ if (class_exists($model)) {
$vars = $this->__loadController();
if (!$actions) {
$actions = $this->_methodsToBake();
@@ -269,17 +271,18 @@ class ViewTask extends BakeTask {
$this->err(__('Controller not found'));
}
- $import = $this->controllerName;
+ $plugin = null;
if ($this->plugin) {
- $import = $this->plugin . '.' . $this->controllerName;
+ $plugin = $this->plugin . '.';
}
- if (!App::import('Controller', $import)) {
- $file = $this->controllerPath . '_controller.php';
+ $controllerClassName = $this->controllerName . 'Controller';
+ App::uses($controllerClassName, $plugin . 'Controller');
+ if (!class_exists($controllerClassName)) {
+ $file = $controllerClassName . '.php';
$this->err(__("The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file));
$this->_stop();
}
- $controllerClassName = $this->controllerName . 'Controller';
$controllerObj = new $controllerClassName();
$controllerObj->plugin = $this->plugin;
$controllerObj->constructClasses();
diff --git a/cake/console/shells/testsuite.php b/lib/Cake/Console/Command/TestsuiteShell.php
similarity index 95%
rename from cake/console/shells/testsuite.php
rename to lib/Cake/Console/Command/TestsuiteShell.php
index b7b588e06..d788cae3d 100644
--- a/cake/console/shells/testsuite.php
+++ b/lib/Cake/Console/Command/TestsuiteShell.php
@@ -18,7 +18,13 @@
* @since CakePHP(tm) v 1.2.0.4433
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-class TestSuiteShell extends Shell {
+
+App::uses('Shell', 'Console');
+App::uses('CakeTestSuiteDispatcher', 'TestSuite');
+App::uses('CakeTestSuiteCommand', 'TestSuite');
+App::uses('CakeTestLoader', 'TestSuite');
+
+class TestsuiteShell extends Shell {
/**
* Dispatcher object for the run.
@@ -131,7 +137,7 @@ class TestSuiteShell extends Shell {
))->addOption('bootstrap', array(
'help' => __('Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!
\n";
$output .="
0):
Debugger::checkSecurityKeys();
endif;
@@ -52,27 +52,38 @@ endif;
?>
+ isConnected()): + echo ''; + echo __('Cake is able to connect to the database.'); + echo ''; + else: + echo ''; + echo __('Cake is NOT able to connect to the database.'); + echo ''; + endif; + ?> +
+ isConnected()): - echo ''; - echo __('Cake is able to connect to the database.'); - echo ''; - else: - echo ''; - echo __('Cake is NOT able to connect to the database.'); - echo ''; - endif; -?> -\n"; -$output .= "\n"; + App::uses('Validation', 'Utility'); + if (!Validation::alphaNumeric('cakephp')) { + echo '';
+ __('PCRE has not been compiled with Unicode support.');
+ echo '
';
+ __('Recompile PCRE with Unicode support by adding --enable-unicode-properties
when configuring');
+ echo '
\n"; $output .= " The name of a supported driver; valid options are as follows: - * mysql - MySQL 4 & 5, - * sqlite - SQLite (PHP5 only), - * postgres - PostgreSQL 7 and higher, - * mssql - Microsoft SQL Server 2000 and higher, - * oracle - Oracle 8 and higher + * Datasabe/Mysql - MySQL 4 & 5, + * Datasabe/Sqlite - SQLite (PHP5 only), + * Datasabe/Postgres - PostgreSQL 7 and higher, + * Datasabe/Mssql - Microsoft SQL Server 2000 and higher, + * Datasabe/Oracle - Oracle 8 and higher * * You can add custom database drivers (or override existing drivers) by adding the - * appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php', - * where 'x' is the name of the database. + * appropriate file to app/models/datasources/database. Drivers should be named 'MyDriver.php', + * * * persistent => true / false * Determines whether or not the database should use a persistent connection * * host => - * the host you connect to the database. To add a socket or port number, use 'port' => # + * the host you connect to the database. To add a socket or port number, use 'port' => # * * prefix => * Uses the given prefix for all the tables in this database. This setting can be overridden * on a per-table basis with the Model::$tablePrefix property. * * schema => - * For Postgresspecifies which schema you would like to use the tables in. Postgres defaults to - * 'public', DB2 defaults to empty. + * For Postgres specifies which schema you would like to use the tables in. Postgres defaults to 'public'. * * encoding => - * For MySQL, Postgres and Sqlite, specifies the character encoding to use when connecting to the - * database. Uses database default. + * For MySQL, Postgres specifies the character encoding to use when connecting to the + * database. Uses database default not specified. * */ class DATABASE_CONFIG { public $default = array( - 'driver' => 'mysql', + 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', @@ -70,7 +69,7 @@ class DATABASE_CONFIG { ); public $test = array( - 'driver' => 'mysql', + 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', diff --git a/cake/console/templates/skel/config/routes.php b/lib/Cake/Console/templates/skel/config/routes.php similarity index 100% rename from cake/console/templates/skel/config/routes.php rename to lib/Cake/Console/templates/skel/config/routes.php diff --git a/cake/console/templates/skel/config/schema/db_acl.php b/lib/Cake/Console/templates/skel/config/schema/db_acl.php similarity index 100% rename from cake/console/templates/skel/config/schema/db_acl.php rename to lib/Cake/Console/templates/skel/config/schema/db_acl.php diff --git a/cake/console/templates/skel/config/schema/db_acl.sql b/lib/Cake/Console/templates/skel/config/schema/db_acl.sql similarity index 100% rename from cake/console/templates/skel/config/schema/db_acl.sql rename to lib/Cake/Console/templates/skel/config/schema/db_acl.sql diff --git a/cake/console/templates/skel/config/schema/i18n.php b/lib/Cake/Console/templates/skel/config/schema/i18n.php similarity index 100% rename from cake/console/templates/skel/config/schema/i18n.php rename to lib/Cake/Console/templates/skel/config/schema/i18n.php diff --git a/cake/console/templates/skel/config/schema/i18n.sql b/lib/Cake/Console/templates/skel/config/schema/i18n.sql similarity index 100% rename from cake/console/templates/skel/config/schema/i18n.sql rename to lib/Cake/Console/templates/skel/config/schema/i18n.sql diff --git a/cake/console/templates/skel/config/schema/sessions.php b/lib/Cake/Console/templates/skel/config/schema/sessions.php similarity index 100% rename from cake/console/templates/skel/config/schema/sessions.php rename to lib/Cake/Console/templates/skel/config/schema/sessions.php diff --git a/cake/console/templates/skel/config/schema/sessions.sql b/lib/Cake/Console/templates/skel/config/schema/sessions.sql similarity index 100% rename from cake/console/templates/skel/config/schema/sessions.sql rename to lib/Cake/Console/templates/skel/config/schema/sessions.sql diff --git a/cake/console/templates/skel/console/cake b/lib/Cake/Console/templates/skel/console/cake similarity index 100% rename from cake/console/templates/skel/console/cake rename to lib/Cake/Console/templates/skel/console/cake diff --git a/cake/console/templates/skel/console/cake.bat b/lib/Cake/Console/templates/skel/console/cake.bat similarity index 100% rename from cake/console/templates/skel/console/cake.bat rename to lib/Cake/Console/templates/skel/console/cake.bat diff --git a/cake/console/templates/skel/console/cake.php b/lib/Cake/Console/templates/skel/console/cake.php similarity index 100% rename from cake/console/templates/skel/console/cake.php rename to lib/Cake/Console/templates/skel/console/cake.php diff --git a/cake/console/templates/skel/console/shells/tasks/empty b/lib/Cake/Console/templates/skel/console/shells/tasks/empty similarity index 100% rename from cake/console/templates/skel/console/shells/tasks/empty rename to lib/Cake/Console/templates/skel/console/shells/tasks/empty diff --git a/cake/console/templates/skel/app_controller.php b/lib/Cake/Console/templates/skel/controllers/AppController.php similarity index 100% rename from cake/console/templates/skel/app_controller.php rename to lib/Cake/Console/templates/skel/controllers/AppController.php diff --git a/cake/console/templates/skel/controllers/pages_controller.php b/lib/Cake/Console/templates/skel/controllers/PagesController.php similarity index 100% rename from cake/console/templates/skel/controllers/pages_controller.php rename to lib/Cake/Console/templates/skel/controllers/PagesController.php diff --git a/cake/console/templates/skel/controllers/components/empty b/lib/Cake/Console/templates/skel/controllers/components/empty similarity index 100% rename from cake/console/templates/skel/controllers/components/empty rename to lib/Cake/Console/templates/skel/controllers/components/empty diff --git a/cake/console/templates/skel/index.php b/lib/Cake/Console/templates/skel/index.php similarity index 100% rename from cake/console/templates/skel/index.php rename to lib/Cake/Console/templates/skel/index.php diff --git a/cake/console/templates/skel/libs/empty b/lib/Cake/Console/templates/skel/libs/empty similarity index 100% rename from cake/console/templates/skel/libs/empty rename to lib/Cake/Console/templates/skel/libs/empty diff --git a/cake/console/templates/skel/locale/eng/LC_MESSAGES/empty b/lib/Cake/Console/templates/skel/locale/eng/LC_MESSAGES/empty similarity index 100% rename from cake/console/templates/skel/locale/eng/LC_MESSAGES/empty rename to lib/Cake/Console/templates/skel/locale/eng/LC_MESSAGES/empty diff --git a/cake/console/templates/skel/app_model.php b/lib/Cake/Console/templates/skel/models/AppModel.php similarity index 100% rename from cake/console/templates/skel/app_model.php rename to lib/Cake/Console/templates/skel/models/AppModel.php diff --git a/cake/console/templates/skel/models/behaviors/empty b/lib/Cake/Console/templates/skel/models/behaviors/empty similarity index 100% rename from cake/console/templates/skel/models/behaviors/empty rename to lib/Cake/Console/templates/skel/models/behaviors/empty diff --git a/cake/console/templates/skel/models/datasources/empty b/lib/Cake/Console/templates/skel/models/datasources/empty similarity index 100% rename from cake/console/templates/skel/models/datasources/empty rename to lib/Cake/Console/templates/skel/models/datasources/empty diff --git a/cake/console/templates/skel/plugins/empty b/lib/Cake/Console/templates/skel/plugins/empty similarity index 100% rename from cake/console/templates/skel/plugins/empty rename to lib/Cake/Console/templates/skel/plugins/empty diff --git a/cake/console/templates/skel/tests/cases/behaviors/empty b/lib/Cake/Console/templates/skel/tests/cases/behaviors/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/behaviors/empty rename to lib/Cake/Console/templates/skel/tests/cases/behaviors/empty diff --git a/cake/console/templates/skel/tests/cases/components/empty b/lib/Cake/Console/templates/skel/tests/cases/components/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/components/empty rename to lib/Cake/Console/templates/skel/tests/cases/components/empty diff --git a/cake/console/templates/skel/tests/cases/controllers/empty b/lib/Cake/Console/templates/skel/tests/cases/controllers/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/controllers/empty rename to lib/Cake/Console/templates/skel/tests/cases/controllers/empty diff --git a/cake/console/templates/skel/tests/cases/datasources/empty b/lib/Cake/Console/templates/skel/tests/cases/datasources/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/datasources/empty rename to lib/Cake/Console/templates/skel/tests/cases/datasources/empty diff --git a/cake/console/templates/skel/tests/cases/helpers/empty b/lib/Cake/Console/templates/skel/tests/cases/helpers/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/helpers/empty rename to lib/Cake/Console/templates/skel/tests/cases/helpers/empty diff --git a/cake/console/templates/skel/tests/cases/models/empty b/lib/Cake/Console/templates/skel/tests/cases/models/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/models/empty rename to lib/Cake/Console/templates/skel/tests/cases/models/empty diff --git a/cake/console/templates/skel/tests/cases/shells/empty b/lib/Cake/Console/templates/skel/tests/cases/shells/empty similarity index 100% rename from cake/console/templates/skel/tests/cases/shells/empty rename to lib/Cake/Console/templates/skel/tests/cases/shells/empty diff --git a/cake/console/templates/skel/tests/fixtures/empty b/lib/Cake/Console/templates/skel/tests/fixtures/empty similarity index 100% rename from cake/console/templates/skel/tests/fixtures/empty rename to lib/Cake/Console/templates/skel/tests/fixtures/empty diff --git a/cake/console/templates/skel/tmp/cache/models/empty b/lib/Cake/Console/templates/skel/tmp/cache/models/empty similarity index 100% rename from cake/console/templates/skel/tmp/cache/models/empty rename to lib/Cake/Console/templates/skel/tmp/cache/models/empty diff --git a/cake/console/templates/skel/tmp/cache/persistent/empty b/lib/Cake/Console/templates/skel/tmp/cache/persistent/empty similarity index 100% rename from cake/console/templates/skel/tmp/cache/persistent/empty rename to lib/Cake/Console/templates/skel/tmp/cache/persistent/empty diff --git a/cake/console/templates/skel/tmp/cache/views/empty b/lib/Cake/Console/templates/skel/tmp/cache/views/empty similarity index 100% rename from cake/console/templates/skel/tmp/cache/views/empty rename to lib/Cake/Console/templates/skel/tmp/cache/views/empty diff --git a/cake/console/templates/skel/tmp/logs/empty b/lib/Cake/Console/templates/skel/tmp/logs/empty similarity index 100% rename from cake/console/templates/skel/tmp/logs/empty rename to lib/Cake/Console/templates/skel/tmp/logs/empty diff --git a/cake/console/templates/skel/tmp/sessions/empty b/lib/Cake/Console/templates/skel/tmp/sessions/empty similarity index 100% rename from cake/console/templates/skel/tmp/sessions/empty rename to lib/Cake/Console/templates/skel/tmp/sessions/empty diff --git a/cake/console/templates/skel/tmp/tests/empty b/lib/Cake/Console/templates/skel/tmp/tests/empty similarity index 100% rename from cake/console/templates/skel/tmp/tests/empty rename to lib/Cake/Console/templates/skel/tmp/tests/empty diff --git a/cake/console/templates/skel/vendors/empty b/lib/Cake/Console/templates/skel/vendors/empty similarity index 100% rename from cake/console/templates/skel/vendors/empty rename to lib/Cake/Console/templates/skel/vendors/empty diff --git a/cake/console/templates/skel/views/elements/email/html/default.ctp b/lib/Cake/Console/templates/skel/views/elements/email/html/default.ctp similarity index 100% rename from cake/console/templates/skel/views/elements/email/html/default.ctp rename to lib/Cake/Console/templates/skel/views/elements/email/html/default.ctp diff --git a/cake/console/templates/skel/views/elements/email/text/default.ctp b/lib/Cake/Console/templates/skel/views/elements/email/text/default.ctp similarity index 100% rename from cake/console/templates/skel/views/elements/email/text/default.ctp rename to lib/Cake/Console/templates/skel/views/elements/email/text/default.ctp diff --git a/cake/console/templates/skel/views/elements/empty b/lib/Cake/Console/templates/skel/views/elements/empty similarity index 100% rename from cake/console/templates/skel/views/elements/empty rename to lib/Cake/Console/templates/skel/views/elements/empty diff --git a/cake/console/templates/skel/views/errors/empty b/lib/Cake/Console/templates/skel/views/errors/empty similarity index 100% rename from cake/console/templates/skel/views/errors/empty rename to lib/Cake/Console/templates/skel/views/errors/empty diff --git a/cake/libs/view/helpers/app_helper.php b/lib/Cake/Console/templates/skel/views/helpers/AppHelper.php similarity index 96% rename from cake/libs/view/helpers/app_helper.php rename to lib/Cake/Console/templates/skel/views/helpers/AppHelper.php index 9ded31b9c..6689abcba 100644 --- a/cake/libs/view/helpers/app_helper.php +++ b/lib/Cake/Console/templates/skel/views/helpers/AppHelper.php @@ -18,7 +18,7 @@ * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('View', 'Helper', false); +App::uses('Helper', 'View'); /** * This is a placeholder class. diff --git a/cake/console/templates/skel/views/helpers/empty b/lib/Cake/Console/templates/skel/views/helpers/empty similarity index 100% rename from cake/console/templates/skel/views/helpers/empty rename to lib/Cake/Console/templates/skel/views/helpers/empty diff --git a/cake/console/templates/skel/views/layouts/ajax.ctp b/lib/Cake/Console/templates/skel/views/layouts/ajax.ctp similarity index 100% rename from cake/console/templates/skel/views/layouts/ajax.ctp rename to lib/Cake/Console/templates/skel/views/layouts/ajax.ctp diff --git a/cake/console/templates/skel/views/layouts/default.ctp b/lib/Cake/Console/templates/skel/views/layouts/default.ctp similarity index 100% rename from cake/console/templates/skel/views/layouts/default.ctp rename to lib/Cake/Console/templates/skel/views/layouts/default.ctp diff --git a/cake/console/templates/skel/views/layouts/email/html/default.ctp b/lib/Cake/Console/templates/skel/views/layouts/email/html/default.ctp similarity index 100% rename from cake/console/templates/skel/views/layouts/email/html/default.ctp rename to lib/Cake/Console/templates/skel/views/layouts/email/html/default.ctp diff --git a/cake/console/templates/skel/views/layouts/email/text/default.ctp b/lib/Cake/Console/templates/skel/views/layouts/email/text/default.ctp similarity index 100% rename from cake/console/templates/skel/views/layouts/email/text/default.ctp rename to lib/Cake/Console/templates/skel/views/layouts/email/text/default.ctp diff --git a/cake/console/templates/skel/views/layouts/flash.ctp b/lib/Cake/Console/templates/skel/views/layouts/flash.ctp similarity index 100% rename from cake/console/templates/skel/views/layouts/flash.ctp rename to lib/Cake/Console/templates/skel/views/layouts/flash.ctp diff --git a/cake/console/templates/skel/views/layouts/js/default.ctp b/lib/Cake/Console/templates/skel/views/layouts/js/default.ctp similarity index 100% rename from cake/console/templates/skel/views/layouts/js/default.ctp rename to lib/Cake/Console/templates/skel/views/layouts/js/default.ctp diff --git a/cake/console/templates/skel/views/layouts/rss/default.ctp b/lib/Cake/Console/templates/skel/views/layouts/rss/default.ctp similarity index 100% rename from cake/console/templates/skel/views/layouts/rss/default.ctp rename to lib/Cake/Console/templates/skel/views/layouts/rss/default.ctp diff --git a/cake/console/templates/skel/views/layouts/xml/default.ctp b/lib/Cake/Console/templates/skel/views/layouts/xml/default.ctp similarity index 100% rename from cake/console/templates/skel/views/layouts/xml/default.ctp rename to lib/Cake/Console/templates/skel/views/layouts/xml/default.ctp diff --git a/cake/console/templates/skel/views/pages/empty b/lib/Cake/Console/templates/skel/views/pages/empty similarity index 100% rename from cake/console/templates/skel/views/pages/empty rename to lib/Cake/Console/templates/skel/views/pages/empty diff --git a/cake/console/templates/skel/views/scaffolds/empty b/lib/Cake/Console/templates/skel/views/scaffolds/empty similarity index 100% rename from cake/console/templates/skel/views/scaffolds/empty rename to lib/Cake/Console/templates/skel/views/scaffolds/empty diff --git a/cake/console/templates/skel/webroot/.htaccess b/lib/Cake/Console/templates/skel/webroot/.htaccess similarity index 100% rename from cake/console/templates/skel/webroot/.htaccess rename to lib/Cake/Console/templates/skel/webroot/.htaccess diff --git a/cake/console/templates/skel/webroot/css.php b/lib/Cake/Console/templates/skel/webroot/css.php similarity index 100% rename from cake/console/templates/skel/webroot/css.php rename to lib/Cake/Console/templates/skel/webroot/css.php diff --git a/cake/console/templates/skel/webroot/css/cake.generic.css b/lib/Cake/Console/templates/skel/webroot/css/cake.generic.css similarity index 100% rename from cake/console/templates/skel/webroot/css/cake.generic.css rename to lib/Cake/Console/templates/skel/webroot/css/cake.generic.css diff --git a/cake/console/templates/skel/webroot/favicon.ico b/lib/Cake/Console/templates/skel/webroot/favicon.ico similarity index 100% rename from cake/console/templates/skel/webroot/favicon.ico rename to lib/Cake/Console/templates/skel/webroot/favicon.ico diff --git a/cake/console/templates/skel/webroot/img/cake.icon.png b/lib/Cake/Console/templates/skel/webroot/img/cake.icon.png similarity index 100% rename from cake/console/templates/skel/webroot/img/cake.icon.png rename to lib/Cake/Console/templates/skel/webroot/img/cake.icon.png diff --git a/cake/console/templates/skel/webroot/img/cake.power.gif b/lib/Cake/Console/templates/skel/webroot/img/cake.power.gif similarity index 100% rename from cake/console/templates/skel/webroot/img/cake.power.gif rename to lib/Cake/Console/templates/skel/webroot/img/cake.power.gif diff --git a/cake/console/templates/skel/webroot/index.php b/lib/Cake/Console/templates/skel/webroot/index.php similarity index 93% rename from cake/console/templates/skel/webroot/index.php rename to lib/Cake/Console/templates/skel/webroot/index.php index f1ff8d197..77b9db786 100644 --- a/cake/console/templates/skel/webroot/index.php +++ b/lib/Cake/Console/templates/skel/webroot/index.php @@ -49,7 +49,7 @@ * */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT); + define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); } /** @@ -67,7 +67,7 @@ define('APP_PATH', ROOT . DS . APP_DIR . DS); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } - if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) { + if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } @@ -75,6 +75,6 @@ return; } - require LIBS . 'dispatcher.php'; + require LIBS . 'Routing' . DS .'Dispatcher.php'; $Dispatcher = new Dispatcher(); $Dispatcher->dispatch(new CakeRequest()); diff --git a/cake/console/templates/skel/webroot/js/empty b/lib/Cake/Console/templates/skel/webroot/js/empty similarity index 100% rename from cake/console/templates/skel/webroot/js/empty rename to lib/Cake/Console/templates/skel/webroot/js/empty diff --git a/cake/console/templates/skel/webroot/test.php b/lib/Cake/Console/templates/skel/webroot/test.php similarity index 87% rename from cake/console/templates/skel/webroot/test.php rename to lib/Cake/Console/templates/skel/webroot/test.php index c11aaac99..cb9180331 100644 --- a/cake/console/templates/skel/webroot/test.php +++ b/lib/Cake/Console/templates/skel/webroot/test.php @@ -67,21 +67,14 @@ if (!defined('CORE_PATH')) { define('APP_PATH', ROOT . DS . APP_DIR . DS); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } -if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) { +if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } -$corePath = App::core('cake'); -if (isset($corePath[0])) { - define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS); -} else { - define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH); -} - if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.')); } -require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php'; +require_once CAKE_TESTS_LIB . 'CakeTestSuiteDispatcher.php'; CakeTestSuiteDispatcher::run(); diff --git a/cake/libs/controller/app_controller.php b/lib/Cake/Controller/AppController.php similarity index 96% rename from cake/libs/controller/app_controller.php rename to lib/Cake/Controller/AppController.php index 07c117dff..383cca2be 100644 --- a/cake/libs/controller/app_controller.php +++ b/lib/Cake/Controller/AppController.php @@ -20,6 +20,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Controller', 'Controller'); + /** * This is a placeholder class. * Create the same file in app/app_controller.php diff --git a/cake/libs/controller/cake_error_controller.php b/lib/Cake/Controller/CakeErrorController.php similarity index 100% rename from cake/libs/controller/cake_error_controller.php rename to lib/Cake/Controller/CakeErrorController.php diff --git a/cake/libs/controller/component.php b/lib/Cake/Controller/Component.php similarity index 98% rename from cake/libs/controller/component.php rename to lib/Cake/Controller/Component.php index f55840d1f..0993c171b 100644 --- a/cake/libs/controller/component.php +++ b/lib/Cake/Controller/Component.php @@ -15,7 +15,7 @@ * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Controller', 'ComponentCollection', false); +App::uses('ComponentCollection', 'Controller'); /** * Base class for an individual Component. Components provide resuable bits of diff --git a/cake/libs/controller/components/acl.php b/lib/Cake/Controller/Component/AclComponent.php similarity index 99% rename from cake/libs/controller/components/acl.php rename to lib/Cake/Controller/Component/AclComponent.php index 6795ab335..e8809f864 100644 --- a/cake/libs/controller/components/acl.php +++ b/lib/Cake/Controller/Component/AclComponent.php @@ -19,6 +19,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Component', 'Controller'); + /** * Access Control List factory class. * @@ -262,9 +264,7 @@ class DbAcl extends Object implements AclInterface { */ function __construct() { parent::__construct(); - if (!class_exists('AclNode')) { - require LIBS . 'model' . DS . 'db_acl.php'; - } + App::uses('AclNode', 'Model'); $this->Aro = ClassRegistry::init(array('class' => 'Aro', 'alias' => 'Aro')); $this->Aco = ClassRegistry::init(array('class' => 'Aco', 'alias' => 'Aco')); } @@ -657,7 +657,7 @@ class IniAcl extends Object implements AclInterface { * @return array INI section structure */ public function readConfigFile($filename) { - App::import('Core', 'config/IniReader'); + App::uses('IniReader', 'Configure'); $iniFile = new IniReader(dirname($filename) . DS); return $iniFile->read(basename($filename)); } diff --git a/cake/libs/controller/components/auth/actions_authorize.php b/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php similarity index 95% rename from cake/libs/controller/components/auth/actions_authorize.php rename to lib/Cake/Controller/Component/Auth/ActionsAuthorize.php index c2f1f35d2..684fb47a0 100644 --- a/cake/libs/controller/components/auth/actions_authorize.php +++ b/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authorize'); + +App::uses('BaseAuthorize', 'Controller/Component/Auth'); /** * An authorization adapter for AuthComponent. Provides the ability to authorize using the AclComponent, diff --git a/cake/libs/controller/components/auth/base_authenticate.php b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php similarity index 98% rename from cake/libs/controller/components/auth/base_authenticate.php rename to lib/Cake/Controller/Component/Auth/BaseAuthenticate.php index 1cfcc8896..aba2a8328 100644 --- a/cake/libs/controller/components/auth/base_authenticate.php +++ b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Security'); + +App::uses('Security', 'Utility'); /** * Base Authentication class with common methods and properties. diff --git a/cake/libs/controller/components/auth/base_authorize.php b/lib/Cake/Controller/Component/Auth/BaseAuthorize.php similarity index 100% rename from cake/libs/controller/components/auth/base_authorize.php rename to lib/Cake/Controller/Component/Auth/BaseAuthorize.php diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php similarity index 98% rename from cake/libs/controller/components/auth/basic_authenticate.php rename to lib/Cake/Controller/Component/Auth/BasicAuthenticate.php index 2ba467e98..148734629 100644 --- a/cake/libs/controller/components/auth/basic_authenticate.php +++ b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authenticate'); + +App::uses('BaseAuthenticate', 'Controller/Component/Auth'); /** * Basic Authentication adapter for AuthComponent. diff --git a/cake/libs/controller/components/auth/controller_authorize.php b/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php similarity index 97% rename from cake/libs/controller/components/auth/controller_authorize.php rename to lib/Cake/Controller/Component/Auth/ControllerAuthorize.php index 8fd66b10d..275cf6875 100644 --- a/cake/libs/controller/components/auth/controller_authorize.php +++ b/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authorize'); + +App::uses('BaseAuthorize', 'Controller/Component/Auth'); /** * An authorization adapter for AuthComponent. Provides the ability to authorize using a controller callback. diff --git a/cake/libs/controller/components/auth/crud_authorize.php b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php similarity index 97% rename from cake/libs/controller/components/auth/crud_authorize.php rename to lib/Cake/Controller/Component/Auth/CrudAuthorize.php index be127f43a..b9fa8329c 100644 --- a/cake/libs/controller/components/auth/crud_authorize.php +++ b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php @@ -12,7 +12,9 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authorize'); + +App::uses('BaseAuthorize', 'Controller/Component/Auth'); +App::uses('Router', 'Routing'); /** * An authorization adapter for AuthComponent. Provides the ability to authorize using CRUD mappings. diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php similarity index 99% rename from cake/libs/controller/components/auth/digest_authenticate.php rename to lib/Cake/Controller/Component/Auth/DigestAuthenticate.php index c27f293c0..69c3ae228 100644 --- a/cake/libs/controller/components/auth/digest_authenticate.php +++ b/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authenticate'); + +App::uses('BaseAuthenticate', 'Controller/Component/Auth'); /** * Digest Authentication adapter for AuthComponent. diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/lib/Cake/Controller/Component/Auth/FormAuthenticate.php similarity index 97% rename from cake/libs/controller/components/auth/form_authenticate.php rename to lib/Cake/Controller/Component/Auth/FormAuthenticate.php index d24d9acf2..f0f708088 100644 --- a/cake/libs/controller/components/auth/form_authenticate.php +++ b/lib/Cake/Controller/Component/Auth/FormAuthenticate.php @@ -12,7 +12,8 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'auth/base_authenticate'); + +App::uses('BaseAuthenticate', 'Controller/Component/Auth'); /** * An authentication adapter for AuthComponent. Provides the ability to authenticate using POST diff --git a/cake/libs/controller/components/auth.php b/lib/Cake/Controller/Component/AuthComponent.php similarity index 96% rename from cake/libs/controller/components/auth.php rename to lib/Cake/Controller/Component/AuthComponent.php index b37ebe69e..c4927be0f 100644 --- a/cake/libs/controller/components/auth.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -19,11 +19,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Router', false); -App::import('Core', 'Security', false); -App::import('Core', 'CakeSession', false); -App::import('Component', 'auth/base_authorize'); -App::import('Component', 'auth/base_authenticate'); + +App::uses('Component', 'Controller'); +App::uses('Router', 'Routing'); +App::uses('Security', 'Utility'); +App::uses('Debugger', 'Utility'); +App::uses('CakeSession', 'Model/Datasource'); +App::uses('BaseAuthorize', 'Controller/Component/Auth'); +App::uses('BaseAuthenticate', 'Controller/Component/Auth'); /** * Authentication control component class @@ -253,7 +256,6 @@ class AuthComponent extends Component { $this->_methods = $controller->methods; if (Configure::read('debug') > 0) { - App::import('Debugger'); Debugger::checkSecurityKeys(); } } @@ -405,8 +407,10 @@ class AuthComponent extends Component { unset($config[AuthComponent::ALL]); } foreach ($config as $class => $settings) { + list($plugin, $class) = pluginSplit($class, true); $className = $class . 'Authorize'; - if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authorize')) { + App::uses($className, $plugin . 'Controller/Component/Auth'); + if (!class_exists($className)) { throw new CakeException(__('Authorization adapter "%s" was not found.', $class)); } if (!method_exists($className, 'authorize')) { @@ -643,8 +647,10 @@ class AuthComponent extends Component { unset($config[AuthComponent::ALL]); } foreach ($config as $class => $settings) { + list($plugin, $class) = pluginSplit($class, true); $className = $class . 'Authenticate'; - if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authenticate')) { + App::uses($className, $plugin . 'Controller/Component/Auth'); + if (!class_exists($className)) { throw new CakeException(__('Authentication adapter "%s" was not found.', $class)); } if (!method_exists($className, 'authenticate')) { diff --git a/cake/libs/controller/components/cookie.php b/lib/Cake/Controller/Component/CookieComponent.php similarity index 99% rename from cake/libs/controller/components/cookie.php rename to lib/Cake/Controller/Component/CookieComponent.php index bb614c0bc..cca49a5bf 100644 --- a/cake/libs/controller/components/cookie.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -17,10 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -/** - * Load Security class - */ -App::import('Core', 'Security'); +App::uses('Component', 'Controller'); +App::uses('Security', 'Utility'); /** * Cookie Component. diff --git a/cake/libs/controller/components/email.php b/lib/Cake/Controller/Component/EmailComponent.php similarity index 99% rename from cake/libs/controller/components/email.php rename to lib/Cake/Controller/Component/EmailComponent.php index 68972daf1..735a50d63 100755 --- a/cake/libs/controller/components/email.php +++ b/lib/Cake/Controller/Component/EmailComponent.php @@ -16,7 +16,9 @@ * @since CakePHP(tm) v 1.2.0.3467 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Multibyte'); + +App::uses('Component', 'Controller'); +App::uses('Multibyte', 'I18n'); /** * EmailComponent @@ -456,9 +458,9 @@ class EmailComponent extends Component { $viewClass = $this->Controller->view; if ($viewClass != 'View') { - list($plugin, $viewClass) = pluginSplit($viewClass); + list($plugin, $viewClass) = pluginSplit($viewClass, true); $viewClass = $viewClass . 'View'; - App::import('View', $this->Controller->view); + App::uses($viewClass, $plugin . 'View'); } $View = new $viewClass($this->Controller); @@ -850,7 +852,7 @@ class EmailComponent extends Component { * @access private */ function _smtp() { - App::import('Core', 'CakeSocket'); + App::uses('CakeSocket', 'Network'); $defaults = array( 'host' => 'localhost', diff --git a/cake/libs/controller/components/paginator.php b/lib/Cake/Controller/Component/PaginatorComponent.php similarity index 100% rename from cake/libs/controller/components/paginator.php rename to lib/Cake/Controller/Component/PaginatorComponent.php diff --git a/cake/libs/controller/components/request_handler.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php similarity index 99% rename from cake/libs/controller/components/request_handler.php rename to lib/Cake/Controller/Component/RequestHandlerComponent.php index f818ef63b..56cf6c448 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -19,6 +19,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Xml', 'Utility'); + /** * Request object for handling HTTP requests * @@ -171,9 +173,6 @@ class RequestHandlerComponent extends Component { } if ($this->requestedWith('xml')) { - if (!class_exists('Xml')) { - App::import('Core', 'Xml'); - } try { $xml = Xml::build(trim(file_get_contents('php://input'))); @@ -542,7 +541,8 @@ class RequestHandlerComponent extends Component { ); if (!$isAdded) { - if (App::import('Helper', $helper)) { + App::uses($helper . 'Helper', 'View/Helper'); + if (class_exists($helper . 'Helper')) { $controller->helpers[] = $helper; } } diff --git a/cake/libs/controller/components/security.php b/lib/Cake/Controller/Component/SecurityComponent.php similarity index 99% rename from cake/libs/controller/components/security.php rename to lib/Cake/Controller/Component/SecurityComponent.php index 7b1f6cac8..16cdc6413 100644 --- a/cake/libs/controller/components/security.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -16,8 +16,10 @@ * @since CakePHP(tm) v 0.10.8.2156 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'String', false); -App::import('Core', 'Security', false); + +App::uses('Component', 'Controller'); +App::uses('String', 'Utility'); +App::uses('Security', 'Utility'); /** * SecurityComponent diff --git a/cake/libs/controller/components/session.php b/lib/Cake/Controller/Component/SessionComponent.php similarity index 98% rename from cake/libs/controller/components/session.php rename to lib/Cake/Controller/Component/SessionComponent.php index fefa7dbf7..9d2231150 100644 --- a/cake/libs/controller/components/session.php +++ b/lib/Cake/Controller/Component/SessionComponent.php @@ -16,9 +16,9 @@ * @since CakePHP(tm) v 0.10.0.1232 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('cakesession')) { - require LIBS . 'cake_session.php'; -} + +App::uses('Component', 'Controller'); +App::uses('CakeSession', 'Model/Datasource'); /** * Session Component. diff --git a/cake/libs/controller/component_collection.php b/lib/Cake/Controller/ComponentCollection.php similarity index 87% rename from cake/libs/controller/component_collection.php rename to lib/Cake/Controller/ComponentCollection.php index 07a2a6eef..909fd70e1 100644 --- a/cake/libs/controller/component_collection.php +++ b/lib/Cake/Controller/ComponentCollection.php @@ -15,6 +15,10 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('ObjectCollection', 'Utility'); +App::uses('Component', 'Controller'); + class ComponentCollection extends ObjectCollection { /** @@ -76,7 +80,7 @@ class ComponentCollection extends ObjectCollection { $alias = $component; $component = $settings['className']; } - list($plugin, $name) = pluginSplit($component); + list($plugin, $name) = pluginSplit($component, true); if (!isset($alias)) { $alias = $name; } @@ -84,19 +88,12 @@ class ComponentCollection extends ObjectCollection { return $this->_loaded[$alias]; } $componentClass = $name . 'Component'; + App::uses($componentClass, $plugin . 'Controller/Component'); if (!class_exists($componentClass)) { - if (!App::import('Component', $component)) { - throw new MissingComponentFileException(array( - 'file' => Inflector::underscore($componentClass) . '.php', - 'class' => $componentClass - )); - } - if (!class_exists($componentClass)) { - throw new MissingComponentClassException(array( - 'file' => Inflector::underscore($componentClass) . '.php', - 'class' => $componentClass - )); - } + throw new MissingComponentClassException(array( + 'file' => Inflector::underscore($componentClass) . '.php', + 'class' => $componentClass + )); } $this->_loaded[$alias] = new $componentClass($this, $settings); $enable = isset($settings['enabled']) ? $settings['enabled'] : true; diff --git a/cake/libs/controller/controller.php b/lib/Cake/Controller/Controller.php similarity index 98% rename from cake/libs/controller/controller.php rename to lib/Cake/Controller/Controller.php index f09601c86..697629387 100644 --- a/cake/libs/controller/controller.php +++ b/lib/Cake/Controller/Controller.php @@ -20,10 +20,10 @@ /** * Include files */ -App::import('Core', 'CakeResponse', false); -App::import('Core', 'ClassRegistry', false); -App::import('Controller', 'Component', false); -App::import('View', 'View', false); +App::uses('CakeResponse', 'Network'); +App::uses('ClassRegistry', 'Utility'); +App::uses('ComponentCollection', 'Controller'); +App::uses('View', 'View'); /** * Application controller class for organization of business logic. @@ -311,18 +311,14 @@ class Controller extends Object { */ public function __construct($request = null) { if ($this->name === null) { - $r = null; - if (!preg_match('/(.*)Controller/i', get_class($this), $r)) { - echo __("Controller::__construct() : Can not get or parse my own class name, exiting."); - $this->_stop(); - } - $this->name = $r[1]; + $this->name = substr(get_class($this), 0, strlen(get_class($this)) -10); } if ($this->viewPath == null) { $this->viewPath = Inflector::underscore($this->name); } - $this->modelClass = Inflector::classify($this->name); + + $this->modelClass = Inflector::singularize($this->name); $this->modelKey = Inflector::underscore($this->modelClass); $this->Components = new ComponentCollection(); @@ -339,7 +335,7 @@ class Controller extends Object { } /** - * Provides backwards compatbility avoid problems with empty and isset to alias properties. + * Provides backwards compatibility to avoid problems with empty and isset to alias properties. * * @return void */ @@ -828,9 +824,9 @@ class Controller extends Object { $viewClass = $this->viewClass; if ($this->viewClass != 'View') { - list($plugin, $viewClass) = pluginSplit($viewClass); + list($plugin, $viewClass) = pluginSplit($viewClass, true); $viewClass = $viewClass . 'View'; - App::import('View', $this->viewClass); + App::uses($viewClass, $plugin . 'View'); } $this->request->params['models'] = $this->modelNames; diff --git a/cake/libs/controller/pages_controller.php b/lib/Cake/Controller/PagesController.php similarity index 97% rename from cake/libs/controller/pages_controller.php rename to lib/Cake/Controller/PagesController.php index 65e8b0465..c842bc9ca 100644 --- a/cake/libs/controller/pages_controller.php +++ b/lib/Cake/Controller/PagesController.php @@ -19,6 +19,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppController', 'Controller'); + /** * Static content controller * diff --git a/cake/libs/controller/scaffold.php b/lib/Cake/Controller/Scaffold.php similarity index 99% rename from cake/libs/controller/scaffold.php rename to lib/Cake/Controller/Scaffold.php index ab66e137a..3eb718df1 100644 --- a/cake/libs/controller/scaffold.php +++ b/lib/Cake/Controller/Scaffold.php @@ -18,7 +18,7 @@ * @since Cake v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('View', 'Scaffold'); +App::uses('Scaffold', 'View'); /** * Scaffolding is a set of automatic actions for starting web development work faster. diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php new file mode 100644 index 000000000..a257b051f --- /dev/null +++ b/lib/Cake/Core/App.php @@ -0,0 +1,791 @@ + array('extends' => null, 'core' => true), + 'file' => array('extends' => null, 'core' => true), + 'model' => array('extends' => 'AppModel', 'core' => false), + 'behavior' => array('extends' => 'ModelBehavior', 'core' => true), + 'controller' => array('suffix' => 'Controller', 'extends' => 'AppController', 'core' => true), + 'component' => array('suffix' => 'Component', 'extends' => null, 'core' => true), + 'lib' => array('extends' => null, 'core' => true), + 'view' => array('suffix' => 'View', 'extends' => null, 'core' => true), + 'helper' => array('suffix' => 'Helper', 'extends' => 'AppHelper', 'core' => true), + 'vendor' => array('extends' => null, 'core' => true), + 'shell' => array('suffix' => 'Shell', 'extends' => 'Shell', 'core' => true), + 'plugin' => array('extends' => null, 'core' => true) + ); + +/** + * Paths to search for files. + * + * @var array + */ + public static $search = array(); + +/** + * Whether or not to return the file that is loaded. + * + * @var boolean + */ + public static $return = false; + +/** + * Determines if $__maps and $__paths cache should be written. + * + * @var boolean + */ + private static $__cache = false; + +/** + * Holds key/value pairs of $type => file path. + * + * @var array + */ + private static $__map = array(); + +/** + * Holds paths for deep searching of files. + * + * @var array + */ + private static $__paths = array(); + +/** + * Holds loaded files. + * + * @var array + */ + private static $__loaded = array(); + +/** + * Holds and key => value array of object types. + * + * @var array + */ + private static $__objects = array(); + +/** + * Holds the location of each class + * + */ + private static $__classMap = array(); + +/** + * Holds the possible paths for each package name + * + */ + private static $__packages = array(); + +/** + * Holds the templates for each customizable package path in the application + * + */ + private static $__packageFormat = array(); + +/** + * Maps an old style CakePHP class type to the corresponding package + * + */ + public static $legacy = array( + 'models' => 'Model', + 'behaviors' => 'Model/Behavior', + 'datasources' => 'Model/Datasource', + 'controllers' => 'Controller', + 'components' => 'Controller/Component', + 'views' => 'View', + 'helpers' => 'View/Helper', + 'shells' => 'Console/Command', + 'libs' => 'Lib' + ); + +/** + * Inicates whether the class cache should be stored again because of an addition to it + * + */ + private static $_cacheChange = false; + +/** + * Inicates whether the object cache should be stored again because of an addition to it + * + */ + private static $_objectCacheChange = false; + +/** + * Used to read information stored path + * + * Usage: + * + * `App::path('Model'); will return all paths for models` + * + * `App::path('Model/Datasource', 'MyPlugin'); will return the path for datasources under the 'MyPlugin' plugin` + * + * @param string $type type of path + * @param string $plugin name of plugin + * @return string array + */ + public static function path($type, $plugin = null) { + if (!empty(self::$legacy[$type])) { + $type = self::$legacy[$type]; + } + + if (!empty($plugin)) { + $path = array(); + $pluginPath = self::pluginPath($plugin); + if (!empty(self::$__packageFormat[$type])) { + foreach (self::$__packageFormat[$type] as $f) { + $path[] = sprintf($f, $pluginPath); + } + } + $path[] = $pluginPath . 'libs' . DS . $type . DS; + return $path; + } + + if (!isset(self::$__packages[$type])) { + return array(); + } + return self::$__packages[$type]; + } + +/** + * Sets up each package location on the file system. You can configure multiple search paths + * for each package, those will be used to look for files one folder at a time in the specified order + * All paths should be terminated with a Directory separator + * + * Usage: + * + * `App::build(array(Model' => array('/a/full/path/to/models/'))); will setup a new search path for the Model package` + * + * `App::build(array('Model' => array('/path/to/models/')), true); will setup the path as the only valid path for searching models` + * + * `App::build(array('View/Helper' => array('/path/to/models/', '/another/path/))); will setup multiple search paths for helpers` + * + * @param array $paths associative array with package names as keys and a list of directories for new search paths + * @param boolean $reset true will set paths, false merges paths [default] false + * @return void + */ + public static function build($paths = array(), $reset = false) { + if (empty(self::$__packageFormat)) { + self::$__packageFormat = array( + 'Model' => array('%s' . 'models' . DS), + 'Model/Behavior' => array('%s' . 'models' . DS . 'behaviors' . DS), + 'Model/Datasource' => array('%s' . 'models' . DS . 'datasources' . DS), + 'Model/Datasource/Database' => array('%s' . 'models' . DS . 'datasources' . DS . 'database' . DS), + 'Model/Datasource/Session' => array('%s' . 'models' . DS . 'datasources' . DS . 'session' . DS), + 'Controller' => array('%s' . 'controllers' . DS), + 'Controller/Component' => array('%s' . 'controllers' . DS . 'components' . DS), + 'View' => array('%s' . 'views' . DS), + 'View/Helper' => array('%s' . 'views' . DS . 'helpers' . DS), + 'Console' => array( + '%s' . 'console' . DS, + '%s' . 'vendors' . DS . 'shells' . DS, + VENDORS . 'shells' . DS + ), + 'Console/Command' => array( + '%s' . 'console' . DS . 'shells' . DS, + '%s' . 'vendors' . DS . 'shells' . DS, + VENDORS . 'shells' . DS + ), + 'Console/Command/Task' => array( + '%s' . 'console' . DS . 'shells' . DS . 'tasks' . DS, + '%s' . 'vendors' . DS . 'shells' . DS . 'tasks' . DS, + VENDORS . 'shells' . DS . 'tasks' . DS + ), + 'Lib' => array('%s' . 'libs' . DS), + 'locales' => array('%s' . 'locale' . DS), + 'vendors' => array('%s' . 'vendors' . DS, VENDORS), + 'plugins' => array(APP . 'plugins' . DS, CAKE_CORE_INCLUDE_PATH . DS . 'plugins' . DS) + ); + } + + if ($reset == true) { + foreach ($paths as $type => $new) { + if (!empty(self::$legacy[$type])) { + $type = self::$legacy[$type]; + } + self::$__packages[$type] = (array)$new; + } + return $paths; + } + + //Provides Backwards compatibility for old-style package names + $legacyPaths = array(); + foreach ($paths as $type => $path) { + if (!empty(self::$legacy[$type])) { + $type = self::$legacy[$type]; + } + $legacyPaths[$type] = $path; + } + + $paths = $legacyPaths; + $defaults = array(); + foreach (self::$__packageFormat as $package => $format) { + foreach ($format as $f) { + $defaults[$package][] = sprintf($f, APP); + } + } + + $mergeExclude = array('Lib', 'locales', 'vendors', 'plugins'); + $appLibs = empty($paths['Lib']) ? $defaults['Lib'] : $paths['Lib']; + + foreach ($defaults as $type => $default) { + if (empty(self::$__packages[$type]) || empty($paths)) { + self::$__packages[$type] = $default; + } + + if (!empty($paths[$type])) { + $path = array_merge((array)$paths[$type], self::$__packages[$type]); + } else { + $path = self::$__packages[$type]; + } + + self::$__packages[$type] = array_values(array_unique($path)); + } + } + +/** + * Gets the path that a plugin is on. Searches through the defined plugin paths. + * + * Usage: + * + * `App::pluginPath('MyPlugin'); will return the full path to 'MyPlugin' plugin'` + * + * @param string $plugin CamelCased/lower_cased plugin name to find the path of. + * @return string full path to the plugin. + */ + public static function pluginPath($plugin) { + $pluginDir = Inflector::underscore($plugin); + foreach (self::$__packages['plugins'] as $pluginPath) { + if (is_dir($pluginPath . $pluginDir)) { + return $pluginPath . $pluginDir . DS ; + } + } + return self::$__packages['plugins'][0] . $pluginDir . DS; + } + +/** + * Finds the path that a theme is on. Searches through the defined theme paths. + * + * Usage: + * + * `App::themePath('MyTheme'); will return the full path to the 'MyTheme' theme` + * + * @param string $theme lower_cased theme name to find the path of. + * @return string full path to the theme. + */ + public static function themePath($theme) { + $themeDir = 'themed' . DS . Inflector::underscore($theme); + foreach (self::$__packages['View'] as $path) { + if (is_dir($path . $themeDir)) { + return $path . $themeDir . DS ; + } + } + return self::$__packages['View'][0] . $themeDir . DS; + } + +/** + * Returns the full path to a package inside the CakePHP core + * + * Usage: + * + * `App::core('Cache/Engine'); will return the full path to the cache engines package` + * + * @param string $type + * @return string full path to package + */ + public static function core($type) { + if ($type) { + return isset($paths[$type]) ? $paths[$type] : array(LIBS . $type . DS); + } + } + +/** + * Returns an array of objects of the given type. + * + * Example usage: + * + * `App::objects('plugin');` returns `array('DebugKit', 'Blog', 'User');` + * + * `App::objects('Controller');` returns `array('PagesController', 'BlogController');` + * + * You can also search only within a plugin's objects by using the plugin dot + * syntax. + * + * `App::objects('MyPlugin.Model');` returns `array('MyPluginPost', 'MyPluginComment');` + * + * @param string $type Type of object, i.e. 'Model', 'Controller', 'View/Helper', 'file', 'class' or 'plugin' + * @param mixed $path Optional Scan only the path given. If null, paths for the chosen type will be used. + * @param boolean $cache Set to false to rescan objects of the chosen type. Defaults to true. + * @return mixed Either false on incorrect / miss. Or an array of found objects. + */ + public static function objects($type, $path = null, $cache = true) { + $objects = array(); + $extension = '/\.php$/'; + $includeDirectories = false; + $name = $type; + + if ($type === 'plugin') { + $type = 'plugins'; + } + + if ($type == 'plugins') { + $extension = '/.*/'; + $includeDirectories = true; + } + + list($plugin, $type) = pluginSplit($type); + + if (isset(self::$legacy[$type . 's'])) { + $type = self::$legacy[$type . 's']; + } + + if ($type === 'file' && !$path) { + return false; + } elseif ($type === 'file') { + $extension = '/\.php$/'; + $name = $type . str_replace(DS, '', $path); + } + + if (empty(self::$__objects) && $cache === true) { + self::$__objects = Cache::read('object_map', '_cake_core_'); + } + + $cacheLocation = empty($plugin) ? 'app' : $plugin; + + if ($cache !== true || !isset(self::$__objects[$cacheLocation][$name])) { + $objects = array(); + + if (empty($path)) { + $path = self::path($type, $plugin); + } + + $items = array(); + + foreach ((array)$path as $dir) { + if ($dir != APP && is_dir($dir)) { + $files = new RegexIterator(new DirectoryIterator($dir), $extension); + foreach ($files as $file) { + if (!$file->isDot()) { + $isDir = $file->isDir() ; + if ($isDir && $includeDirectories) { + $objects[] = basename($file); + } elseif (!$includeDirectories && !$isDir) { + $objects[] = substr(basename($file), 0, -4); + } + } + } + } + } + + if ($type !== 'file') { + foreach ($objects as $key => $value) { + $objects[$key] = Inflector::camelize($value); + } + } + + if ($cache === true) { + self::$__cache = true; + } + if ($plugin) { + return $objects; + } + self::$__objects[$cacheLocation][$name] = $objects; + self::$_objectCacheChange = true; + } + + return self::$__objects[$cacheLocation][$name]; + } + +/** + * Allows you to modify the object listings that App maintains inside of it + * Useful for testing + * + * @param string $type Type of object listing you are changing + * @param array $values The values $type should be set to. + * @return void + */ + public static function setObjects($type, $values) { + list($plugin, $type) = pluginSplit($type); + $cacheLocation = empty($plugin) ? 'app' : $plugin; + self::$__objects[$cacheLocation][$type] = $values; + } + +/** + * Declares a package for a class. This package location will be used + * by the automatic class loader if the class is tried to be used + * + * Usage: + * + * `App::use('MyCustomController', 'Controller');` will setup the class to be found under Controller package + * + * `App::use('MyHelper', 'MyPlugin.View/Helper');` will setup the helper class to be found in plugin's helper package + * + * @param string $className the name of the class to configure package for + * @param string $location the package name + */ + public static function uses($className, $location) { + self::$__classMap[$className] = $location; + } + +/** + * Method to handle the automatic class loading. It will look for each class' package + * defined using App::uses() and with this information it will resolve the package name to a full path + * to load the class from. File name for each class should follow the class name. For instance, + * if a class is name `MyCustomClass` the file name should be `MyCustomClass.php` + * + * @param string $className the name of the class to load + */ + public static function load($className) { + if (isset(self::$__classMap[$className])) { + if ($file = self::__mapped($className)) { + return include $file; + } + + $parts = explode('.', self::$__classMap[$className], 2); + list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts)); + $paths = self::path($package, $plugin); + + if (empty($plugin)) { + $appLibs = empty(self::$__packages['Lib']) ? APPLIBS : current(self::$__packages['Lib']); + $paths[] = $appLibs . $package . DS; + $paths[] = LIBS . $package . DS; + } + + foreach ($paths as $path) { + $file = $path . $className . '.php'; + if (file_exists($file)) { + self::__map($file, $className); + return include $file; + } + } + + //To help apps migrate to 2.0 old style file names are allowed + foreach ($paths as $path) { + $underscored = Inflector::underscore($className); + $tries = array($path . $underscored . '.php'); + $parts = explode('_', $underscored); + if (count($parts) > 1) { + array_pop($parts); + $tries[] = $path . implode('_', $parts) . '.php'; + } + foreach ($tries as $file) { + if (file_exists($file)) { + self::__map($file, $className); + return include $file; + } + } + } + } + + return false; + } + +/** + * Finds classes based on $name or specific file(s) to search. Calling App::import() will + * not construct any classes contained in the files. It will only find and require() the file. + * + * @link http://book.cakephp.org/view/934/Using-App-import + * @param mixed $type The type of Class if passed as a string, or all params can be passed as + * an single array to $type, + * @param string $name Name of the Class or a unique name for the file + * @param mixed $parent boolean true if Class Parent should be searched, accepts key => value + * array('parent' => $parent ,'file' => $file, 'search' => $search, 'ext' => '$ext'); + * $ext allows setting the extension of the file name + * based on Inflector::underscore($name) . ".$ext"; + * @param array $search paths to search for files, array('path 1', 'path 2', 'path 3'); + * @param string $file full name of the file to search for including extension + * @param boolean $return, return the loaded file, the file must have a return + * statement in it to work: return $variable; + * @return boolean true if Class is already in memory or if file is found and loaded, false if not + */ + public static function import($type = null, $name = null, $parent = true, $search = array(), $file = null, $return = false) { + $ext = $plugin = $directory = null; + + if (is_array($type)) { + extract($type, EXTR_OVERWRITE); + } + + if (is_array($parent)) { + extract($parent, EXTR_OVERWRITE); + } + + if ($name == null && $file == null) { + return false; + } + + if (is_array($name)) { + foreach ($name as $class) { + if (!App::import(compact('type', 'parent', 'search', 'file', 'return') + array('name' => $class))) { + return false; + } + } + return true; + } + + $originalType = $type = strtolower($type); + $specialPackage = in_array($type, array('file', 'vendor')); + if (!$specialPackage && isset(self::$legacy[$type . 's'])) { + $type = self::$legacy[$type . 's']; + } + list($plugin, $name) = pluginSplit($name); + if (!empty($plugin)) { + $plugin = Inflector::camelize($plugin); + } + + if (!$specialPackage) { + return self::_loadClass($name, $plugin, $type, $originalType, $parent); + } + + if ($type == 'file' && !empty($file)) { + return self::_loadFile($name, $plugin, $search, $file, $return); + } + + if ($type == 'vendor') { + return self::_loadVendor($name, $plugin, $file, $ext); + } + + return false; + } + +/** + * Helper function to include classes + * This is a compatibility wrapper around using App::uses() and automatic class loading + * + * @param string $name unique name of the file for identifying it inside the application + * @param string $plugin camel cased plugin name if any + * @param string $type name of the packed where the class is located + * @param string $file filename if known, the $name param will be used otherwise + * @param string $originalType type name as supplied initially by the user + * @param boolean $parent whether to load the class parent or not + * @return boolean true indicating the successful load and existence of the class + */ + private function _loadClass($name, $plugin, $type, $originalType, $parent) { + if ($type == 'Console/Command' && $name == 'Shell') { + $type = 'Console'; + } else if (isset(self::$types[$originalType]['suffix'])) { + $suffix = self::$types[$originalType]['suffix']; + $name .= ($suffix == $name) ? '' : $suffix; + } + + if ($parent && isset(self::$types[$originalType]['extends'])) { + $extends = self::$types[$originalType]['extends']; + App::uses($extends, $type); + if ($plugin && in_array($originalType, array('controller', 'model'))) { + App::uses($plugin . $extends, $plugin . '.' .$type); + } + } + if ($plugin) { + $plugin .= '.'; + } + $name = Inflector::camelize($name); + App::uses($name, $plugin . $type); + return class_exists($name); + } + +/** + * Helper function to include single files + * + * @param string $name unique name of the file for identifying it inside the application + * @param string $plugin camel cased plugin name if any + * @param array $search list of paths to search the file into + * @param string $file filename if known, the $name param will be used otherwise + * @param boolean $return whether this function should return the contents of the file after being parsed by php or just a success notice + * @return mixed, if $return contents of the file after php parses it, boolean indicating success otherwise + */ + private function _loadFile($name, $plugin, $search, $file, $return) { + $mapped = self::__mapped($name, $plugin); + if ($mapped) { + $file = $mapped; + } else if (!empty($search)) { + foreach ($search as $path) { + $found = false; + if (file_exists($path . $file)) { + $file = $path . $file; + $found = true; + break; + } + if (empty($found)) { + $file = false; + } + } + } + if (!empty($file) && file_exists($file)) { + self::__map($file, $name, $plugin); + $returnValue = include $file; + if ($return) { + return $returnValue; + } + return (bool) $returnValue; + } + return false; + } + +/** + * Helper function to load files from vendors folders + * + * @param string $name unique name of the file for identifying it inside the application + * @param string $plugin camel cased plugin name if any + * @param string $file file name if known + * @param string $ext file extension if known + * @return boolean true if the file was loaded successfully, false otherwise + */ + private function _loadVendor($name, $plugin, $file, $ext) { + if ($mapped = self::__mapped($name, $plugin)) { + return (bool) include_once($mapped); + } + $fileTries = array(); + $paths = ($plugin) ? App::path('vendors', $plugin) : App::path('vendors'); + if (empty($ext)) { + $ext = 'php'; + } + if (empty($file)) { + $fileTries[] = $name . '.' . $ext; + $fileTries[] = Inflector::underscore($name) . '.' . $ext; + } else { + $fileTries[] = $file; + } + + foreach ($fileTries as $file) { + foreach ($paths as $path) { + if (file_exists($path . $file)) { + self::__map($path . $file, $name, $plugin); + return (bool) include($path . $file); + } + } + } + return false; + } + +/** + * Initializes the cache for App, registers a shutdown function. + * + * @return void + */ + public static function init() { + self::$__map = (array)Cache::read('file_map', '_cake_core_'); + self::$__objects = (array)Cache::read('object_map', '_cake_core_'); + register_shutdown_function(array('App', 'shutdown')); + } + +/** + * Maps the $name to the $file. + * + * @param string $file full path to file + * @param string $name unique name for this map + * @param string $plugin camelized if object is from a plugin, the name of the plugin + * @return void + * @access private + */ + private static function __map($file, $name, $plugin = null) { + if ($plugin) { + self::$__map['Plugin'][$plugin][$name] = $file; + } else { + self::$__map[$name] = $file; + } + self::$_cacheChange = true; + } + +/** + * Returns a file's complete path. + * + * @param string $name unique name + * @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 + */ + private static function __mapped($name, $plugin = null) { + if ($plugin) { + if (isset(self::$__map['Plugin'][$plugin][$name])) { + return self::$__map['Plugin'][$plugin][$name]; + } + return false; + } + + if (isset(self::$__map[$name])) { + return self::$__map[$name]; + } + return false; + } + +/** + * Object destructor. + * + * Writes cache file if changes have been made to the $__map or $__paths + * + * @return void + */ + public static function shutdown() { + if (self::$__cache && self::$_cacheChange) { + Cache::write('file_map', array_filter(self::$__map), '_cake_core_'); + } + if (self::$__cache && self::$_objectCacheChange) { + Cache::write('object_map', self::$__objects, '_cake_core_'); + } + } +} diff --git a/cake/libs/configure.php b/lib/Cake/Core/Configure.php similarity index 99% rename from cake/libs/configure.php rename to lib/Cake/Core/Configure.php index 29633732c..c1ed73fc8 100644 --- a/cake/libs/configure.php +++ b/lib/Cake/Core/Configure.php @@ -307,7 +307,7 @@ class Configure { */ public static function version() { if (!isset(self::$_values['Cake']['version'])) { - require(CORE_PATH . 'cake' . DS . 'config' . DS . 'config.php'); + require(LIBS . 'config' . DS . 'config.php'); self::write($config); } return self::$_values['Cake']['version']; diff --git a/cake/libs/object.php b/lib/Cake/Core/Object.php similarity index 99% rename from cake/libs/object.php rename to lib/Cake/Core/Object.php index 9096ae121..28a3d0d29 100644 --- a/cake/libs/object.php +++ b/lib/Cake/Core/Object.php @@ -20,6 +20,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Set', 'Utility'); + /** * Object class provides a few generic methods used in several subclasses. * @@ -64,9 +66,7 @@ class Object { if (empty($url)) { return false; } - if (!class_exists('dispatcher')) { - require LIBS . 'dispatcher.php'; - } + App::uses('Dispatcher', 'Routing'); if (in_array('return', $extra, true)) { $extra = array_merge($extra, array('return' => 0, 'autoRender' => 1)); } diff --git a/cake/libs/error/error_handler.php b/lib/Cake/Error/ErrorHandler.php similarity index 94% rename from cake/libs/error/error_handler.php rename to lib/Cake/Error/ErrorHandler.php index 775bd8d43..6787e23f7 100644 --- a/cake/libs/error/error_handler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -19,6 +19,11 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Debugger', 'Utility'); +App::uses('CakeLog', 'Log'); +App::uses('ExceptionRenderer', 'Error'); +App::uses('AppController', 'Controller'); + /** * * Error Handler provides basic error and exception handling for your application. It captures and @@ -102,12 +107,8 @@ class ErrorHandler { * @see http://php.net/manual/en/function.set-exception-handler.php */ public static function handleException(Exception $exception) { - App::import('Core', 'error/ExceptionRenderer'); $config = Configure::read('Exception'); if (!empty($config['log'])) { - if (!class_exists('CakeLog')) { - require LIBS . 'cake_log.php'; - } $message = sprintf("[%s] %s\n%s", get_class($exception), $exception->getMessage(), @@ -116,7 +117,7 @@ class ErrorHandler { CakeLog::write(LOG_ERR, $message); } if ($config['renderer'] !== 'ExceptionRenderer') { - App::import('Lib', $config['renderer']); + App::uses($config['renderer'], 'Error'); } $error = new $config['renderer']($exception); $error->render(); @@ -146,9 +147,6 @@ class ErrorHandler { $debug = Configure::read('debug'); if ($debug) { - if (!class_exists('Debugger')) { - require LIBS . 'debugger.php'; - } $data = array( 'level' => $log, 'code' => $code, @@ -162,14 +160,8 @@ class ErrorHandler { ); return Debugger::getInstance()->outputError($data); } else { - if (!class_exists('CakeLog')) { - require LIBS . 'cake_log.php'; - } $message = $error . ' (' . $code . '): ' . $description . ' in [' . $file . ', line ' . $line . ']'; if (!empty($errorConfig['trace'])) { - if (!class_exists('Debugger')) { - require LIBS . 'debugger.php'; - } $trace = Debugger::trace(array('start' => 1, 'format' => 'log')); $message .= "\nTrace:\n" . $trace . "\n"; } diff --git a/cake/libs/error/exception_renderer.php b/lib/Cake/Error/ExceptionRenderer.php similarity index 98% rename from cake/libs/error/exception_renderer.php rename to lib/Cake/Error/ExceptionRenderer.php index 328fffd8d..1b0eb68fe 100644 --- a/cake/libs/error/exception_renderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -19,6 +19,9 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('Sanitize', 'Utility'); + /** * Exception Renderer. * @@ -86,8 +89,6 @@ class ExceptionRenderer { * @param array $messages Error messages */ function __construct(Exception $exception) { - App::import('Core', 'Sanitize'); - $this->controller = $this->_getController($exception); if (method_exists($this->controller, 'apperror')) { @@ -142,7 +143,7 @@ class ExceptionRenderer { */ protected function _getController($exception) { static $__previousError = null; - App::import('Controller', 'CakeError'); + App::uses('CakeErrorController', 'Controller'); if ($__previousError != $exception) { $__previousError = $exception; diff --git a/cake/libs/error/exceptions.php b/lib/Cake/Error/exceptions.php similarity index 89% rename from cake/libs/error/exceptions.php rename to lib/Cake/Error/exceptions.php index 7baa957c1..232379d02 100644 --- a/cake/libs/error/exceptions.php +++ b/lib/Cake/Error/exceptions.php @@ -20,12 +20,14 @@ /** * Parent class for all of the HTTP related exceptions in CakePHP. - * All HTTP status/error related exceptions should extend this class so + * All HTTP status/error related exceptions should extend this class so * catch blocks can be specifically typed. * * @package cake.libs */ -class HttpException extends RuntimeException { } +if (!class_exists('HttpException')) { + class HttpException extends RuntimeException { } +} /** * Represents an HTTP 400 error. @@ -198,12 +200,12 @@ class CakeException extends RuntimeException { } /** - * Missing Controller exception - used when a controller + * Missing Controller exception - used when a controller * cannot be found. * * @package cake.libs */ -class MissingControllerException extends CakeException { +class MissingControllerException extends CakeException { protected $_messageTemplate = 'Controller class %s could not be found.'; public function __construct($message, $code = 404) { @@ -212,12 +214,12 @@ class MissingControllerException extends CakeException { } /** - * Missing Action exception - used when a controller action + * Missing Action exception - used when a controller action * cannot be found. * * @package cake.libs */ -class MissingActionException extends CakeException { +class MissingActionException extends CakeException { protected $_messageTemplate = 'Action %s::%s() could not be found.'; public function __construct($message, $code = 404) { @@ -225,12 +227,12 @@ class MissingActionException extends CakeException { } } /** - * Private Action exception - used when a controller action + * Private Action exception - used when a controller action * is protected, or starts with a `_`. * * @package cake.libs */ -class PrivateActionException extends CakeException { +class PrivateActionException extends CakeException { protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.'; public function __construct($message, $code = 404, Exception $previous = null) { @@ -243,7 +245,7 @@ class PrivateActionException extends CakeException { * * @package cake.libs */ -class MissingComponentFileException extends CakeException { +class MissingComponentFileException extends CakeException { protected $_messageTemplate = 'Component File "%s" is missing.'; } @@ -252,7 +254,7 @@ class MissingComponentFileException extends CakeException { * * @package cake.libs */ -class MissingComponentClassException extends CakeException { +class MissingComponentClassException extends CakeException { protected $_messageTemplate = 'Component class "%s" is missing.'; } @@ -275,7 +277,7 @@ class MissingBehaviorClassException extends CakeException { } * * @package cake.libs */ -class MissingViewException extends CakeException { +class MissingViewException extends CakeException { protected $_messageTemplate = 'View file "%s" is missing.'; } @@ -284,7 +286,7 @@ class MissingViewException extends CakeException { * * @package cake.libs */ -class MissingLayoutException extends CakeException { +class MissingLayoutException extends CakeException { protected $_messageTemplate = 'Layout file "%s" is missing.'; } @@ -293,7 +295,7 @@ class MissingLayoutException extends CakeException { * * @package cake.libs */ -class MissingHelperFileException extends CakeException { +class MissingHelperFileException extends CakeException { protected $_messageTemplate = 'Helper File "%s" is missing.'; } @@ -302,7 +304,7 @@ class MissingHelperFileException extends CakeException { * * @package cake.libs */ -class MissingHelperClassException extends CakeException { +class MissingHelperClassException extends CakeException { protected $_messageTemplate = 'Helper class "%s" is missing.'; } @@ -330,7 +332,7 @@ class MissingConnectionException extends CakeException { * * @package cake.libs */ -class MissingTaskFileException extends CakeException { +class MissingTaskFileException extends CakeException { protected $_messageTemplate = 'Task file "%s" is missing.'; } @@ -339,7 +341,7 @@ class MissingTaskFileException extends CakeException { * * @package cake.libs */ -class MissingTaskClassException extends CakeException { +class MissingTaskClassException extends CakeException { protected $_messageTemplate = 'Task class "%s" is missing.'; } @@ -348,7 +350,7 @@ class MissingTaskClassException extends CakeException { * * @package cake.libs */ -class MissingShellMethodException extends CakeException { +class MissingShellMethodException extends CakeException { protected $_messageTemplate = "Unknown command %1\$s %2\$s.\nFor usage try `cake %1\$s --help`"; } @@ -357,7 +359,7 @@ class MissingShellMethodException extends CakeException { * * @package cake.libs */ -class MissingShellClassException extends CakeException { +class MissingShellClassException extends CakeException { protected $_messageTemplate = "Shell class %s could not be loaded."; } @@ -366,7 +368,7 @@ class MissingShellClassException extends CakeException { * * @package cake.libs */ -class MissingShellFileException extends CakeException { +class MissingShellFileException extends CakeException { protected $_messageTemplate = "Shell file %s could not be loaded."; } @@ -406,6 +408,15 @@ class MissingModelException extends CakeException { protected $_messageTemplate = 'Model %s could not be found.'; } +/** + * Exception Raised when a test loader could not be found + * + * @package cake.libs + */ +class MissingTestLoaderException extends CakeException { + protected $_messageTemplate = 'Test loader %s could not be found.'; +} + /** * Exception class for Cache. This exception will be thrown from Cache when it @@ -470,4 +481,3 @@ class XmlException extends CakeException { } * @package cake.libs */ class ConsoleException extends CakeException { } - diff --git a/cake/libs/i18n.php b/lib/Cake/I18n/I18n.php similarity index 99% rename from cake/libs/i18n.php rename to lib/Cake/I18n/I18n.php index b140790d4..e05e1bcdc 100644 --- a/cake/libs/i18n.php +++ b/lib/Cake/I18n/I18n.php @@ -20,8 +20,8 @@ /** * Included libraries. */ -App::import('Core', 'L10n'); -App::import('Core', 'Multibyte'); +App::uses('L10n', 'I18n'); +App::uses('Multibyte', 'I18n'); /** * I18n handles translation of Text and time format strings. @@ -99,7 +99,7 @@ class I18n { /** * Used by the translation functions in basics.php - * Can also be used like I18n::translate(); but only if the App::import('I18n'); has been used to load the class. + * Returns a translated string based on current language and translation files stored in locale folder * * @param string $singular String to translate * @param string $plural Plural string (if any) diff --git a/cake/libs/l10n.php b/lib/Cake/I18n/L10n.php similarity index 99% rename from cake/libs/l10n.php rename to lib/Cake/I18n/L10n.php index 2da41af34..c9bef1e79 100644 --- a/cake/libs/l10n.php +++ b/lib/Cake/I18n/L10n.php @@ -16,7 +16,7 @@ * @since CakePHP(tm) v 1.2.0.4116 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'CakeRequest'); +App::uses('CakeRequest', 'Network'); /** * Localization diff --git a/cake/libs/multibyte.php b/lib/Cake/I18n/Multibyte.php similarity index 99% rename from cake/libs/multibyte.php rename to lib/Cake/I18n/Multibyte.php index 123d3d11b..9ad06c093 100644 --- a/cake/libs/multibyte.php +++ b/lib/Cake/I18n/Multibyte.php @@ -1076,7 +1076,7 @@ class Multibyte { return null; } if (!Configure::configured('_cake_core_')) { - App::import('Core', 'config/PhpReader'); + App::uses('PhpReader', 'Configure'); Configure::config('_cake_core_', new PhpReader(CAKE . 'config' . DS)); } Configure::load('unicode' . DS . 'casefolding' . DS . $range, '_cake_core_'); diff --git a/cake/libs/cake_log.php b/lib/Cake/Log/CakeLog.php similarity index 88% rename from cake/libs/cake_log.php rename to lib/Cake/Log/CakeLog.php index e632c2898..0a1875a23 100644 --- a/cake/libs/cake_log.php +++ b/lib/Cake/Log/CakeLog.php @@ -36,22 +36,6 @@ define('LOG_INFO', 6); } -/** - * CakeLogStreamInterface is the interface that should be implemented - * by all classes that are going to be used as Log streams. - * - * @package cake.libs - */ -interface CakeLogInterface { -/** - * Write method to handle writes being made to the Logger - * - * @param string $type - * @param string $message - * @return void - */ - public function write($type, $message); -} /** * Logs messages to configured Log adapters. One or more adapters can be configured @@ -121,15 +105,9 @@ class CakeLog { * @return mixed boolean false on any failures, string of classname to use if search was successful. */ protected static function _getLogger($loggerName) { - list($plugin, $loggerName) = pluginSplit($loggerName); + list($plugin, $loggerName) = pluginSplit($loggerName, true); - if ($plugin) { - App::import('Lib', $plugin . '.log/' . $loggerName); - } else { - if (!App::import('Lib', 'log/' . $loggerName)) { - App::import('Core', 'log/' . $loggerName); - } - } + App::uses($loggerName, $plugin . 'Log/Engine'); if (!class_exists($loggerName)) { throw new CakeLogException(__('Could not load class %s', $loggerName)); } @@ -162,9 +140,7 @@ class CakeLog { * @return void */ protected static function _autoConfig() { - if (!class_exists('FileLog')) { - App::import('Core', 'log/FileLog'); - } + self::_getLogger('FileLog'); self::$_streams['default'] = new FileLog(array('path' => LOGS)); } diff --git a/lib/Cake/Log/CakeLogInterface.php b/lib/Cake/Log/CakeLogInterface.php new file mode 100644 index 000000000..0b2cd1a3c --- /dev/null +++ b/lib/Cake/Log/CakeLogInterface.php @@ -0,0 +1,18 @@ + array('with' => 'Permission')); -} - -/** - * Action for Access Control Object - * - * @package cake.libs.model - */ -class AcoAction extends AppModel { - -/** - * Model name - * - * @var string - * @access public - */ - public $name = 'AcoAction'; - -/** - * ACO Actions belong to ACOs - * - * @var array - * @access public - */ - public $belongsTo = array('Aco'); -} - -/** - * Access Request Object - * - * @package cake.libs.model - */ -class Aro extends AclNode { - -/** - * Model name - * - * @var string - * @access public - */ - public $name = 'Aro'; - -/** - * AROs are linked to ACOs by means of Permission - * - * @var array - * @access public - */ - public $hasAndBelongsToMany = array('Aco' => array('with' => 'Permission')); -} - -/** - * Permissions linking AROs with ACOs - * - * @package cake.libs.model - */ -class Permission extends AppModel { - -/** - * Model name - * - * @var string - * @access public - */ - public $name = 'Permission'; - -/** - * Explicitly disable in-memory query caching - * - * @var boolean - * @access public - */ - public $cacheQueries = false; - -/** - * Override default table name - * - * @var string - * @access public - */ - public $useTable = 'aros_acos'; - -/** - * Permissions link AROs with ACOs - * - * @var array - * @access public - */ - public $belongsTo = array('Aro', 'Aco'); - -/** - * No behaviors for this model - * - * @var array - * @access public - */ - public $actsAs = null; - -/** - * Constructor, used to tell this model to use the - * database configured for ACL - */ - function __construct() { - $config = Configure::read('Acl.database'); - if (!empty($config)) { - $this->useDbConfig = $config; - } - parent::__construct(); - } -} diff --git a/lib/Cake/Model/Aco.php b/lib/Cake/Model/Aco.php new file mode 100644 index 000000000..f8a92bcf4 --- /dev/null +++ b/lib/Cake/Model/Aco.php @@ -0,0 +1,48 @@ + array('with' => 'Permission')); +} \ No newline at end of file diff --git a/lib/Cake/Model/AcoAction.php b/lib/Cake/Model/AcoAction.php new file mode 100644 index 000000000..fe9734228 --- /dev/null +++ b/lib/Cake/Model/AcoAction.php @@ -0,0 +1,48 @@ + array('with' => 'Permission')); +} diff --git a/cake/libs/model/behaviors/acl.php b/lib/Cake/Model/Behavior/AclBehavior.php similarity index 100% rename from cake/libs/model/behaviors/acl.php rename to lib/Cake/Model/Behavior/AclBehavior.php diff --git a/cake/libs/model/behaviors/containable.php b/lib/Cake/Model/Behavior/ContainableBehavior.php similarity index 100% rename from cake/libs/model/behaviors/containable.php rename to lib/Cake/Model/Behavior/ContainableBehavior.php diff --git a/cake/libs/model/behaviors/translate.php b/lib/Cake/Model/Behavior/TranslateBehavior.php similarity index 99% rename from cake/libs/model/behaviors/translate.php rename to lib/Cake/Model/Behavior/TranslateBehavior.php index ff7c9bdc5..416881c4c 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('I18n', 'I18n'); + /** * Translate behavior * @@ -335,9 +337,6 @@ class TranslateBehavior extends ModelBehavior { */ protected function _getLocale($model) { if (!isset($model->locale) || is_null($model->locale)) { - if (!class_exists('I18n')) { - App::import('Core', 'i18n'); - } $I18n = I18n::getInstance(); $I18n->l10n->get(Configure::read('Config.language')); $model->locale = $I18n->l10n->locale; diff --git a/cake/libs/model/behaviors/tree.php b/lib/Cake/Model/Behavior/TreeBehavior.php similarity index 100% rename from cake/libs/model/behaviors/tree.php rename to lib/Cake/Model/Behavior/TreeBehavior.php diff --git a/cake/libs/model/behavior_collection.php b/lib/Cake/Model/BehaviorCollection.php similarity index 95% rename from cake/libs/model/behavior_collection.php rename to lib/Cake/Model/BehaviorCollection.php index 8bd92198f..341e5ccc1 100644 --- a/cake/libs/model/behavior_collection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -18,6 +18,9 @@ * @since CakePHP(tm) v 1.2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('ObjectCollection', 'Utility'); + /** * Model behavior collection class. * @@ -94,26 +97,21 @@ class BehaviorCollection extends ObjectCollection { * @param string $behavior CamelCased name of the behavior to load * @param array $config Behavior configuration parameters * @return boolean True on success, false on failure - * @throws MissingBehaviorFileException or MissingBehaviorClassException when a behavior could not be found. + * @throws MissingBehaviorClassException when a behavior could not be found. */ public function load($behavior, $config = array()) { if (is_array($config) && isset($config['className'])) { $alias = $behavior; $behavior = $config['className']; } - list($plugin, $name) = pluginSplit($behavior); + list($plugin, $name) = pluginSplit($behavior, true); if (!isset($alias)) { $alias = $name; } $class = $name . 'Behavior'; - if (!App::import('Behavior', $behavior)) { - throw new MissingBehaviorFileException(array( - 'file' => Inflector::underscore($behavior) . '.php', - 'class' => $class - )); - } + App::uses($class, $plugin . 'Model/Behavior'); if (!class_exists($class)) { throw new MissingBehaviorClassException(array( 'file' => Inflector::underscore($behavior) . '.php', diff --git a/cake/libs/model/cake_schema.php b/lib/Cake/Model/CakeSchema.php similarity index 97% rename from cake/libs/model/cake_schema.php rename to lib/Cake/Model/CakeSchema.php index 5579540b0..37208581a 100644 --- a/cake/libs/model/cake_schema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -16,8 +16,9 @@ * @since CakePHP(tm) v 1.2.0.5550 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Model'); -App::import('Core', 'ConnectionManager'); +App::uses('Model', 'Model'); +App::uses('AppModel', 'Model'); +App::uses('ConnectionManager', 'Model'); /** * Base Class for Schema management @@ -204,9 +205,8 @@ class CakeSchema extends Object { )); $db = ConnectionManager::getDataSource($connection); - App::import('Model', 'AppModel'); if (isset($this->plugin)) { - App::import('Model', Inflector::camelize($this->plugin) . 'AppModel'); + App::uses(Inflector::camelize($this->plugin) . 'AppModel', $this->plugin . '.Model'); } $tables = array(); @@ -219,21 +219,29 @@ class CakeSchema extends Object { if (!is_array($models) && $models !== false) { if (isset($this->plugin)) { - $models = App::objects('model', App::pluginPath($this->plugin) . 'models' . DS, false); + $models = App::objects($this->plugin . '.Model', null, false); } else { - $models = App::objects('model'); + $models = App::objects('Model'); } } if (is_array($models)) { foreach ($models as $model) { $importModel = $model; + $plugin = null; if (isset($this->plugin)) { - $importModel = $this->plugin . '.' . $model; + if ($model == $this->plugin . 'AppModel') { + continue; + } + $importModel = $model; + $plugin = $this->plugin . '.'; } - if (!App::import('Model', $importModel)) { + + App::uses($importModel, $plugin . 'Model'); + if (!class_exists($importModel)) { continue; } + $vars = get_class_vars($model); if (empty($vars['useDbConfig']) || $vars['useDbConfig'] != $connection) { continue; diff --git a/cake/libs/model/connection_manager.php b/lib/Cake/Model/ConnectionManager.php similarity index 53% rename from cake/libs/model/connection_manager.php rename to lib/Cake/Model/ConnectionManager.php index 7e3bd4f51..0f0ac3435 100644 --- a/cake/libs/model/connection_manager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -18,7 +18,8 @@ * @since CakePHP(tm) v 0.10.x.1402 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require LIBS . 'model' . DS . 'datasources' . DS . 'datasource.php'; + +App::uses('DataSource', 'Model/Datasource'); config('database'); /** @@ -34,7 +35,7 @@ class ConnectionManager { * @var DATABASE_CONFIG * @access public */ - public $config = null; + public static $config = null; /** * Holds instances DataSource objects @@ -42,7 +43,7 @@ class ConnectionManager { * @var array * @access protected */ - protected $_dataSources = array(); + protected static $_dataSources = array(); /** * Contains a list of all file and class names used in Connection settings @@ -50,32 +51,26 @@ class ConnectionManager { * @var array * @access protected */ - protected $_connectionsEnum = array(); + protected static $_connectionsEnum = array(); /** - * Constructor. + * Indicates if the init code for this class has alredy been executed + * + * @var boolean + */ + private static $_init = false; + +/** + * Loads connections configuration. * */ - function __construct() { + private static function init() { + include_once CONFIGS . 'database.php'; if (class_exists('DATABASE_CONFIG')) { - $this->config = new DATABASE_CONFIG(); - $this->_getConnectionObjects(); + self::$config = new DATABASE_CONFIG(); } - } - -/** - * Gets a reference to the ConnectionManger object instance - * - * @return object Instance - */ - public static function &getInstance() { - static $instance = array(); - - if (!$instance) { - $instance[0] = new ConnectionManager(); - } - - return $instance[0]; + register_shutdown_function('ConnectionManager::shutdown'); + self::$_init = true; } /** @@ -87,23 +82,27 @@ class ConnectionManager { * @throws MissingDatasourceFileException */ public static function getDataSource($name) { - $_this = ConnectionManager::getInstance(); - - if (!empty($_this->_dataSources[$name])) { - return $_this->_dataSources[$name]; + if (empty(self::$_init)) { + self::init(); } - if (empty($_this->_connectionsEnum[$name])) { - throw new MissingDatasourceConfigException(array('config' => $name)); + if (!empty(self::$_dataSources[$name])) { + $return = self::$_dataSources[$name]; + return $return; } - $conn = $_this->_connectionsEnum[$name]; + + if (empty(self::$_connectionsEnum[$name])) { + self::_getConnectionObject($name); + } + + self::loadDataSource($name); + $conn = self::$_connectionsEnum[$name]; $class = $conn['classname']; - $_this->loadDataSource($name); - $_this->_dataSources[$name] = new $class($_this->config->{$name}); - $_this->_dataSources[$name]->configKeyName = $name; + self::$_dataSources[$name] = new $class(self::$config->{$name}); + self::$_dataSources[$name]->configKeyName = $name; - return $_this->_dataSources[$name]; + return self::$_dataSources[$name]; } /** @@ -112,23 +111,25 @@ class ConnectionManager { * @return array List of available connections */ public static function sourceList() { - $_this = ConnectionManager::getInstance(); - return array_keys($_this->_dataSources); + if (empty(self::$_init)) { + self::init(); + } + return array_keys(self::$_dataSources); } /** * Gets a DataSource name from an object reference. * - * **Warning** this method may cause fatal errors in PHP4. - * * @param object $source DataSource object * @return string Datasource name, or null if source is not present * in the ConnectionManager. */ - public static function getSourceName(&$source) { - $_this = ConnectionManager::getInstance(); - foreach ($_this->_dataSources as $name => $ds) { - if ($ds == $source) { + public static function getSourceName($source) { + if (empty(self::$_init)) { + self::init(); + } + foreach (self::$_dataSources as $name => $ds) { + if ($ds === $source) { return $name; } } @@ -145,27 +146,31 @@ class ConnectionManager { * @throws MissingDatasourceFileException */ public static function loadDataSource($connName) { - $_this = ConnectionManager::getInstance(); + if (empty(self::$_init)) { + self::init(); + } if (is_array($connName)) { $conn = $connName; } else { - $conn = $_this->_connectionsEnum[$connName]; + $conn = self::$_connectionsEnum[$connName]; } - if (class_exists($conn['classname'])) { + if (class_exists($conn['classname'], false)) { return false; } - if (!empty($conn['parent'])) { - $_this->loadDataSource($conn['parent']); + $plugin = $package = null; + if (!empty($conn['plugin'])) { + $plugin = $conn['plugin'] . '.'; + } + if (!empty($conn['package'])) { + $package = '/' . $conn['package']; } - $conn = array_merge(array('plugin' => null, 'classname' => null, 'parent' => null), $conn); - $class = "{$conn['plugin']}.{$conn['classname']}"; - - if (!App::import('Datasource', $class, !is_null($conn['plugin']))) { - throw new MissingDatasourceFileException(array('class' => $conn['classname'], 'plugin' => $conn['plugin'])); + App::uses($conn['classname'], $plugin . 'Model/Datasource' . $package); + if (!class_exists($conn['classname'])) { + throw new MissingDatasourceFileException(array('class' => $conn['classname'], 'plugin' => $plugin)); } return true; } @@ -177,8 +182,10 @@ class ConnectionManager { * (as defined in Connections), and the value is an array with keys 'filename' and 'classname'. */ public static function enumConnectionObjects() { - $_this = ConnectionManager::getInstance(); - return $_this->_connectionsEnum; + if (empty(self::$_init)) { + self::init(); + } + return (array) self::$config; } /** @@ -188,16 +195,18 @@ class ConnectionManager { * @param array $config The DataSource configuration settings * @return object A reference to the DataSource object, or null if creation failed */ - public static function &create($name = '', $config = array()) { - $_this = ConnectionManager::getInstance(); + public static function create($name = '', $config = array()) { + if (empty(self::$_init)) { + self::init(); + } - if (empty($name) || empty($config) || array_key_exists($name, $_this->_connectionsEnum)) { + if (empty($name) || empty($config) || array_key_exists($name, self::$_connectionsEnum)) { $null = null; return $null; } - $_this->config->{$name} = $config; - $_this->_connectionsEnum[$name] = $_this->__connectionData($config); - $return = $_this->getDataSource($name); + self::$config->{$name} = $config; + self::$_connectionsEnum[$name] = self::_connectionData($config); + $return = self::getDataSource($name); return $return; } @@ -206,15 +215,11 @@ class ConnectionManager { * * @return void */ - protected function _getConnectionObjects() { - $connections = get_object_vars($this->config); - - if ($connections != null) { - foreach ($connections as $name => $config) { - $this->_connectionsEnum[$name] = $this->__connectionData($config); - } + protected static function _getConnectionObject($name) { + if (!empty(self::$config->{$name})) { + self::$_connectionsEnum[$name] = self::_connectionData(self::$config->{$name}); } else { - throw new MissingConnectionException(array('class' => 'ConnectionManager')); + throw new MissingDatasourceConfigException(array('config' => $name)); } } @@ -223,44 +228,22 @@ class ConnectionManager { * * @return array An indexed array with: filename, classname, plugin and parent */ - private function __connectionData($config) { - if (!isset($config['datasource'])) { - $config['datasource'] = 'dbo'; - } - $filename = $classname = $parent = $plugin = null; + private static function _connectionData($config) { + $package = $classname = $plugin = null; - if (!empty($config['driver'])) { - $parent = $this->__connectionData(array('datasource' => $config['datasource'])); - $parentSource = preg_replace('/_source$/', '', $parent['filename']); - - list($plugin, $classname) = pluginSplit($config['driver']); - if ($plugin) { - $source = Inflector::underscore($classname); - } else { - $source = $parentSource . '_' . $config['driver']; - $classname = Inflector::camelize(strtolower($source)); - } - $filename = $parentSource . DS . $source; - } else { - list($plugin, $classname) = pluginSplit($config['datasource']); - if ($plugin) { - $filename = Inflector::underscore($classname); - } else { - $filename = Inflector::underscore($config['datasource']); - } - if (substr($filename, -7) != '_source') { - $filename .= '_source'; - } - $classname = Inflector::camelize(strtolower($filename)); + list($plugin, $classname) = pluginSplit($config['datasource']); + if (strpos($classname, '/') !== false) { + $package = dirname($classname); + $classname = basename($classname); } - return compact('filename', 'classname', 'parent', 'plugin'); + return compact('package', 'classname', 'plugin'); } /** * Destructor. * */ - function __destruct() { + public static function shutdown() { if (Configure::read('Session.defaults') == 'database' && function_exists('session_write_close')) { session_write_close(); } diff --git a/cake/libs/cake_session.php b/lib/Cake/Model/Datasource/CakeSession.php similarity index 97% rename from cake/libs/cake_session.php rename to lib/Cake/Model/Datasource/CakeSession.php index ec7a86b27..45a70f69d 100644 --- a/cake/libs/cake_session.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -21,9 +21,9 @@ * @since CakePHP(tm) v .0.10.0.1222 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('Security')) { - App::import('Core', 'Security'); -} + +App::uses('Set', 'Utility'); +App::uses('Security', 'Utility'); /** * Session class for Cake. @@ -331,11 +331,12 @@ class CakeSession { * @return boolean */ protected static function _validAgentAndTime() { + $config = self::read('Config'); $validAgent = ( Configure::read('Session.checkAgent') === false || - self::$_userAgent == self::read('Config.userAgent') + self::$_userAgent == $config['userAgent'] ); - return ($validAgent && self::$time <= self::read('Config.time')); + return ($validAgent && self::$time <= $config['time']); } /** @@ -511,10 +512,7 @@ class CakeSession { */ protected static function _getHandler($handler) { list($plugin, $class) = pluginSplit($handler, true); - $found = App::import('Lib', $plugin . 'session/' . $class); - if (!$found) { - App::import('Core', 'session/' . $class); - } + App::uses($class, $plugin . 'Model/Datasource/Session'); if (!class_exists($class)) { throw new CakeSessionException(__('Could not load %s to handle the session.', $class)); } @@ -629,14 +627,14 @@ class CakeSession { self::$valid = false; return false; } - if (self::read('Config')) { + if ($config = self::read('Config')) { $sessionConfig = Configure::read('Session'); if (self::_validAgentAndTime()) { - $time = self::read('Config.time'); + $time = $config['time']; self::write('Config.time', self::$sessionTime); if (isset($sessionConfig['autoRegenerate']) && $sessionConfig['autoRegenerate'] === true) { - $check = self::read('Config.countdown'); + $check = $config['countdown']; $check -= 1; self::write('Config.countdown', $check); diff --git a/cake/libs/model/datasources/datasource.php b/lib/Cake/Model/Datasource/DataSource.php similarity index 100% rename from cake/libs/model/datasources/datasource.php rename to lib/Cake/Model/Datasource/DataSource.php diff --git a/cake/libs/model/datasources/dbo/dbo_mssql.php b/lib/Cake/Model/Datasource/Database/Mssql.php similarity index 100% rename from cake/libs/model/datasources/dbo/dbo_mssql.php rename to lib/Cake/Model/Datasource/Database/Mssql.php diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php similarity index 99% rename from cake/libs/model/datasources/dbo/dbo_mysql.php rename to lib/Cake/Model/Datasource/Database/Mysql.php index 29c98c4a0..5c924c801 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('DboSource', 'Model/Datasource'); + /** * MySQL DBO driver object * @@ -24,7 +26,7 @@ * * @package cake.libs.model.datasources.dbo */ -class DboMysql extends DboSource { +class Mysql extends DboSource { /** * Datasource description diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/lib/Cake/Model/Datasource/Database/Oracle.php similarity index 100% rename from cake/libs/model/datasources/dbo/dbo_oracle.php rename to lib/Cake/Model/Datasource/Database/Oracle.php diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php similarity index 99% rename from cake/libs/model/datasources/dbo/dbo_postgres.php rename to lib/Cake/Model/Datasource/Database/Postgres.php index 2b53aa1e5..b964d73ff 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('DboSource', 'Model/Datasource'); + /** * PostgreSQL layer for DBO. * @@ -24,7 +26,7 @@ * * @package cake.libs.model.datasources.dbo */ -class DboPostgres extends DboSource { +class Postgres extends DboSource { /** * Driver description diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php similarity index 99% rename from cake/libs/model/datasources/dbo/dbo_sqlite.php rename to lib/Cake/Model/Datasource/Database/Sqlite.php index 6819adf9a..0780622dd 100644 --- a/cake/libs/model/datasources/dbo/dbo_sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('DboSource', 'Model/Datasource'); + /** * DBO implementation for the SQLite3 DBMS. * @@ -24,7 +26,7 @@ * * @package cake.libs.model.datasources.dbo */ -class DboSqlite extends DboSource { +class Sqlite extends DboSource { /** * Datasource Description diff --git a/cake/libs/model/datasources/dbo_source.php b/lib/Cake/Model/Datasource/DboSource.php similarity index 99% rename from cake/libs/model/datasources/dbo_source.php rename to lib/Cake/Model/Datasource/DboSource.php index 1f85d0ac1..5e9b560d2 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -16,7 +16,10 @@ * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'String'); + +App::uses('DataSource', 'Model/Datasource'); +App::uses('String', 'Utility'); +App::uses('View', 'View'); /** * DboSource @@ -889,7 +892,6 @@ class DboSource extends DataSource { return; } if (PHP_SAPI != 'cli') { - App::import('Core', 'View'); $controller = null; $View = new View($controller, false); $View->set('logs', array($this->configKeyName => $log)); diff --git a/cake/libs/session/cache_session.php b/lib/Cake/Model/Datasource/Session/CacheSession.php similarity index 100% rename from cake/libs/session/cache_session.php rename to lib/Cake/Model/Datasource/Session/CacheSession.php diff --git a/cake/libs/session/database_session.php b/lib/Cake/Model/Datasource/Session/DatabaseSession.php similarity index 100% rename from cake/libs/session/database_session.php rename to lib/Cake/Model/Datasource/Session/DatabaseSession.php diff --git a/cake/libs/model/model.php b/lib/Cake/Model/Model.php similarity index 99% rename from cake/libs/model/model.php rename to lib/Cake/Model/Model.php index e5e0e4819..fa20aa513 100644 --- a/cake/libs/model/model.php +++ b/lib/Cake/Model/Model.php @@ -22,12 +22,13 @@ /** * Included libs */ -App::import('Core', 'ClassRegistry', false); -App::import('Core', 'Validation', false); -App::import('Core', 'String', false); -App::import('Model', 'BehaviorCollection', false); -App::import('Model', 'ModelBehavior', false); -App::import('Model', 'ConnectionManager', false); +App::uses('ClassRegistry', 'Utility'); +App::uses('Validation', 'Utility'); +App::uses('String', 'Utility'); +App::uses('BehaviorCollection', 'Model'); +App::uses('ModelBehavior', 'Model'); +App::uses('ConnectionManager', 'Model'); +App::uses('Xml', 'Utility'); /** * Object-relational mapper. @@ -834,7 +835,6 @@ class Model extends Object { } if (is_object($one)) { if ($one instanceof SimpleXMLElement || $one instanceof DOMNode) { - App::import('Core', 'Xml'); $one = $this->_normalizeXmlData(Xml::toArray($one)); } else { $one = Set::reverse($one); diff --git a/cake/libs/model/model_behavior.php b/lib/Cake/Model/ModelBehavior.php similarity index 100% rename from cake/libs/model/model_behavior.php rename to lib/Cake/Model/ModelBehavior.php diff --git a/lib/Cake/Model/Permission.php b/lib/Cake/Model/Permission.php new file mode 100644 index 000000000..5ca0f0682 --- /dev/null +++ b/lib/Cake/Model/Permission.php @@ -0,0 +1,84 @@ +useDbConfig = $config; + } + parent::__construct(); + } +} \ No newline at end of file diff --git a/cake/libs/cake_request.php b/lib/Cake/Network/CakeRequest.php similarity index 99% rename from cake/libs/cake_request.php rename to lib/Cake/Network/CakeRequest.php index 90435ed8b..8963f0e7a 100644 --- a/cake/libs/cake_request.php +++ b/lib/Cake/Network/CakeRequest.php @@ -16,6 +16,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Set', 'Utility'); + /** * A class that helps wrap Request information and particulars about a single request. * Provides methods commonly used to introspect on the request headers and request body. @@ -223,13 +225,14 @@ class CakeRequest implements ArrayAccess { $config = Configure::read('App'); extract($config); - if (!$base) { + if (empty($base)) { $base = $this->base; } if ($base !== false) { $this->webroot = $base . '/'; return $this->base = $base; } + if (!$baseUrl) { $base = dirname(env('SCRIPT_NAME')); diff --git a/cake/libs/cake_response.php b/lib/Cake/Network/CakeResponse.php similarity index 100% rename from cake/libs/cake_response.php rename to lib/Cake/Network/CakeResponse.php diff --git a/cake/libs/cake_socket.php b/lib/Cake/Network/CakeSocket.php similarity index 99% rename from cake/libs/cake_socket.php rename to lib/Cake/Network/CakeSocket.php index 82610ff92..3be6984f5 100644 --- a/cake/libs/cake_socket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -16,7 +16,7 @@ * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Validation'); +App::uses('Validation', 'Utility'); /** * Cake network socket connection class. diff --git a/cake/libs/http/basic_authentication.php b/lib/Cake/Network/Http/BasicAuthentication.php similarity index 100% rename from cake/libs/http/basic_authentication.php rename to lib/Cake/Network/Http/BasicAuthentication.php diff --git a/cake/libs/http/digest_authentication.php b/lib/Cake/Network/Http/DigestAuthentication.php similarity index 100% rename from cake/libs/http/digest_authentication.php rename to lib/Cake/Network/Http/DigestAuthentication.php diff --git a/cake/libs/http_response.php b/lib/Cake/Network/Http/HttpResponse.php similarity index 100% rename from cake/libs/http_response.php rename to lib/Cake/Network/Http/HttpResponse.php diff --git a/cake/libs/http_socket.php b/lib/Cake/Network/Http/HttpSocket.php similarity index 98% rename from cake/libs/http_socket.php rename to lib/Cake/Network/Http/HttpSocket.php index 9e820f921..1d5d1400d 100644 --- a/cake/libs/http_socket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -16,8 +16,8 @@ * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'CakeSocket'); -App::import('Core', 'Router'); +App::uses('CakeSocket', 'Network'); +App::uses('Router', 'Routing'); /** * Cake network socket connection class. @@ -530,8 +530,11 @@ class HttpSocket extends CakeSocket { return; } $method = key($this->_auth); - $authClass = Inflector::camelize($method) . 'Authentication'; - if (!App::import('Lib', 'http/' . $authClass)) { + list($plugin, $authClass) = pluginSplit($method, true); + $authClass = Inflector::camelize($authClass) . 'Authentication'; + App::uses($authClass, $plugin . 'Network/Http'); + + if (!class_exists($authClass)) { throw new SocketException(__('Unknown authentication method.')); } if (!method_exists($authClass, 'authentication')) { @@ -556,8 +559,11 @@ class HttpSocket extends CakeSocket { if (empty($this->_proxy['method']) || !isset($this->_proxy['user'], $this->_proxy['pass'])) { return; } - $authClass = Inflector::camelize($this->_proxy['method']) . 'Authentication'; - if (!App::import('Lib', 'http/' . $authClass)) { + list($plugin, $authClass) = pluginSplit($this->_proxy['method'], true); + $authClass = Inflector::camelize($authClass) . 'Authentication'; + App::uses($authClass, $plugin. 'Network/Http'); + + if (!class_exists($authClass)) { throw new SocketException(__('Unknown authentication method for proxy.')); } if (!method_exists($authClass, 'proxyAuthentication')) { diff --git a/cake/libs/dispatcher.php b/lib/Cake/Routing/Dispatcher.php similarity index 95% rename from cake/libs/dispatcher.php rename to lib/Cake/Routing/Dispatcher.php index 9d82935a8..be0ebe77e 100644 --- a/cake/libs/dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -23,10 +23,13 @@ /** * List of helpers to include */ -App::import('Core', 'Router', false); -App::import('Core', 'CakeRequest', false); -App::import('Core', 'CakeResponse', false); -App::import('Controller', 'Controller', false); +App::uses('Router', 'Routing'); +App::uses('CakeRequest', 'Network'); +App::uses('CakeResponse', 'Network'); +App::uses('Controller', 'Controller'); +App::uses('Scaffold', 'Controller'); +App::uses('View', 'View'); +App::uses('Debugger', 'Utility'); /** * Dispatcher converts Requests into controller actions. It uses the dispatched Request @@ -116,6 +119,7 @@ class Dispatcher { $privateAction = in_array($prefix, $prefixes); } } + return $privateAction; } @@ -137,7 +141,6 @@ class Dispatcher { if (!isset($methods[$request->params['action']])) { if ($controller->scaffold !== false) { - App::import('Controller', 'Scaffold', false); return new Scaffold($controller, $request); } throw new MissingActionException(array( @@ -197,10 +200,7 @@ class Dispatcher { if (!$ctrlClass) { return false; } - $ctrlClass .= 'Controller'; - if (class_exists($ctrlClass)) { - return new $ctrlClass($request); - } + return new $ctrlClass($request); } /** @@ -219,8 +219,12 @@ class Dispatcher { $controller = Inflector::camelize($request->params['controller']); } if ($pluginPath . $controller) { - if (App::import('Controller', $pluginPath . $controller)) { - return $controller; + $class = $controller . 'Controller'; + App::uses('AppController', 'Controller'); + App::uses($pluginName . 'AppController', $pluginPath . 'Controller'); + App::uses($class, $pluginPath . 'Controller'); + if (class_exists($class)) { + return $class; } } return false; @@ -254,9 +258,6 @@ class Dispatcher { } if (file_exists($filename)) { - if (!class_exists('View')) { - App::import('View', 'View', false); - } $controller = null; $view = new View($controller); return $view->renderCache($filename, microtime(true)); diff --git a/cake/libs/route/cake_route.php b/lib/Cake/Routing/Route/CakeRoute.php similarity index 100% rename from cake/libs/route/cake_route.php rename to lib/Cake/Routing/Route/CakeRoute.php diff --git a/cake/libs/route/plugin_short_route.php b/lib/Cake/Routing/Route/PluginShortRoute.php similarity index 97% rename from cake/libs/route/plugin_short_route.php rename to lib/Cake/Routing/Route/PluginShortRoute.php index 9509c5d32..a0f2d18a9 100644 --- a/cake/libs/route/plugin_short_route.php +++ b/lib/Cake/Routing/Route/PluginShortRoute.php @@ -1,5 +1,5 @@ $url); @@ -579,7 +579,7 @@ class Router { */ private static function __connectDefaultRoutes() { if ($plugins = App::objects('plugin')) { - App::import('Core', 'route/PluginShortRoute'); + App::uses('PluginShortRoute', 'Routing/Route'); foreach ($plugins as $key => $value) { $plugins[$key] = Inflector::underscore($value); } diff --git a/cake/tests/lib/cake_test_case.php b/lib/Cake/TestSuite/CakeTestCase.php similarity index 98% rename from cake/tests/lib/cake_test_case.php rename to lib/Cake/TestSuite/CakeTestCase.php index 7581bd6a8..318a42458 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -19,19 +19,18 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); -require_once CAKE_TESTS_LIB . 'cake_fixture_manager.php'; -require_once CAKE_TESTS_LIB . 'cake_test_model.php'; -require_once CAKE_TESTS_LIB . 'cake_test_fixture.php'; +App::uses('CakeFixtureManager', 'TestSuite/Fixture'); +App::uses('CakeTestFixture', 'TestSuite/Fixture'); /** * CakeTestCase class * * @package cake.tests.lib */ -class CakeTestCase extends PHPUnit_Framework_TestCase { +abstract class CakeTestCase extends PHPUnit_Framework_TestCase { /** - * The class responsible for managinf the creation, loading and removing of fixtures + * The class responsible for managing the creation, loading and removing of fixtures * * @var CakeFixtureManager * @access public diff --git a/cake/tests/lib/cake_test_loader.php b/lib/Cake/TestSuite/CakeTestLoader.php similarity index 100% rename from cake/tests/lib/cake_test_loader.php rename to lib/Cake/TestSuite/CakeTestLoader.php diff --git a/cake/tests/lib/cake_test_runner.php b/lib/Cake/TestSuite/CakeTestRunner.php similarity index 92% rename from cake/tests/lib/cake_test_runner.php rename to lib/Cake/TestSuite/CakeTestRunner.php index f1d2c9eda..c0eea1b56 100644 --- a/cake/tests/lib/cake_test_runner.php +++ b/lib/Cake/TestSuite/CakeTestRunner.php @@ -80,12 +80,14 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { */ protected function _getFixtureManager($arguments) { if (isset($arguments['fixtureManager'])) { - if (App::import('Lib', 'test_suite/' . Inflector::underscore($arguments['fixtureManager']))) { + App::uses($arguments['fixtureManager'], 'TestSuite'); + if (class_exists($arguments['fixtureManager'])) { return new $arguments['fixtureManager']; } throw new RuntimeException(__('Could not find fixture manager %s.', $arguments['fixtureManager'])); } - if (App::import('Lib', 'test_suite/AppFixtureManager')) { + App::uses('AppFixtureManager', 'TestSuite'); + if (class_exists('AppFixtureManager')) { return new AppFixtureManager(); } return new CakeFixtureManager(); diff --git a/cake/tests/lib/cake_test_suite.php b/lib/Cake/TestSuite/CakeTestSuite.php similarity index 100% rename from cake/tests/lib/cake_test_suite.php rename to lib/Cake/TestSuite/CakeTestSuite.php diff --git a/cake/tests/lib/cake_test_suite_command.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php similarity index 86% rename from cake/tests/lib/cake_test_suite_command.php rename to lib/Cake/TestSuite/CakeTestSuiteCommand.php index 2ed6eab0f..29dfd8f1d 100644 --- a/cake/tests/lib/cake_test_suite_command.php +++ b/lib/Cake/TestSuite/CakeTestSuiteCommand.php @@ -16,17 +16,15 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -define('CORE_TEST_CASES', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases'); -define('APP_TEST_CASES', TESTS . 'cases'); require 'PHPUnit/TextUI/Command.php'; -require_once CAKE_TESTS_LIB . 'cake_test_runner.php'; -require_once CAKE_TESTS_LIB . 'cake_test_loader.php'; -require_once CAKE_TESTS_LIB . 'cake_test_suite.php'; -require_once CAKE_TESTS_LIB . 'cake_test_case.php'; -require_once CAKE_TESTS_LIB . 'controller_test_case.php'; - +App::uses('CakeTestRunner', 'TestSuite'); +App::uses('CakeTestLoader', 'TestSuite'); +App::uses('CakeTestSuite', 'TestSuite'); +App::uses('CakeTestCase', 'TestSuite'); +App::uses('ControllerTestCase', 'TestSuite'); +App::uses('CakeTestModel', 'TestSuite/Fixture'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); @@ -43,6 +41,9 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { * @param array $params list of options to be used for this run */ public function __construct($loader, $params = array()) { + if ($loader && !class_exists($loader)) { + throw new MissingTestLoaderException(array('class' => $loader)); + } $this->arguments['loader'] = $loader; $this->arguments['test'] = $params['case']; $this->arguments['testFile'] = $params; @@ -161,13 +162,14 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { $type = strtolower($reporter); $coreClass = 'Cake' . ucwords($reporter) . 'Reporter'; - $coreFile = CAKE_TESTS_LIB . 'reporter/cake_' . $type . '_reporter.php'; + App::uses($coreClass, 'TestSuite/Reporter'); $appClass = $reporter . 'Reporter'; - $appFile = APPLIBS . 'test_suite/reporter/' . $type . '_reporter.php'; - if (include_once $coreFile) { + App::uses($appClass, 'TestSuite/Reporter'); + + if (!class_exists($appClass)) { $object = new $coreClass(null, $this->_params); - } elseif (include_once $appFile) { + } else { $object = new $appClass(null, $this->_params); } return $this->arguments['printer'] = $object; diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php similarity index 97% rename from cake/tests/lib/cake_test_suite_dispatcher.php rename to lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index 05fd8411e..4765b8971 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -17,6 +17,11 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +define('CORE_TEST_CASES', LIBS . 'tests' . DS . 'cases'); +define('APP_TEST_CASES', TESTS . 'cases'); + +App::uses('CakeTestSuiteCommand', 'TestSuite'); + /** * CakeTestSuiteDispatcher handles web requests to the test suite and runs the correct action. * @@ -88,8 +93,6 @@ class CakeTestSuiteDispatcher { $this->_checkPHPUnit(); $this->_parseParams(); - require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php'; - if ($this->params['case']) { $value = $this->_runTestCase(); } else { diff --git a/cake/tests/lib/controller_test_case.php b/lib/Cake/TestSuite/ControllerTestCase.php similarity index 91% rename from cake/tests/lib/controller_test_case.php rename to lib/Cake/TestSuite/ControllerTestCase.php index 76d34f310..09ba4af67 100644 --- a/cake/tests/lib/controller_test_case.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -19,9 +19,12 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); -require_once CAKE . 'libs' . DS . 'dispatcher.php'; -require_once CAKE_TESTS_LIB . 'cake_test_case.php'; -App::import('Core', array('Router', 'CakeRequest', 'CakeResponse', 'Helper')); +App::uses('Dispatcher', 'Routing'); +App::uses('CakeTestCase', 'TestSuite'); +App::uses('Router', 'Routing'); +App::uses('CakeRequest', 'Network'); +App::uses('CakeResponse', 'Network'); +App::uses('Helper', 'View'); /** * ControllerTestDispatcher class @@ -252,7 +255,13 @@ class ControllerTestCase extends CakeTestCase { * @return Controller Mocked controller */ public function generate($controller, $mocks = array()) { - if (!class_exists($controller.'Controller') && App::import('Controller', $controller) === false) { + list($plugin, $controller) = pluginSplit($controller); + if ($plugin) { + App::uses($plugin . 'AppController', $plugin . '.Controller'); + $plugin .= '.'; + } + App::uses($controller . 'Controller', $plugin . 'Controller'); + if (!class_exists($controller.'Controller')) { throw new MissingControllerException(array('controller' => $controller.'Controller')); } ClassRegistry::flush(); @@ -293,10 +302,11 @@ class ControllerTestCase extends CakeTestCase { if ($methods === true) { $methods = array(); } - list($plugin, $name) = pluginSplit($component); - if (!App::import('Component', $component)) { + list($plugin, $name) = pluginSplit($component, true); + App::uses($name . 'Component', $plugin . 'Controller/Component'); + if (!class_exists($name . 'Component')) { throw new MissingComponentFileException(array( - 'file' => Inflector::underscore($name) . '.php', + 'file' => $name . 'Component.php', 'class' => $name.'Component' )); } diff --git a/cake/tests/lib/coverage/base_coverage_report.php b/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php similarity index 99% rename from cake/tests/lib/coverage/base_coverage_report.php rename to lib/Cake/TestSuite/Coverage/BaseCoverageReport.php index 7960a6e75..3a04a946c 100644 --- a/cake/tests/lib/coverage/base_coverage_report.php +++ b/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php @@ -101,7 +101,7 @@ abstract class BaseCoverageReport { } elseif ($this->pluginTest) { $path = App::pluginPath($this->pluginTest); } else { - $path = TEST_CAKE_CORE_INCLUDE_PATH; + $path = LIBS; } return $path; } diff --git a/cake/tests/lib/coverage/html_coverage_report.php b/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php similarity index 98% rename from cake/tests/lib/coverage/html_coverage_report.php rename to lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php index bdd18e972..e57e9e3de 100644 --- a/cake/tests/lib/coverage/html_coverage_report.php +++ b/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php @@ -16,10 +16,11 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once dirname(__FILE__) . '/base_coverage_report.php'; PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); +App::uses('BaseCoverageReport', 'TestSuite/Coverage'); + class HtmlCoverageReport extends BaseCoverageReport { /** diff --git a/cake/tests/lib/coverage/text_coverage_report.php b/lib/Cake/TestSuite/Coverage/TextCoverageReport.php similarity index 100% rename from cake/tests/lib/coverage/text_coverage_report.php rename to lib/Cake/TestSuite/Coverage/TextCoverageReport.php diff --git a/cake/tests/lib/cake_fixture_manager.php b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php similarity index 89% rename from cake/tests/lib/cake_fixture_manager.php rename to lib/Cake/TestSuite/Fixture/CakeFixtureManager.php index 2615847ca..7f2b307f0 100644 --- a/cake/tests/lib/cake_fixture_manager.php +++ b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php @@ -18,6 +18,9 @@ */ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); +App::uses('ConnectionManager', 'Model'); +App::uses('ClassRegistry', 'Utility'); + class CakeFixtureManager { /** @@ -54,7 +57,7 @@ class CakeFixtureManager { * @param CakeTestCase $test the test case to inspect * @return void */ - public function fixturize(CakeTestCase $test) { + public function fixturize($test) { if (empty($test->fixtures) || !empty($this->_processed[get_class($test)])) { $test->db = $this->_db; return; @@ -80,22 +83,7 @@ class CakeFixtureManager { if ($this->_initialized) { return; } - $testDbAvailable = in_array('test', array_keys(ConnectionManager::enumConnectionObjects())); - - $_prefix = null; - - if ($testDbAvailable) { - // Try for test DB - @$db = ConnectionManager::getDataSource('test'); - $testDbAvailable = $db->isConnected(); - } else { - throw new MissingConnectionException(__('You need to create a $test datasource connection to start using fixtures')); - } - - if (!$testDbAvailable) { - throw new MissingConnectionException(__('Unable to connect to the $test datasource')); - } - + $db = ConnectionManager::getDataSource('test'); $this->_db = $db; ClassRegistry::config(array('ds' => 'test')); $this->_initialized = true; @@ -114,11 +102,10 @@ class CakeFixtureManager { if (isset($this->_loaded[$fixture])) { continue; } + if (strpos($fixture, 'core.') === 0) { $fixture = substr($fixture, strlen('core.')); - foreach (App::core('cake') as $key => $path) { - $fixturePaths[] = $path . 'tests' . DS . 'fixtures'; - } + $fixturePaths[] = LIBS . 'tests' . DS . 'fixtures'; } elseif (strpos($fixture, 'app.') === 0) { $fixture = substr($fixture, strlen('app.')); $fixturePaths = array( @@ -138,7 +125,7 @@ class CakeFixtureManager { $fixturePaths = array( TESTS . 'fixtures', VENDORS . 'tests' . DS . 'fixtures', - TEST_CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'tests' . DS . 'fixtures' + LIBS . DS . 'cake' . DS . 'tests' . DS . 'fixtures' ); } diff --git a/cake/tests/lib/cake_test_fixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php similarity index 95% rename from cake/tests/lib/cake_test_fixture.php rename to lib/Cake/TestSuite/Fixture/CakeTestFixture.php index 21a36b214..156d0be20 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php @@ -19,6 +19,8 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); +App::uses('CakeSchema', 'Model'); + /** * Short description for class. * @@ -57,7 +59,6 @@ class CakeTestFixture { $this->name = get_class($this); } } - App::import('Model', 'CakeSchema'); $this->Schema = new CakeSchema(array('name' => 'TestSuite', 'connection' => 'test')); $this->init(); } @@ -73,9 +74,12 @@ class CakeTestFixture { is_array($this->import) ? $this->import : array('model' => $this->import) ); - if (isset($import['model']) && App::import('Model', $import['model'])) { - App::import('Model', $import['model']); - list(, $modelClass) = pluginSplit($import['model']); + if (isset($import['model'])) { + list($plugin, $modelClass) = pluginSplit($import['model'], true); + App::uses($modelClass, $plugin . 'Model'); + if (!class_exists($modelClass)) { + throw new MissingModelException(array('class' => $modelClass)); + } $model = new $modelClass(null, null, $import['connection']); $db = $model->getDataSource(); if (empty($model->tablePrefix)) { diff --git a/cake/tests/lib/cake_test_model.php b/lib/Cake/TestSuite/Fixture/CakeTestModel.php similarity index 95% rename from cake/tests/lib/cake_test_model.php rename to lib/Cake/TestSuite/Fixture/CakeTestModel.php index a896a50d9..39632a45b 100644 --- a/cake/tests/lib/cake_test_model.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestModel.php @@ -16,7 +16,8 @@ * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once LIBS.'model'.DS.'model.php'; + +App::uses('Model', 'Model'); /** * Short description for class. diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/lib/Cake/TestSuite/Reporter/CakeBaseReporter.php similarity index 100% rename from cake/tests/lib/reporter/cake_base_reporter.php rename to lib/Cake/TestSuite/Reporter/CakeBaseReporter.php diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php similarity index 98% rename from cake/tests/lib/reporter/cake_html_reporter.php rename to lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php index 6af5c6029..e676c570d 100755 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php @@ -16,7 +16,7 @@ * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -include_once dirname(__FILE__) . DS . 'cake_base_reporter.php'; +App::uses('CakeBaseReporter', 'TestSuite/Reporter'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); @@ -157,8 +157,7 @@ class CakeHtmlReporter extends CakeBaseReporter { * @return void */ public function paintCoverage(array $coverage) { - $file = dirname(dirname(__FILE__)) . '/coverage/html_coverage_report.php'; - include_once $file; + App::uses('HtmlCoverageReport', 'TestSuite/Coverage'); $reporter = new HtmlCoverageReport($coverage, $this); echo $reporter->report(); } diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/lib/Cake/TestSuite/Reporter/CakeTextReporter.php similarity index 100% rename from cake/tests/lib/reporter/cake_text_reporter.php rename to lib/Cake/TestSuite/Reporter/CakeTextReporter.php diff --git a/cake/tests/lib/templates/footer.php b/lib/Cake/TestSuite/templates/footer.php similarity index 96% rename from cake/tests/lib/templates/footer.php rename to lib/Cake/TestSuite/templates/footer.php index 0f6ab6a69..059077000 100644 --- a/cake/tests/lib/templates/footer.php +++ b/lib/Cake/TestSuite/templates/footer.php @@ -26,7 +26,7 @@
element('sql_dump'); diff --git a/cake/tests/lib/templates/header.php b/lib/Cake/TestSuite/templates/header.php similarity index 100% rename from cake/tests/lib/templates/header.php rename to lib/Cake/TestSuite/templates/header.php diff --git a/cake/tests/lib/templates/menu.php b/lib/Cake/TestSuite/templates/menu.php similarity index 100% rename from cake/tests/lib/templates/menu.php rename to lib/Cake/TestSuite/templates/menu.php diff --git a/cake/tests/lib/templates/missing_conenction.php b/lib/Cake/TestSuite/templates/missing_conenction.php similarity index 100% rename from cake/tests/lib/templates/missing_conenction.php rename to lib/Cake/TestSuite/templates/missing_conenction.php diff --git a/cake/tests/lib/templates/phpunit.php b/lib/Cake/TestSuite/templates/phpunit.php similarity index 100% rename from cake/tests/lib/templates/phpunit.php rename to lib/Cake/TestSuite/templates/phpunit.php diff --git a/cake/tests/lib/templates/xdebug.php b/lib/Cake/TestSuite/templates/xdebug.php similarity index 100% rename from cake/tests/lib/templates/xdebug.php rename to lib/Cake/TestSuite/templates/xdebug.php diff --git a/cake/libs/class_registry.php b/lib/Cake/Utility/ClassRegistry.php similarity index 97% rename from cake/libs/class_registry.php rename to lib/Cake/Utility/ClassRegistry.php index 25659089f..c0d4e6685 100644 --- a/cake/libs/class_registry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -132,7 +132,11 @@ class ClassRegistry { return $model; } - if (class_exists($class) || App::import($type, $pluginPath . $class)) { + App::uses('Model', 'Model'); + App::uses('AppModel', 'Model'); + App::uses($plugin . 'AppModel', $pluginPath . $type); + App::uses($class, $pluginPath . $type); + if (class_exists($class)) { ${$class} = new $class($settings); } elseif ($type === 'Model') { if ($plugin && class_exists($plugin . 'AppModel')) { diff --git a/cake/libs/debugger.php b/lib/Cake/Utility/Debugger.php similarity index 98% rename from cake/libs/debugger.php rename to lib/Cake/Utility/Debugger.php index 942aa1c63..e92edb4bf 100644 --- a/cake/libs/debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -23,12 +23,8 @@ * Included libraries. * */ -if (!class_exists('CakeLog')) { - require_once LIBS . 'cake_log.php'; -} -if (!class_exists('String')) { - require_once LIBS . 'string.php'; -} +App::uses('CakeLog', 'Log'); +App::uses('String', 'Utility'); /** * Provide custom logging and error handling. @@ -404,12 +400,9 @@ class Debugger { } elseif (strpos($path, ROOT) === 0) { return str_replace(ROOT, 'ROOT', $path); } - $corePaths = App::core('cake'); - - foreach ($corePaths as $corePath) { - if (strpos($path, $corePath) === 0) { - return str_replace($corePath, 'CORE' .DS . 'cake' .DS, $path); - } + + if (strpos($path, LIBS) === 0) { + return str_replace($corePath, 'CORE' . DS, $path); } return $path; } diff --git a/cake/libs/file.php b/lib/Cake/Utility/File.php similarity index 99% rename from cake/libs/file.php rename to lib/Cake/Utility/File.php index 49d030e4d..ff0eadaa1 100644 --- a/cake/libs/file.php +++ b/lib/Cake/Utility/File.php @@ -21,9 +21,7 @@ * Included libraries. * */ -if (!class_exists('Folder')) { - require LIBS . 'folder.php'; -} +App::uses('Folder', 'Utility'); /** * Convenience class for reading, writing and appending to files. diff --git a/cake/libs/folder.php b/lib/Cake/Utility/Folder.php similarity index 100% rename from cake/libs/folder.php rename to lib/Cake/Utility/Folder.php diff --git a/cake/libs/inflector.php b/lib/Cake/Utility/Inflector.php similarity index 100% rename from cake/libs/inflector.php rename to lib/Cake/Utility/Inflector.php diff --git a/cake/libs/magic_db.php b/lib/Cake/Utility/MagicDb.php similarity index 100% rename from cake/libs/magic_db.php rename to lib/Cake/Utility/MagicDb.php diff --git a/cake/libs/object_collection.php b/lib/Cake/Utility/ObjectCollection.php similarity index 100% rename from cake/libs/object_collection.php rename to lib/Cake/Utility/ObjectCollection.php diff --git a/cake/libs/sanitize.php b/lib/Cake/Utility/Sanitize.php similarity index 100% rename from cake/libs/sanitize.php rename to lib/Cake/Utility/Sanitize.php diff --git a/cake/libs/security.php b/lib/Cake/Utility/Security.php similarity index 98% rename from cake/libs/security.php rename to lib/Cake/Utility/Security.php index e8b01e2b8..fdb2dccb8 100644 --- a/cake/libs/security.php +++ b/lib/Cake/Utility/Security.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('String', 'Utility'); + /** * Security Library contains utility methods related to security * @@ -57,9 +59,6 @@ class Security { * @return string Hash */ public static function generateAuthKey() { - if (!class_exists('String')) { - App::import('Core', 'String'); - } return Security::hash(String::uuid()); } diff --git a/cake/libs/set.php b/lib/Cake/Utility/Set.php similarity index 99% rename from cake/libs/set.php rename to lib/Cake/Utility/Set.php index b16aeb59a..839372f19 100644 --- a/cake/libs/set.php +++ b/lib/Cake/Utility/Set.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('String', 'Utility'); + /** * Class used for manipulation of arrays. * @@ -42,7 +44,7 @@ class Set { $r = (array)current($args); while (($arg = next($args)) !== false) { foreach ((array)$arg as $key => $val) { - if (is_array($val) && isset($r[$key]) && is_array($r[$key])) { + if (!empty($r[$key]) && is_array($r[$key]) && is_array($val)) { $r[$key] = Set::merge($r[$key], $val); } elseif (is_int($key)) { $r[] = $val; @@ -591,15 +593,14 @@ class Set { return $data; } - if (!is_array($path)) { - if (!class_exists('String')) { - App::import('Core', 'String'); - } + if (is_string($path) && strpos($path, '{') !== false) { $path = String::tokenize($path, '.', '{', '}'); + } elseif (is_string($path)) { + $path = explode('.', $path); } $tmp = array(); - if (!is_array($path) || empty($path)) { + if (empty($path)) { return null; } @@ -673,11 +674,12 @@ class Set { } $_list =& $list; + $count = count($path); foreach ($path as $i => $key) { if (is_numeric($key) && intval($key) > 0 || $key === '0') { $key = intval($key); } - if ($i === count($path) - 1) { + if ($i === $count - 1) { $_list[$key] = $data; } else { if (!isset($_list[$key])) { diff --git a/cake/libs/string.php b/lib/Cake/Utility/String.php similarity index 100% rename from cake/libs/string.php rename to lib/Cake/Utility/String.php diff --git a/cake/libs/validation.php b/lib/Cake/Utility/Validation.php similarity index 99% rename from cake/libs/validation.php rename to lib/Cake/Utility/Validation.php index bcb679e9f..8d0871922 100644 --- a/cake/libs/validation.php +++ b/lib/Cake/Utility/Validation.php @@ -16,9 +16,8 @@ * @since CakePHP(tm) v 1.2.0.3830 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('Multibyte')) { - App::import('Core', 'Multibyte', false); -} + +App::uses('Multibyte', 'I18n'); /** * Offers different validation methods. diff --git a/cake/libs/xml.php b/lib/Cake/Utility/Xml.php similarity index 100% rename from cake/libs/xml.php rename to lib/Cake/Utility/Xml.php diff --git a/cake/libs/view/helper.php b/lib/Cake/View/Helper.php similarity index 87% rename from cake/libs/view/helper.php rename to lib/Cake/View/Helper.php index dd9e6476c..448917f22 100644 --- a/cake/libs/view/helper.php +++ b/lib/Cake/View/Helper.php @@ -19,9 +19,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('Router')) { - App::import('Core', 'Router'); -} +App::uses('Router', 'Routing'); /** * Abstract base class for all other Helpers in CakePHP. @@ -240,11 +238,9 @@ class Helper extends Object { * @return string Path with a timestamp added, or not. */ public function assetTimestamp($path) { - $timestampEnabled = ( - (Configure::read('Asset.timestamp') === true && Configure::read('debug') > 0) || - Configure::read('Asset.timestamp') === 'force' - ); - if (strpos($path, '?') === false && $timestampEnabled) { + $stamp = Configure::read('Asset.timestamp'); + $timestampEnabled = $stamp === 'force' || ($stamp === true && Configure::read('debug') > 0); + if ($timestampEnabled && strpos($path, '?') === false) { $filepath = preg_replace('/^' . preg_quote($this->request->webroot, '/') . '/', '', $path); $webrootPath = WWW_ROOT . str_replace('/', DS, $filepath); if (file_exists($webrootPath)) { @@ -290,6 +286,96 @@ class Helper extends Object { return $this->__cleaned; } +/** +<<<<<<< HEAD:lib/Cake/View/Helper.php + * Returns a space-delimited string with items of the $options array. If a + * key of $options array happens to be one of: + * + * - 'compact' + * - 'checked' + * - 'declare' + * - 'readonly' + * - 'disabled' + * - 'selected' + * - 'defer' + * - 'ismap' + * - 'nohref' + * - 'noshade' + * - 'nowrap' + * - 'multiple' + * - 'noresize' + * + * And its value is one of: + * + * - '1' (string) + * - 1 (integer) + * - true (boolean) + * - 'true' (string) + * + * Then the value will be reset to be identical with key's name. + * If the value is not one of these 3, the parameter is not output. + * + * 'escape' is a special option in that it controls the conversion of + * attributes to their html-entity encoded equivalents. Set to false to disable html-encoding. + * + * If value for any option key is set to `null` or `false`, that option will be excluded from output. + * + * @param array $options Array of options. + * @param array $exclude Array of options to be excluded, the options here will not be part of the return. + * @param string $insertBefore String to be inserted before options. + * @param string $insertAfter String to be inserted after options. + * @return string Composed attributes. + */ + public function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { + if (!is_string($options)) { + $options = (array) $options + array('escape' => true); + + if (!is_array($exclude)) { + $exclude = array(); + } + + $exclude = array('escape' => true) + array_flip($exclude); + $escape = $options['escape']; + $attributes = array(); + + foreach ($options as $key => $value) { + if (!isset($exclude[$key]) && $value !== false && $value !== null) { + $attributes[] = $this->_formatAttribute($key, $value, $escape); + } + } + $out = implode(' ', $attributes); + } else { + $out = $options; + } + return $out ? $insertBefore . $out . $insertAfter : ''; + } + +/** + * Formats an individual attribute, and returns the string value of the composed attribute. + * Works with minimized attributes that have the same value as their name such as 'disabled' and 'checked' + * + * @param string $key The name of the attribute to create + * @param string $value The value of the attribute to create. + * @return string The composed attribute. + */ + protected function _formatAttribute($key, $value, $escape = true) { + $attribute = ''; + if (is_array($value)) { + $value = ''; + } + + if (is_numeric($key)) { + $attribute = sprintf($this->_minimizedAttributeFormat, $value, $value); + } elseif (in_array($key, $this->_minimizedAttributes)) { + if ($value === 1 || $value === true || $value === 'true' || $value === '1' || $value == $key) { + $attribute = sprintf($this->_minimizedAttributeFormat, $key, $key); + } + } else { + $attribute = sprintf($this->_attributeFormat, $key, ($escape ? h($value) : $value)); + } + return $attribute; + } + /** * Sets this helper's model and field properties to the dot-separated value-pair in $entity. * @@ -298,7 +384,7 @@ class Helper extends Object { * @return void */ public function setEntity($entity, $setScope = false) { - $view =& $this->_View; + $view = $this->_View; if ($setScope) { $view->modelScope = false; } elseif (!empty($view->entityPath) && $view->entityPath == $entity) { @@ -345,7 +431,7 @@ class Helper extends Object { } if (ClassRegistry::isKeySet($model)) { - $ModelObj =& ClassRegistry::getObject($model); + $ModelObj = ClassRegistry::getObject($model); for ($i = 0; $i < $count; $i++) { if ( is_a($ModelObj, 'Model') && diff --git a/cake/console/templates/skel/app_helper.php b/lib/Cake/View/Helper/AppHelper.php similarity index 96% rename from cake/console/templates/skel/app_helper.php rename to lib/Cake/View/Helper/AppHelper.php index 02955a34e..b293bfaba 100644 --- a/cake/console/templates/skel/app_helper.php +++ b/lib/Cake/View/Helper/AppHelper.php @@ -19,7 +19,7 @@ * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Helper', false); +App::uses('Helper', 'View'); /** * This is a placeholder class. diff --git a/cake/libs/view/helpers/cache.php b/lib/Cake/View/Helper/CacheHelper.php similarity index 99% rename from cake/libs/view/helpers/cache.php rename to lib/Cake/View/Helper/CacheHelper.php index ef63994e1..5bd804474 100644 --- a/cake/libs/view/helpers/cache.php +++ b/lib/Cake/View/Helper/CacheHelper.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppHelper', 'View/Helper'); + /** * CacheHelper helps create full page view caching. * diff --git a/cake/libs/view/helpers/form.php b/lib/Cake/View/Helper/FormHelper.php similarity index 99% rename from cake/libs/view/helpers/form.php rename to lib/Cake/View/Helper/FormHelper.php index 74c0e2f38..73de5a336 100644 --- a/cake/libs/view/helpers/form.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -19,6 +19,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppHelper', 'View/Helper'); + /** * Form helper library. * diff --git a/cake/libs/view/helpers/html.php b/lib/Cake/View/Helper/HtmlHelper.php similarity index 99% rename from cake/libs/view/helpers/html.php rename to lib/Cake/View/Helper/HtmlHelper.php index 52458329c..1f098864f 100644 --- a/cake/libs/view/helpers/html.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -16,6 +16,9 @@ * @since CakePHP(tm) v 0.9.1 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('AppHelper', 'View/Helper'); + /** * Html Helper class for easy use of HTML widgets. * @@ -941,7 +944,8 @@ class HtmlHelper extends AppHelper { } $readerClass = Inflector::camelize($reader) . 'Reader'; - if (!App::import('Lib', 'config/' . $readerClass)) { + App::uses($readerClass, 'Configure'); + if (!class_exists($readerClass)) { throw new ConfigureException(__('Cannot load the configuration file. Unknown reader.')); } diff --git a/cake/libs/view/helpers/jquery_engine.php b/lib/Cake/View/Helper/JqueryEngineHelper.php similarity index 99% rename from cake/libs/view/helpers/jquery_engine.php rename to lib/Cake/View/Helper/JqueryEngineHelper.php index 2644acadd..91e22d033 100644 --- a/cake/libs/view/helpers/jquery_engine.php +++ b/lib/Cake/View/Helper/JqueryEngineHelper.php @@ -21,7 +21,9 @@ * @package cake.libs.view.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Js'); + +App::uses('AppHelper', 'View/Helper'); +App::uses('JsBaseEngineHelper', 'View/Helper'); class JqueryEngineHelper extends JsBaseEngineHelper { /** diff --git a/cake/libs/view/helpers/js.php b/lib/Cake/View/Helper/JsBaseEngineHelper.php similarity index 58% rename from cake/libs/view/helpers/js.php rename to lib/Cake/View/Helper/JsBaseEngineHelper.php index 172c67556..ade4ca558 100644 --- a/cake/libs/view/helpers/js.php +++ b/lib/Cake/View/Helper/JsBaseEngineHelper.php @@ -1,6 +1,6 @@ __engineName = $className . 'Engine'; - $engineClass = $engineName . 'Engine'; - $this->helpers[] = $engineClass; - parent::__construct($View, $settings); - } - -/** - * call__ Allows for dispatching of methods to the Engine Helper. - * methods in the Engines bufferedMethods list will be automatically buffered. - * You can control buffering with the buffer param as well. By setting the last parameter to - * any engine method to a boolean you can force or disable buffering. - * - * e.g. `$js->get('#foo')->effect('fadeIn', array('speed' => 'slow'), true);` - * - * Will force buffering for the effect method. If the method takes an options array you may also add - * a 'buffer' param to the options array and control buffering there as well. - * - * e.g. `$js->get('#foo')->event('click', $functionContents, array('buffer' => true));` - * - * The buffer parameter will not be passed onto the EngineHelper. - * - * @param string $method Method to be called - * @param array $params Parameters for the method being called. - * @return mixed Depends on the return of the dispatched method, or it could be an instance of the EngineHelper - */ - public function __call($method, $params) { - if ($this->{$this->__engineName} && method_exists($this->{$this->__engineName}, $method)) { - $buffer = false; - $engineHelper = $this->{$this->__engineName}; - if (in_array(strtolower($method), $engineHelper->bufferedMethods)) { - $buffer = true; - } - if (count($params) > 0) { - $lastParam = $params[count($params) - 1]; - $hasBufferParam = (is_bool($lastParam) || is_array($lastParam) && isset($lastParam['buffer'])); - if ($hasBufferParam && is_bool($lastParam)) { - $buffer = $lastParam; - unset($params[count($params) - 1]); - } elseif ($hasBufferParam && is_array($lastParam)) { - $buffer = $lastParam['buffer']; - unset($params['buffer']); - } - } - - $out = call_user_func_array(array(&$engineHelper, $method), $params); - if ($this->bufferScripts && $buffer && is_string($out)) { - $this->buffer($out); - return null; - } - if (is_object($out) && is_a($out, 'JsBaseEngineHelper')) { - return $this; - } - return $out; - } - if (method_exists($this, $method . '_')) { - return call_user_func(array(&$this, $method . '_'), $params); - } - trigger_error(__('JsHelper:: Missing Method %s is undefined', $method), E_USER_WARNING); - } - -/** - * Overwrite inherited Helper::value() - * See JsBaseEngineHelper::value() for more information on this method. - * - * @param mixed $val A PHP variable to be converted to JSON - * @param boolean $quoteStrings If false, leaves string values unquoted - * @return string a JavaScript-safe/JSON representation of $val - * @access public - **/ - function value($val, $quoteString = true) { - return $this->{$this->__engineName}->value($val, $quoteString); - } - -/** - * Writes all Javascript generated so far to a code block or - * caches them to a file and returns a linked script. If no scripts have been - * buffered this method will return null. If the request is an XHR(ajax) request - * onDomReady will be set to false. As the dom is already 'ready'. - * - * ### Options - * - * - `inline` - Set to true to have scripts output as a script block inline - * if `cache` is also true, a script link tag will be generated. (default true) - * - `cache` - Set to true to have scripts cached to a file and linked in (default false) - * - `clear` - Set to false to prevent script cache from being cleared (default true) - * - `onDomReady` - wrap cached scripts in domready event (default true) - * - `safe` - if an inline block is generated should it be wrapped in (default true) - * - * @param array $options options for the code block - * @return mixed Completed javascript tag if there are scripts, if there are no buffered - * scripts null will be returned. - */ - public function writeBuffer($options = array()) { - $domReady = $this->request->is('ajax'); - $defaults = array( - 'onDomReady' => $domReady, 'inline' => true, - 'cache' => false, 'clear' => true, 'safe' => true - ); - $options = array_merge($defaults, $options); - $script = implode("\n", $this->getBuffer($options['clear'])); - - if (empty($script)) { - return null; - } - - if ($options['onDomReady']) { - $script = $this->{$this->__engineName}->domReady($script); - } - $opts = $options; - unset($opts['onDomReady'], $opts['cache'], $opts['clear']); - - if (!$options['cache'] && $options['inline']) { - return $this->Html->scriptBlock($script, $opts); - } - - if ($options['cache'] && $options['inline']) { - $filename = md5($script); - if (!file_exists(JS . $filename . '.js')) { - cache(str_replace(WWW_ROOT, '', JS) . $filename . '.js', $script, '+999 days', 'public'); - } - return $this->Html->script($filename); - } - $this->Html->scriptBlock($script, $opts); - return null; - } - -/** - * Write a script to the buffered scripts. - * - * @param string $script Script string to add to the buffer. - * @param boolean $top If true the script will be added to the top of the - * buffered scripts array. If false the bottom. - * @return void - */ - public function buffer($script, $top = false) { - if ($top) { - array_unshift($this->__bufferedScripts, $script); - } else { - $this->__bufferedScripts[] = $script; - } - } - -/** - * Get all the buffered scripts - * - * @param boolean $clear Whether or not to clear the script caches (default true) - * @return array Array of scripts added to the request. - */ - public function getBuffer($clear = true) { - $this->_createVars(); - $scripts = $this->__bufferedScripts; - if ($clear) { - $this->__bufferedScripts = array(); - $this->__jsVars = array(); - } - return $scripts; - } - -/** - * Generates the object string for variables passed to javascript. - * - * @return string Generated JSON object of all set vars - */ - protected function _createVars() { - if (!empty($this->__jsVars)) { - $setVar = (strpos($this->setVariable, '.')) ? $this->setVariable : 'window.' . $this->setVariable; - $this->buffer($setVar . ' = ' . $this->object($this->__jsVars) . ';', true); - } - } - -/** - * Generate an 'Ajax' link. Uses the selected JS engine to create a link - * element that is enhanced with Javascript. Options can include - * both those for HtmlHelper::link() and JsBaseEngine::request(), JsBaseEngine::event(); - * - * ### Options - * - * - `confirm` - Generate a confirm() dialog before sending the event. - * - `id` - use a custom id. - * - `htmlAttributes` - additional non-standard htmlAttributes. Standard attributes are class, id, - * rel, title, escape, onblur and onfocus. - * - `buffer` - Disable the buffering and return a script tag in addition to the link. - * - * @param string $title Title for the link. - * @param mixed $url Mixed either a string URL or an cake url array. - * @param array $options Options for both the HTML element and Js::request() - * @return string Completed link. If buffering is disabled a script tag will be returned as well. - */ - public function link($title, $url = null, $options = array()) { - if (!isset($options['id'])) { - $options['id'] = 'link-' . intval(mt_rand()); - } - list($options, $htmlOptions) = $this->_getHtmlOptions($options); - $out = $this->Html->link($title, $url, $htmlOptions); - $this->get('#' . $htmlOptions['id']); - $requestString = $event = ''; - if (isset($options['confirm'])) { - $requestString = $this->confirmReturn($options['confirm']); - unset($options['confirm']); - } - $buffer = isset($options['buffer']) ? $options['buffer'] : null; - $safe = isset($options['safe']) ? $options['safe'] : true; - unset($options['buffer'], $options['safe']); - - $requestString .= $this->request($url, $options); - - if (!empty($requestString)) { - $event = $this->event('click', $requestString, $options + array('buffer' => $buffer)); - } - if (isset($buffer) && !$buffer) { - $opts = array('safe' => $safe); - $out .= $this->Html->scriptBlock($event, $opts); - } - return $out; - } - -/** - * Pass variables into Javascript. Allows you to set variables that will be - * output when the buffer is fetched with `JsHelper::getBuffer()` or `JsHelper::writeBuffer()` - * The Javascript variable used to output set variables can be controlled with `JsHelper::$setVariable` - * - * @param mixed $one Either an array of variables to set, or the name of the variable to set. - * @param mixed $two If $one is a string, $two is the value for that key. - * @return void - */ - public function set($one, $two = null) { - $data = null; - if (is_array($one)) { - if (is_array($two)) { - $data = array_combine($one, $two); - } else { - $data = $one; - } - } else { - $data = array($one => $two); - } - if ($data == null) { - return false; - } - $this->__jsVars = array_merge($this->__jsVars, $data); - } - -/** - * Uses the selected JS engine to create a submit input - * element that is enhanced with Javascript. Options can include - * both those for FormHelper::submit() and JsBaseEngine::request(), JsBaseEngine::event(); - * - * Forms submitting with this method, cannot send files. Files do not transfer over XmlHttpRequest - * and require an iframe or flash. - * - * ### Options - * - * - `url` The url you wish the XHR request to submit to. - * - `confirm` A string to use for a confirm() message prior to submitting the request. - * - `method` The method you wish the form to send by, defaults to POST - * - `buffer` Whether or not you wish the script code to be buffered, defaults to true. - * - Also see options for JsHelper::request() and JsHelper::event() - * - * @param string $title The display text of the submit button. - * @param array $options Array of options to use. See the options for the above mentioned methods. - * @return string Completed submit button. - */ - public function submit($caption = null, $options = array()) { - if (!isset($options['id'])) { - $options['id'] = 'submit-' . intval(mt_rand()); - } - $formOptions = array('div'); - list($options, $htmlOptions) = $this->_getHtmlOptions($options, $formOptions); - $out = $this->Form->submit($caption, $htmlOptions); - - $this->get('#' . $htmlOptions['id']); - - $options['data'] = $this->serializeForm(array('isForm' => false, 'inline' => true)); - $requestString = $url = ''; - if (isset($options['confirm'])) { - $requestString = $this->confirmReturn($options['confirm']); - unset($options['confirm']); - } - if (isset($options['url'])) { - $url = $options['url']; - unset($options['url']); - } - if (!isset($options['method'])) { - $options['method'] = 'post'; - } - $options['dataExpression'] = true; - - $buffer = isset($options['buffer']) ? $options['buffer'] : null; - $safe = isset($options['safe']) ? $options['safe'] : true; - unset($options['buffer'], $options['safe']); - - $requestString .= $this->request($url, $options); - if (!empty($requestString)) { - $event = $this->event('click', $requestString, $options + array('buffer' => $buffer)); - } - if (isset($buffer) && !$buffer) { - $opts = array('safe' => $safe); - $out .= $this->Html->scriptBlock($event, $opts); - } - return $out; - } - -/** - * Parse a set of Options and extract the Html options. - * Extracted Html Options are removed from the $options param. - * - * @param array $options Options to filter. - * @param array $additional Array of additional keys to extract and include in the return options array. - * @return array Array of js options and Htmloptions - */ - protected function _getHtmlOptions($options, $additional = array()) { - $htmlKeys = array_merge(array('class', 'id', 'escape', 'onblur', 'onfocus', 'rel', 'title'), $additional); - $htmlOptions = array(); - foreach ($htmlKeys as $key) { - if (isset($options[$key])) { - $htmlOptions[$key] = $options[$key]; - } - unset($options[$key]); - } - if (isset($options['htmlAttributes'])) { - $htmlOptions = array_merge($htmlOptions, $options['htmlAttributes']); - unset($options['htmlAttributes']); - } - return array($options, $htmlOptions); - } -} +App::uses('AppHelper', 'View/Helper'); /** * JsEngineBaseClass @@ -474,8 +73,6 @@ abstract class JsBaseEngineHelper extends AppHelper { /** * Constructor. * - * @param View $View The View this helper is attached to. - * @param array $settings An array of settings. */ function __construct($View, $settings = array()) { parent::__construct($View, $settings); @@ -650,7 +247,6 @@ abstract class JsBaseEngineHelper extends AppHelper { * @return string Escaped string. */ public function escape($string) { - App::import('Core', 'Multibyte'); return $this->_utf8ToHex($string); } @@ -1053,4 +649,4 @@ abstract class JsBaseEngineHelper extends AppHelper { } return $out; } -} +} \ No newline at end of file diff --git a/lib/Cake/View/Helper/JsHelper.php b/lib/Cake/View/Helper/JsHelper.php new file mode 100644 index 000000000..1495b72a6 --- /dev/null +++ b/lib/Cake/View/Helper/JsHelper.php @@ -0,0 +1,424 @@ +__engineName = $className . 'Engine'; + $engineClass = $engineName . 'Engine'; + $this->helpers[] = $engineClass; + parent::__construct($View, $settings); + } + +/** + * call__ Allows for dispatching of methods to the Engine Helper. + * methods in the Engines bufferedMethods list will be automatically buffered. + * You can control buffering with the buffer param as well. By setting the last parameter to + * any engine method to a boolean you can force or disable buffering. + * + * e.g. `$js->get('#foo')->effect('fadeIn', array('speed' => 'slow'), true);` + * + * Will force buffering for the effect method. If the method takes an options array you may also add + * a 'buffer' param to the options array and control buffering there as well. + * + * e.g. `$js->get('#foo')->event('click', $functionContents, array('buffer' => true));` + * + * The buffer parameter will not be passed onto the EngineHelper. + * + * @param string $method Method to be called + * @param array $params Parameters for the method being called. + * @return mixed Depends on the return of the dispatched method, or it could be an instance of the EngineHelper + */ + public function __call($method, $params) { + if ($this->{$this->__engineName} && method_exists($this->{$this->__engineName}, $method)) { + $buffer = false; + $engineHelper = $this->{$this->__engineName}; + if (in_array(strtolower($method), $engineHelper->bufferedMethods)) { + $buffer = true; + } + if (count($params) > 0) { + $lastParam = $params[count($params) - 1]; + $hasBufferParam = (is_bool($lastParam) || is_array($lastParam) && isset($lastParam['buffer'])); + if ($hasBufferParam && is_bool($lastParam)) { + $buffer = $lastParam; + unset($params[count($params) - 1]); + } elseif ($hasBufferParam && is_array($lastParam)) { + $buffer = $lastParam['buffer']; + unset($params['buffer']); + } + } + + $out = call_user_func_array(array(&$engineHelper, $method), $params); + if ($this->bufferScripts && $buffer && is_string($out)) { + $this->buffer($out); + return null; + } + if (is_object($out) && is_a($out, 'JsBaseEngineHelper')) { + return $this; + } + return $out; + } + if (method_exists($this, $method . '_')) { + return call_user_func(array(&$this, $method . '_'), $params); + } + trigger_error(__('JsHelper:: Missing Method %s is undefined', $method), E_USER_WARNING); + } + +/** + * Overwrite inherited Helper::value() + * See JsBaseEngineHelper::value() for more information on this method. + * + * @param mixed $val A PHP variable to be converted to JSON + * @param boolean $quoteStrings If false, leaves string values unquoted + * @return string a JavaScript-safe/JSON representation of $val + * @access public + **/ + function value($val, $quoteString = true) { + return $this->{$this->__engineName}->value($val, $quoteString); + } + +/** + * Writes all Javascript generated so far to a code block or + * caches them to a file and returns a linked script. If no scripts have been + * buffered this method will return null. If the request is an XHR(ajax) request + * onDomReady will be set to false. As the dom is already 'ready'. + * + * ### Options + * + * - `inline` - Set to true to have scripts output as a script block inline + * if `cache` is also true, a script link tag will be generated. (default true) + * - `cache` - Set to true to have scripts cached to a file and linked in (default false) + * - `clear` - Set to false to prevent script cache from being cleared (default true) + * - `onDomReady` - wrap cached scripts in domready event (default true) + * - `safe` - if an inline block is generated should it be wrapped in (default true) + * + * @param array $options options for the code block + * @return mixed Completed javascript tag if there are scripts, if there are no buffered + * scripts null will be returned. + */ + public function writeBuffer($options = array()) { + $domReady = $this->request->is('ajax'); + $defaults = array( + 'onDomReady' => $domReady, 'inline' => true, + 'cache' => false, 'clear' => true, 'safe' => true + ); + $options = array_merge($defaults, $options); + $script = implode("\n", $this->getBuffer($options['clear'])); + + if (empty($script)) { + return null; + } + + if ($options['onDomReady']) { + $script = $this->{$this->__engineName}->domReady($script); + } + $opts = $options; + unset($opts['onDomReady'], $opts['cache'], $opts['clear']); + + if (!$options['cache'] && $options['inline']) { + return $this->Html->scriptBlock($script, $opts); + } + + if ($options['cache'] && $options['inline']) { + $filename = md5($script); + if (!file_exists(JS . $filename . '.js')) { + cache(str_replace(WWW_ROOT, '', JS) . $filename . '.js', $script, '+999 days', 'public'); + } + return $this->Html->script($filename); + } + $this->Html->scriptBlock($script, $opts); + return null; + } + +/** + * Write a script to the buffered scripts. + * + * @param string $script Script string to add to the buffer. + * @param boolean $top If true the script will be added to the top of the + * buffered scripts array. If false the bottom. + * @return void + */ + public function buffer($script, $top = false) { + if ($top) { + array_unshift($this->__bufferedScripts, $script); + } else { + $this->__bufferedScripts[] = $script; + } + } + +/** + * Get all the buffered scripts + * + * @param boolean $clear Whether or not to clear the script caches (default true) + * @return array Array of scripts added to the request. + */ + public function getBuffer($clear = true) { + $this->_createVars(); + $scripts = $this->__bufferedScripts; + if ($clear) { + $this->__bufferedScripts = array(); + $this->__jsVars = array(); + } + return $scripts; + } + +/** + * Generates the object string for variables passed to javascript. + * + * @return string Generated JSON object of all set vars + */ + protected function _createVars() { + if (!empty($this->__jsVars)) { + $setVar = (strpos($this->setVariable, '.')) ? $this->setVariable : 'window.' . $this->setVariable; + $this->buffer($setVar . ' = ' . $this->object($this->__jsVars) . ';', true); + } + } + +/** + * Generate an 'Ajax' link. Uses the selected JS engine to create a link + * element that is enhanced with Javascript. Options can include + * both those for HtmlHelper::link() and JsBaseEngine::request(), JsBaseEngine::event(); + * + * ### Options + * + * - `confirm` - Generate a confirm() dialog before sending the event. + * - `id` - use a custom id. + * - `htmlAttributes` - additional non-standard htmlAttributes. Standard attributes are class, id, + * rel, title, escape, onblur and onfocus. + * - `buffer` - Disable the buffering and return a script tag in addition to the link. + * + * @param string $title Title for the link. + * @param mixed $url Mixed either a string URL or an cake url array. + * @param array $options Options for both the HTML element and Js::request() + * @return string Completed link. If buffering is disabled a script tag will be returned as well. + */ + public function link($title, $url = null, $options = array()) { + if (!isset($options['id'])) { + $options['id'] = 'link-' . intval(mt_rand()); + } + list($options, $htmlOptions) = $this->_getHtmlOptions($options); + $out = $this->Html->link($title, $url, $htmlOptions); + $this->get('#' . $htmlOptions['id']); + $requestString = $event = ''; + if (isset($options['confirm'])) { + $requestString = $this->confirmReturn($options['confirm']); + unset($options['confirm']); + } + $buffer = isset($options['buffer']) ? $options['buffer'] : null; + $safe = isset($options['safe']) ? $options['safe'] : true; + unset($options['buffer'], $options['safe']); + + $requestString .= $this->request($url, $options); + + if (!empty($requestString)) { + $event = $this->event('click', $requestString, $options + array('buffer' => $buffer)); + } + if (isset($buffer) && !$buffer) { + $opts = array('safe' => $safe); + $out .= $this->Html->scriptBlock($event, $opts); + } + return $out; + } + +/** + * Pass variables into Javascript. Allows you to set variables that will be + * output when the buffer is fetched with `JsHelper::getBuffer()` or `JsHelper::writeBuffer()` + * The Javascript variable used to output set variables can be controlled with `JsHelper::$setVariable` + * + * @param mixed $one Either an array of variables to set, or the name of the variable to set. + * @param mixed $two If $one is a string, $two is the value for that key. + * @return void + */ + public function set($one, $two = null) { + $data = null; + if (is_array($one)) { + if (is_array($two)) { + $data = array_combine($one, $two); + } else { + $data = $one; + } + } else { + $data = array($one => $two); + } + if ($data == null) { + return false; + } + $this->__jsVars = array_merge($this->__jsVars, $data); + } + +/** + * Uses the selected JS engine to create a submit input + * element that is enhanced with Javascript. Options can include + * both those for FormHelper::submit() and JsBaseEngine::request(), JsBaseEngine::event(); + * + * Forms submitting with this method, cannot send files. Files do not transfer over XmlHttpRequest + * and require an iframe or flash. + * + * ### Options + * + * - `url` The url you wish the XHR request to submit to. + * - `confirm` A string to use for a confirm() message prior to submitting the request. + * - `method` The method you wish the form to send by, defaults to POST + * - `buffer` Whether or not you wish the script code to be buffered, defaults to true. + * - Also see options for JsHelper::request() and JsHelper::event() + * + * @param string $title The display text of the submit button. + * @param array $options Array of options to use. See the options for the above mentioned methods. + * @return string Completed submit button. + */ + public function submit($caption = null, $options = array()) { + if (!isset($options['id'])) { + $options['id'] = 'submit-' . intval(mt_rand()); + } + $formOptions = array('div'); + list($options, $htmlOptions) = $this->_getHtmlOptions($options, $formOptions); + $out = $this->Form->submit($caption, $htmlOptions); + + $this->get('#' . $htmlOptions['id']); + + $options['data'] = $this->serializeForm(array('isForm' => false, 'inline' => true)); + $requestString = $url = ''; + if (isset($options['confirm'])) { + $requestString = $this->confirmReturn($options['confirm']); + unset($options['confirm']); + } + if (isset($options['url'])) { + $url = $options['url']; + unset($options['url']); + } + if (!isset($options['method'])) { + $options['method'] = 'post'; + } + $options['dataExpression'] = true; + + $buffer = isset($options['buffer']) ? $options['buffer'] : null; + $safe = isset($options['safe']) ? $options['safe'] : true; + unset($options['buffer'], $options['safe']); + + $requestString .= $this->request($url, $options); + if (!empty($requestString)) { + $event = $this->event('click', $requestString, $options + array('buffer' => $buffer)); + } + if (isset($buffer) && !$buffer) { + $opts = array('safe' => $safe); + $out .= $this->Html->scriptBlock($event, $opts); + } + return $out; + } + +/** + * Parse a set of Options and extract the Html options. + * Extracted Html Options are removed from the $options param. + * + * @param array $options Options to filter. + * @param array $additional Array of additional keys to extract and include in the return options array. + * @return array Array of js options and Htmloptions + */ + protected function _getHtmlOptions($options, $additional = array()) { + $htmlKeys = array_merge(array('class', 'id', 'escape', 'onblur', 'onfocus', 'rel', 'title'), $additional); + $htmlOptions = array(); + foreach ($htmlKeys as $key) { + if (isset($options[$key])) { + $htmlOptions[$key] = $options[$key]; + } + unset($options[$key]); + } + if (isset($options['htmlAttributes'])) { + $htmlOptions = array_merge($htmlOptions, $options['htmlAttributes']); + unset($options['htmlAttributes']); + } + return array($options, $htmlOptions); + } +} \ No newline at end of file diff --git a/cake/libs/view/helpers/mootools_engine.php b/lib/Cake/View/Helper/MootoolsEngineHelper.php similarity index 99% rename from cake/libs/view/helpers/mootools_engine.php rename to lib/Cake/View/Helper/MootoolsEngineHelper.php index 0b3e50af8..37c61b6c9 100644 --- a/cake/libs/view/helpers/mootools_engine.php +++ b/lib/Cake/View/Helper/MootoolsEngineHelper.php @@ -24,7 +24,8 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Js'); + +App::uses('JsBaseEngineHelper', 'View/Helper'); class MootoolsEngineHelper extends JsBaseEngineHelper { /** diff --git a/cake/libs/view/helpers/number.php b/lib/Cake/View/Helper/NumberHelper.php similarity index 99% rename from cake/libs/view/helpers/number.php rename to lib/Cake/View/Helper/NumberHelper.php index 8c9a2e665..f2449a4ea 100644 --- a/cake/libs/view/helpers/number.php +++ b/lib/Cake/View/Helper/NumberHelper.php @@ -19,6 +19,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppHelper', 'View/Helper'); + /** * Number helper library. * diff --git a/cake/libs/view/helpers/paginator.php b/lib/Cake/View/Helper/PaginatorHelper.php similarity index 99% rename from cake/libs/view/helpers/paginator.php rename to lib/Cake/View/Helper/PaginatorHelper.php index e84ed1a74..eed163a95 100755 --- a/cake/libs/view/helpers/paginator.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppHelper', 'View/Helper'); + /** * Pagination Helper class for easy generation of pagination links. * @@ -96,9 +98,7 @@ class PaginatorHelper extends AppHelper { $ajaxProvider = isset($settings['ajax']) ? $settings['ajax'] : 'Js'; $this->helpers[] = $ajaxProvider; $this->_ajaxHelperClass = $ajaxProvider; - if (!class_exists($ajaxProvider . 'Helper')) { - App::import('Helper', $ajaxProvider); - } + App::uses($ajaxProvider . 'Helper', 'View/Helper'); $classname = $ajaxProvider . 'Helper'; if (!method_exists($classname, 'link')) { throw new CakeException(sprintf( diff --git a/cake/libs/view/helpers/prototype_engine.php b/lib/Cake/View/Helper/PrototypeEngineHelper.php similarity index 99% rename from cake/libs/view/helpers/prototype_engine.php rename to lib/Cake/View/Helper/PrototypeEngineHelper.php index 17706d8e1..79c5ac17a 100644 --- a/cake/libs/view/helpers/prototype_engine.php +++ b/lib/Cake/View/Helper/PrototypeEngineHelper.php @@ -19,7 +19,8 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Js'); + +App::uses('JsBaseEngineHelper', 'View/Helper'); class PrototypeEngineHelper extends JsBaseEngineHelper { /** diff --git a/cake/libs/view/helpers/rss.php b/lib/Cake/View/Helper/RssHelper.php similarity index 99% rename from cake/libs/view/helpers/rss.php rename to lib/Cake/View/Helper/RssHelper.php index c1b7d219d..890e7c603 100644 --- a/cake/libs/view/helpers/rss.php +++ b/lib/Cake/View/Helper/RssHelper.php @@ -16,7 +16,9 @@ * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Xml'); + +App::uses('AppHelper', 'View/Helper'); +App::uses('Xml', 'Utility'); /** * RSS Helper class for easy output RSS structures. diff --git a/cake/libs/view/helpers/session.php b/lib/Cake/View/Helper/SessionHelper.php similarity index 98% rename from cake/libs/view/helpers/session.php rename to lib/Cake/View/Helper/SessionHelper.php index 6dcf90294..eaa5260af 100644 --- a/cake/libs/view/helpers/session.php +++ b/lib/Cake/View/Helper/SessionHelper.php @@ -16,9 +16,10 @@ * @since CakePHP(tm) v 1.1.7.3328 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('CakeSession')) { - require LIBS . 'cake_session.php'; -} + +App::uses('AppHelper', 'View/Helper'); +App::uses('CakeSession', 'Model/Datasource'); + /** * Session Helper. * diff --git a/cake/libs/view/helpers/text.php b/lib/Cake/View/Helper/TextHelper.php similarity index 98% rename from cake/libs/view/helpers/text.php rename to lib/Cake/View/Helper/TextHelper.php index 307859513..4195c3ac0 100644 --- a/cake/libs/view/helpers/text.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -23,12 +23,9 @@ * Included libraries. * */ -if (!class_exists('HtmlHelper')) { - App::import('Helper', 'Html'); -} -if (!class_exists('Multibyte')) { - App::import('Core', 'Multibyte'); -} +App::uses('AppHelper', 'View/Helper'); +App::uses('HtmlHelper', 'Helper'); +App::uses('Multibyte', 'I18n'); /** * Text helper library. diff --git a/cake/libs/view/helpers/time.php b/lib/Cake/View/Helper/TimeHelper.php similarity index 99% rename from cake/libs/view/helpers/time.php rename to lib/Cake/View/Helper/TimeHelper.php index 901c0a074..269c4b9f0 100644 --- a/cake/libs/view/helpers/time.php +++ b/lib/Cake/View/Helper/TimeHelper.php @@ -17,6 +17,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppHelper', 'View/Helper'); + /** * Time Helper class for easy use of time data. * diff --git a/cake/libs/view/helper_collection.php b/lib/Cake/View/HelperCollection.php similarity index 86% rename from cake/libs/view/helper_collection.php rename to lib/Cake/View/HelperCollection.php index 4a6fd5d88..ee291525b 100644 --- a/cake/libs/view/helper_collection.php +++ b/lib/Cake/View/HelperCollection.php @@ -15,6 +15,9 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('ObjectCollection', 'Utility'); + class HelperCollection extends ObjectCollection { /** @@ -59,7 +62,7 @@ class HelperCollection extends ObjectCollection { $alias = $helper; $helper = $settings['className']; } - list($plugin, $name) = pluginSplit($helper); + list($plugin, $name) = pluginSplit($helper, true); if (!isset($alias)) { $alias = $name; } @@ -68,19 +71,12 @@ class HelperCollection extends ObjectCollection { return $this->_loaded[$alias]; } $helperClass = $name . 'Helper'; + App::uses($helperClass, $plugin . 'View/Helper'); if (!class_exists($helperClass)) { - if (!App::import('Helper', $helper)) { - throw new MissingHelperFileException(array( - 'class' => $helperClass, - 'file' => Inflector::underscore($name) . '.php' - )); - } - if (!class_exists($helperClass)) { - throw new MissingHelperClassException(array( - 'class' => $helperClass, - 'file' => Inflector::underscore($name) . '.php' - )); - } + throw new MissingHelperClassException(array( + 'class' => $helperClass, + 'file' => $helperClass . '.php' + )); } $this->_loaded[$alias] = new $helperClass($this->_View, $settings); diff --git a/cake/libs/view/media.php b/lib/Cake/View/MediaView.php similarity index 98% rename from cake/libs/view/media.php rename to lib/Cake/View/MediaView.php index a2b9c1cff..70e92979c 100644 --- a/cake/libs/view/media.php +++ b/lib/Cake/View/MediaView.php @@ -16,7 +16,8 @@ * @since CakePHP(tm) v 1.2.0.5714 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('View', 'View', false); +App::uses('View', 'View'); +App::uses('CakeRequest', 'Network'); /** * Media View provides a custom view implementation for sending files to visitors. Its great @@ -78,7 +79,6 @@ class MediaView extends View { if (is_object($controller) && isset($controller->response)) { $this->response = $controller->response; } else { - App::import('Core', 'CakeRequest'); $this->response = new CakeResponse; } } diff --git a/cake/libs/view/scaffold.php b/lib/Cake/View/ScaffoldView.php similarity index 95% rename from cake/libs/view/scaffold.php rename to lib/Cake/View/ScaffoldView.php index 6f051a211..746e84eea 100644 --- a/cake/libs/view/scaffold.php +++ b/lib/Cake/View/ScaffoldView.php @@ -18,7 +18,7 @@ * @since Cake v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('View', 'Theme'); +App::uses('ThemeView', 'View'); /** * ScaffoldView provides specific view file loading features for scaffolded views. @@ -80,7 +80,7 @@ class ScaffoldView extends ThemeView { } if ($name === 'scaffolds' . DS . $subDir . 'error') { - return LIBS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp'; + return LIBS . 'View' . DS . 'errors' . DS . 'scaffold_error.ctp'; } throw new MissingViewException($paths[0] . $name . $this->ext); diff --git a/cake/libs/view/theme.php b/lib/Cake/View/ThemeView.php similarity index 96% rename from cake/libs/view/theme.php rename to lib/Cake/View/ThemeView.php index 544aacdc3..df85282b7 100644 --- a/cake/libs/view/theme.php +++ b/lib/Cake/View/ThemeView.php @@ -16,7 +16,7 @@ * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('View', 'View'); +App::uses('View', 'View'); /** * Theme view class @@ -58,7 +58,7 @@ class ThemeView extends View { $count = count($paths); for ($i = 0; $i < $count; $i++) { if (strpos($paths[$i], DS . 'plugins' . DS) === false - && strpos($paths[$i], DS . 'libs' . DS . 'view') === false) { + && strpos($paths[$i], DS . 'Cake' . DS . 'View') === false) { if ($plugin) { $themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS . 'plugins' . DS . $plugin . DS; } diff --git a/cake/libs/view/view.php b/lib/Cake/View/View.php similarity index 98% rename from cake/libs/view/view.php rename to lib/Cake/View/View.php index 89d5ae5d5..26b9f2e35 100644 --- a/cake/libs/view/view.php +++ b/lib/Cake/View/View.php @@ -20,8 +20,8 @@ /** * Included libraries. */ -App::import('View', 'HelperCollection', false); -App::import('View', 'Helper', false); +App::uses('HelperCollection', 'View'); +App::uses('Router', 'Routing'); /** * View, the V in the MVC triad. View interacts with Helpers and view variables passed @@ -687,7 +687,7 @@ class View extends Object { if (strpos($name, DS) === false && $name[0] !== '.') { $name = $this->viewPath . DS . $subDir . Inflector::underscore($name); } elseif (strpos($name, DS) !== false) { - if ($name{0} === DS || $name{1} === ':') { + if ($name[0] === DS || $name[1] === ':') { if (is_file($name)) { return $name; } @@ -799,8 +799,8 @@ class View extends Object { return $this->__paths; } $paths = array(); - $viewPaths = App::path('views'); - $corePaths = array_flip(App::core('views')); + $viewPaths = App::path('View'); + $corePaths = array_flip(App::core('View')); if (!empty($plugin)) { $count = count($viewPaths); @@ -809,9 +809,10 @@ class View extends Object { $paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS; } } - $paths[] = App::pluginPath($plugin) . 'views' . DS; + $paths = array_merge($paths, App::path('View', $plugin)); } - $this->__paths = array_merge($paths, $viewPaths); + + $this->__paths = array_unique(array_merge($paths, $viewPaths, array_keys($corePaths))); return $this->__paths; } } diff --git a/cake/libs/view/elements/email/html/default.ctp b/lib/Cake/View/elements/email/html/default.ctp similarity index 100% rename from cake/libs/view/elements/email/html/default.ctp rename to lib/Cake/View/elements/email/html/default.ctp diff --git a/cake/libs/view/elements/email/text/default.ctp b/lib/Cake/View/elements/email/text/default.ctp similarity index 100% rename from cake/libs/view/elements/email/text/default.ctp rename to lib/Cake/View/elements/email/text/default.ctp diff --git a/cake/libs/view/elements/exception_stack_trace.ctp b/lib/Cake/View/elements/exception_stack_trace.ctp similarity index 100% rename from cake/libs/view/elements/exception_stack_trace.ctp rename to lib/Cake/View/elements/exception_stack_trace.ctp diff --git a/cake/libs/view/elements/sql_dump.ctp b/lib/Cake/View/elements/sql_dump.ctp similarity index 100% rename from cake/libs/view/elements/sql_dump.ctp rename to lib/Cake/View/elements/sql_dump.ctp diff --git a/cake/libs/view/errors/error400.ctp b/lib/Cake/View/errors/error400.ctp similarity index 100% rename from cake/libs/view/errors/error400.ctp rename to lib/Cake/View/errors/error400.ctp diff --git a/cake/libs/view/errors/error500.ctp b/lib/Cake/View/errors/error500.ctp similarity index 100% rename from cake/libs/view/errors/error500.ctp rename to lib/Cake/View/errors/error500.ctp diff --git a/cake/libs/view/errors/missing_action.ctp b/lib/Cake/View/errors/missing_action.ctp similarity index 100% rename from cake/libs/view/errors/missing_action.ctp rename to lib/Cake/View/errors/missing_action.ctp diff --git a/cake/libs/view/errors/missing_behavior_class.ctp b/lib/Cake/View/errors/missing_behavior_class.ctp similarity index 100% rename from cake/libs/view/errors/missing_behavior_class.ctp rename to lib/Cake/View/errors/missing_behavior_class.ctp diff --git a/cake/libs/view/errors/missing_behavior_file.ctp b/lib/Cake/View/errors/missing_behavior_file.ctp similarity index 100% rename from cake/libs/view/errors/missing_behavior_file.ctp rename to lib/Cake/View/errors/missing_behavior_file.ctp diff --git a/cake/libs/view/errors/missing_component_class.ctp b/lib/Cake/View/errors/missing_component_class.ctp similarity index 100% rename from cake/libs/view/errors/missing_component_class.ctp rename to lib/Cake/View/errors/missing_component_class.ctp diff --git a/cake/libs/view/errors/missing_component_file.ctp b/lib/Cake/View/errors/missing_component_file.ctp similarity index 100% rename from cake/libs/view/errors/missing_component_file.ctp rename to lib/Cake/View/errors/missing_component_file.ctp diff --git a/cake/libs/view/errors/missing_connection.ctp b/lib/Cake/View/errors/missing_connection.ctp similarity index 100% rename from cake/libs/view/errors/missing_connection.ctp rename to lib/Cake/View/errors/missing_connection.ctp diff --git a/cake/libs/view/errors/missing_controller.ctp b/lib/Cake/View/errors/missing_controller.ctp similarity index 100% rename from cake/libs/view/errors/missing_controller.ctp rename to lib/Cake/View/errors/missing_controller.ctp diff --git a/cake/libs/view/errors/missing_database.ctp b/lib/Cake/View/errors/missing_database.ctp similarity index 100% rename from cake/libs/view/errors/missing_database.ctp rename to lib/Cake/View/errors/missing_database.ctp diff --git a/cake/libs/view/errors/missing_datasource_config.ctp b/lib/Cake/View/errors/missing_datasource_config.ctp similarity index 100% rename from cake/libs/view/errors/missing_datasource_config.ctp rename to lib/Cake/View/errors/missing_datasource_config.ctp diff --git a/cake/libs/view/errors/missing_datasource_file.ctp b/lib/Cake/View/errors/missing_datasource_file.ctp similarity index 100% rename from cake/libs/view/errors/missing_datasource_file.ctp rename to lib/Cake/View/errors/missing_datasource_file.ctp diff --git a/cake/libs/view/errors/missing_helper_class.ctp b/lib/Cake/View/errors/missing_helper_class.ctp similarity index 100% rename from cake/libs/view/errors/missing_helper_class.ctp rename to lib/Cake/View/errors/missing_helper_class.ctp diff --git a/cake/libs/view/errors/missing_helper_file.ctp b/lib/Cake/View/errors/missing_helper_file.ctp similarity index 100% rename from cake/libs/view/errors/missing_helper_file.ctp rename to lib/Cake/View/errors/missing_helper_file.ctp diff --git a/cake/libs/view/errors/missing_layout.ctp b/lib/Cake/View/errors/missing_layout.ctp similarity index 100% rename from cake/libs/view/errors/missing_layout.ctp rename to lib/Cake/View/errors/missing_layout.ctp diff --git a/cake/libs/view/errors/missing_table.ctp b/lib/Cake/View/errors/missing_table.ctp similarity index 100% rename from cake/libs/view/errors/missing_table.ctp rename to lib/Cake/View/errors/missing_table.ctp diff --git a/cake/libs/view/errors/missing_view.ctp b/lib/Cake/View/errors/missing_view.ctp similarity index 100% rename from cake/libs/view/errors/missing_view.ctp rename to lib/Cake/View/errors/missing_view.ctp diff --git a/cake/libs/view/errors/private_action.ctp b/lib/Cake/View/errors/private_action.ctp similarity index 100% rename from cake/libs/view/errors/private_action.ctp rename to lib/Cake/View/errors/private_action.ctp diff --git a/cake/libs/view/errors/scaffold_error.ctp b/lib/Cake/View/errors/scaffold_error.ctp similarity index 100% rename from cake/libs/view/errors/scaffold_error.ctp rename to lib/Cake/View/errors/scaffold_error.ctp diff --git a/cake/libs/view/layouts/ajax.ctp b/lib/Cake/View/layouts/ajax.ctp similarity index 100% rename from cake/libs/view/layouts/ajax.ctp rename to lib/Cake/View/layouts/ajax.ctp diff --git a/cake/libs/view/layouts/default.ctp b/lib/Cake/View/layouts/default.ctp similarity index 100% rename from cake/libs/view/layouts/default.ctp rename to lib/Cake/View/layouts/default.ctp diff --git a/cake/libs/view/layouts/email/html/default.ctp b/lib/Cake/View/layouts/email/html/default.ctp similarity index 100% rename from cake/libs/view/layouts/email/html/default.ctp rename to lib/Cake/View/layouts/email/html/default.ctp diff --git a/cake/libs/view/layouts/email/text/default.ctp b/lib/Cake/View/layouts/email/text/default.ctp similarity index 100% rename from cake/libs/view/layouts/email/text/default.ctp rename to lib/Cake/View/layouts/email/text/default.ctp diff --git a/cake/libs/view/layouts/flash.ctp b/lib/Cake/View/layouts/flash.ctp similarity index 100% rename from cake/libs/view/layouts/flash.ctp rename to lib/Cake/View/layouts/flash.ctp diff --git a/cake/libs/view/layouts/js/default.ctp b/lib/Cake/View/layouts/js/default.ctp similarity index 100% rename from cake/libs/view/layouts/js/default.ctp rename to lib/Cake/View/layouts/js/default.ctp diff --git a/cake/libs/view/layouts/rss/default.ctp b/lib/Cake/View/layouts/rss/default.ctp similarity index 100% rename from cake/libs/view/layouts/rss/default.ctp rename to lib/Cake/View/layouts/rss/default.ctp diff --git a/cake/libs/view/layouts/xml/default.ctp b/lib/Cake/View/layouts/xml/default.ctp similarity index 100% rename from cake/libs/view/layouts/xml/default.ctp rename to lib/Cake/View/layouts/xml/default.ctp diff --git a/cake/libs/view/pages/home.ctp b/lib/Cake/View/pages/home.ctp similarity index 95% rename from cake/libs/view/pages/home.ctp rename to lib/Cake/View/pages/home.ctp index 400df888b..96aa8dfad 100644 --- a/cake/libs/view/pages/home.ctp +++ b/lib/Cake/View/pages/home.ctp @@ -15,15 +15,15 @@ * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (Configure::read() == 0): +if (Configure::read('debug') == 0): throw new NotFoundException(); endif; -App::import('Core', 'Debugger'); +App::uses('Debugger', 'Utility'); ?> 0): +if (Configure::read('debug') > 0): Debugger::checkSecurityKeys(); endif; ?> @@ -71,24 +71,11 @@ endif; endif; ?> -'; - __('PCRE has not been compiled with Unicode support.'); - echo '--enable-unicode-properties
when configuring');
- echo '';
- }
-?>
getDataSource('default');
+ $connected = ConnectionManager::getDataSource('default');
} catch (Exception $e) {
$connected = false;
}
@@ -107,6 +94,16 @@ if (isset($filePresent)):
?>
+';
+ __('PCRE has not been compiled with Unicode support.');
+ echo '--enable-unicode-properties
when configuring');
+ echo '';
+ }
+?>
array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale' . DS)
+ 'locales' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'locale' . DS)
));
$this->_language = Configure::read('Config.language');
}
diff --git a/cake/tests/cases/console/all_console.test.php b/lib/Cake/tests/cases/console/all_console.test.php
similarity index 100%
rename from cake/tests/cases/console/all_console.test.php
rename to lib/Cake/tests/cases/console/all_console.test.php
diff --git a/cake/tests/cases/console/all_console_libs.test.php b/lib/Cake/tests/cases/console/all_console_libs.test.php
similarity index 100%
rename from cake/tests/cases/console/all_console_libs.test.php
rename to lib/Cake/tests/cases/console/all_console_libs.test.php
diff --git a/cake/tests/cases/console/all_shells.test.php b/lib/Cake/tests/cases/console/all_shells.test.php
similarity index 100%
rename from cake/tests/cases/console/all_shells.test.php
rename to lib/Cake/tests/cases/console/all_shells.test.php
diff --git a/cake/tests/cases/console/all_tasks.test.php b/lib/Cake/tests/cases/console/all_tasks.test.php
similarity index 100%
rename from cake/tests/cases/console/all_tasks.test.php
rename to lib/Cake/tests/cases/console/all_tasks.test.php
diff --git a/cake/tests/cases/console/libs/console_error_handler.test.php b/lib/Cake/tests/cases/console/libs/console_error_handler.test.php
similarity index 98%
rename from cake/tests/cases/console/libs/console_error_handler.test.php
rename to lib/Cake/tests/cases/console/libs/console_error_handler.test.php
index 51d16ab0f..6b4538d41 100644
--- a/cake/tests/cases/console/libs/console_error_handler.test.php
+++ b/lib/Cake/tests/cases/console/libs/console_error_handler.test.php
@@ -16,7 +16,8 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-require_once CONSOLE_LIBS . 'console_error_handler.php';
+
+App::uses('ConsoleErrorHandler', 'Console');
/**
* ConsoleErrorHandler Test case.
diff --git a/cake/tests/cases/console/libs/console_option_parser.test.php b/lib/Cake/tests/cases/console/libs/console_option_parser.test.php
similarity index 99%
rename from cake/tests/cases/console/libs/console_option_parser.test.php
rename to lib/Cake/tests/cases/console/libs/console_option_parser.test.php
index fac420ecd..1c60f414b 100644
--- a/cake/tests/cases/console/libs/console_option_parser.test.php
+++ b/lib/Cake/tests/cases/console/libs/console_option_parser.test.php
@@ -17,7 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-require_once CONSOLE_LIBS . 'console_option_parser.php';
+App::uses('ConsoleOptionParser', 'Console');
class ConsoleOptionParserTest extends CakeTestCase {
diff --git a/cake/tests/cases/console/libs/console_output.test.php b/lib/Cake/tests/cases/console/libs/console_output.test.php
similarity index 99%
rename from cake/tests/cases/console/libs/console_output.test.php
rename to lib/Cake/tests/cases/console/libs/console_output.test.php
index d2af99d04..1063a2640 100644
--- a/cake/tests/cases/console/libs/console_output.test.php
+++ b/lib/Cake/tests/cases/console/libs/console_output.test.php
@@ -17,7 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-require_once CONSOLE_LIBS . 'console_output.php';
+App::uses('ConsoleOutput', 'Console');
class ConsoleOutputTest extends CakeTestCase {
diff --git a/cake/tests/cases/console/libs/help_formatter.test.php b/lib/Cake/tests/cases/console/libs/help_formatter.test.php
similarity index 99%
rename from cake/tests/cases/console/libs/help_formatter.test.php
rename to lib/Cake/tests/cases/console/libs/help_formatter.test.php
index 5caae1490..f296a84ea 100644
--- a/cake/tests/cases/console/libs/help_formatter.test.php
+++ b/lib/Cake/tests/cases/console/libs/help_formatter.test.php
@@ -1,7 +1,7 @@
getMock('ShellDispatcher', array(), array(), '', false);
$shell = $this->getMock('Shell', array(), array(), '', false);
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$this->Tasks = new TaskCollection($shell, $dispatcher);
diff --git a/cake/tests/cases/console/shell_dispatcher.test.php b/lib/Cake/tests/cases/console/shell_dispatcher.test.php
similarity index 97%
rename from cake/tests/cases/console/shell_dispatcher.test.php
rename to lib/Cake/tests/cases/console/shell_dispatcher.test.php
index eb6fd2bd6..4e2f8efe4 100644
--- a/cake/tests/cases/console/shell_dispatcher.test.php
+++ b/lib/Cake/tests/cases/console/shell_dispatcher.test.php
@@ -16,7 +16,8 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+
+App::uses('ShellDispatcher', 'Console');
/**
* TestShellDispatcher class
@@ -116,11 +117,10 @@ class ShellDispatcherTest extends CakeTestCase {
parent::setUp();
App::build(array(
'plugins' => array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
+ LIBS . '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 . 'console' . DS . 'shells' . DS
+ 'Console/Command' => array(
+ LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS . 'shells' . DS
)
), true);
}
diff --git a/cake/tests/cases/console/shells/acl.test.php b/lib/Cake/tests/cases/console/shells/acl.test.php
similarity index 98%
rename from cake/tests/cases/console/shells/acl.test.php
rename to lib/Cake/tests/cases/console/shells/acl.test.php
index b13d593b4..7f03ae7d8 100644
--- a/cake/tests/cases/console/shells/acl.test.php
+++ b/lib/Cake/tests/cases/console/shells/acl.test.php
@@ -16,10 +16,11 @@
* @since CakePHP v 1.2.0.7726
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', 'Acl');
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('Shell', 'Console');
+App::uses('AclShell', 'Console/Command');
+App::uses('ComponentCollection', 'Controller');
/**
* AclShellTest class
diff --git a/cake/tests/cases/console/shells/api.test.php b/lib/Cake/tests/cases/console/shells/api.test.php
similarity index 95%
rename from cake/tests/cases/console/shells/api.test.php
rename to lib/Cake/tests/cases/console/shells/api.test.php
index 99e5abf33..03576ddb7 100644
--- a/cake/tests/cases/console/shells/api.test.php
+++ b/lib/Cake/tests/cases/console/shells/api.test.php
@@ -16,11 +16,10 @@
* @since CakePHP v 1.2.0.7726
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', 'Api');
-
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('Shell', 'Console');
+App::uses('ApiShell', 'Console/Command');
/**
* ApiShellTest class
diff --git a/cake/tests/cases/console/shells/bake.test.php b/lib/Cake/tests/cases/console/shells/bake.test.php
similarity index 89%
rename from cake/tests/cases/console/shells/bake.test.php
rename to lib/Cake/tests/cases/console/shells/bake.test.php
index 7b2767389..a4c90203f 100644
--- a/cake/tests/cases/console/shells/bake.test.php
+++ b/lib/Cake/tests/cases/console/shells/bake.test.php
@@ -17,14 +17,14 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', 'Bake', false);
-App::import('Shell', 'tasks/model');
-App::import('Shell', 'tasks/controller');
-App::import('Shell', 'tasks/db_config');
-App::import('Core', 'Controller');
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('Shell', 'Console');
+App::uses('BakeShell', 'Console/Command');
+App::uses('ModelTask', 'Console/Command/Task');
+App::uses('ControllerTask', 'Console/Command/Task');
+App::uses('DbConfigTask', 'Console/Command/Task');
+App::uses('Controller', 'Controller');
if (!class_exists('UsersController')) {
class UsersController extends Controller {
@@ -75,7 +75,7 @@ class BakeShellTest extends CakeTestCase {
* @return void
*/
public function testAllWithModelName() {
- App::import('Model', 'User');
+ App::uses('User', 'Model');
$userExists = class_exists('User');
if ($this->skipIf($userExists, 'User class exists, cannot test `bake all [param]`. %s')) {
return;
diff --git a/cake/tests/cases/console/shells/command_list.test.php b/lib/Cake/tests/cases/console/shells/command_list.test.php
similarity index 89%
rename from cake/tests/cases/console/shells/command_list.test.php
rename to lib/Cake/tests/cases/console/shells/command_list.test.php
index 7b518730a..461fe00c0 100644
--- a/cake/tests/cases/console/shells/command_list.test.php
+++ b/lib/Cake/tests/cases/console/shells/command_list.test.php
@@ -16,7 +16,11 @@
* @since CakePHP v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'CommandList', false);
+
+App::uses('CommandListShell', 'Console/Command');
+App::uses('ConsoleOutput', 'Console');
+App::uses('ConsoleInput', 'Console');
+App::uses('Shell', 'Console');
class TestStringOutput extends ConsoleOutput {
@@ -37,13 +41,10 @@ class CommandListTest extends CakeTestCase {
parent::setUp();
App::build(array(
'plugins' => array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
+ LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
),
- 'shells' => array(
- CORE_PATH ?
- CORE_PATH . CAKE . 'console' . DS . 'shells' . DS :
- CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'shells' .DS,
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'console' . DS . 'shells' . DS
+ 'Console/Command' => array(
+ LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS . 'shells' . DS
)
), true);
App::objects('plugin', null, false);
@@ -83,6 +84,7 @@ class CommandListTest extends CakeTestCase {
$expected = "/welcome \[.*TestPluginTwo.*\]/";
$this->assertPattern($expected, $output);
+
$expected = "/acl \[.*CORE.*\]/";
$this->assertPattern($expected, $output);
diff --git a/cake/tests/cases/console/shells/schema.test.php b/lib/Cake/tests/cases/console/shells/schema.test.php
similarity index 94%
rename from cake/tests/cases/console/shells/schema.test.php
rename to lib/Cake/tests/cases/console/shells/schema.test.php
index d18b7a478..ce48e0626 100644
--- a/cake/tests/cases/console/shells/schema.test.php
+++ b/lib/Cake/tests/cases/console/shells/schema.test.php
@@ -16,13 +16,13 @@
* @since CakePHP v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', 'Schema', false);
-App::import('Model', 'CakeSchema', false);
-
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
-
+App::uses('ShellDispatcher', 'Console');
+App::uses('ConsoleOutput', 'Console');
+App::uses('ConsoleInput', 'Console');
+App::uses('Shell', 'Console');
+App::uses('CakeSchema', 'Model');
+App::uses('SchemaShell', 'Console/Command');
/**
* Test for Schema database management
@@ -187,7 +187,7 @@ class SchemaShellTest extends CakeTestCase {
*/
public function testViewWithPlugins() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$this->Shell->args = array('TestPlugin.schema');
$this->Shell->startup();
@@ -236,7 +236,7 @@ class SchemaShellTest extends CakeTestCase {
*/
public function testDumpFileWritingWithPlugins() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$this->Shell->args = array('TestPlugin.TestPluginApp');
$this->Shell->params = array(
@@ -332,7 +332,7 @@ class SchemaShellTest extends CakeTestCase {
*/
public function testGenerateWithPlugins() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
App::objects('plugin', null, false);
@@ -445,14 +445,14 @@ class SchemaShellTest extends CakeTestCase {
*/
public function testPluginParam() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$this->Shell->params = array(
'plugin' => 'TestPlugin',
'connection' => 'test'
);
$this->Shell->startup();
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'config' . DS . 'schema';
+ $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'config' . DS . 'schema';
$this->assertEqual($this->Shell->Schema->path, $expected);
}
@@ -463,7 +463,7 @@ class SchemaShellTest extends CakeTestCase {
*/
public function testPluginDotSyntaxWithCreate() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$this->Shell->params = array(
'connection' => 'test'
diff --git a/cake/tests/cases/console/shells/shell.test.php b/lib/Cake/tests/cases/console/shells/shell.test.php
similarity index 98%
rename from cake/tests/cases/console/shells/shell.test.php
rename to lib/Cake/tests/cases/console/shells/shell.test.php
index ac5d77faf..fbbab30b1 100644
--- a/cake/tests/cases/console/shells/shell.test.php
+++ b/lib/Cake/tests/cases/console/shells/shell.test.php
@@ -18,10 +18,10 @@
* @since CakePHP v 1.2.0.7726
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Folder');
-App::import('Shell', 'Shell', false);
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('Shell', 'Console');
+App::uses('Folder', 'Utility');
/**
* ShellTestShell class
@@ -169,8 +169,8 @@ class ShellTest extends CakeTestCase {
*/
public function testInitialize() {
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)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS)
), true);
$this->Shell->uses = array('TestPlugin.TestPluginPost');
diff --git a/cake/tests/cases/console/shells/tasks/controller.test.php b/lib/Cake/tests/cases/console/shells/tasks/controller.test.php
similarity index 94%
rename from cake/tests/cases/console/shells/tasks/controller.test.php
rename to lib/Cake/tests/cases/console/shells/tasks/controller.test.php
index 5abda16c9..a03f82066 100644
--- a/cake/tests/cases/console/shells/tasks/controller.test.php
+++ b/lib/Cake/tests/cases/console/shells/tasks/controller.test.php
@@ -16,33 +16,32 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'ClassRegistry');
-App::import('View', 'Helper', false);
-App::import('Shell', 'Shell', false);
-App::import('Shell', array(
- 'tasks/project',
- 'tasks/controller',
- 'tasks/model',
- 'tasks/template',
- 'tasks/test'
-));
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('Shell', 'Console');
+App::uses('CakeSchema', 'Model');
+App::uses('ClassRegistry', 'Utility');
+App::uses('Helper', 'View/Helper');
+App::uses('ProjectTask', 'Console/Command/Task');
+App::uses('ControllerTask', 'Console/Command/Task');
+App::uses('ModelTask', 'Console/Command/Task');
+App::uses('TemplateTask', 'Console/Command/Task');
+App::uses('TestTask', 'Console/Command/Task');
+App::uses('Model', 'Model');
-$imported = App::import('Model', 'BakeArticle');
-$imported = $imported || App::import('Model', 'BakeComment');
-$imported = $imported || App::import('Model', 'BakeTag');
+App::uses('BakeArticle', 'Model');
+App::uses('BakeComment', 'Model');
+App::uses('BakeTags', 'Model');
+$imported = class_exists('BakeArticle') || class_exists('BakeComment') || class_exists('BakeTag');
if (!$imported) {
define('ARTICLE_MODEL_CREATED', true);
- App::import('Core', 'Model');
class BakeArticle extends Model {
public $name = 'BakeArticle';
public $hasMany = array('BakeComment');
public $hasAndBelongsToMany = array('BakeTag');
}
-
}
/**
@@ -300,7 +299,7 @@ class ControllerTaskTest extends CakeTestCase {
$components = array('Acl', 'Auth');
$uses = array('Comment', 'User');
- $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'articles_controller.php';
+ $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'ArticlesController.php';
$this->Task->expects($this->at(1))->method('createFile')->with(
$path,
@@ -314,7 +313,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->bake('Articles', '--actions--', array(), array(), array());
$this->Task->plugin = 'controllerTest';
- $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'articles_controller.php';
+ $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'ArticlesController.php';
$this->Task->bake('Articles', '--actions--', array(), array(), array());
$this->assertEqual($this->Task->Template->templateVars['plugin'], 'ControllerTest');
@@ -443,7 +442,7 @@ class ControllerTaskTest extends CakeTestCase {
'y' // looks good?
));
- $filename = '/my/path/bake_articles_controller.php';
+ $filename = '/my/path/BakeArticlesController.php';
$this->Task->expects($this->once())->method('createFile')->with(
$filename,
new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/')
@@ -483,7 +482,7 @@ class ControllerTaskTest extends CakeTestCase {
->method('getPrefix')
->will($this->returnValue('admin_'));
- $filename = '/my/path/bake_articles_controller.php';
+ $filename = '/my/path/BakeArticlesController.php';
$this->Task->expects($this->once())->method('createFile')->with(
$filename,
new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/')
@@ -513,7 +512,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->expects($this->any())->method('_checkUnitTest')->will($this->returnValue(true));
$this->Task->Test->expects($this->once())->method('bake');
- $filename = '/my/path/bake_articles_controller.php';
+ $filename = '/my/path/BakeArticlesController.php';
$this->Task->expects($this->once())->method('createFile')->with(
$filename,
new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/')
@@ -535,7 +534,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->path = '/my/path/';
$this->Task->args = array('BakeArticles');
- $filename = '/my/path/bake_articles_controller.php';
+ $filename = '/my/path/BakeArticlesController.php';
$this->Task->expects($this->once())->method('createFile')->with(
$filename,
new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/')
@@ -569,7 +568,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->path = '/my/path/';
$this->Task->args = array($name);
- $filename = '/my/path/bake_articles_controller.php';
+ $filename = '/my/path/BakeArticlesController.php';
$this->Task->expects($this->once())->method('createFile')->with(
$filename, new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/')
);
@@ -590,7 +589,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->args = array('BakeArticles');
$this->Task->params = array('public' => true);
- $filename = '/my/path/bake_articles_controller.php';
+ $filename = '/my/path/BakeArticlesController.php';
$expected = new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/'));
$this->Task->expects($this->once())->method('createFile')->with(
$filename, $expected
@@ -613,7 +612,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->args = array('BakeArticles');
$this->Task->params = array('public' => true, 'admin' => true);
- $filename = '/my/path/bake_articles_controller.php';
+ $filename = '/my/path/BakeArticlesController.php';
$this->Task->expects($this->once())->method('createFile')->with(
$filename, new PHPUnit_Framework_Constraint_PCREMatch('/admin_index/')
);
@@ -635,7 +634,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->args = array('BakeArticles');
$this->Task->params = array('admin' => true);
- $filename = '/my/path/bake_articles_controller.php';
+ $filename = '/my/path/BakeArticlesController.php';
$this->Task->expects($this->once())->method('createFile')->with(
$filename, new PHPUnit_Framework_Constraint_PCREMatch('/admin_index/')
);
diff --git a/cake/tests/cases/console/shells/tasks/db_config.test.php b/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php
similarity index 95%
rename from cake/tests/cases/console/shells/tasks/db_config.test.php
rename to lib/Cake/tests/cases/console/shells/tasks/db_config.test.php
index 6d37ffbb8..e00e31249 100644
--- a/cake/tests/cases/console/shells/tasks/db_config.test.php
+++ b/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php
@@ -16,11 +16,12 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', 'tasks/DbConfig');
-
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('ConsoleOutput', 'Console');
+App::uses('ConsoleInput', 'Console');
+App::uses('Shell', 'Console');
+App::uses('DbConfigTask', 'Console/Command/Task');
class TEST_DATABASE_CONFIG {
public $default = array(
diff --git a/cake/tests/cases/console/shells/tasks/extract.test.php b/lib/Cake/tests/cases/console/shells/tasks/extract.test.php
similarity index 91%
rename from cake/tests/cases/console/shells/tasks/extract.test.php
rename to lib/Cake/tests/cases/console/shells/tasks/extract.test.php
index 0b2fbf4bc..333aae290 100644
--- a/cake/tests/cases/console/shells/tasks/extract.test.php
+++ b/lib/Cake/tests/cases/console/shells/tasks/extract.test.php
@@ -18,11 +18,11 @@
* @since CakePHP v 1.2.0.7726
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Folder');
-App::import('Shell', 'Shell', false);
-App::import('Shell', 'tasks/Extract', false);
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('Folder', 'Utility');
+App::uses('ShellDispatcher', 'Console');
+App::uses('Shell', 'Console');
+App::uses('ExtractTask', 'Console/Command/Task');
/**
* ExtractTaskTest class
@@ -70,7 +70,7 @@ class ExtractTaskTest extends CakeTestCase {
public function testExecute() {
$this->Task->interactive = false;
- $this->Task->params['paths'] = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages';
+ $this->Task->params['paths'] = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages';
$this->Task->params['output'] = $this->path . DS;
$this->Task->expects($this->never())->method('err');
$this->Task->expects($this->any())->method('in')
@@ -152,7 +152,7 @@ class ExtractTaskTest extends CakeTestCase {
function testExtractWithExclude() {
$this->Task->interactive = false;
- $this->Task->params['paths'] = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views';
+ $this->Task->params['paths'] = LIBS . 'tests' . DS . 'test_app' . DS . 'views';
$this->Task->params['output'] = $this->path . DS;
$this->Task->params['exclude'] = 'pages,layouts';
@@ -179,8 +179,8 @@ class ExtractTaskTest extends CakeTestCase {
$this->Task->interactive = false;
$this->Task->params['paths'] =
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages,' .
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'posts';
+ LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'pages,' .
+ LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'posts';
$this->Task->params['output'] = $this->path . DS;
$this->Task->expects($this->never())->method('err');
diff --git a/cake/tests/cases/console/shells/tasks/fixture.test.php b/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php
similarity index 97%
rename from cake/tests/cases/console/shells/tasks/fixture.test.php
rename to lib/Cake/tests/cases/console/shells/tasks/fixture.test.php
index febd38ff8..1fd607f85 100644
--- a/cake/tests/cases/console/shells/tasks/fixture.test.php
+++ b/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php
@@ -16,14 +16,14 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', array(
- 'tasks/fixture',
- 'tasks/template',
- 'tasks/db_config'
-));
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('Shell', 'Console');
+App::uses('ConsoleOutput', 'Console');
+App::uses('ConsoleInput', 'Console');
+App::uses('FixtureTask', 'Console/Command/Task');
+App::uses('TemplateTask', 'Console/Command/Task');
+App::uses('DbConfigTask', 'Console/Command/Task');
/**
* FixtureTaskTest class
diff --git a/cake/tests/cases/console/shells/tasks/model.test.php b/lib/Cake/tests/cases/console/shells/tasks/model.test.php
similarity index 96%
rename from cake/tests/cases/console/shells/tasks/model.test.php
rename to lib/Cake/tests/cases/console/shells/tasks/model.test.php
index 0927dd981..5ebf1367b 100644
--- a/cake/tests/cases/console/shells/tasks/model.test.php
+++ b/lib/Cake/tests/cases/console/shells/tasks/model.test.php
@@ -18,14 +18,14 @@
* @since CakePHP v 1.2.6
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', array(
- 'tasks/model',
- 'tasks/fixture',
- 'tasks/template'
-));
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('Shell', 'Console');
+App::uses('ConsoleOutput', 'Console');
+App::uses('ConsoleInput', 'Console');
+App::uses('FixtureTask', 'Console/Command/Task');
+App::uses('TemplateTask', 'Console/Command/Task');
+App::uses('ModelTask', 'Console/Command/Task');
/**
* ModelTaskTest class
@@ -745,7 +745,7 @@ STRINGEND;
public function testBakeWithPlugin() {
$this->Task->plugin = 'controllerTest';
- $path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'bake_article.php';
+ $path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'BakeArticle.php';
$this->Task->expects($this->once())->method('createFile')
->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/BakeArticle extends ControllerTestAppModel/'));
@@ -763,8 +763,8 @@ STRINGEND;
public function testExecuteWithNamedModel() {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
- $this->Task->args = array('bake_article');
- $filename = '/my/path/bake_article.php';
+ $this->Task->args = array('BakeArticle');
+ $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
$this->Task->expects($this->once())->method('createFile')
@@ -799,7 +799,7 @@ STRINGEND;
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
$this->Task->args = array($name);
- $filename = '/my/path/bake_article.php';
+ $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle extends AppModel/'));
@@ -814,8 +814,8 @@ STRINGEND;
public function testExecuteWithNamedModelHasManyCreated() {
$this->Task->connection = 'test';
$this->Task->path = '/my/path/';
- $this->Task->args = array('bake_article');
- $filename = '/my/path/bake_article.php';
+ $this->Task->args = array('BakeArticle');
+ $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
$this->Task->expects($this->at(0))->method('createFile')
@@ -843,23 +843,23 @@ STRINGEND;
$this->Task->Fixture->expects($this->exactly(5))->method('bake');
$this->Task->Test->expects($this->exactly(5))->method('bake');
- $filename = '/my/path/bake_article.php';
+ $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->at(1))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/'));
- $filename = '/my/path/bake_articles_bake_tag.php';
+ $filename = '/my/path/BakeArticlesBakeTag.php';
$this->Task->expects($this->at(2))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesBakeTag/'));
- $filename = '/my/path/bake_comment.php';
+ $filename = '/my/path/BakeComment.php';
$this->Task->expects($this->at(3))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeComment/'));
- $filename = '/my/path/bake_tag.php';
+ $filename = '/my/path/BakeTag.php';
$this->Task->expects($this->at(4))
->method('createFile')->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeTag/'));
- $filename = '/my/path/category_thread.php';
+ $filename = '/my/path/CategoryThread.php';
$this->Task->expects($this->at(5))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/'));
@@ -889,19 +889,19 @@ STRINGEND;
$this->Task->Fixture->expects($this->exactly(4))->method('bake');
$this->Task->Test->expects($this->exactly(4))->method('bake');
- $filename = '/my/path/bake_article.php';
+ $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->at(1))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/'));
- $filename = '/my/path/bake_articles_bake_tag.php';
+ $filename = '/my/path/BakeArticlesBakeTag.php';
$this->Task->expects($this->at(2))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesBakeTag/'));
- $filename = '/my/path/bake_comment.php';
+ $filename = '/my/path/BakeComment.php';
$this->Task->expects($this->at(3))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeComment/'));
- $filename = '/my/path/category_thread.php';
+ $filename = '/my/path/CategoryThread.php';
$this->Task->expects($this->at(4))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/'));
@@ -939,7 +939,7 @@ STRINGEND;
$this->Task->Test->expects($this->once())->method('bake');
$this->Task->Fixture->expects($this->once())->method('bake');
- $filename = '/my/path/bake_article.php';
+ $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->once())->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/'));
diff --git a/cake/tests/cases/console/shells/tasks/plugin.test.php b/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php
similarity index 93%
rename from cake/tests/cases/console/shells/tasks/plugin.test.php
rename to lib/Cake/tests/cases/console/shells/tasks/plugin.test.php
index 22131744e..a46465857 100644
--- a/cake/tests/cases/console/shells/tasks/plugin.test.php
+++ b/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php
@@ -18,15 +18,15 @@
* @since CakePHP v 1.3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', array(
- 'tasks/plugin',
- 'tasks/model'
-));
-App::import('Core', array('File'));
-
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('ConsoleOutput', 'Console');
+App::uses('ConsoleInput', 'Console');
+App::uses('Shell', 'Console');
+App::uses('PluginTask', 'Console/Command/Task');
+App::uses('ModelTask', 'Console/Command/Task');
+App::uses('Folder', 'Utility');
+App::uses('File', 'Utility');
/**
* PluginTaskPlugin class
diff --git a/cake/tests/cases/console/shells/tasks/project.test.php b/lib/Cake/tests/cases/console/shells/tasks/project.test.php
similarity index 96%
rename from cake/tests/cases/console/shells/tasks/project.test.php
rename to lib/Cake/tests/cases/console/shells/tasks/project.test.php
index 65a5b4a52..9816b145a 100644
--- a/cake/tests/cases/console/shells/tasks/project.test.php
+++ b/lib/Cake/tests/cases/console/shells/tasks/project.test.php
@@ -18,12 +18,14 @@
* @since CakePHP v 1.3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', 'tasks/project');
-App::import('Core', 'File');
-
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('ConsoleOutput', 'Console');
+App::uses('ConsoleInput', 'Console');
+App::uses('Shell', 'Console');
+App::uses('ProjectTask', 'Console/Command/Task');
+App::uses('Folder', 'Utility');
+App::uses('File', 'Utility');
/**
* ProjectTask Test class
@@ -68,7 +70,7 @@ class ProjectTaskTest extends CakeTestCase {
* @return void
*/
protected function _setupTestProject() {
- $skel = CAKE . 'console' . DS . 'templates' . DS . 'skel';
+ $skel = LIBS . 'Console' . DS . 'templates' . DS . 'skel';
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
$this->Task->bake($this->Task->path . 'bake_test_app', $skel);
}
diff --git a/cake/tests/cases/console/shells/tasks/template.test.php b/lib/Cake/tests/cases/console/shells/tasks/template.test.php
similarity index 89%
rename from cake/tests/cases/console/shells/tasks/template.test.php
rename to lib/Cake/tests/cases/console/shells/tasks/template.test.php
index d33006cac..693637fb4 100644
--- a/cake/tests/cases/console/shells/tasks/template.test.php
+++ b/lib/Cake/tests/cases/console/shells/tasks/template.test.php
@@ -19,11 +19,12 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', 'tasks/template');
-
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('ConsoleOutput', 'Console');
+App::uses('ConsoleInput', 'Console');
+App::uses('Shell', 'Console');
+App::uses('TemplateTask', 'Console/Command/Task');
/**
* TemplateTaskTest class
*
@@ -86,7 +87,7 @@ class TemplateTaskTest extends CakeTestCase {
* @return void
*/
public function testFindingInstalledThemesForBake() {
- $consoleLibs = CAKE . 'console' . DS;
+ $consoleLibs = LIBS . 'Console' . DS;
$this->Task->initialize();
$this->assertEqual($this->Task->templatePaths['default'], $consoleLibs . 'templates' . DS . 'default' . DS);
}
@@ -98,7 +99,7 @@ class TemplateTaskTest extends CakeTestCase {
* @return void
*/
public function testGetThemePath() {
- $defaultTheme = CAKE_CORE_INCLUDE_PATH . DS . dirname(CONSOLE_LIBS) . 'templates' . DS . 'default' .DS;
+ $defaultTheme = LIBS . dirname(CONSOLE_LIBS) . 'templates' . DS . 'default' .DS;
$this->Task->templatePaths = array('default' => $defaultTheme);
$this->Task->expects($this->exactly(1))->method('in')->will($this->returnValue('1'));
@@ -124,8 +125,8 @@ class TemplateTaskTest extends CakeTestCase {
*/
public function testGenerate() {
App::build(array(
- 'shells' => array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'console' . DS
+ 'Console' => array(
+ LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS
)
));
$this->Task->initialize();
@@ -144,8 +145,8 @@ class TemplateTaskTest extends CakeTestCase {
*/
public function testGenerateWithTemplateFallbacks() {
App::build(array(
- 'shells' => array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'console' . DS,
+ 'Console' => array(
+ LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS,
CAKE_CORE_INCLUDE_PATH . DS . 'console' . DS
)
));
@@ -161,4 +162,4 @@ class TemplateTaskTest extends CakeTestCase {
$result = $this->Task->generate('classes', 'fixture');
$this->assertPattern('/ArticleFixture extends CakeTestFixture/', $result);
}
-}
\ No newline at end of file
+}
diff --git a/cake/tests/cases/console/shells/tasks/test.test.php b/lib/Cake/tests/cases/console/shells/tasks/test.test.php
similarity index 96%
rename from cake/tests/cases/console/shells/tasks/test.test.php
rename to lib/Cake/tests/cases/console/shells/tasks/test.test.php
index 5b25fb0b0..f6e8376e1 100644
--- a/cake/tests/cases/console/shells/tasks/test.test.php
+++ b/lib/Cake/tests/cases/console/shells/tasks/test.test.php
@@ -18,16 +18,15 @@
* @since CakePHP v 1.2.0.7726
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', array(
- 'tasks/test',
- 'tasks/template'
-));
-App::import('Controller', 'Controller', false);
-App::import('Model', 'Model', false);
-
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('ConsoleOutput', 'Console');
+App::uses('ConsoleInput', 'Console');
+App::uses('Shell', 'Console');
+App::uses('TestTask', 'Console/Command/Task');
+App::uses('TemplateTask', 'Console/Command/Task');
+App::uses('Controller', 'Controller');
+App::uses('Model', 'Model');
/**
* Test Article model
@@ -374,7 +373,7 @@ class TestTaskTest extends CakeTestCase {
*/
public function testGetClassName() {
$objects = App::objects('model');
- $skip = $this->skipIf(empty($objects), 'No models in app, this test will fail. %s');
+ $skip = $this->skipIf(empty($objects), 'No models in app, this test will fail.');
if ($skip) {
return;
}
@@ -438,7 +437,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->bake('Model', 'TestTaskArticle');
- $this->assertContains("App::import('Model', 'TestTaskArticle')", $result);
+ $this->assertContains("App::uses('TestTaskArticle', 'Model')", $result);
$this->assertContains('class TestTaskArticleTestCase extends CakeTestCase', $result);
$this->assertContains('function setUp()', $result);
@@ -469,7 +468,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->bake('Controller', 'TestTaskComments');
- $this->assertContains("App::import('Controller', 'TestTaskComments')", $result);
+ $this->assertContains("App::uses('TestTaskCommentsController', 'Controller')", $result);
$this->assertContains('class TestTaskCommentsControllerTestCase extends CakeTestCase', $result);
$this->assertContains('class TestTestTaskCommentsController extends TestTaskCommentsController', $result);
@@ -539,13 +538,13 @@ class TestTaskTest extends CakeTestCase {
* @return void
*/
function testInteractiveWithPlugin() {
- $testApp = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS;
+ $testApp = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS;
App::build(array(
'plugins' => array($testApp)
), true);
$this->Task->plugin = 'TestPlugin';
- $path = $testApp . 'test_plugin' . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'other_helper.test.php';
+ $path = $testApp . 'test_plugin' . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'other_helper_helper.test.php';
$this->Task->expects($this->any())
->method('in')
->will($this->onConsecutiveCalls(
@@ -559,7 +558,7 @@ class TestTaskTest extends CakeTestCase {
$this->Task->stdout->expects($this->at(21))
->method('write')
- ->with('1. OtherHelper');
+ ->with('1. OtherHelperHelper');
$this->Task->execute();
}
diff --git a/cake/tests/cases/console/shells/tasks/view.test.php b/lib/Cake/tests/cases/console/shells/tasks/view.test.php
similarity index 97%
rename from cake/tests/cases/console/shells/tasks/view.test.php
rename to lib/Cake/tests/cases/console/shells/tasks/view.test.php
index 99f1afdf9..b41cdd233 100644
--- a/cake/tests/cases/console/shells/tasks/view.test.php
+++ b/lib/Cake/tests/cases/console/shells/tasks/view.test.php
@@ -18,16 +18,18 @@
* @since CakePHP v 1.2.0.7726
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', array(
- 'tasks/view',
- 'tasks/controller',
- 'tasks/template',
- 'tasks/project',
- 'tasks/db_config'
-));
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
+App::uses('ShellDispatcher', 'Console');
+App::uses('ConsoleOutput', 'Console');
+App::uses('ConsoleInput', 'Console');
+App::uses('Shell', 'Console');
+App::uses('ViewTask', 'Console/Command/Task');
+App::uses('ControllerTask', 'Console/Command/Task');
+App::uses('TemplateTask', 'Console/Command/Task');
+App::uses('ProjectTask', 'Console/Command/Task');
+App::uses('DbConfigTask', 'Console/Command/Task');
+App::uses('Model', 'Model');
+App::uses('Controller', 'Controller');
/**
* Test View Task Comment Model
diff --git a/cake/tests/cases/console/shells/testsuite.test.php b/lib/Cake/tests/cases/console/shells/testsuite.test.php
similarity index 93%
rename from cake/tests/cases/console/shells/testsuite.test.php
rename to lib/Cake/tests/cases/console/shells/testsuite.test.php
index 30ad6f8e9..5d0d2914a 100644
--- a/cake/tests/cases/console/shells/testsuite.test.php
+++ b/lib/Cake/tests/cases/console/shells/testsuite.test.php
@@ -17,13 +17,10 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Shell', 'Shell', false);
-App::import('Shell', 'Testsuite');
+App::uses('ShellDispatcher', 'Console');
+App::uses('TestsuiteShell', 'Console/Command');
-require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
-
-
-class TestSuiteShellTest extends CakeTestCase {
+class TestsuiteShellTest extends CakeTestCase {
/**
@@ -36,7 +33,7 @@ class TestSuiteShellTest extends CakeTestCase {
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Shell = $this->getMock(
- 'TestSuiteShell',
+ 'TestsuiteShell',
array('in', 'out', 'hr', 'help', 'error', 'err', '_stop', 'initialize', 'run', 'clear'),
array($out, $out, $in)
);
diff --git a/cake/tests/cases/libs/all_behaviors.test.php b/lib/Cake/tests/cases/libs/all_behaviors.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_behaviors.test.php
rename to lib/Cake/tests/cases/libs/all_behaviors.test.php
diff --git a/cake/tests/cases/libs/all_cache_engines.test.php b/lib/Cake/tests/cases/libs/all_cache_engines.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_cache_engines.test.php
rename to lib/Cake/tests/cases/libs/all_cache_engines.test.php
diff --git a/cake/tests/cases/libs/all_components.test.php b/lib/Cake/tests/cases/libs/all_components.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_components.test.php
rename to lib/Cake/tests/cases/libs/all_components.test.php
diff --git a/cake/tests/cases/libs/all_configure.test.php b/lib/Cake/tests/cases/libs/all_configure.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_configure.test.php
rename to lib/Cake/tests/cases/libs/all_configure.test.php
diff --git a/cake/tests/cases/libs/all_controllers.test.php b/lib/Cake/tests/cases/libs/all_controllers.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_controllers.test.php
rename to lib/Cake/tests/cases/libs/all_controllers.test.php
diff --git a/cake/tests/cases/libs/all_database.test.php b/lib/Cake/tests/cases/libs/all_database.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_database.test.php
rename to lib/Cake/tests/cases/libs/all_database.test.php
diff --git a/cake/tests/cases/libs/all_error.test.php b/lib/Cake/tests/cases/libs/all_error.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_error.test.php
rename to lib/Cake/tests/cases/libs/all_error.test.php
diff --git a/cake/tests/cases/libs/all_helpers.test.php b/lib/Cake/tests/cases/libs/all_helpers.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_helpers.test.php
rename to lib/Cake/tests/cases/libs/all_helpers.test.php
diff --git a/cake/tests/cases/libs/all_js_helpers.test.php b/lib/Cake/tests/cases/libs/all_js_helpers.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_js_helpers.test.php
rename to lib/Cake/tests/cases/libs/all_js_helpers.test.php
diff --git a/cake/tests/cases/libs/all_libs.test.php b/lib/Cake/tests/cases/libs/all_libs.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_libs.test.php
rename to lib/Cake/tests/cases/libs/all_libs.test.php
diff --git a/cake/tests/cases/libs/all_localization.test.php b/lib/Cake/tests/cases/libs/all_localization.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_localization.test.php
rename to lib/Cake/tests/cases/libs/all_localization.test.php
diff --git a/cake/tests/cases/libs/all_model.test.php b/lib/Cake/tests/cases/libs/all_model.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_model.test.php
rename to lib/Cake/tests/cases/libs/all_model.test.php
diff --git a/cake/tests/cases/libs/all_routing.test.php b/lib/Cake/tests/cases/libs/all_routing.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_routing.test.php
rename to lib/Cake/tests/cases/libs/all_routing.test.php
diff --git a/cake/tests/cases/libs/all_socket.test.php b/lib/Cake/tests/cases/libs/all_socket.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_socket.test.php
rename to lib/Cake/tests/cases/libs/all_socket.test.php
diff --git a/cake/tests/cases/libs/all_test_suite.test.php b/lib/Cake/tests/cases/libs/all_test_suite.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_test_suite.test.php
rename to lib/Cake/tests/cases/libs/all_test_suite.test.php
diff --git a/cake/tests/cases/libs/all_tests.test.php b/lib/Cake/tests/cases/libs/all_tests.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_tests.test.php
rename to lib/Cake/tests/cases/libs/all_tests.test.php
diff --git a/cake/tests/cases/libs/all_views.test.php b/lib/Cake/tests/cases/libs/all_views.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_views.test.php
rename to lib/Cake/tests/cases/libs/all_views.test.php
diff --git a/cake/tests/cases/libs/all_xml.test.php b/lib/Cake/tests/cases/libs/all_xml.test.php
similarity index 100%
rename from cake/tests/cases/libs/all_xml.test.php
rename to lib/Cake/tests/cases/libs/all_xml.test.php
diff --git a/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php
new file mode 100644
index 000000000..e90e1b06b
--- /dev/null
+++ b/lib/Cake/tests/cases/libs/app.test.php
@@ -0,0 +1,680 @@
+assertEqual($expected, $old);
+
+ App::build(array('Model' => array('/path/to/models/')));
+
+ $new = App::path('Model');
+
+ $expected = array(
+ '/path/to/models/',
+ APP . 'models' . DS
+ );
+ $this->assertEqual($expected, $new);
+
+ App::build(); //reset defaults
+ $defaults = App::path('Model');
+ $this->assertEqual($old, $defaults);
+ }
+
+/**
+ * tests that it is possible to set up paths using the cake 1.3 notation for them (models, behaviors, controllers...)
+ *
+ * @access public
+ * @return void
+ */
+ function testCompatibleBuild() {
+ $old = App::path('models');
+ $expected = array(
+ APP . 'models' . DS
+ );
+ $this->assertEqual($expected, $old);
+
+ App::build(array('models' => array('/path/to/models/')));
+
+ $new = App::path('models');
+
+ $expected = array(
+ '/path/to/models/',
+ APP . 'models' . DS
+ );
+ $this->assertEqual($expected, $new);
+ $this->assertEqual($expected, App::path('Model'));
+
+ App::build(array('datasources' => array('/path/to/datasources/')));
+ $expected = array(
+ '/path/to/datasources/',
+ APP . 'models' . DS . 'datasources' . DS
+ );
+ $result = App::path('datasources');
+ $this->assertEqual($expected, $result);
+ $this->assertEqual($expected, App::path('Model/Datasource'));
+
+ App::build(array('behaviors' => array('/path/to/behaviors/')));
+ $expected = array(
+ '/path/to/behaviors/',
+ APP . 'models' . DS . 'behaviors' . DS
+ );
+ $result = App::path('behaviors');
+ $this->assertEqual($expected, $result);
+ $this->assertEqual($expected, App::path('Model/Behavior'));
+
+ App::build(array('controllers' => array('/path/to/controllers/')));
+ $expected = array(
+ '/path/to/controllers/',
+ APP . 'controllers' . DS
+ );
+ $result = App::path('controllers');
+ $this->assertEqual($expected, $result);
+ $this->assertEqual($expected, App::path('Controller'));
+
+ App::build(array('components' => array('/path/to/components/')));
+ $expected = array(
+ '/path/to/components/',
+ APP . 'controllers' . DS . 'components' . DS
+ );
+ $result = App::path('components');
+ $this->assertEqual($expected, $result);
+ $this->assertEqual($expected, App::path('Controller/Component'));
+
+ App::build(array('views' => array('/path/to/views/')));
+ $expected = array(
+ '/path/to/views/',
+ APP . 'views' . DS
+ );
+ $result = App::path('views');
+ $this->assertEqual($expected, $result);
+ $this->assertEqual($expected, App::path('View'));
+
+ App::build(array('helpers' => array('/path/to/helpers/')));
+ $expected = array(
+ '/path/to/helpers/',
+ APP . 'views' . DS . 'helpers' . DS
+ );
+ $result = App::path('helpers');
+ $this->assertEqual($expected, $result);
+ $this->assertEqual($expected, App::path('View/Helper'));
+
+ App::build(array('shells' => array('/path/to/shells/')));
+ $expected = array(
+ '/path/to/shells/',
+ APP . 'console' . DS . 'shells' . DS,
+ APP . 'vendors' . DS . 'shells' . DS,
+ ROOT . DS . 'vendors' . DS . 'shells' . DS
+ );
+ $result = App::path('shells');
+ $this->assertEqual($expected, $result);
+ $this->assertEqual($expected, App::path('Console/Command'));
+
+ App::build(); //reset defaults
+ $defaults = App::path('Model');
+ $this->assertEqual($old, $defaults);
+ }
+
+/**
+ * testBuildWithReset method
+ *
+ * @access public
+ * @return void
+ */
+ function testBuildWithReset() {
+ $old = App::path('Model');
+ $expected = array(
+ APP . 'models' . DS
+ );
+ $this->assertEqual($expected, $old);
+
+ App::build(array('Model' => array('/path/to/models/')), true);
+
+ $new = App::path('Model');
+
+ $expected = array(
+ '/path/to/models/'
+ );
+ $this->assertEqual($expected, $new);
+
+ App::build(); //reset defaults
+ $defaults = App::path('Model');
+ $this->assertEqual($old, $defaults);
+ }
+
+/**
+ * testCore method
+ *
+ * @access public
+ * @return void
+ */
+ function testCore() {
+ $model = App::core('Model');
+ $this->assertEqual(array(LIBS . 'Model' . DS), $model);
+
+ $view = App::core('View');
+ $this->assertEqual(array(LIBS . 'View' . DS), $view);
+
+ $controller = App::core('Controller');
+ $this->assertEqual(array(LIBS . 'Controller' . DS), $controller);
+
+ $component = App::core('Controller/Component');
+ $this->assertEqual(array(LIBS . 'Controller' . DS . 'Component' . DS), $component);
+
+ $auth = App::core('Controller/Component/Auth');
+ $this->assertEqual(array(LIBS . 'Controller' . DS . 'Component' . DS . 'Auth' . DS), $auth);
+
+ $datasource = App::core('Model/Datasource');
+ $this->assertEqual(array(LIBS . 'Model' . DS . 'Datasource' . DS), $datasource);
+ }
+
+/**
+ * testListObjects method
+ *
+ * @access public
+ * @return void
+ */
+ function testListObjects() {
+ $result = App::objects('class', LIBS . 'Routing', false);
+ $this->assertTrue(in_array('Dispatcher', $result));
+ $this->assertTrue(in_array('Router', $result));
+
+ App::build(array(
+ 'Model/Behavior' => App::core('Model/Behavior'),
+ 'Controller' => App::core('Controller'),
+ 'Controller/Component' => App::core('Controller/Component'),
+ 'View' => App::core('View'),
+ 'Model' => App::core('Model'),
+ 'View/Helper' => App::core('View/Helper'),
+ ), true);
+ $result = App::objects('behavior', null, false);
+ $this->assertTrue(in_array('TreeBehavior', $result));
+ $result = App::objects('Model/Behavior', null, false);
+ $this->assertTrue(in_array('TreeBehavior', $result));
+
+ $result = App::objects('controller', null, false);
+ $this->assertTrue(in_array('PagesController', $result));
+ $result = App::objects('Controller', null, false);
+ $this->assertTrue(in_array('PagesController', $result));
+
+ $result = App::objects('component', null, false);
+ $this->assertTrue(in_array('AuthComponent', $result));
+ $result = App::objects('Controller/Component', null, false);
+ $this->assertTrue(in_array('AuthComponent', $result));
+
+ $result = App::objects('view', null, false);
+ $this->assertTrue(in_array('MediaView', $result));
+ $result = App::objects('View', null, false);
+ $this->assertTrue(in_array('MediaView', $result));
+
+ $result = App::objects('helper', null, false);
+ $this->assertTrue(in_array('HtmlHelper', $result));
+ $result = App::objects('View/Helper', null, false);
+ $this->assertTrue(in_array('HtmlHelper', $result));
+
+ $result = App::objects('model', null, false);
+ $this->assertTrue(in_array('AcoAction', $result));
+ $result = App::objects('Model', null, false);
+ $this->assertTrue(in_array('AcoAction', $result));
+
+ $result = App::objects('file');
+ $this->assertFalse($result);
+
+ $result = App::objects('file', 'non_existing_configure');
+ $expected = array();
+ $this->assertEqual($result, $expected);
+
+ $result = App::objects('NonExistingType');
+ $this->assertEqual($result, array());
+
+ App::build(array(
+ 'plugins' => array(
+ LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS
+ )
+ ));
+ $result = App::objects('plugin', null, false);
+ $this->assertTrue(in_array('Cache', $result));
+ $this->assertTrue(in_array('Log', $result));
+
+ App::build();
+ }
+
+/**
+ * Tests listing objects within a plugin
+ *
+ * @return void
+ */
+ function testListObjectsInPlugin() {
+ App::build(array(
+ 'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ ));
+
+ $result = App::objects('TestPlugin.model');
+ $this->assertTrue(in_array('TestPluginPost', $result));
+ $result = App::objects('TestPlugin.Model');
+ $this->assertTrue(in_array('TestPluginPost', $result));
+
+ $result = App::objects('TestPlugin.behavior');
+ $this->assertTrue(in_array('TestPluginPersisterOne', $result));
+ $result = App::objects('TestPlugin.Model/Behavior');
+ $this->assertTrue(in_array('TestPluginPersisterOne', $result));
+
+ $result = App::objects('TestPlugin.helper');
+ $expected = array('OtherHelperHelper', 'PluggedHelper', 'TestPluginApp');
+ $this->assertEquals($result, $expected);
+ $result = App::objects('TestPlugin.View/Helper');
+ $expected = array('OtherHelperHelper', 'PluggedHelper', 'TestPluginApp');
+ $this->assertEquals($result, $expected);
+
+ $result = App::objects('TestPlugin.component');
+ $this->assertTrue(in_array('OtherComponent', $result));
+ $result = App::objects('TestPlugin.Controller/Component');
+ $this->assertTrue(in_array('OtherComponent', $result));
+
+ $result = App::objects('TestPluginTwo.behavior');
+ $this->assertEquals($result, array());
+ $result = App::objects('TestPluginTwo.Model/Behavior');
+ $this->assertEquals($result, array());
+
+ $result = App::objects('model', null, false);
+ $this->assertTrue(in_array('Comment', $result));
+ $this->assertTrue(in_array('Post', $result));
+
+ $result = App::objects('Model', null, false);
+ $this->assertTrue(in_array('Comment', $result));
+ $this->assertTrue(in_array('Post', $result));
+
+ App::build();
+ }
+
+/**
+ * test that pluginPath can find paths for plugins.
+ *
+ * @return void
+ */
+ function testPluginPath() {
+ App::build(array(
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ ));
+ $path = App::pluginPath('test_plugin');
+ $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
+ $this->assertEqual($path, $expected);
+
+ $path = App::pluginPath('TestPlugin');
+ $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS;
+ $this->assertEqual($path, $expected);
+
+ $path = App::pluginPath('TestPluginTwo');
+ $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS;
+ $this->assertEqual($path, $expected);
+ App::build();
+ }
+
+/**
+ * test that pluginPath can find paths for plugins.
+ *
+ * @return void
+ */
+ function testThemePath() {
+ App::build(array(
+ 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS)
+ ));
+ $path = App::themePath('test_theme');
+ $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;
+ $this->assertEqual($path, $expected);
+
+ $path = App::themePath('TestTheme');
+ $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS;
+ $this->assertEqual($path, $expected);
+
+ App::build();
+ }
+
+/**
+ * testClassLoading method
+ *
+ * @access public
+ * @return void
+ */
+ function testClassLoading() {
+ $file = App::import('Model', 'Model', false);
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('Model'));
+
+ $file = App::import('Controller', 'Controller', false);
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('Controller'));
+
+ $file = App::import('Component', 'Auth', false);
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('AuthComponent'));
+
+ $file = App::import('Shell', 'Shell', false);
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('Shell'));
+
+ $file = App::import('Configure', 'PhpReader');
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('PhpReader'));
+
+ $file = App::import('Model', 'SomeRandomModelThatDoesNotExist', false);
+ $this->assertFalse($file);
+
+ $file = App::import('Model', 'AppModel', false);
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('AppModel'));
+
+ $file = App::import('WrongType', null, true, array(), '');
+ $this->assertFalse($file);
+
+ $file = App::import('Model', 'NonExistingPlugin.NonExistingModel', false);
+ $this->assertFalse($file);
+
+ $file = App::import('Model', array('NonExistingPlugin.NonExistingModel'), false);
+ $this->assertFalse($file);
+
+ if (!class_exists('AppController')) {
+ $classes = array_flip(get_declared_classes());
+
+ $this->assertFalse(isset($classes['PagesController']));
+ $this->assertFalse(isset($classes['AppController']));
+
+ $file = App::import('Controller', 'Pages');
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('PagesController'));
+
+ $classes = array_flip(get_declared_classes());
+
+ $this->assertTrue(isset($classes['PagesController']));
+ $this->assertTrue(isset($classes['AppController']));
+
+ $file = App::import('Behavior', 'Containable');
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('ContainableBehavior'));
+
+ $file = App::import('Component', 'RequestHandler');
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('RequestHandlerComponent'));
+
+ $file = App::import('Helper', 'Form');
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('FormHelper'));
+
+ $file = App::import('Model', 'NonExistingModel');
+ $this->assertFalse($file);
+
+ $file = App::import('Datasource', 'DboSource');
+ $this->assertTrue($file);
+ $this->assertTrue(class_exists('DboSource'));
+ }
+ App::build();
+ }
+
+/**
+ * test import() with plugins
+ *
+ * @return void
+ */
+ function testPluginImporting() {
+ App::build(array(
+ 'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ ));
+
+ $result = App::import('Controller', 'TestPlugin.Tests');
+ $this->assertTrue($result);
+ $this->assertTrue(class_exists('TestPluginAppController'));
+ $this->assertTrue(class_exists('TestsController'));
+
+ $result = App::import('Lib', 'TestPlugin.TestPluginLibrary');
+ $this->assertTrue($result);
+ $this->assertTrue(class_exists('TestPluginLibrary'));
+
+ $result = App::import('Lib', 'Library');
+ $this->assertTrue($result);
+ $this->assertTrue(class_exists('Library'));
+
+ $result = App::import('Helper', 'TestPlugin.OtherHelper');
+ $this->assertTrue($result);
+ $this->assertTrue(class_exists('OtherHelperHelper'));
+
+ $result = App::import('Helper', 'TestPlugin.TestPluginApp');
+ $this->assertTrue($result);
+ $this->assertTrue(class_exists('TestPluginAppHelper'));
+
+ $result = App::import('Datasource', 'TestPlugin.TestSource');
+ $this->assertTrue($result);
+ $this->assertTrue(class_exists('TestSource'));
+
+ App::build();
+ }
+
+/**
+ * test that building helper paths actually works.
+ *
+ * @return void
+ * @link http://cakephp.lighthouseapp.com/projects/42648/tickets/410
+ */
+ function testImportingHelpersFromAlternatePaths() {
+
+ $this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper exists, cannot test importing it.');
+ App::build(array(
+ 'View/Helper' => array(
+ LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS
+ )
+ ));
+ $this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper exists, cannot test importing it.');
+ App::import('Helper', 'Banana');
+ $this->assertTrue(class_exists('BananaHelper', false), 'BananaHelper was not loaded.');
+
+ App::build();
+ }
+
+/**
+ * testFileLoading method
+ *
+ * @access public
+ * @return void
+ */
+ function testFileLoading () {
+ $file = App::import('File', 'RealFile', false, array(), LIBS . 'config' . DS . 'config.php');
+ $this->assertTrue($file);
+
+ $file = App::import('File', 'NoFile', false, array(), LIBS . 'config' . DS . 'cake' . DS . 'config.php');
+ $this->assertFalse($file);
+ }
+
+/**
+ * testFileLoadingWithArray method
+ *
+ * @access public
+ * @return void
+ */
+ function testFileLoadingWithArray() {
+ $type = array('type' => 'File', 'name' => 'SomeName', 'parent' => false,
+ 'file' => LIBS . DS . 'config' . DS . 'config.php');
+ $file = App::import($type);
+ $this->assertTrue($file);
+
+ $type = array('type' => 'File', 'name' => 'NoFile', 'parent' => false,
+ 'file' => LIBS . 'config' . DS . 'cake' . DS . 'config.php');
+ $file = App::import($type);
+ $this->assertFalse($file);
+ }
+
+/**
+ * testFileLoadingReturnValue method
+ *
+ * @access public
+ * @return void
+ */
+ function testFileLoadingReturnValue () {
+ $file = App::import('File', 'Name', false, array(), LIBS . 'config' . DS . 'config.php', true);
+ $this->assertTrue(!empty($file));
+
+ $this->assertTrue(isset($file['Cake.version']));
+
+ $type = array('type' => 'File', 'name' => 'OtherName', 'parent' => false,
+ 'file' => LIBS . 'config' . DS . 'config.php', 'return' => true);
+ $file = App::import($type);
+ $this->assertTrue(!empty($file));
+
+ $this->assertTrue(isset($file['Cake.version']));
+ }
+
+/**
+ * testLoadingWithSearch method
+ *
+ * @access public
+ * @return void
+ */
+ function testLoadingWithSearch () {
+ $file = App::import('File', 'NewName', false, array(LIBS . 'config' . DS), 'config.php');
+ $this->assertTrue($file);
+
+ $file = App::import('File', 'AnotherNewName', false, array(LIBS), 'config.php');
+ $this->assertFalse($file);
+ }
+
+/**
+ * testLoadingWithSearchArray method
+ *
+ * @access public
+ * @return void
+ */
+ function testLoadingWithSearchArray() {
+ $type = array(
+ 'type' => 'File',
+ 'name' => 'RandomName',
+ 'parent' => false,
+ 'file' => 'config.php',
+ 'search' => array(LIBS . 'config' . DS)
+ );
+ $file = App::import($type);
+ $this->assertTrue($file);
+
+ $type = array(
+ 'type' => 'File',
+ 'name' => 'AnotherRandomName',
+ 'parent' => false,
+ 'file' => 'config.php',
+ 'search' => array(LIBS)
+ );
+ $file = App::import($type);
+ $this->assertFalse($file);
+ }
+
+/**
+ * testMultipleLoading method
+ *
+ * @access public
+ * @return void
+ */
+ function testMultipleLoading() {
+ if (class_exists('PersisterOne', false) || class_exists('PersisterTwo', false)) {
+ $this->markTestSkipped('Cannot test loading of classes that exist.');
+ }
+ App::build(array(
+ 'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS)
+ ));
+ $toLoad = array('PersisterOne', 'PersisterTwo');
+ $load = App::import('Model', $toLoad);
+ $this->assertTrue($load);
+
+ $classes = array_flip(get_declared_classes());
+
+
+ $this->assertTrue(isset($classes['PersisterOne']));
+ $this->assertTrue(isset($classes['PersisterTwo']));
+
+ $load = App::import('Model', array('PersisterOne', 'SomeNotFoundClass', 'PersisterTwo'));
+ $this->assertFalse($load);
+ }
+
+
+ function testLoadingVendor() {
+ App::build(array(
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'vendors' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
+ ), true);
+
+ ob_start();
+ $result = App::import('Vendor', 'css/TestAsset', array('ext' => 'css'));
+ $text = ob_get_clean();
+ $this->assertTrue($result);
+ $this->assertEqual($text, 'this is the test asset css file');
+
+ $result = App::import('Vendor', 'TestPlugin.sample/SamplePlugin');
+ $this->assertTrue($result);
+ $this->assertTrue(class_exists('SamplePluginClassTestName'));
+
+ $result = App::import('Vendor', 'sample/ConfigureTestVendorSample');
+ $this->assertTrue($result);
+ $this->assertTrue(class_exists('ConfigureTestVendorSample'));
+
+ ob_start();
+ $result = App::import('Vendor', 'SomeNameInSubfolder', array('file' => 'somename/some.name.php'));
+ $text = ob_get_clean();
+ $this->assertTrue($result);
+ $this->assertEqual($text, 'This is a file with dot in file name');
+
+ ob_start();
+ $result = App::import('Vendor', 'TestHello', array('file' => 'Test'.DS.'hello.php'));
+ $text = ob_get_clean();
+ $this->assertTrue($result);
+ $this->assertEqual($text, 'This is the hello.php file in Test directory');
+
+ ob_start();
+ $result = App::import('Vendor', 'MyTest', array('file' => 'Test'.DS.'MyTest.php'));
+ $text = ob_get_clean();
+ $this->assertTrue($result);
+ $this->assertEqual($text, 'This is the MyTest.php file');
+
+ ob_start();
+ $result = App::import('Vendor', 'Welcome');
+ $text = ob_get_clean();
+ $this->assertTrue($result);
+ $this->assertEqual($text, 'This is the welcome.php file in vendors directory');
+
+ ob_start();
+ $result = App::import('Vendor', 'TestPlugin.Welcome');
+ $text = ob_get_clean();
+ $this->assertTrue($result);
+ $this->assertEqual($text, 'This is the welcome.php file in test_plugin/vendors directory');
+ }
+
+/**
+ * Tests that the automatic class loader will also find in "libs" folder for both
+ * app and plugins if it does not find the class in other configured paths
+ *
+ */
+ public function testLoadClassInLibs() {
+ App::build(array(
+ 'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ ), true);
+
+ $this->assertFalse(class_exists('CustomLibClass', false));
+ App::uses('CustomLibClass', 'TestPlugin.Custom/Package');
+ $this->assertTrue(class_exists('CustomLibClass'));
+
+ $this->assertFalse(class_exists('TestUtilityClass', false));
+ App::uses('TestUtilityClass', 'Utility');
+ $this->assertTrue(class_exists('CustomLibClass'));
+ }
+}
diff --git a/cake/tests/cases/libs/cache.test.php b/lib/Cake/tests/cases/libs/cache.test.php
similarity index 91%
rename from cake/tests/cases/libs/cache.test.php
rename to lib/Cake/tests/cases/libs/cache.test.php
index 644672de3..ce5150e8b 100644
--- a/cake/tests/cases/libs/cache.test.php
+++ b/lib/Cake/tests/cases/libs/cache.test.php
@@ -16,9 +16,8 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-if (!class_exists('Cache')) {
- require LIBS . 'cache.php';
-}
+
+App::uses('Cache', 'Cache');
/**
* CacheTest class
@@ -90,8 +89,8 @@ class CacheTest extends CakeTestCase {
*/
function testConfigWithLibAndPluginEngines() {
App::build(array(
- 'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'Lib' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
$settings = array('engine' => 'TestAppCache', 'path' => TMP, 'prefix' => 'cake_test_');
@@ -234,19 +233,12 @@ class CacheTest extends CakeTestCase {
* @return void
*/
function testInitSettings() {
- Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
+ $initial = Cache::settings();
+ $override = array('engine' => 'File', 'path' => TMP . 'tests');
+ Cache::config('default', $override);
$settings = Cache::settings();
- $expecting = array(
- 'engine' => 'File',
- 'duration'=> 3600,
- 'probability' => 100,
- 'path'=> TMP . 'tests',
- 'prefix'=> 'cake_',
- 'lock' => false,
- 'serialize'=> true,
- 'isWindows' => DIRECTORY_SEPARATOR == '\\'
- );
+ $expecting = $override + $initial;
$this->assertEqual($settings, $expecting);
}
@@ -258,8 +250,8 @@ class CacheTest extends CakeTestCase {
*/
function testDrop() {
App::build(array(
- 'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
$result = Cache::drop('some_config_that_does_not_exist');
@@ -311,8 +303,8 @@ class CacheTest extends CakeTestCase {
*/
function testWriteTriggerError() {
App::build(array(
- 'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
Cache::config('test_trigger', array('engine' => 'TestAppCache', 'prefix' => ''));
diff --git a/cake/tests/cases/libs/cache/apc.test.php b/lib/Cake/tests/cases/libs/cache/apc.test.php
similarity index 98%
rename from cake/tests/cases/libs/cache/apc.test.php
rename to lib/Cake/tests/cases/libs/cache/apc.test.php
index 0abd07778..28043b908 100644
--- a/cake/tests/cases/libs/cache/apc.test.php
+++ b/lib/Cake/tests/cases/libs/cache/apc.test.php
@@ -16,9 +16,8 @@
* @since CakePHP(tm) v 1.2.0.5434
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-if (!class_exists('Cache')) {
- require LIBS . 'cache.php';
-}
+
+App::uses('Cache', 'Cache');
/**
* ApcEngineTest class
diff --git a/cake/tests/cases/libs/cache/file.test.php b/lib/Cake/tests/cases/libs/cache/file.test.php
similarity index 99%
rename from cake/tests/cases/libs/cache/file.test.php
rename to lib/Cake/tests/cases/libs/cache/file.test.php
index e38a09872..5395ac025 100644
--- a/cake/tests/cases/libs/cache/file.test.php
+++ b/lib/Cake/tests/cases/libs/cache/file.test.php
@@ -16,9 +16,8 @@
* @since CakePHP(tm) v 1.2.0.5434
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-if (!class_exists('Cache')) {
- require LIBS . 'cache.php';
-}
+
+App::uses('Cache', 'Cache');
/**
* FileEngineTest class
diff --git a/cake/tests/cases/libs/cache/memcache.test.php b/lib/Cake/tests/cases/libs/cache/memcache.test.php
similarity index 98%
rename from cake/tests/cases/libs/cache/memcache.test.php
rename to lib/Cake/tests/cases/libs/cache/memcache.test.php
index 61bcec550..ada9c52bc 100644
--- a/cake/tests/cases/libs/cache/memcache.test.php
+++ b/lib/Cake/tests/cases/libs/cache/memcache.test.php
@@ -16,10 +16,9 @@
* @since CakePHP(tm) v 1.2.0.5434
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-if (!class_exists('Cache')) {
- require LIBS . 'cache.php';
-}
-require_once LIBS . 'cache' . DS . 'memcache.php';
+
+App::uses('Cache', 'Cache');
+App::uses('MemcacheEngine', 'Cache/Engine');
class TestMemcacheEngine extends MemcacheEngine {
/**
diff --git a/cake/tests/cases/libs/cache/xcache.test.php b/lib/Cake/tests/cases/libs/cache/xcache.test.php
similarity index 98%
rename from cake/tests/cases/libs/cache/xcache.test.php
rename to lib/Cake/tests/cases/libs/cache/xcache.test.php
index eea1c4b2c..5788118c3 100644
--- a/cake/tests/cases/libs/cache/xcache.test.php
+++ b/lib/Cake/tests/cases/libs/cache/xcache.test.php
@@ -16,9 +16,8 @@
* @since CakePHP(tm) v 1.2.0.5434
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-if (!class_exists('Cache')) {
- require LIBS . 'cache.php';
-}
+
+App::uses('Cache', 'Cache');
/**
* XcacheEngineTest class
diff --git a/cake/tests/cases/libs/cake_log.test.php b/lib/Cake/tests/cases/libs/cake_log.test.php
similarity index 93%
rename from cake/tests/cases/libs/cake_log.test.php
rename to lib/Cake/tests/cases/libs/cake_log.test.php
index 0d21cb5b2..3b3abf2e0 100644
--- a/cake/tests/cases/libs/cake_log.test.php
+++ b/lib/Cake/tests/cases/libs/cake_log.test.php
@@ -16,8 +16,9 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'CakeLog');
-App::import('Core', 'log/FileLog');
+
+App::uses('CakeLog', 'Log');
+App::uses('FileLog', 'Log/Engine');
/**
* CakeLogTest class
@@ -46,8 +47,8 @@ class CakeLogTest extends CakeTestCase {
*/
function testImportingLoggers() {
App::build(array(
- 'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
$result = CakeLog::config('libtest', array(
diff --git a/cake/tests/cases/libs/cake_request.test.php b/lib/Cake/tests/cases/libs/cake_request.test.php
similarity index 99%
rename from cake/tests/cases/libs/cake_request.test.php
rename to lib/Cake/tests/cases/libs/cake_request.test.php
index 3df9a8713..65eb45042 100644
--- a/cake/tests/cases/libs/cake_request.test.php
+++ b/lib/Cake/tests/cases/libs/cake_request.test.php
@@ -16,8 +16,9 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Dispatcher');
-App::import('Core', 'CakeRequest');
+
+App::uses('Dispatcher', 'Routing');
+App::uses('CakeRequest', 'Network');
class CakeRequestTestCase extends CakeTestCase {
/**
diff --git a/cake/tests/cases/libs/cake_response.test.php b/lib/Cake/tests/cases/libs/cake_response.test.php
similarity index 99%
rename from cake/tests/cases/libs/cake_response.test.php
rename to lib/Cake/tests/cases/libs/cake_response.test.php
index d0d2a9e58..e38cfe513 100644
--- a/cake/tests/cases/libs/cake_response.test.php
+++ b/lib/Cake/tests/cases/libs/cake_response.test.php
@@ -1,6 +1,6 @@
array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'Model/Datasource/Session' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS . 'datasources' . DS . 'Session' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
Configure::write('Session', array(
'defaults' => 'cake',
@@ -550,8 +549,7 @@ class CakeSessionTest extends CakeTestCase {
*/
function testUsingPluginHandler() {
App::build(array(
- 'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
Configure::write('Session', array(
diff --git a/cake/tests/cases/libs/cake_socket.test.php b/lib/Cake/tests/cases/libs/cake_socket.test.php
similarity index 99%
rename from cake/tests/cases/libs/cake_socket.test.php
rename to lib/Cake/tests/cases/libs/cake_socket.test.php
index 0fc6f826a..ba3f21589 100644
--- a/cake/tests/cases/libs/cake_socket.test.php
+++ b/lib/Cake/tests/cases/libs/cake_socket.test.php
@@ -16,7 +16,8 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'CakeSocket');
+
+App::uses('CakeSocket', 'Network');
/**
* SocketTest class
diff --git a/cake/tests/cases/libs/cake_test_case.test.php b/lib/Cake/tests/cases/libs/cake_test_case.test.php
similarity index 91%
rename from cake/tests/cases/libs/cake_test_case.test.php
rename to lib/Cake/tests/cases/libs/cake_test_case.test.php
index 505dd8a08..589c72bf4 100644
--- a/cake/tests/cases/libs/cake_test_case.test.php
+++ b/lib/Cake/tests/cases/libs/cake_test_case.test.php
@@ -18,11 +18,12 @@
* @since CakePHP v 1.2.0.4487
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Controller', 'Controller', false);
-require_once TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'lib' . DS . 'reporter' . DS . 'cake_html_reporter.php';
-if (!class_exists('AppController')) {
- require_once LIBS . 'controller' . DS . 'app_controller.php';
+App::uses('Controller', 'Controller');
+App::uses('CakeHtmlReporter', 'TestSuite/Reporter');
+
+if (!class_exists('AppController', false)) {
+ require_once LIBS . 'Controller' . DS . 'AppController.php';
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
define('APP_CONTROLLER_EXISTS', true);
}
@@ -35,8 +36,8 @@ if (!class_exists('AppController')) {
class CakeTestCaseTest extends CakeTestCase {
public static function setUpBeforeClass() {
- require_once TEST_CAKE_CORE_INCLUDE_PATH . DS . 'tests' . DS . 'fixtures' . DS . 'assert_tags_test_case.php';
- require_once TEST_CAKE_CORE_INCLUDE_PATH . DS . 'tests' . DS . 'fixtures' . DS . 'fixturized_test_case.php';
+ require_once LIBS . 'tests' . DS . 'fixtures' . DS . 'assert_tags_test_case.php';
+ require_once LIBS . 'tests' . DS . 'fixtures' . DS . 'fixturized_test_case.php';
}
/**
diff --git a/cake/tests/cases/libs/cake_test_fixture.test.php b/lib/Cake/tests/cases/libs/cake_test_fixture.test.php
similarity index 98%
rename from cake/tests/cases/libs/cake_test_fixture.test.php
rename to lib/Cake/tests/cases/libs/cake_test_fixture.test.php
index f329fc69c..edfe8e888 100644
--- a/cake/tests/cases/libs/cake_test_fixture.test.php
+++ b/lib/Cake/tests/cases/libs/cake_test_fixture.test.php
@@ -16,7 +16,9 @@
* @since CakePHP(tm) v 1.2.0.4667
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Datasource', 'DboSource', false);
+App::uses('DboSource', 'Model/Datasource');
+App::uses('Model', 'Model');
+App::uses('CakeTestFixture', 'TestSuite/Fixture');
/**
* CakeTestFixtureTestFixture class
diff --git a/cake/tests/cases/libs/class_registry.test.php b/lib/Cake/tests/cases/libs/class_registry.test.php
similarity index 99%
rename from cake/tests/cases/libs/class_registry.test.php
rename to lib/Cake/tests/cases/libs/class_registry.test.php
index 21aa081b1..7f6e4d54e 100644
--- a/cake/tests/cases/libs/class_registry.test.php
+++ b/lib/Cake/tests/cases/libs/class_registry.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'ClassRegistry');
+App::uses('ClassRegistry', 'Utility');
/**
* ClassRegisterModel class
diff --git a/cake/tests/cases/libs/config/ini_reader.test.php b/lib/Cake/tests/cases/libs/config/ini_reader.test.php
similarity index 95%
rename from cake/tests/cases/libs/config/ini_reader.test.php
rename to lib/Cake/tests/cases/libs/config/ini_reader.test.php
index 4f077873a..dcc5a3f68 100644
--- a/cake/tests/cases/libs/config/ini_reader.test.php
+++ b/lib/Cake/tests/cases/libs/config/ini_reader.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'config/IniReader');
+App::uses('IniReader', 'Configure');
class IniReaderTest extends CakeTestCase {
@@ -34,7 +34,7 @@ class IniReaderTest extends CakeTestCase {
*/
function setup() {
parent::setup();
- $this->path = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS;
+ $this->path = LIBS . 'tests' . DS . 'test_app' . DS . 'config'. DS;
}
/**
diff --git a/cake/tests/cases/libs/config/php_reader.test.php b/lib/Cake/tests/cases/libs/config/php_reader.test.php
similarity index 90%
rename from cake/tests/cases/libs/config/php_reader.test.php
rename to lib/Cake/tests/cases/libs/config/php_reader.test.php
index a1d3034fc..e66fed473 100644
--- a/cake/tests/cases/libs/config/php_reader.test.php
+++ b/lib/Cake/tests/cases/libs/config/php_reader.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'config/PhpReader');
+App::uses('PhpReader', 'Configure');
class PhpReaderTest extends CakeTestCase {
/**
@@ -26,7 +26,7 @@ class PhpReaderTest extends CakeTestCase {
*/
function setUp() {
parent::setUp();
- $this->path = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS;
+ $this->path = LIBS . 'tests' . DS . 'test_app' . DS . 'config'. DS;
}
/**
* test reading files
@@ -83,7 +83,7 @@ class PhpReaderTest extends CakeTestCase {
*/
function testReadPluginValue() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
$reader = new PhpReader($this->path);
$result = $reader->read('TestPlugin.load');
diff --git a/cake/tests/cases/libs/configure.test.php b/lib/Cake/tests/cases/libs/configure.test.php
similarity index 96%
rename from cake/tests/cases/libs/configure.test.php
rename to lib/Cake/tests/cases/libs/configure.test.php
index e58874e21..5a9708cd5 100644
--- a/cake/tests/cases/libs/configure.test.php
+++ b/lib/Cake/tests/cases/libs/configure.test.php
@@ -18,7 +18,7 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'config/PhpReader');
+App::uses('PhpReader', 'Configure');
/**
* ConfigureTest
@@ -198,7 +198,7 @@ class ConfigureTest extends CakeTestCase {
* @return void
*/
function testLoad() {
- Configure::config('test', new PhpReader(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS));
+ Configure::config('test', new PhpReader(LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS));
$result = Configure::load('var_test', 'test');
$this->assertTrue($result);
@@ -213,7 +213,7 @@ class ConfigureTest extends CakeTestCase {
* @return void
*/
function testLoadPlugin() {
- App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
+ App::build(array('plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true);
Configure::config('test', new PhpReader());
$result = Configure::load('test_plugin.load', 'test');
diff --git a/cake/tests/cases/libs/controller/component.test.php b/lib/Cake/tests/cases/libs/controller/component.test.php
similarity index 94%
rename from cake/tests/cases/libs/controller/component.test.php
rename to lib/Cake/tests/cases/libs/controller/component.test.php
index eb01dae61..e1685c25e 100644
--- a/cake/tests/cases/libs/controller/component.test.php
+++ b/lib/Cake/tests/cases/libs/controller/component.test.php
@@ -16,8 +16,9 @@
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Controller', 'Controller', false);
-App::import('Controller', 'Component', false);
+
+App::uses('Controller', 'Controller');
+App::uses('Component', 'Controller');
/**
* ParamTestComponent
@@ -50,7 +51,7 @@ class ParamTestComponent extends Component {
* @access public
* @return void
*/
- function initialize($controllerz) {
+ function initialize(&$controller, $settings) {
foreach ($settings as $key => $value) {
if (is_numeric($key)) {
$this->{$value} = true;
@@ -116,7 +117,7 @@ class AppleComponent extends Component {
* @access public
* @return void
*/
- function startup($controller) {
+ function startup(&$controller) {
$this->testName = $controller->name;
}
}
@@ -143,7 +144,7 @@ class OrangeComponent extends Component {
* @access public
* @return void
*/
- function initialize($controller) {
+ function initialize(&$controller) {
$this->Controller = $controller;
$this->Banana->testField = 'OrangeField';
}
@@ -154,7 +155,7 @@ class OrangeComponent extends Component {
* @param Controller $controller
* @return string
*/
- public function startup($controller) {
+ public function startup(&$controller) {
$controller->foo = 'pass';
}
}
@@ -180,7 +181,7 @@ class BananaComponent extends Component {
* @param Controller $controller
* @return string
*/
- public function startup($controller) {
+ public function startup(&$controller) {
$controller->bar = 'fail';
}
}
@@ -250,7 +251,7 @@ class ComponentTest extends CakeTestCase {
function setUp() {
$this->_pluginPaths = App::path('plugins');
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
}
diff --git a/cake/tests/cases/libs/controller/component_collection.test.php b/lib/Cake/tests/cases/libs/controller/component_collection.test.php
similarity index 92%
rename from cake/tests/cases/libs/controller/component_collection.test.php
rename to lib/Cake/tests/cases/libs/controller/component_collection.test.php
index 549e246a3..a6b779073 100644
--- a/cake/tests/cases/libs/controller/component_collection.test.php
+++ b/lib/Cake/tests/cases/libs/controller/component_collection.test.php
@@ -17,8 +17,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Component', array('Cookie', 'Security'));
-App::import('Core', 'ComponentCollection');
+App::uses('CookieComponent', 'Controller/Component');
+App::uses('SecurityComponent', 'Controller/Component');
+App::uses('ComponentCollection', 'Controller');
/**
* Extended CookieComponent
@@ -83,7 +84,7 @@ class ComponentCollectionTest extends CakeTestCase {
$result = $this->Components->load('Cookie');
$this->assertInstanceOf('CookieAliasComponent', $result);
- App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)));
+ App::build(array('plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)));
$result = $this->Components->load('SomeOther', array('className' => 'TestPlugin.OtherComponent'));
$this->assertInstanceOf('OtherComponentComponent', $result);
$this->assertInstanceOf('OtherComponentComponent', $this->Components->SomeOther);
@@ -108,7 +109,7 @@ class ComponentCollectionTest extends CakeTestCase {
/**
* test missingcomponent exception
*
- * @expectedException MissingComponentFileException
+ * @expectedException MissingComponentClassException
* @return void
*/
function testLoadMissingComponentFile() {
@@ -122,7 +123,7 @@ class ComponentCollectionTest extends CakeTestCase {
*/
function testLoadPluginComponent() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
));
$result = $this->Components->load('TestPlugin.OtherComponent');
$this->assertInstanceOf('OtherComponentComponent', $result, 'Component class is wrong.');
diff --git a/cake/tests/cases/libs/controller/components/acl.test.php b/lib/Cake/tests/cases/libs/controller/components/acl.test.php
similarity index 98%
rename from cake/tests/cases/libs/controller/components/acl.test.php
rename to lib/Cake/tests/cases/libs/controller/components/acl.test.php
index 4e10cce48..102a040d4 100644
--- a/cake/tests/cases/libs/controller/components/acl.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/acl.test.php
@@ -16,8 +16,10 @@
* @since CakePHP(tm) v 1.2.0.5435
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Component', 'Acl');
-App::import('model' . DS . 'db_acl');
+
+App::uses('AclComponent', 'Controller/Component');
+App::uses('AclNode', 'Model');
+class_exists('AclComponent');
/**
* AclNodeTwoTestBase class
@@ -260,7 +262,7 @@ class IniAclTest extends CakeTestCase {
* @return void
*/
function testCheck() {
- $iniFile = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS . 'acl.ini.php';
+ $iniFile = LIBS . 'tests' . DS . 'test_app' . DS . 'config'. DS . 'acl.ini.php';
$Ini = new IniAcl();
$Ini->config = $Ini->readConfigFile($iniFile);
@@ -283,7 +285,7 @@ class IniAclTest extends CakeTestCase {
* @return void
*/
function testCheckArray() {
- $iniFile = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS . 'acl.ini.php';
+ $iniFile = LIBS . 'tests' . DS . 'test_app' . DS . 'config'. DS . 'acl.ini.php';
$Ini = new IniAcl();
$Ini->config = $Ini->readConfigFile($iniFile);
diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/lib/Cake/tests/cases/libs/controller/components/auth.test.php
similarity index 99%
rename from cake/tests/cases/libs/controller/components/auth.test.php
rename to lib/Cake/tests/cases/libs/controller/components/auth.test.php
index fc32e2709..dbc939990 100644
--- a/cake/tests/cases/libs/controller/components/auth.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/auth.test.php
@@ -16,10 +16,11 @@
* @since CakePHP(tm) v 1.2.0.5347
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Controller');
-App::import('Component', array('Auth', 'Acl'));
-App::import('Component', 'auth/form_authenticate');
-App::import('Model', 'DbAcl');
+
+App::uses('Controller', 'Controller');
+App::uses('AuthComponent', 'Controller/Component');
+App::uses('AclComponent', 'Controller/Component');
+App::uses('FormAuthenticate', 'Controller/Component/Auth');
/**
* TestAuthComponent class
@@ -947,11 +948,11 @@ class AuthTest extends CakeTestCase {
*/
function testAjaxLogin() {
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
));
$_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest";
- App::import('Core', 'Dispatcher');
+ App::uses('Dispatcher', 'Routing');
ob_start();
$Dispatcher = new Dispatcher();
diff --git a/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php
similarity index 93%
rename from cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php
rename to lib/Cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php
index 242606416..d4d967214 100644
--- a/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php
@@ -13,11 +13,12 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Component', 'auth/actions_authorize');
-App::import('Controller', 'ComponentCollection');
-App::import('Component', 'Acl');
-App::import('Core', 'CakeRequest');
-App::import('Core', 'Controller');
+
+App::uses('ActionsAuthorize', 'Controller/Component/Auth');
+App::uses('ComponentCollection', 'Controller');
+App::uses('AclComponent', 'Controller/Component');
+App::uses('CakeRequest', 'Network');
+App::uses('CakeResponse', 'Network');
class ActionsAuthorizeTest extends CakeTestCase {
diff --git a/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php
similarity index 96%
rename from cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php
rename to lib/Cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php
index f310faac5..6e0c9df57 100644
--- a/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php
@@ -14,11 +14,11 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Component', 'Auth');
-App::import('Component', 'auth/basic_authenticate');
-App::import('Model', 'AppModel');
-App::import('Core', 'CakeRequest');
-App::import('Core', 'CakeResponse');
+App::uses('AuthComponent', 'Controller/Component');
+App::uses('BasicAuthenticate', 'Controller/Component/Auth');
+App::uses('AppModel', 'Model');
+App::uses('CakeRequest', 'Network');
+App::uses('CakeResponse', 'Network');
require_once CAKE_TESTS . 'cases' . DS . 'libs' . DS . 'model' . DS . 'models.php';
diff --git a/cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php
similarity index 91%
rename from cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php
rename to lib/Cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php
index a3f687f0d..09ef5c6f8 100644
--- a/cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php
@@ -13,9 +13,11 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Component', 'auth/controller_authorize');
-App::import('Core', 'CakeRequest');
-App::import('Core', 'Controller');
+
+App::uses('Controller', 'Controller');
+App::uses('ControllerAuthorize', 'Controller/Component/Auth');
+App::uses('CakeRequest', 'Network');
+App::uses('CakeResponse', 'Network');
class ControllerAuthorizeTest extends CakeTestCase {
diff --git a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php
similarity index 94%
rename from cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php
rename to lib/Cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php
index a78fb71ec..853b01e32 100644
--- a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php
@@ -13,11 +13,12 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Component', 'auth/crud_authorize');
-App::import('Controller', 'ComponentCollection');
-App::import('Component', 'Acl');
-App::import('Core', 'CakeRequest');
-App::import('Core', 'Controller');
+
+App::uses('CrudAuthorize', 'Controller/Component/Auth');
+App::uses('ComponentCollection', 'Controller');
+App::uses('AclComponent', 'Controller/Component');
+App::uses('CakeRequest', 'Network');
+App::uses('CakeResponse', 'Network');
class CrudAuthorizeTest extends CakeTestCase {
diff --git a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php
similarity index 97%
rename from cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php
rename to lib/Cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php
index 5d81c0bf1..829d5bda6 100644
--- a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php
@@ -14,11 +14,10 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Component', 'auth/digest_authenticate');
-App::import('Model', 'AppModel');
-App::import('Core', 'CakeRequest');
-App::import('Core', 'CakeResponse');
-
+App::uses('DigestAuthenticate', 'Controller/Component/Auth');
+App::uses('AppModel', 'Model');
+App::uses('CakeRequest', 'Network');
+App::uses('CakeResponse', 'Network');
require_once CAKE_TESTS . 'cases' . DS . 'libs' . DS . 'model' . DS . 'models.php';
diff --git a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php
similarity index 94%
rename from cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php
rename to lib/Cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php
index 7e99b3b7b..cc0e22bd1 100644
--- a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php
@@ -14,11 +14,11 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Component', 'Auth');
-App::import('Component', 'auth/form_authenticate');
-App::import('Model', 'AppModel');
-App::import('Core', 'CakeRequest');
-App::import('Core', 'CakeResponse');
+App::uses('AuthComponent', 'Controller/Component');
+App::uses('FormAuthenticate', 'Controller/Component/Auth');
+App::uses('AppModel', 'Model');
+App::uses('CakeRequest', 'Network');
+App::uses('CakeResponse', 'Network');
require_once CAKE_TESTS . 'cases' . DS . 'libs' . DS . 'model' . DS . 'models.php';
@@ -155,7 +155,7 @@ class FormAuthenticateTest extends CakeTestCase {
function testPluginModel() {
Cache::delete('object_map', '_cake_core_');
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
), true);
App::objects('plugin', null, false);
diff --git a/cake/tests/cases/libs/controller/components/cookie.test.php b/lib/Cake/tests/cases/libs/controller/components/cookie.test.php
similarity index 99%
rename from cake/tests/cases/libs/controller/components/cookie.test.php
rename to lib/Cake/tests/cases/libs/controller/components/cookie.test.php
index 0dc3ccd38..9254ef94c 100644
--- a/cake/tests/cases/libs/controller/components/cookie.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/cookie.test.php
@@ -16,8 +16,11 @@
* @since CakePHP(tm) v 1.2.0.5435
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Controller', array('Component', 'Controller'), false);
-App::import('Component', 'Cookie');
+
+App::uses('Component', 'Controller');
+App::uses('Controller', 'Controller');
+App::uses('CookieComponent', 'Controller/Component');
+
/**
* CookieComponentTestController class
diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/lib/Cake/tests/cases/libs/controller/components/email.test.php
similarity index 98%
rename from cake/tests/cases/libs/controller/components/email.test.php
rename to lib/Cake/tests/cases/libs/controller/components/email.test.php
index 35b96c34b..a3b1bd358 100755
--- a/cake/tests/cases/libs/controller/components/email.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/email.test.php
@@ -18,9 +18,9 @@
* @since CakePHP(tm) v 1.2.0.5347
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Controller');
-App::import('Component', 'Email');
-App::import('Core', 'CakeSocket');
+App::uses('Controller', 'Controller');
+App::uses('EmailComponent', 'Controller/Component');
+App::uses('CakeSocket', 'Network');
/**
* EmailTestComponent class
@@ -252,11 +252,10 @@ class EmailComponentTest extends CakeTestCase {
$this->Controller->Components->init($this->Controller);
$this->Controller->EmailTest->initialize($this->Controller, array());
- $view = new View($this->Controller);
- ClassRegistry::addObject('view', $view);
+ ClassRegistry::addObject('view', new View($this->Controller));
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
));
}
@@ -806,7 +805,7 @@ HTMLBLOC;
*/
function testMessageRetrievalWithoutTemplate() {
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
));
$this->Controller->EmailTest->to = 'postmaster@localhost';
@@ -844,7 +843,7 @@ HTMLBLOC;
*/
function testMessageRetrievalWithTemplate() {
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
));
$this->Controller->set('value', 22091985);
@@ -1176,8 +1175,8 @@ HTMLBLOC;
function testPluginCustomViewClass() {
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)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
));
$this->Controller->view = 'TestPlugin.Email';
diff --git a/cake/tests/cases/libs/controller/components/paginator.test.php b/lib/Cake/tests/cases/libs/controller/components/paginator.test.php
similarity index 99%
rename from cake/tests/cases/libs/controller/components/paginator.test.php
rename to lib/Cake/tests/cases/libs/controller/components/paginator.test.php
index cbaecb2b9..c286c0a67 100644
--- a/cake/tests/cases/libs/controller/components/paginator.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/paginator.test.php
@@ -18,9 +18,11 @@
* @since CakePHP(tm) v 2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Controller', 'Controller', false);
-App::import('Component', 'Paginator');
-App::import('Core', array('CakeRequest', 'CakeResponse'));
+
+App::uses('Controller', 'Controller');
+App::uses('PaginatorComponent', 'Controller/Component');
+App::uses('CakeRequest', 'Network');
+App::uses('CakeResponse', 'Network');
/**
* PaginatorTestController class
diff --git a/cake/tests/cases/libs/controller/components/request_handler.test.php b/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php
similarity index 98%
rename from cake/tests/cases/libs/controller/components/request_handler.test.php
rename to lib/Cake/tests/cases/libs/controller/components/request_handler.test.php
index 3ce9ccc4e..3d0ea9c9b 100644
--- a/cake/tests/cases/libs/controller/components/request_handler.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php
@@ -16,9 +16,11 @@
* @since CakePHP(tm) v 1.2.0.5435
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Controller', 'Controller', false);
-App::import('Component', array('RequestHandler'));
-App::import('Core', array('CakeRequest', 'CakeResponse'));
+App::uses('Controller', 'Controller');
+App::uses('RequestHandlerComponent', 'Controller/Component');
+App::uses('CakeRequest', 'Network');
+App::uses('CakeResponse', 'Network');
+App::uses('Router', 'Routing');
/**
* RequestHandlerTestController class
@@ -668,7 +670,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
*/
function testAjaxRedirectAsRequestAction() {
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
), true);
$this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
@@ -697,7 +699,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
*/
function testAjaxRedirectAsRequestActionStillRenderingLayout() {
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
), true);
$this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components));
diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/lib/Cake/tests/cases/libs/controller/components/security.test.php
similarity index 99%
rename from cake/tests/cases/libs/controller/components/security.test.php
rename to lib/Cake/tests/cases/libs/controller/components/security.test.php
index f3d1240e6..4f2209070 100644
--- a/cake/tests/cases/libs/controller/components/security.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/security.test.php
@@ -16,8 +16,9 @@
* @since CakePHP(tm) v 1.2.0.5435
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Controller', 'Controller', false);
-App::import('Component', 'Security');
+
+App::uses('SecurityComponent', 'Controller/Component');
+App::uses('Controller', 'Controller');
/**
* TestSecurityComponent
diff --git a/cake/tests/cases/libs/controller/components/session.test.php b/lib/Cake/tests/cases/libs/controller/components/session.test.php
similarity index 98%
rename from cake/tests/cases/libs/controller/components/session.test.php
rename to lib/Cake/tests/cases/libs/controller/components/session.test.php
index 938d8dd00..d0af41057 100644
--- a/cake/tests/cases/libs/controller/components/session.test.php
+++ b/lib/Cake/tests/cases/libs/controller/components/session.test.php
@@ -16,8 +16,8 @@
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Controller', 'Controller', false);
-App::import('Component', 'Session');
+App::uses('Controller', 'Controller');
+App::uses('SessionComponent', 'Controller/Component');
/**
* SessionTestController class
diff --git a/cake/tests/cases/libs/controller/controller.test.php b/lib/Cake/tests/cases/libs/controller/controller.test.php
similarity index 96%
rename from cake/tests/cases/libs/controller/controller.test.php
rename to lib/Cake/tests/cases/libs/controller/controller.test.php
index dd637e622..ec7345ca2 100644
--- a/cake/tests/cases/libs/controller/controller.test.php
+++ b/lib/Cake/tests/cases/libs/controller/controller.test.php
@@ -16,11 +16,12 @@
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Controller', 'Controller', false);
-App::import('Core', array('CakeRequest', 'CakeResponse'));
-App::import('Component', 'Security');
-App::import('Component', 'Cookie');
-
+App::uses('Controller', 'Controller');
+App::uses('Router', 'Routing');
+App::uses('CakeRequest', 'Network');
+App::uses('CakeResponse', 'Network');
+App::uses('SecurityComponent', 'Controller/Component');
+App::uses('CookieComponent', 'Controller/Component');
/**
* AppController class
@@ -110,13 +111,13 @@ class ControllerPost extends CakeTestModel {
* @access public
* @return void
*/
- function find($conditions = null, $fields = array(), $order = null, $recursive = null) {
- if ($conditions == 'popular') {
+ function find($type, $options = array()) {
+ if ($type == 'popular') {
$conditions = array($this->name . '.' . $this->primaryKey .' > ' => '1');
- $options = Set::merge($fields, compact('conditions'));
- return parent::find('all', $fields);
+ $options = Set::merge($options, compact('conditions'));
+ return parent::find('all', $options);
}
- return parent::find($conditions, $fields);
+ return parent::find($type, $options);
}
}
@@ -317,7 +318,7 @@ class TestComponent extends Object {
* @access public
* @return void
*/
- function initialize($controller) {
+ function initialize(&$controller) {
}
/**
@@ -326,7 +327,7 @@ class TestComponent extends Object {
* @access public
* @return void
*/
- function startup($controller) {
+ function startup(&$controller) {
}
/**
* shutdown method
@@ -334,14 +335,14 @@ class TestComponent extends Object {
* @access public
* @return void
*/
- function shutdown($controller) {
+ function shutdown(&$controller) {
}
/**
* beforeRender callback
*
* @return void
*/
- function beforeRender($controller) {
+ function beforeRender(&$controller) {
if ($this->viewclass) {
$controller->viewClass = $this->viewclass;
}
@@ -437,11 +438,12 @@ class ControllerTest extends CakeTestCase {
*/
function testLoadModelInPlugins() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
- 'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS),
- 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'Controller' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS),
+ 'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS)
));
- App::import('Controller', 'TestPlugin.TestPlugin');
+ App::uses('TestPluginAppController', 'TestPlugin.Controller');
+ App::uses('TestPluginController', 'TestPlugin.Controller');
$Controller = new TestPluginController();
$Controller->plugin = 'TestPlugin';
@@ -486,7 +488,7 @@ class ControllerTest extends CakeTestCase {
unset($Controller);
- App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)));
+ App::build(array('plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)));
$Controller = new Controller($request);
$Controller->uses = array('TestPlugin.TestPluginPost');
@@ -576,7 +578,7 @@ class ControllerTest extends CakeTestCase {
$this->assertEqual($result, $expected);
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
));
$Controller = new Controller($request);
$Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
@@ -638,7 +640,7 @@ class ControllerTest extends CakeTestCase {
*/
function testRender() {
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
), true);
$request = new CakeRequest('controller_posts/index');
$request->params['action'] = 'index';
@@ -685,7 +687,7 @@ class ControllerTest extends CakeTestCase {
$core = App::core('views');
App::build(array(
'views' => array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS,
+ LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS,
$core[0]
)
), true);
diff --git a/cake/tests/cases/libs/controller/controller_merge_vars.test.php b/lib/Cake/tests/cases/libs/controller/controller_merge_vars.test.php
similarity index 99%
rename from cake/tests/cases/libs/controller/controller_merge_vars.test.php
rename to lib/Cake/tests/cases/libs/controller/controller_merge_vars.test.php
index 80e12d88c..dc4fb6130 100644
--- a/cake/tests/cases/libs/controller/controller_merge_vars.test.php
+++ b/lib/Cake/tests/cases/libs/controller/controller_merge_vars.test.php
@@ -18,7 +18,7 @@
* @since CakePHP(tm) v 1.2.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Controller');
+App::uses('Controller', 'Controller');
/**
* Test case AppController
diff --git a/cake/tests/cases/libs/controller/pages_controller.test.php b/lib/Cake/tests/cases/libs/controller/pages_controller.test.php
similarity index 85%
rename from cake/tests/cases/libs/controller/pages_controller.test.php
rename to lib/Cake/tests/cases/libs/controller/pages_controller.test.php
index 1d9d3febc..de1dd5b11 100644
--- a/cake/tests/cases/libs/controller/pages_controller.test.php
+++ b/lib/Cake/tests/cases/libs/controller/pages_controller.test.php
@@ -16,7 +16,8 @@
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Controller', 'Pages');
+
+App::uses('PagesController', 'Controller');
/**
* PagesControllerTest class
@@ -25,6 +26,16 @@ App::import('Controller', 'Pages');
*/
class PagesControllerTest extends CakeTestCase {
+/**
+ * endTest method
+ *
+ * @access public
+ * @return void
+ */
+ function endTest() {
+ App::build();
+ }
+
/**
* testDisplay method
*
@@ -33,7 +44,7 @@ class PagesControllerTest extends CakeTestCase {
*/
function testDisplay() {
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)
+ 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS, LIBS . 'libs' . DS . 'view' . DS)
));
$Pages = new PagesController(new CakeRequest(null, false));
diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/lib/Cake/tests/cases/libs/controller/scaffold.test.php
similarity index 92%
rename from cake/tests/cases/libs/controller/scaffold.test.php
rename to lib/Cake/tests/cases/libs/controller/scaffold.test.php
index 7c1e4d51c..27503f07a 100644
--- a/cake/tests/cases/libs/controller/scaffold.test.php
+++ b/lib/Cake/tests/cases/libs/controller/scaffold.test.php
@@ -16,8 +16,10 @@
* @since CakePHP(tm) v 1.2.0.5436
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Scaffold', false);
-App::import('Core', 'Controller', false);
+
+App::uses('Controller', 'Controller');
+App::uses('Scaffold', 'Controller');
+App::uses('ScaffoldView', 'View');
/**
* ScaffoldMockController class
@@ -89,8 +91,8 @@ class TestScaffoldMock extends Scaffold {
*
* @param unknown_type $params
*/
- function _scaffold(CakeRequest $request) {
- $this->_params = $request;
+ function _scaffold($params) {
+ $this->_params = $params;
}
/**
@@ -277,8 +279,8 @@ class ScaffoldViewTest extends CakeTestCase {
$this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
}
@@ -305,39 +307,39 @@ class ScaffoldViewTest extends CakeTestCase {
$this->Controller->request->params['action'] = 'index';
$ScaffoldView = new TestScaffoldView($this->Controller);
$result = $ScaffoldView->testGetFilename('index');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'index.ctp';
+ $expected = LIBS . 'View' . DS . 'scaffolds' . DS . 'index.ctp';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('edit');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'form.ctp';
+ $expected = LIBS . 'View' . DS . 'scaffolds' . DS . 'form.ctp';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('add');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'form.ctp';
+ $expected = LIBS . 'View' . DS . 'scaffolds' . DS . 'form.ctp';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('view');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'view.ctp';
+ $expected = LIBS . 'View' . DS . 'scaffolds' . DS . 'view.ctp';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('admin_index');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'index.ctp';
+ $expected = LIBS . 'View' . DS . 'scaffolds' . DS . 'index.ctp';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('admin_view');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'view.ctp';
+ $expected = LIBS . 'View' . DS . 'scaffolds' . DS . 'view.ctp';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('admin_edit');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'form.ctp';
+ $expected =LIBS . 'View' . DS . 'scaffolds' . DS . 'form.ctp';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('admin_add');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'form.ctp';
+ $expected = LIBS . 'View' . DS . 'scaffolds' . DS . 'form.ctp';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('error');
- $expected = CAKE . 'libs' . DS . 'view' . DS . 'errors' . DS . 'scaffold_error.ctp';
+ $expected = LIBS . 'View' . DS . 'errors' . DS . 'scaffold_error.ctp';
$this->assertEqual($result, $expected);
$Controller = new ScaffoldMockController($this->request);
@@ -347,11 +349,11 @@ class ScaffoldViewTest extends CakeTestCase {
$ScaffoldView = new TestScaffoldView($Controller);
$result = $ScaffoldView->testGetFilename('admin_edit');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' .DS . 'views' . DS . 'posts' . DS . 'scaffold.form.ctp';
+ $expected = LIBS . 'tests' . DS . 'test_app' .DS . 'views' . DS . 'posts' . DS . 'scaffold.form.ctp';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('edit');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' .DS . 'views' . DS . 'posts' . DS . 'scaffold.form.ctp';
+ $expected = LIBS . 'tests' . DS . 'test_app' .DS . 'views' . DS . 'posts' . DS . 'scaffold.form.ctp';
$this->assertEqual($result, $expected);
$Controller = new ScaffoldMockController($this->request);
@@ -366,12 +368,12 @@ class ScaffoldViewTest extends CakeTestCase {
$ScaffoldView = new TestScaffoldView($Controller);
$result = $ScaffoldView->testGetFilename('admin_add');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins'
+ $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins'
. DS .'test_plugin' . DS . 'views' . DS . 'tests' . DS . 'scaffold.form.ctp';
$this->assertEqual($result, $expected);
$result = $ScaffoldView->testGetFilename('add');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins'
+ $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins'
. DS .'test_plugin' . DS . 'views' . DS . 'tests' . DS . 'scaffold.form.ctp';
$this->assertEqual($result, $expected);
@@ -390,7 +392,7 @@ class ScaffoldViewTest extends CakeTestCase {
$ScaffoldView = new TestScaffoldView($this->Controller);
$result = $ScaffoldView->testGetFilename('index');
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS
+ $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS
. 'themed' . DS . 'test_theme' . DS . 'posts' . DS . 'scaffold.index.ctp';
$this->assertEqual($result, $expected);
}
diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/lib/Cake/tests/cases/libs/controller_test_case.test.php
similarity index 92%
rename from cake/tests/cases/libs/controller_test_case.test.php
rename to lib/Cake/tests/cases/libs/controller_test_case.test.php
index 9e4feb4b7..a64d36521 100644
--- a/cake/tests/cases/libs/controller_test_case.test.php
+++ b/lib/Cake/tests/cases/libs/controller_test_case.test.php
@@ -19,12 +19,20 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+App::uses('Controller', 'Controller');
+App::uses('Model', 'Model');
+App::uses('AppModel', 'Model');
+App::uses('CakeHtmlReporter', 'TestSuite/Reporter');
+
+require_once dirname(__FILE__) . DS . 'model' . DS . 'models.php';
+
+
/**
* AppController class
*
* @package cake.tests.cases.libs.controller
*/
-if (!class_exists('AppController')) {
+if (!class_exists('AppController', false)) {
/**
* AppController class
*
@@ -114,10 +122,10 @@ class ControllerTestCaseTest extends CakeTestCase {
function setUp() {
parent::setUp();
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
- 'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . 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)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'Controller' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS),
+ 'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS)
));
$this->Case = new ControllerTestCase();
Router::reload();
@@ -263,7 +271,7 @@ class ControllerTestCaseTest extends CakeTestCase {
* Tests using loaded routes during tests
*/
function testUseRoutes() {
- include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
+ include LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
$controller = $this->Case->generate('TestsApps');
$controller->Components->load('RequestHandler');
$result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'view'));
@@ -271,16 +279,16 @@ class ControllerTestCaseTest extends CakeTestCase {
$expected = array('cakephp' => 'cool');
$this->assertEquals($result, $expected);
- include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
+ include LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
$result = $this->Case->testAction('/some_alias');
$this->assertEquals($result, 5);
- include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
+ include LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
$this->Case->testAction('/redirect_me_now');
$result = $this->Case->headers['Location'];
$this->assertEquals($result, 'http://cakephp.org');
- include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
+ include LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
$this->Case->testAction('/redirect_me');
$result = $this->Case->headers['Location'];
$this->assertEquals($result, Router::url(array('controller' => 'tests_apps', 'action' => 'some_method'), true));
@@ -292,7 +300,7 @@ class ControllerTestCaseTest extends CakeTestCase {
* @expectedException MissingActionException
*/
function testSkipRoutes() {
- include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
+ include LIBS . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
$this->Case->loadRoutes = false;
$result = $this->Case->testAction('/tests_apps/missing_action.json', array('return' => 'view'));
diff --git a/cake/tests/cases/libs/debugger.test.php b/lib/Cake/tests/cases/libs/debugger.test.php
similarity index 99%
rename from cake/tests/cases/libs/debugger.test.php
rename to lib/Cake/tests/cases/libs/debugger.test.php
index e728fb5ea..ac1d51b25 100644
--- a/cake/tests/cases/libs/debugger.test.php
+++ b/lib/Cake/tests/cases/libs/debugger.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Debugger');
+App::uses('Debugger', 'Utility');
/**
* DebugggerTestCaseDebuggger class
@@ -214,7 +214,7 @@ class DebuggerTest extends CakeTestCase {
* @return void
*/
function testExportVar() {
- App::import('Controller');
+ App::uses('Controller', 'Controller');
$Controller = new Controller();
$Controller->helpers = array('Html', 'Form');
$View = new View($Controller);
diff --git a/cake/tests/cases/libs/dispatcher.test.php b/lib/Cake/tests/cases/libs/dispatcher.test.php
similarity index 95%
rename from cake/tests/cases/libs/dispatcher.test.php
rename to lib/Cake/tests/cases/libs/dispatcher.test.php
index 07823552a..bcfa6517a 100644
--- a/cake/tests/cases/libs/dispatcher.test.php
+++ b/lib/Cake/tests/cases/libs/dispatcher.test.php
@@ -16,11 +16,11 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Dispatcher', false);
-App::import('Core', 'CakeResponse', false);
+App::uses('Dispatcher', 'Routing');
+App::uses('CakeResponse', 'Network');
-if (!class_exists('AppController')) {
- require_once LIBS . 'controller' . DS . 'app_controller.php';
+if (!class_exists('AppController', false)) {
+ require_once LIBS . 'Controller' . DS . 'AppController.php';
} elseif (!defined('APP_CONTROLLER_EXISTS')){
define('APP_CONTROLLER_EXISTS', true);
}
@@ -538,7 +538,7 @@ class DispatcherTest extends CakeTestCase {
$this->_debug = Configure::read('debug');
- App::build(App::core());
+ App::build();
App::objects('plugin', null, false);
}
@@ -765,7 +765,7 @@ class DispatcherTest extends CakeTestCase {
*/
public function testDispatchBasic() {
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
));
$Dispatcher = new TestDispatcher();
Configure::write('App.baseUrl', '/index.php');
@@ -1047,7 +1047,7 @@ class DispatcherTest extends CakeTestCase {
}
Router::reload();
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
App::objects('plugin', null, false);
@@ -1147,7 +1147,7 @@ class DispatcherTest extends CakeTestCase {
public function testTestPluginDispatch() {
$Dispatcher = new TestDispatcher();
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
App::objects('plugin', null, false);
Router::reload();
@@ -1205,9 +1205,9 @@ class DispatcherTest extends CakeTestCase {
Router::reload();
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),
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'vendors' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
+ 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
));
$Dispatcher = new TestDispatcher();
@@ -1231,21 +1231,21 @@ class DispatcherTest extends CakeTestCase {
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/flash/theme_test.swf'));
$result = ob_get_clean();
- $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'flash' . DS . 'theme_test.swf');
+ $file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'flash' . DS . 'theme_test.swf');
$this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load swf file from the theme.', $result);
ob_start();
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/pdfs/theme_test.pdf'));
$result = ob_get_clean();
- $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'pdfs' . DS . 'theme_test.pdf');
+ $file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'pdfs' . DS . 'theme_test.pdf');
$this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load pdf file from the theme.', $result);
ob_start();
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/img/test.jpg'));
$result = ob_get_clean();
- $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'img' . DS . 'test.jpg');
+ $file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'img' . DS . 'test.jpg');
$this->assertEqual($file, $result);
ob_start();
@@ -1266,20 +1266,20 @@ class DispatcherTest extends CakeTestCase {
ob_start();
$Dispatcher->asset('test_plugin/root.js');
$result = ob_get_clean();
- $expected = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'root.js');
+ $expected = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'root.js');
$this->assertEqual($result, $expected);
ob_start();
$Dispatcher->dispatch(new CakeRequest('test_plugin/flash/plugin_test.swf'));
$result = ob_get_clean();
- $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'flash' . DS . 'plugin_test.swf');
+ $file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'flash' . DS . 'plugin_test.swf');
$this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load swf file from the plugin.', $result);
ob_start();
$Dispatcher->dispatch(new CakeRequest('test_plugin/pdfs/plugin_test.pdf'));
$result = ob_get_clean();
- $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'pdfs' . DS . 'plugin_test.pdf');
+ $file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'webroot' . DS . 'pdfs' . DS . 'plugin_test.pdf');
$this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load pdf file from the plugin.', $result);
@@ -1301,7 +1301,7 @@ class DispatcherTest extends CakeTestCase {
ob_start();
$Dispatcher->asset('test_plugin/img/cake.icon.gif');
$result = ob_get_clean();
- $file = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' .DS . 'webroot' . DS . 'img' . DS . 'cake.icon.gif');
+ $file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' .DS . 'webroot' . DS . 'img' . DS . 'cake.icon.gif');
$this->assertEqual($file, $result);
ob_start();
@@ -1392,7 +1392,7 @@ class DispatcherTest extends CakeTestCase {
Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index'));
App::build(array(
- 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
+ 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS),
), true);
$dispatcher = new TestDispatcher();
diff --git a/cake/tests/cases/libs/error/error_handler.test.php b/lib/Cake/tests/cases/libs/error/error_handler.test.php
similarity index 96%
rename from cake/tests/cases/libs/error/error_handler.test.php
rename to lib/Cake/tests/cases/libs/error/error_handler.test.php
index ee5e43bca..fd76ac7d1 100644
--- a/cake/tests/cases/libs/error/error_handler.test.php
+++ b/lib/Cake/tests/cases/libs/error/error_handler.test.php
@@ -17,7 +17,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', array('ErrorHandler', 'Controller', 'Router'));
+App::uses('ErrorHandler', 'Error');
+App::uses('Controller', 'Controller');
+App::uses('Router', 'Routing');
/**
* ErrorHandlerTest class
@@ -35,8 +37,8 @@ class ErrorHandlerTest extends CakeTestCase {
function setUp() {
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
+ LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS,
+ LIBS . 'libs' . DS . 'view' . DS
)
), true);
Router::reload();
diff --git a/cake/tests/cases/libs/error/exception_renderer.test.php b/lib/Cake/tests/cases/libs/error/exception_renderer.test.php
similarity index 97%
rename from cake/tests/cases/libs/error/exception_renderer.test.php
rename to lib/Cake/tests/cases/libs/error/exception_renderer.test.php
index b8a25ddfb..950caba78 100644
--- a/cake/tests/cases/libs/error/exception_renderer.test.php
+++ b/lib/Cake/tests/cases/libs/error/exception_renderer.test.php
@@ -17,7 +17,11 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', array('ExceptionRenderer', 'Controller', 'Component'));
+App::uses('ExceptionRenderer', 'Error');
+App::uses('Controller', 'Controller');
+App::uses('AppController', 'Controller');
+App::uses('Component', 'Controller');
+App::uses('Router', 'Routing');
/**
* Short description for class.
@@ -64,7 +68,7 @@ class BlueberryComponent extends Component {
* @access public
* @return void
*/
- function initialize($controller) {
+ function initialize(&$controller) {
$this->testName = 'BlueberryComponent';
}
}
@@ -154,8 +158,8 @@ class ExceptionRendererTest extends CakeTestCase {
function setUp() {
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
+ LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS,
+ LIBS . 'libs' . DS . 'view' . DS
)
), true);
Router::reload();
diff --git a/cake/tests/cases/libs/file.test.php b/lib/Cake/tests/cases/libs/file.test.php
similarity index 99%
rename from cake/tests/cases/libs/file.test.php
rename to lib/Cake/tests/cases/libs/file.test.php
index d120ff8f3..02110a285 100644
--- a/cake/tests/cases/libs/file.test.php
+++ b/lib/Cake/tests/cases/libs/file.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'File');
+App::uses('File', 'Utility');
/**
* FileTest class
diff --git a/cake/tests/cases/libs/folder.test.php b/lib/Cake/tests/cases/libs/folder.test.php
similarity index 85%
rename from cake/tests/cases/libs/folder.test.php
rename to lib/Cake/tests/cases/libs/folder.test.php
index b30bfc616..65d153b9f 100644
--- a/cake/tests/cases/libs/folder.test.php
+++ b/lib/Cake/tests/cases/libs/folder.test.php
@@ -16,7 +16,8 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'File');
+App::uses('Folder', 'Utility');
+App::uses('File', 'Utility');
/**
* FolderTest class
@@ -146,7 +147,7 @@ class FolderTest extends CakeTestCase {
* @return void
*/
function testOperations() {
- $path = TEST_CAKE_CORE_INCLUDE_PATH . 'console' . DS . 'templates' . DS . 'skel';
+ $path = LIBS . 'console' . DS . 'templates' . DS . 'skel';
$Folder = new Folder($path);
$result = is_dir($Folder->pwd());
@@ -219,7 +220,7 @@ class FolderTest extends CakeTestCase {
public function testChmod() {
$this->skipIf(DIRECTORY_SEPARATOR === '\\', '%s Folder permissions tests not supported on Windows');
- $path = TEST_CAKE_CORE_INCLUDE_PATH . 'console' . DS . 'templates' . DS . 'skel';
+ $path = LIBS . 'console' . DS . 'templates' . DS . 'skel';
$Folder = new Folder($path);
$subdir = 'test_folder_new';
@@ -315,42 +316,41 @@ class FolderTest extends CakeTestCase {
$Folder = new Folder();
$expected = array(
array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'config',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding'
+ LIBS . 'config',
+ LIBS . 'config' . DS . 'unicode',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding'
),
array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'paths.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0080_00ff.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0100_017f.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0180_024F.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0250_02af.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0370_03ff.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0400_04ff.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0500_052f.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0530_058f.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '1e00_1eff.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '1f00_1fff.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2100_214f.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2150_218f.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2460_24ff.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c00_2c5f.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c60_2c7f.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c80_2cff.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . 'ff00_ffef.php'
+ LIBS . 'config' . DS . 'config.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0080_00ff.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0100_017f.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0180_024F.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0250_02af.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0370_03ff.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0400_04ff.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0500_052f.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '0530_058f.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '1e00_1eff.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '1f00_1fff.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2100_214f.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2150_218f.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2460_24ff.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c00_2c5f.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c60_2c7f.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c80_2cff.php',
+ LIBS . 'config' . DS . 'unicode' . DS . 'casefolding' . DS . 'ff00_ffef.php'
)
);
- $result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false);
+ $result = $Folder->tree(LIBS . 'config', false);
$this->assertIdentical(array_diff($expected[0], $result[0]), array());
$this->assertIdentical(array_diff($result[0], $expected[0]), array());
- $result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false, 'dir');
+ $result = $Folder->tree(LIBS . 'config', false, 'dir');
$this->assertIdentical(array_diff($expected[0], $result), array());
$this->assertIdentical(array_diff($result, $expected[0]), array());
- $result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false, 'files');
+ $result = $Folder->tree(LIBS . 'config', false, 'files');
$this->assertIdentical(array_diff($expected[1], $result), array());
$this->assertIdentical(array_diff($result, $expected[1]), array());
}
@@ -472,9 +472,8 @@ class FolderTest extends CakeTestCase {
$result = $Folder->inCakePath($path);
$this->assertFalse($result);
- // WHY DOES THIS FAIL ??
- $path = DS . 'cake' . DS . 'config';
- $Folder->cd(ROOT . DS . 'cake' . DS . 'config');
+ $path = DS . 'lib' . DS . 'Cake' . DS . 'config';
+ $Folder->cd(ROOT . DS . 'lib' . DS . 'Cake' . DS . 'config');
$result = $Folder->inCakePath($path);
$this->assertTrue($result);
}
@@ -487,31 +486,31 @@ class FolderTest extends CakeTestCase {
*/
function testFind() {
$Folder = new Folder();
- $Folder->cd(TEST_CAKE_CORE_INCLUDE_PATH . 'config');
+ $Folder->cd(LIBS . 'config');
$result = $Folder->find();
- $expected = array('config.php', 'paths.php');
+ $expected = array('config.php');
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->find('.*', true);
- $expected = array('config.php', 'paths.php');
+ $expected = array('config.php');
$this->assertIdentical($result, $expected);
$result = $Folder->find('.*\.php');
- $expected = array('config.php', 'paths.php');
+ $expected = array('config.php');
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->find('.*\.php', true);
- $expected = array('config.php', 'paths.php');
+ $expected = array('config.php');
$this->assertIdentical($result, $expected);
$result = $Folder->find('.*ig\.php');
$expected = array('config.php');
$this->assertIdentical($result, $expected);
- $result = $Folder->find('paths\.php');
- $expected = array('paths.php');
+ $result = $Folder->find('config\.php');
+ $expected = array('config.php');
$this->assertIdentical($result, $expected);
$Folder->cd(TMP);
@@ -540,19 +539,17 @@ class FolderTest extends CakeTestCase {
*/
function testFindRecursive() {
$Folder = new Folder();
- $Folder->cd(TEST_CAKE_CORE_INCLUDE_PATH);
+ $Folder->cd(LIBS);
$result = $Folder->findRecursive('(config|paths)\.php');
$expected = array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'paths.php'
+ LIBS . 'config' . DS . 'config.php'
);
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->findRecursive('(config|paths)\.php', true);
$expected = array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php',
- TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'paths.php'
+ LIBS . 'config' . DS . 'config.php'
);
$this->assertIdentical($result, $expected);
@@ -586,7 +583,7 @@ class FolderTest extends CakeTestCase {
);
$this->assertIdentical($result, $expected);
- $Folder->cd(TEST_CAKE_CORE_INCLUDE_PATH . 'config');
+ $Folder->cd(LIBS . 'config');
$Folder->cd(TMP);
$Folder->delete($Folder->pwd() . DS . 'testme');
$File->delete();
diff --git a/cake/tests/cases/libs/html_coverage_report.test.php b/lib/Cake/tests/cases/libs/html_coverage_report.test.php
similarity index 92%
rename from cake/tests/cases/libs/html_coverage_report.test.php
rename to lib/Cake/tests/cases/libs/html_coverage_report.test.php
index 90fe7f69a..a8d6ae7db 100644
--- a/cake/tests/cases/libs/html_coverage_report.test.php
+++ b/lib/Cake/tests/cases/libs/html_coverage_report.test.php
@@ -17,7 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-require_once CAKE . 'tests' . DS . 'lib' . DS . 'coverage' . DS . 'html_coverage_report.php';
+App::uses('HtmlCoverageReport', 'TestSuite/Coverage');
class HtmlCoverageReportTest extends CakeTestCase {
/**
@@ -40,7 +40,7 @@ class HtmlCoverageReportTest extends CakeTestCase {
function testGetPathFilter() {
$this->Coverage->appTest = false;
$result = $this->Coverage->getPathFilter();
- $this->assertEquals(TEST_CAKE_CORE_INCLUDE_PATH, $result);
+ $this->assertEquals(LIBS, $result);
$this->Coverage->appTest = true;
$result = $this->Coverage->getPathFilter();
@@ -59,7 +59,7 @@ class HtmlCoverageReportTest extends CakeTestCase {
*/
function testFilterCoverageDataByPathRemovingElements() {
$data = array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php' => array(
+ LIBS . 'dispatcher.php' => array(
10 => -1,
12 => 1
),
@@ -69,8 +69,8 @@ class HtmlCoverageReportTest extends CakeTestCase {
)
);
$this->Coverage->setCoverage($data);
- $result = $this->Coverage->filterCoverageDataByPath(TEST_CAKE_CORE_INCLUDE_PATH);
- $this->assertTrue(isset($result[TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php']));
+ $result = $this->Coverage->filterCoverageDataByPath(LIBS);
+ $this->assertTrue(isset($result[LIBS . 'dispatcher.php']));
$this->assertFalse(isset($result[APP . 'app_model.php']));
}
diff --git a/cake/tests/cases/libs/http/basic_authentication.test.php b/lib/Cake/tests/cases/libs/http/basic_authentication.test.php
similarity index 94%
rename from cake/tests/cases/libs/http/basic_authentication.test.php
rename to lib/Cake/tests/cases/libs/http/basic_authentication.test.php
index 990ed0750..3989b6f37 100644
--- a/cake/tests/cases/libs/http/basic_authentication.test.php
+++ b/lib/Cake/tests/cases/libs/http/basic_authentication.test.php
@@ -17,8 +17,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'HttpSocket');
-App::import('Lib', 'http/BasicAuthentication');
+App::uses('HttpSocket', 'Network/Http');
+App::uses('BasicAuthentication', 'Network/Http');
/**
* BasicMethodTest class
diff --git a/cake/tests/cases/libs/http/digest_authentication.test.php b/lib/Cake/tests/cases/libs/http/digest_authentication.test.php
similarity index 98%
rename from cake/tests/cases/libs/http/digest_authentication.test.php
rename to lib/Cake/tests/cases/libs/http/digest_authentication.test.php
index 17832ce45..0b9b6daea 100644
--- a/cake/tests/cases/libs/http/digest_authentication.test.php
+++ b/lib/Cake/tests/cases/libs/http/digest_authentication.test.php
@@ -17,8 +17,8 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'HttpSocket');
-App::import('Lib', 'http/DigestAuthentication');
+App::uses('HttpSocket', 'Network/Http');
+App::uses('DigestAuthentication', 'Network/Http');
class DigestHttpSocket extends HttpSocket {
diff --git a/cake/tests/cases/libs/http_response.test.php b/lib/Cake/tests/cases/libs/http_response.test.php
similarity index 99%
rename from cake/tests/cases/libs/http_response.test.php
rename to lib/Cake/tests/cases/libs/http_response.test.php
index 9155bb8a3..53afc8ed9 100644
--- a/cake/tests/cases/libs/http_response.test.php
+++ b/lib/Cake/tests/cases/libs/http_response.test.php
@@ -16,7 +16,8 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'HttpResponse');
+
+App::uses('HttpResponse', 'Network/Http');
/**
* TestHttpResponse class
diff --git a/cake/tests/cases/libs/http_socket.test.php b/lib/Cake/tests/cases/libs/http_socket.test.php
similarity index 99%
rename from cake/tests/cases/libs/http_socket.test.php
rename to lib/Cake/tests/cases/libs/http_socket.test.php
index 94de48389..d0f46de52 100644
--- a/cake/tests/cases/libs/http_socket.test.php
+++ b/lib/Cake/tests/cases/libs/http_socket.test.php
@@ -16,7 +16,9 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'HttpSocket');
+
+App::uses('HttpSocket', 'Network/Http');
+App::uses('HttpResponse', 'Network/Http');
/**
* TestAuthentication class
diff --git a/cake/tests/cases/libs/i18n.test.php b/lib/Cake/tests/cases/libs/i18n.test.php
similarity index 99%
rename from cake/tests/cases/libs/i18n.test.php
rename to lib/Cake/tests/cases/libs/i18n.test.php
index 5fdf3a93a..a5de7dd49 100644
--- a/cake/tests/cases/libs/i18n.test.php
+++ b/lib/Cake/tests/cases/libs/i18n.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'i18n');
+App::uses('I18n', 'I18n');
/**
* I18nTest class
@@ -34,8 +34,8 @@ class I18nTest extends CakeTestCase {
function setUp() {
Cache::delete('object_map', '_cake_core_');
App::build(array(
- 'locales' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'locales' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'locale' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
App::objects('plugin', null, false);
}
@@ -2432,7 +2432,7 @@ class I18nTest extends CakeTestCase {
*/
function testPluginTranslation() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
Configure::write('Config.language', 'po');
diff --git a/cake/tests/cases/libs/inflector.test.php b/lib/Cake/tests/cases/libs/inflector.test.php
similarity index 99%
rename from cake/tests/cases/libs/inflector.test.php
rename to lib/Cake/tests/cases/libs/inflector.test.php
index 3c04e0363..33be79e94 100644
--- a/cake/tests/cases/libs/inflector.test.php
+++ b/lib/Cake/tests/cases/libs/inflector.test.php
@@ -24,7 +24,7 @@
* Included libraries.
*
*/
-App::import('Core', 'Inflector');
+App::uses('Inflector', 'Utility');
/**
* Short description for class.
diff --git a/cake/tests/cases/libs/l10n.test.php b/lib/Cake/tests/cases/libs/l10n.test.php
similarity index 99%
rename from cake/tests/cases/libs/l10n.test.php
rename to lib/Cake/tests/cases/libs/l10n.test.php
index dd7a5a79c..85a01f64a 100644
--- a/cake/tests/cases/libs/l10n.test.php
+++ b/lib/Cake/tests/cases/libs/l10n.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'l10n');
+App::uses('L10n', 'I18n');
/**
* L10nTest class
diff --git a/cake/tests/cases/libs/log/file_log.test.php b/lib/Cake/tests/cases/libs/log/file_log.test.php
similarity index 98%
rename from cake/tests/cases/libs/log/file_log.test.php
rename to lib/Cake/tests/cases/libs/log/file_log.test.php
index d861426b3..9dab415ea 100644
--- a/cake/tests/cases/libs/log/file_log.test.php
+++ b/lib/Cake/tests/cases/libs/log/file_log.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.3
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'log/FileLog');
+App::uses('FileLog', 'Log/Engine');
/**
* CakeLogTest class
diff --git a/cake/tests/cases/libs/magic_db.test.php b/lib/Cake/tests/cases/libs/magic_db.test.php
similarity index 100%
rename from cake/tests/cases/libs/magic_db.test.php
rename to lib/Cake/tests/cases/libs/magic_db.test.php
diff --git a/cake/tests/cases/libs/model/behavior_collection.test.php b/lib/Cake/tests/cases/libs/model/behavior_collection.test.php
similarity index 99%
rename from cake/tests/cases/libs/model/behavior_collection.test.php
rename to lib/Cake/tests/cases/libs/model/behavior_collection.test.php
index 8d653ced9..6724c2784 100644
--- a/cake/tests/cases/libs/model/behavior_collection.test.php
+++ b/lib/Cake/tests/cases/libs/model/behavior_collection.test.php
@@ -18,7 +18,8 @@
* @since 1.2
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Model', 'AppModel');
+
+App::uses('AppModel', 'Model');
require_once dirname(__FILE__) . DS . 'models.php';
/**
@@ -452,7 +453,7 @@ class BehaviorCollectionTest extends CakeTestCase {
$this->assertEquals($Apple->testMethod(true), 'working');
$this->assertEquals($Apple->Behaviors->dispatchMethod($Apple, 'testMethod'), 'working');
- App::build(array('plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)));
+ App::build(array('plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)));
$this->assertTrue($Apple->Behaviors->load('SomeOther', array('className' => 'TestPlugin.TestPluginPersisterOne')));
$this->assertInstanceOf('TestPluginPersisterOneBehavior', $Apple->Behaviors->SomeOther);
@@ -552,7 +553,7 @@ class BehaviorCollectionTest extends CakeTestCase {
/**
* test that attaching a non existant Behavior triggers a cake error.
*
- * @expectedException MissingBehaviorFileException
+ * @expectedException MissingBehaviorClassException
* @return void
*/
function testInvalidBehaviorCausingCakeError() {
diff --git a/cake/tests/cases/libs/model/behaviors/acl.test.php b/lib/Cake/tests/cases/libs/model/behaviors/acl.test.php
similarity index 98%
rename from cake/tests/cases/libs/model/behaviors/acl.test.php
rename to lib/Cake/tests/cases/libs/model/behaviors/acl.test.php
index e3ec6daf9..8d1ea6ce3 100644
--- a/cake/tests/cases/libs/model/behaviors/acl.test.php
+++ b/lib/Cake/tests/cases/libs/model/behaviors/acl.test.php
@@ -18,8 +18,13 @@
* @since CakePHP v 1.2.0.4487
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Behavior', 'Acl');
-App::import('Core', 'db_acl');
+
+App::uses('AclBehavior', 'Model/Behavior');
+App::uses('Aco', 'Model');
+App::uses('Aro', 'Model');
+App::uses('AclNode', 'Model');
+App::uses('DbAcl', 'Model');
+
/**
* Test Person class - self joined model
diff --git a/cake/tests/cases/libs/model/behaviors/containable.test.php b/lib/Cake/tests/cases/libs/model/behaviors/containable.test.php
similarity index 99%
rename from cake/tests/cases/libs/model/behaviors/containable.test.php
rename to lib/Cake/tests/cases/libs/model/behaviors/containable.test.php
index 9b6e223f5..0b60115ef 100644
--- a/cake/tests/cases/libs/model/behaviors/containable.test.php
+++ b/lib/Cake/tests/cases/libs/model/behaviors/containable.test.php
@@ -16,7 +16,9 @@
* @since CakePHP(tm) v 1.2.0.5669
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', array('AppModel', 'Model'));
+
+App::uses('Model', 'Model');
+App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
/**
diff --git a/cake/tests/cases/libs/model/behaviors/translate.test.php b/lib/Cake/tests/cases/libs/model/behaviors/translate.test.php
similarity index 99%
rename from cake/tests/cases/libs/model/behaviors/translate.test.php
rename to lib/Cake/tests/cases/libs/model/behaviors/translate.test.php
index 24f39807d..292f0cdf0 100644
--- a/cake/tests/cases/libs/model/behaviors/translate.test.php
+++ b/lib/Cake/tests/cases/libs/model/behaviors/translate.test.php
@@ -20,7 +20,8 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
-App::import('Core', array('AppModel', 'Model'));
+App::uses('Model', 'Model');
+App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
/**
@@ -431,7 +432,7 @@ class TranslateBehaviorTest extends CakeTestCase {
$this->assertEqual($result, $expected);
// MSSQL trigger an error and stops the page even if the debug = 0
- if ($this->db->config['driver'] != 'mssql') {
+ if ($this->db instanceof Mssql) {
$debug = Configure::read('debug');
Configure::write('debug', 0);
diff --git a/cake/tests/cases/libs/model/behaviors/tree.test.php b/lib/Cake/tests/cases/libs/model/behaviors/tree.test.php
similarity index 99%
rename from cake/tests/cases/libs/model/behaviors/tree.test.php
rename to lib/Cake/tests/cases/libs/model/behaviors/tree.test.php
index 8e8323df6..7d1f648f9 100644
--- a/cake/tests/cases/libs/model/behaviors/tree.test.php
+++ b/lib/Cake/tests/cases/libs/model/behaviors/tree.test.php
@@ -18,7 +18,9 @@
* @since CakePHP(tm) v 1.2.0.5330
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', array('AppModel', 'Model'));
+
+App::uses('Model', 'Model');
+App::uses('AppModel', 'Model');
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
/**
diff --git a/cake/tests/cases/libs/model/cake_schema.test.php b/lib/Cake/tests/cases/libs/model/cake_schema.test.php
similarity index 98%
rename from cake/tests/cases/libs/model/cake_schema.test.php
rename to lib/Cake/tests/cases/libs/model/cake_schema.test.php
index 78890fbf7..12dab45b0 100644
--- a/cake/tests/cases/libs/model/cake_schema.test.php
+++ b/lib/Cake/tests/cases/libs/model/cake_schema.test.php
@@ -17,7 +17,9 @@
* @since CakePHP(tm) v 1.2.0.5550
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Model', 'CakeSchema', false);
+
+App::uses('CakeSchema', 'Model');
+App::uses('CakeTestFixture', 'TestSuite/Fixture');
/**
* Test for Schema database management
@@ -646,7 +648,7 @@ class CakeSchemaTest extends CakeTestCase {
* @return void
*/
function testSchemaReadWithConfigPrefix() {
- $db =& ConnectionManager::getDataSource('test');
+ $db = ConnectionManager::getDataSource('test');
$config = $db->config;
$config['prefix'] = 'schema_test_prefix_';
ConnectionManager::create('schema_prefix', $config);
@@ -662,7 +664,7 @@ class CakeSchemaTest extends CakeTestCase {
function testSchemaReadWithPlugins() {
App::objects('model', null, false);
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$Schema = new CakeSchema();
@@ -980,7 +982,7 @@ class CakeSchemaTest extends CakeTestCase {
*/
function testSchemaLoadingFromPlugin() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$Other = $this->Schema->load(array('name' => 'TestPluginApp', 'plugin' => 'TestPlugin'));
$this->assertEqual($Other->name, 'TestPluginApp');
diff --git a/cake/tests/cases/libs/model/connection_manager.test.php b/lib/Cake/tests/cases/libs/model/connection_manager.test.php
similarity index 76%
rename from cake/tests/cases/libs/model/connection_manager.test.php
rename to lib/Cake/tests/cases/libs/model/connection_manager.test.php
index 66e93a207..4fe0daec6 100644
--- a/cake/tests/cases/libs/model/connection_manager.test.php
+++ b/lib/Cake/tests/cases/libs/model/connection_manager.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5550
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'ConnectionManager');
+App::uses('ConnectionManager', 'Model');
/**
* ConnectionManagerTest
@@ -25,36 +25,6 @@ App::import('Core', 'ConnectionManager');
*/
class ConnectionManagerTest extends CakeTestCase {
-/**
- * setUp method
- *
- * @access public
- * @return void
- */
- function setUp() {
- $this->ConnectionManager = ConnectionManager::getInstance();
- }
-
-/**
- * tearDown method
- *
- * @access public
- * @return void
- */
- function tearDown() {
- unset($this->ConnectionManager);
- }
-
-/**
- * testInstantiation method
- *
- * @access public
- * @return void
- */
- function testInstantiation() {
- $this->assertTrue(is_a($this->ConnectionManager, 'ConnectionManager'));
- }
-
/**
* testEnumConnectionObjects method
*
@@ -101,7 +71,7 @@ class ConnectionManagerTest extends CakeTestCase {
*/
function testGetPluginDataSource() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$name = 'test_source';
@@ -123,11 +93,11 @@ class ConnectionManagerTest extends CakeTestCase {
*/
function testGetPluginDataSourceAndPluginDriver() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$name = 'test_plugin_source_and_driver';
- $config = array('datasource' => 'TestPlugin.TestSource', 'driver' => 'TestPlugin.TestDriver');
+ $config = array('datasource' => 'TestPlugin.Database/TestDriver');
$connection = ConnectionManager::create($name, $config);
@@ -147,11 +117,11 @@ class ConnectionManagerTest extends CakeTestCase {
*/
function testGetLocalDataSourceAndPluginDriver() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$name = 'test_local_source_and_plugin_driver';
- $config = array('datasource' => 'dbo', 'driver' => 'TestPlugin.DboDummy');
+ $config = array('datasource' => 'TestPlugin.Database/DboDummy');
$connection = ConnectionManager::create($name, $config);
@@ -170,12 +140,12 @@ class ConnectionManagerTest extends CakeTestCase {
*/
function testGetPluginDataSourceAndLocalDriver() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
- 'datasources' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS . 'datasources' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'Model/Datasource/Database' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS . 'datasources' . DS . 'Database' . DS)
));
$name = 'test_plugin_source_and_local_driver';
- $config = array('datasource' => 'TestPlugin.TestSource', 'driver' => 'local_driver');
+ $config = array('datasource' => 'Database/TestLocalDriver');
$connection = ConnectionManager::create($name, $config);
@@ -227,15 +197,15 @@ class ConnectionManagerTest extends CakeTestCase {
*/
function testLoadDataSource() {
$connections = array(
- array('classname' => 'DboMysql', 'filename' => 'dbo' . DS . 'dbo_mysql'),
- array('classname' => 'DboMssql', 'filename' => 'dbo' . DS . 'dbo_mssql'),
- array('classname' => 'DboOracle', 'filename' => 'dbo' . DS . 'dbo_oracle'),
+ array('classname' => 'Mysql', 'filename' => 'Mysql', 'package' => 'Database'),
+ array('classname' => 'Postgres', 'filename' => 'Postgres', 'package' => 'Database'),
+ array('classname' => 'Sqlite', 'filename' => 'Sqlite', 'package' => 'Database'),
);
foreach ($connections as $connection) {
$exists = class_exists($connection['classname']);
$loaded = ConnectionManager::loadDataSource($connection);
- $this->assertEqual($loaded, !$exists, "%s Failed loading the {$connection['classname']} datasource");
+ $this->assertEqual($loaded, !$exists, "Failed loading the {$connection['classname']} datasource");
}
}
@@ -291,18 +261,15 @@ class ConnectionManagerTest extends CakeTestCase {
*/
function testConnectionData() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
- 'datasources' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS . 'datasources' . DS)
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'Model/Datasource' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS . 'datasources' . DS)
));
$expected = array(
- 'filename' => 'test2_source',
- 'classname' => 'Test2Source',
- 'parent' => '',
- 'plugin' => ''
+ 'datasource' => 'Test2Source'
);
- ConnectionManager::create('connection1', array('datasource' => 'Test2'));
+ ConnectionManager::create('connection1', array('datasource' => 'Test2Source'));
$connections = ConnectionManager::enumConnectionObjects();
$this->assertEqual($expected, $connections['connection1']);
@@ -310,33 +277,29 @@ class ConnectionManagerTest extends CakeTestCase {
$connections = ConnectionManager::enumConnectionObjects();
$this->assertEqual($expected, $connections['connection2']);
- ConnectionManager::create('connection3', array('datasource' => 'TestPlugin.Test'));
+ ConnectionManager::create('connection3', array('datasource' => 'TestPlugin.TestSource'));
$connections = ConnectionManager::enumConnectionObjects();
- $expected['filename'] = 'test_source';
- $expected['classname'] = 'TestSource';
- $expected['plugin'] = 'TestPlugin';
+ $expected['datasource'] = 'TestPlugin.TestSource';
$this->assertEqual($expected, $connections['connection3']);
ConnectionManager::create('connection4', array('datasource' => 'TestPlugin.TestSource'));
$connections = ConnectionManager::enumConnectionObjects();
$this->assertEqual($expected, $connections['connection4']);
- ConnectionManager::create('connection5', array('datasource' => 'Test2Other'));
+ ConnectionManager::create('connection5', array('datasource' => 'Test2OtherSource'));
$connections = ConnectionManager::enumConnectionObjects();
- $expected['filename'] = 'test2_other_source';
- $expected['classname'] = 'Test2OtherSource';
- $expected['plugin'] = '';
+ $expected['datasource'] = 'Test2OtherSource';
+
$this->assertEqual($expected, $connections['connection5']);
ConnectionManager::create('connection6', array('datasource' => 'Test2OtherSource'));
$connections = ConnectionManager::enumConnectionObjects();
$this->assertEqual($expected, $connections['connection6']);
- ConnectionManager::create('connection7', array('datasource' => 'TestPlugin.TestOther'));
+ ConnectionManager::create('connection7', array('datasource' => 'TestPlugin.TestOtherSource'));
$connections = ConnectionManager::enumConnectionObjects();
- $expected['filename'] = 'test_other_source';
- $expected['classname'] = 'TestOtherSource';
- $expected['plugin'] = 'TestPlugin';
+ $expected['datasource'] = 'TestPlugin.TestOtherSource';
+
$this->assertEqual($expected, $connections['connection7']);
ConnectionManager::create('connection8', array('datasource' => 'TestPlugin.TestOtherSource'));
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
similarity index 100%
rename from cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
rename to lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
similarity index 99%
rename from cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
rename to lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
index e01d30039..b76f970ca 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
+++ b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php
@@ -16,8 +16,11 @@
* @since CakePHP(tm) v 1.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboMysql'));
-App::import('Model', 'App');
+App::uses('Model', 'Model');
+App::uses('AppModel', 'Model');
+App::uses('Mysql', 'Model/Datasource/Database');
+App::uses('CakeSchema', 'Model');
+
require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php';
/**
@@ -60,8 +63,7 @@ class DboMysqlTest extends CakeTestCase {
*/
public function setUp() {
$this->Dbo = ConnectionManager::getDataSource('test');
- $this->skipIf(!($this->Dbo instanceof DboMysql));
- if ($this->Dbo->config['driver'] !== 'mysql') {
+ if (!($this->Dbo instanceof Mysql)) {
$this->markTestSkipped('The MySQL extension is not available.');
}
$this->_debug = Configure::read('debug');
@@ -306,7 +308,7 @@ class DboMysqlTest extends CakeTestCase {
function testIndexOnMySQL4Output() {
$name = $this->Dbo->fullTableName('simple');
- $mockDbo = $this->getMock('DboMysql', array('connect', '_execute', 'getVersion'));
+ $mockDbo = $this->getMock('Mysql', array('connect', '_execute', 'getVersion'));
$columnData = array(
array('0' => array(
'Table' => 'with_compound_keys',
@@ -455,7 +457,6 @@ class DboMysqlTest extends CakeTestCase {
* @return void
*/
function testAlterSchemaIndexes() {
- App::import('Model', 'CakeSchema');
$this->Dbo->cacheSources = $this->Dbo->testing = false;
$table = $this->Dbo->fullTableName('altertest');
@@ -576,7 +577,6 @@ class DboMysqlTest extends CakeTestCase {
* @return void
*/
function testAlteringTableParameters() {
- App::import('Model', 'CakeSchema');
$this->Dbo->cacheSources = $this->Dbo->testing = false;
$schema1 = new CakeSchema(array(
@@ -778,7 +778,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void
*/
public function testListSources() {
- $db = $this->getMock('DboMysql', array('connect', '_execute'));
+ $db = $this->getMock('Mysql', array('connect', '_execute'));
$queryResult = $this->getMock('PDOStatement');
$db->expects($this->once())
->method('_execute')
@@ -828,7 +828,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void
*/
public function testGetEncoding() {
- $db = $this->getMock('DboMysql', array('connect', '_execute'));
+ $db = $this->getMock('Mysql', array('connect', '_execute'));
$queryResult = $this->getMock('PDOStatement');
$db->expects($this->once())
@@ -852,7 +852,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void
*/
function testFieldDoubleEscaping() {
- $test = $this->getMock('DboMysql', array('connect', '_execute', 'execute'));
+ $test = $this->getMock('Mysql', array('connect', '_execute', 'execute'));
$this->Model = $this->getMock('Article2', array('getDataSource'));
$this->Model->alias = 'Article';
$this->Model->expects($this->any())
@@ -894,7 +894,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void
*/
function testGenerateAssociationQuerySelfJoin() {
- $this->Dbo = $this->getMock('DboMysql', array('connect', '_execute', 'execute'));
+ $this->Dbo = $this->getMock('Mysql', array('connect', '_execute', 'execute'));
$this->startTime = microtime(true);
$this->Model = new Article2();
$this->_buildRelatedModels($this->Model);
@@ -1030,7 +1030,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void
*/
function testGenerateInnerJoinAssociationQuery() {
- $test = $this->getMock('DboMysql', array('connect', '_execute', 'execute'));
+ $test = $this->getMock('Mysql', array('connect', '_execute', 'execute'));
$this->Model = $this->getMock('TestModel9', array('getDataSource'));
$this->Model->expects($this->any())
->method('getDataSource')
@@ -2848,7 +2848,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void
*/
function testHasAny() {
- $this->Dbo = $this->getMock('DboMysql', array('connect', '_execute', 'execute', 'value'));
+ $this->Dbo = $this->getMock('Mysql', array('connect', '_execute', 'execute', 'value'));
$this->Model = $this->getMock('TestModel', array('getDataSource'));
$this->Model->expects($this->any())
->method('getDataSource')
@@ -3398,7 +3398,7 @@ class DboMysqlTest extends CakeTestCase {
* @return void
*/
function testExceptionOnBrokenConnection() {
- $dbo = new DboMysql(array(
+ $dbo = new Mysql(array(
'driver' => 'mysql',
'host' => 'imaginary_host',
'login' => 'mark',
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php
similarity index 100%
rename from cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php
rename to lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
similarity index 97%
rename from cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
rename to lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
index 7d18d0970..c4b5da022 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
+++ b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php
@@ -16,8 +16,11 @@
* @since CakePHP(tm) v 1.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboPostgres'));
-App::import('Model', 'App');
+
+App::uses('Model', 'Model');
+App::uses('AppModel', 'Model');
+App::uses('Postgres', 'Model/Datasource/Database');
+
require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php';
/**
@@ -25,7 +28,7 @@ require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php';
*
* @package cake.tests.cases.libs.model.datasources
*/
-class DboPostgresTestDb extends DboPostgres {
+class DboPostgresTestDb extends Postgres {
/**
* simulated property
@@ -240,9 +243,8 @@ class DboPostgresTest extends CakeTestCase {
public function setUp() {
Configure::write('Cache.disable', true);
$this->Dbo = ConnectionManager::getDataSource('test');
- $this->skipIf(!($this->Dbo instanceof DboPostgres));
+ $this->skipIf(!($this->Dbo instanceof Postgres));
$this->Dbo2 = new DboPostgresTestDb($this->Dbo->config, false);
- $this->skipUnless($this->Dbo->config['driver'] == 'postgres', 'PostgreSQL connection not available');
$this->model = new PostgresTestModel();
}
@@ -617,7 +619,6 @@ class DboPostgresTest extends CakeTestCase {
'PRIMARY' => array('unique' => true, 'column' => 'id'),
'pointless_bool' => array('unique' => false, 'column' => 'bool'),
'char_index' => array('unique' => true, 'column' => 'small_char'),
-
);
$result = $this->Dbo->index($name);
$this->Dbo->query('DROP TABLE ' . $name);
@@ -710,10 +711,10 @@ class DboPostgresTest extends CakeTestCase {
'name' => 'AlterTest2',
'connection' => 'test',
'altertest' => array(
- 'id' => array('type' => 'integer', 'null' => 0, 'default' => 0),
- 'name' => array('type' => 'string', 'null' => 0, 'length' => 50),
- 'group1' => array('type' => 'integer', 'null' => 1),
- 'group2' => array('type' => 'integer', 'null' => 1),
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
+ 'name' => array('type' => 'string', 'null' => false, 'length' => 50),
+ 'group1' => array('type' => 'integer', 'null' => true),
+ 'group2' => array('type' => 'integer', 'null' => true),
'indexes' => array(
'name_idx' => array('unique' => false, 'column' => 'name'),
'group_idx' => array('unique' => false, 'column' => 'group1'),
@@ -732,10 +733,10 @@ class DboPostgresTest extends CakeTestCase {
'name' => 'AlterTest3',
'connection' => 'test',
'altertest' => array(
- 'id' => array('type' => 'integer', 'null' => 0, 'default' => 0),
- 'name' => array('type' => 'string', 'null' => 0, 'length' => 50),
- 'group1' => array('type' => 'integer', 'null' => 1),
- 'group2' => array('type' => 'integer', 'null' => 1),
+ 'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
+ 'name' => array('type' => 'string', 'null' => false, 'length' => 50),
+ 'group1' => array('type' => 'integer', 'null' => true),
+ 'group2' => array('type' => 'integer', 'null' => true),
'indexes' => array(
'name_idx' => array('unique' => true, 'column' => 'name'),
'group_idx' => array('unique' => false, 'column' => 'group2'),
diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
similarity index 96%
rename from cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
rename to lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
index a1fc1cd4a..9bd875d2c 100644
--- a/cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
+++ b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php
@@ -16,14 +16,16 @@
* @since CakePHP(tm) v 1.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboSqlite'));
+App::uses('Model', 'Model');
+App::uses('AppModel', 'Model');
+App::uses('Sqlite', 'Model/Datasource/Database');
/**
* DboSqliteTestDb class
*
* @package cake.tests.cases.libs.model.datasources
*/
-class DboSqliteTestDb extends DboSqlite {
+class DboSqliteTestDb extends Sqlite {
/**
* simulated property
@@ -94,7 +96,7 @@ class DboSqliteTest extends CakeTestCase {
public function setUp() {
Configure::write('Cache.disable', true);
$this->Dbo = ConnectionManager::getDataSource('test');
- if ($this->Dbo->config['driver'] !== 'sqlite') {
+ if (!$this->Dbo instanceof Sqlite) {
$this->markTestSkipped('The Sqlite extension is not available.');
}
}
@@ -165,7 +167,7 @@ class DboSqliteTest extends CakeTestCase {
$this->assertFalse(file_exists(TMP . $dbName));
$config = $this->Dbo->config;
- $db = new DboSqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName)));
+ $db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName)));
$this->assertTrue(file_exists(TMP . $dbName));
$db->execute("CREATE TABLE test_list (id VARCHAR(255));");
diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/lib/Cake/tests/cases/libs/model/datasources/dbo_source.test.php
similarity index 99%
rename from cake/tests/cases/libs/model/datasources/dbo_source.test.php
rename to lib/Cake/tests/cases/libs/model/datasources/dbo_source.test.php
index 027f1c43b..e6b8d5482 100644
--- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php
+++ b/lib/Cake/tests/cases/libs/model/datasources/dbo_source.test.php
@@ -17,9 +17,16 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Model', array('Model', 'DataSource', 'DboSource', 'DboMysql', 'App'));
+App::uses('Model', 'Model');
+App::uses('AppModel', 'Model');
+App::uses('DataSource', 'Model/Datasource');
+App::uses('DboSource', 'Model/Datasource');
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
+class MockDataSource extends DataSource {
+
+}
+
/**
* DboSourceTest class
*
@@ -783,7 +790,7 @@ class DboSourceTest extends CakeTestCase {
function testReadOnlyCallingQueryAssociationWhenDefined() {
$this->loadFixtures('Article', 'User', 'ArticlesTag', 'Tag');
ConnectionManager::create('test_no_queryAssociation', array(
- 'datasource' => 'data'
+ 'datasource' => 'MockDataSource'
));
$Article = ClassRegistry::init('Article');
$Article->Comment->useDbConfig = 'test_no_queryAssociation';
diff --git a/cake/tests/cases/libs/model/db_acl.test.php b/lib/Cake/tests/cases/libs/model/db_acl.test.php
similarity index 98%
rename from cake/tests/cases/libs/model/db_acl.test.php
rename to lib/Cake/tests/cases/libs/model/db_acl.test.php
index 07cff6748..fc0b3d2a5 100644
--- a/cake/tests/cases/libs/model/db_acl.test.php
+++ b/lib/Cake/tests/cases/libs/model/db_acl.test.php
@@ -16,8 +16,10 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Component', 'Acl');
-App::import('Core', 'db_acl');
+
+App::uses('AclComponent', 'Controller/Component');
+App::uses('AclNode', 'Model');
+class_exists('AclComponent');
/**
* DB ACL wrapper test class
diff --git a/cake/tests/cases/libs/model/model.test.php b/lib/Cake/tests/cases/libs/model/model.test.php
similarity index 98%
rename from cake/tests/cases/libs/model/model.test.php
rename to lib/Cake/tests/cases/libs/model/model.test.php
index 3fa31afd6..9a069d74f 100644
--- a/cake/tests/cases/libs/model/model.test.php
+++ b/lib/Cake/tests/cases/libs/model/model.test.php
@@ -16,7 +16,9 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', array('AppModel', 'Model'));
+
+App::uses('Model', 'Model');
+App::uses('AppModel', 'Model');
require_once dirname(__FILE__) . DS . 'models.php';
PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT');
diff --git a/cake/tests/cases/libs/model/model_delete.test.php b/lib/Cake/tests/cases/libs/model/model_delete.test.php
similarity index 100%
rename from cake/tests/cases/libs/model/model_delete.test.php
rename to lib/Cake/tests/cases/libs/model/model_delete.test.php
diff --git a/cake/tests/cases/libs/model/model_integration.test.php b/lib/Cake/tests/cases/libs/model/model_integration.test.php
similarity index 99%
rename from cake/tests/cases/libs/model/model_integration.test.php
rename to lib/Cake/tests/cases/libs/model/model_integration.test.php
index 776ce8467..b897046e0 100644
--- a/cake/tests/cases/libs/model/model_integration.test.php
+++ b/lib/Cake/tests/cases/libs/model/model_integration.test.php
@@ -18,8 +18,9 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
+
require_once dirname(__FILE__) . DS . 'model.test.php';
-App::import('Core', 'DboSource');
+App::uses('DboSource', 'Model/Datasource');
/**
* DboMock class
@@ -2000,7 +2001,7 @@ class ModelIntegrationTest extends BaseModelTest {
$expected = $db->name('Domain.DomainHandle');
$this->assertEqual($result, $expected);
- ConnectionManager::create('mock', array('driver' => 'mock'));
+ ConnectionManager::create('mock', array('datasource' => 'DboMock'));
$TestModel->setDataSource('mock');
$db = $TestModel->getDataSource();
diff --git a/cake/tests/cases/libs/model/model_read.test.php b/lib/Cake/tests/cases/libs/model/model_read.test.php
similarity index 99%
rename from cake/tests/cases/libs/model/model_read.test.php
rename to lib/Cake/tests/cases/libs/model/model_read.test.php
index b74ee5632..d71b71666 100755
--- a/cake/tests/cases/libs/model/model_read.test.php
+++ b/lib/Cake/tests/cases/libs/model/model_read.test.php
@@ -79,8 +79,8 @@ class ModelReadTest extends BaseModelTest {
*/
function testGroupBy() {
$db = ConnectionManager::getDataSource('test');
- $isStrictGroupBy = in_array($db->config['driver'], array('postgres', 'oracle', 'sqlite'));
- $message = '%s Postgres and Oracle have strict GROUP BY and are incompatible with this test.';
+ $isStrictGroupBy = $this->db instanceof Postgres || $this->db instanceof Sqlite || $this->db instanceof Oracle;
+ $message = 'Postgres and Oracle have strict GROUP BY and are incompatible with this test.';
if ($this->skipIf($isStrictGroupBy, $message )) {
return;
@@ -367,10 +367,10 @@ class ModelReadTest extends BaseModelTest {
* @return void
*/
function testVeryStrangeUseCase() {
- $message = "%s skipping SELECT * FROM ? WHERE ? = ? AND ? = ?; prepared query.";
+ $message = "skipping SELECT * FROM ? WHERE ? = ? AND ? = ?; prepared query.";
$message .= " MSSQL is incompatible with this test.";
- if ($this->skipIf($this->db->config['driver'] == 'mssql', $message)) {
+ if ($this->skipIf($this->db instanceof Mssql, $message)) {
return;
}
@@ -4019,7 +4019,7 @@ class ModelReadTest extends BaseModelTest {
$result = $TestModel->find('all', compact('conditions', 'recursive', 'order'));
$this->assertEqual($result, $expected);
- if ($this->skipIf($this->db->config['driver'] == 'postgres', 'The rest of testFindAllWithConditionsHavingMixedDataTypes test is not compatible with Postgres')) {
+ if ($this->skipIf($this->db instanceof Postgres, 'The rest of testFindAllWithConditionsHavingMixedDataTypes test is not compatible with Postgres')) {
return;
}
$conditions = array('id' => array('1', 2, '3.0'));
@@ -6227,7 +6227,7 @@ class ModelReadTest extends BaseModelTest {
// These tests are expected to fail on SQL Server since the LIMIT/OFFSET
// hack can't handle small record counts.
- if ($this->db->config['driver'] != 'mssql') {
+ if ($this->db instanceof Mssql) {
$result = $TestModel->find('all', array('limit' => 3, 'page' => 2));
$expected = array(
array(
@@ -6253,7 +6253,7 @@ class ModelReadTest extends BaseModelTest {
* @return void
*/
function testGenerateFindList() {
- $this->loadFixtures('Article', 'Apple', 'Post', 'Author', 'User');
+ $this->loadFixtures('Article', 'Apple', 'Post', 'Author', 'User', 'Comment');
$TestModel = new Article();
$TestModel->displayField = 'title';
@@ -6270,7 +6270,7 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected);
$db = ConnectionManager::getDataSource('test');
- if ($db->config['driver'] == 'mysql') {
+ if ($db instanceof Mysql) {
$result = $TestModel->find('list', array(
'order' => array('FIELD(Article.id, 3, 2) ASC', 'Article.title ASC')
));
@@ -6622,7 +6622,7 @@ class ModelReadTest extends BaseModelTest {
*/
function testFindCountDistinct() {
$skip = $this->skipIf(
- $this->db->config['driver'] == 'sqlite',
+ $this->db instanceof Sqlite,
'SELECT COUNT(DISTINCT field) is not compatible with SQLite'
);
if ($skip) {
@@ -6645,7 +6645,7 @@ class ModelReadTest extends BaseModelTest {
* @return void
*/
function testFindCountWithDbExpressions() {
- if ($this->skipIf($this->db->config['driver'] == 'postgres', '%s testFindCountWithExpressions is not compatible with Postgres')) {
+ if ($this->skipIf($this->db instanceof Postgres, 'testFindCountWithExpressions is not compatible with Postgres')) {
return;
}
$this->loadFixtures('Project');
@@ -7470,7 +7470,7 @@ class ModelReadTest extends BaseModelTest {
*
*/
public function testVirtualFieldsMysql() {
- if ($this->skipIf($this->db->config['driver'] != 'mysql', 'The rest of virtualFieds test is not compatible with Postgres')) {
+ if ($this->skipIf(!($this->db instanceof Mysql), 'The rest of virtualFieds test is not compatible with Postgres')) {
return;
}
$this->loadFixtures('Post', 'Author');
diff --git a/cake/tests/cases/libs/model/model_validation.test.php b/lib/Cake/tests/cases/libs/model/model_validation.test.php
similarity index 100%
rename from cake/tests/cases/libs/model/model_validation.test.php
rename to lib/Cake/tests/cases/libs/model/model_validation.test.php
diff --git a/cake/tests/cases/libs/model/model_write.test.php b/lib/Cake/tests/cases/libs/model/model_write.test.php
similarity index 99%
rename from cake/tests/cases/libs/model/model_write.test.php
rename to lib/Cake/tests/cases/libs/model/model_write.test.php
index 5e301cbc8..cbb4f22fd 100644
--- a/cake/tests/cases/libs/model/model_write.test.php
+++ b/lib/Cake/tests/cases/libs/model/model_write.test.php
@@ -146,7 +146,7 @@ class ModelWriteTest extends BaseModelTest {
*/
function testAutoSaveUuid() {
// SQLite does not support non-integer primary keys
- $this->skipIf($this->db->config['driver'] == 'sqlite');
+ $this->skipIf($this->db instanceof Sqlite);
$this->loadFixtures('Uuid');
$TestModel = new Uuid();
@@ -168,7 +168,7 @@ class ModelWriteTest extends BaseModelTest {
*/
public function testSaveUuidNull() {
// SQLite does not support non-integer primary keys
- $this->skipIf($this->db->config['driver'] == 'sqlite');
+ $this->skipIf($this->db instanceof Sqlite);
$this->loadFixtures('Uuid');
$TestModel = new Uuid();
@@ -190,7 +190,7 @@ class ModelWriteTest extends BaseModelTest {
*/
function testZeroDefaultFieldValue() {
$this->skipIf(
- $this->db->config['driver'] == 'sqlite',
+ $this->db instanceof Sqlite,
'%s SQLite uses loose typing, this operation is unsupported'
);
$this->loadFixtures('DataTest');
@@ -407,7 +407,7 @@ class ModelWriteTest extends BaseModelTest {
*/
public function testCounterCacheWithSelfJoin() {
$skip = $this->skipIf(
- ($this->db->config['driver'] == 'sqlite'),
+ ($this->db instanceof Sqlite),
'SQLite 2.x does not support ALTER TABLE ADD COLUMN'
);
if ($skip) {
@@ -1014,7 +1014,7 @@ class ModelWriteTest extends BaseModelTest {
function testSaveFromXml() {
$this->markTestSkipped('This feature needs to be fixed or dropped');
$this->loadFixtures('Article');
- App::import('Core', 'Xml');
+ App::uses('Xml', 'Utility');
$Article = new Article();
$result = $Article->save(Xml::build(''));
@@ -2985,7 +2985,7 @@ class ModelWriteTest extends BaseModelTest {
$this->getMock('DboSource', array(), array(), 'MockTransactionDboSource');
$db = ConnectionManager::create('mock_transaction', array(
- 'datasource' => 'MockTransactionDbo',
+ 'datasource' => 'MockTransactionDboSource',
));
$db->expects($this->once())
@@ -3016,7 +3016,7 @@ class ModelWriteTest extends BaseModelTest {
$mock = $this->getMock('DboSource', array(), array(), 'MockTransactionAssociatedDboSource', false);
$db =& ConnectionManager::create('mock_transaction_assoc', array(
- 'datasource' => 'MockTransactionAssociatedDbo',
+ 'datasource' => 'MockTransactionAssociatedDboSource',
));
$this->mockObjects[] = $db;
$db->columns = $testDb->columns;
@@ -3832,7 +3832,7 @@ class ModelWriteTest extends BaseModelTest {
*/
function testProductUpdateAll() {
$this->skipIf(
- $this->db->config['driver'] != 'mysql',
+ !$this->db instanceof Mysql,
'%s Currently, there is no way of doing joins in an update statement in postgresql or sqlite'
);
$this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll');
@@ -3883,7 +3883,7 @@ class ModelWriteTest extends BaseModelTest {
*/
function testProductUpdateAllWithoutForeignKey() {
$this->skipIf(
- $this->db->config['driver'] != 'mysql',
+ !$this->db instanceof Mysql,
'%s Currently, there is no way of doing joins in an update statement in postgresql'
);
$this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll');
diff --git a/cake/tests/cases/libs/model/models.php b/lib/Cake/tests/cases/libs/model/models.php
similarity index 100%
rename from cake/tests/cases/libs/model/models.php
rename to lib/Cake/tests/cases/libs/model/models.php
diff --git a/cake/tests/cases/libs/multibyte.test.php b/lib/Cake/tests/cases/libs/multibyte.test.php
similarity index 99%
rename from cake/tests/cases/libs/multibyte.test.php
rename to lib/Cake/tests/cases/libs/multibyte.test.php
index f9998cdf9..692dd85bd 100644
--- a/cake/tests/cases/libs/multibyte.test.php
+++ b/lib/Cake/tests/cases/libs/multibyte.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.6833
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Multibyte');
+App::uses('Multibyte', 'I18n');
/**
* MultibyteTest class
diff --git a/cake/tests/cases/libs/object.test.php b/lib/Cake/tests/cases/libs/object.test.php
similarity index 94%
rename from cake/tests/cases/libs/object.test.php
rename to lib/Cake/tests/cases/libs/object.test.php
index 45126a053..0c959065e 100644
--- a/cake/tests/cases/libs/object.test.php
+++ b/lib/Cake/tests/cases/libs/object.test.php
@@ -16,7 +16,10 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', array('Object', 'Controller', 'Model'));
+
+App::uses('Object', 'Core');
+App::uses('Controller', 'Controller');
+App::uses('Model', 'Model');
/**
* RequestActionPost class
@@ -475,9 +478,9 @@ class ObjectTest extends CakeTestCase {
Configure::write('Cache.disable', false);
App::build(array(
- 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins'. DS),
- 'behaviors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS),
+ 'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins'. DS),
+ 'behaviors' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS),
), true);
$this->assertFalse(class_exists('PersisterOneBehaviorBehavior'));
@@ -536,8 +539,8 @@ class ObjectTest extends CakeTestCase {
$this->assertFalse(class_exists('ContainableBehavior'));
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),
+ 'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'behaviors' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS),
), true);
$this->assertFalse(class_exists('PersistOneBehaviorBehavior'));
@@ -680,9 +683,9 @@ class ObjectTest extends CakeTestCase {
*/
function testRequestAction() {
App::build(array(
- '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)
+ 'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS),
+ 'controllers' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)
));
$result = $this->object->requestAction('');
$this->assertFalse($result);
@@ -720,7 +723,7 @@ class ObjectTest extends CakeTestCase {
*/
function testRequestActionPlugins() {
App::build(array(
- 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
+ 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
));
App::objects('plugin', null, false);
Router::reload();
@@ -760,9 +763,9 @@ class ObjectTest extends CakeTestCase {
*/
function testRequestActionArray() {
App::build(array(
- '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)
+ 'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
+ 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS),
+ 'controllers' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)
));
$result = $this->object->requestAction(
diff --git a/cake/tests/cases/libs/object_collection.test.php b/lib/Cake/tests/cases/libs/object_collection.test.php
similarity index 99%
rename from cake/tests/cases/libs/object_collection.test.php
rename to lib/Cake/tests/cases/libs/object_collection.test.php
index e3a0f82ca..cdbab3bc0 100644
--- a/cake/tests/cases/libs/object_collection.test.php
+++ b/lib/Cake/tests/cases/libs/object_collection.test.php
@@ -17,7 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'ObjectCollection');
+App::uses('ObjectCollection', 'Utility');
/**
* A generic object class
diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/lib/Cake/tests/cases/libs/route/cake_route.test.php
similarity index 99%
rename from cake/tests/cases/libs/route/cake_route.test.php
rename to lib/Cake/tests/cases/libs/route/cake_route.test.php
index d70eed4e6..0eec8b3dd 100644
--- a/cake/tests/cases/libs/route/cake_route.test.php
+++ b/lib/Cake/tests/cases/libs/route/cake_route.test.php
@@ -1,7 +1,7 @@
array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
+ LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
)
), true);
App::objects('plugin', null, false);
@@ -2200,7 +2201,7 @@ class RouterTest extends CakeTestCase {
function testConnectDefaultRoutes() {
App::build(array(
'plugins' => array(
- TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
+ LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
)
), true);
App::objects('plugin', null, false);
diff --git a/cake/tests/cases/libs/sanitize.test.php b/lib/Cake/tests/cases/libs/sanitize.test.php
similarity index 99%
rename from cake/tests/cases/libs/sanitize.test.php
rename to lib/Cake/tests/cases/libs/sanitize.test.php
index c3f420782..3bff7768d 100644
--- a/cake/tests/cases/libs/sanitize.test.php
+++ b/lib/Cake/tests/cases/libs/sanitize.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5428
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Sanitize');
+App::uses('Sanitize', 'Utility');
/**
* DataTest class
diff --git a/cake/tests/cases/libs/security.test.php b/lib/Cake/tests/cases/libs/security.test.php
similarity index 99%
rename from cake/tests/cases/libs/security.test.php
rename to lib/Cake/tests/cases/libs/security.test.php
index a1c7a18af..944cc7f37 100644
--- a/cake/tests/cases/libs/security.test.php
+++ b/lib/Cake/tests/cases/libs/security.test.php
@@ -16,7 +16,7 @@
* @since CakePHP(tm) v 1.2.0.5432
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Security');
+App::uses('Security', 'Utility');
/**
* SecurityTest class
diff --git a/cake/tests/cases/libs/session/cache_session.test.php b/lib/Cake/tests/cases/libs/session/cache_session.test.php
similarity index 94%
rename from cake/tests/cases/libs/session/cache_session.test.php
rename to lib/Cake/tests/cases/libs/session/cache_session.test.php
index 9f0572cd0..0cb111929 100644
--- a/cake/tests/cases/libs/session/cache_session.test.php
+++ b/lib/Cake/tests/cases/libs/session/cache_session.test.php
@@ -17,8 +17,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'CakeSession');
-App::import('Core', 'session/CacheSession');
+App::uses('CakeSession', 'Model/Datasource');
+App::uses('CacheSession', 'Model/Datasource/Session');
+class_exists('CakeSession');
class CacheSessionTest extends CakeTestCase {
diff --git a/cake/tests/cases/libs/session/database_session.test.php b/lib/Cake/tests/cases/libs/session/database_session.test.php
similarity index 95%
rename from cake/tests/cases/libs/session/database_session.test.php
rename to lib/Cake/tests/cases/libs/session/database_session.test.php
index 657ce8159..4bf31d0bd 100644
--- a/cake/tests/cases/libs/session/database_session.test.php
+++ b/lib/Cake/tests/cases/libs/session/database_session.test.php
@@ -17,9 +17,10 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Model');
-App::import('Core', 'CakeSession');
-App::import('Core', 'session/DatabaseSession');
+App::uses('Model', 'Model');
+App::uses('CakeSession', 'Model/Datasource');
+App::uses('DatabaseSession', 'Model/Datasource/Session');
+class_exists('CakeSession');
class SessionTestModel extends Model {
var $name = 'SessionTestModel';
diff --git a/cake/tests/cases/libs/set.test.php b/lib/Cake/tests/cases/libs/set.test.php
similarity index 99%
rename from cake/tests/cases/libs/set.test.php
rename to lib/Cake/tests/cases/libs/set.test.php
index b974bfe3d..59b83bf0a 100644
--- a/cake/tests/cases/libs/set.test.php
+++ b/lib/Cake/tests/cases/libs/set.test.php
@@ -16,7 +16,8 @@
* @since CakePHP(tm) v 1.2.0.4206
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::import('Core', 'Set');
+App::uses('Set', 'Utility');
+App::uses('Model', 'Model');
/**
* SetTest class
@@ -2737,7 +2738,7 @@ class SetTest extends CakeTestCase {
* @return void
*/
function testXmlSetReverse() {
- App::import('Core', 'Xml');
+ App::uses('Xml', 'Utility');
$string = '
diff --git a/cake/tests/test_app/views/scaffolds/empty b/lib/Cake/tests/test_app/views/scaffolds/empty
similarity index 100%
rename from cake/tests/test_app/views/scaffolds/empty
rename to lib/Cake/tests/test_app/views/scaffolds/empty
diff --git a/cake/tests/test_app/views/tests_apps/index.ctp b/lib/Cake/tests/test_app/views/tests_apps/index.ctp
similarity index 100%
rename from cake/tests/test_app/views/tests_apps/index.ctp
rename to lib/Cake/tests/test_app/views/tests_apps/index.ctp
diff --git a/cake/tests/test_app/views/tests_apps/json/index.ctp b/lib/Cake/tests/test_app/views/tests_apps/json/index.ctp
similarity index 100%
rename from cake/tests/test_app/views/tests_apps/json/index.ctp
rename to lib/Cake/tests/test_app/views/tests_apps/json/index.ctp
diff --git a/cake/tests/test_app/views/themed/test_theme/elements/test_element.ctp b/lib/Cake/tests/test_app/views/themed/test_theme/elements/test_element.ctp
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/elements/test_element.ctp
rename to lib/Cake/tests/test_app/views/themed/test_theme/elements/test_element.ctp
diff --git a/cake/tests/test_app/views/themed/test_theme/layouts/default.ctp b/lib/Cake/tests/test_app/views/themed/test_theme/layouts/default.ctp
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/layouts/default.ctp
rename to lib/Cake/tests/test_app/views/themed/test_theme/layouts/default.ctp
diff --git a/cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/layouts/plugin_default.ctp b/lib/Cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/layouts/plugin_default.ctp
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/layouts/plugin_default.ctp
rename to lib/Cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/layouts/plugin_default.ctp
diff --git a/cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/tests/index.ctp b/lib/Cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/tests/index.ctp
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/tests/index.ctp
rename to lib/Cake/tests/test_app/views/themed/test_theme/plugins/test_plugin/tests/index.ctp
diff --git a/cake/tests/test_app/views/themed/test_theme/posts/index.ctp b/lib/Cake/tests/test_app/views/themed/test_theme/posts/index.ctp
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/posts/index.ctp
rename to lib/Cake/tests/test_app/views/themed/test_theme/posts/index.ctp
diff --git a/cake/tests/test_app/views/themed/test_theme/posts/scaffold.index.ctp b/lib/Cake/tests/test_app/views/themed/test_theme/posts/scaffold.index.ctp
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/posts/scaffold.index.ctp
rename to lib/Cake/tests/test_app/views/themed/test_theme/posts/scaffold.index.ctp
diff --git a/cake/tests/test_app/views/themed/test_theme/webroot/css/test_asset.css b/lib/Cake/tests/test_app/views/themed/test_theme/webroot/css/test_asset.css
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/webroot/css/test_asset.css
rename to lib/Cake/tests/test_app/views/themed/test_theme/webroot/css/test_asset.css
diff --git a/cake/tests/test_app/views/themed/test_theme/webroot/css/theme_webroot.css b/lib/Cake/tests/test_app/views/themed/test_theme/webroot/css/theme_webroot.css
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/webroot/css/theme_webroot.css
rename to lib/Cake/tests/test_app/views/themed/test_theme/webroot/css/theme_webroot.css
diff --git a/cake/tests/test_app/views/themed/test_theme/webroot/flash/theme_test.swf b/lib/Cake/tests/test_app/views/themed/test_theme/webroot/flash/theme_test.swf
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/webroot/flash/theme_test.swf
rename to lib/Cake/tests/test_app/views/themed/test_theme/webroot/flash/theme_test.swf
diff --git a/cake/tests/test_app/views/themed/test_theme/webroot/img/cake.power.gif b/lib/Cake/tests/test_app/views/themed/test_theme/webroot/img/cake.power.gif
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/webroot/img/cake.power.gif
rename to lib/Cake/tests/test_app/views/themed/test_theme/webroot/img/cake.power.gif
diff --git a/cake/tests/test_app/views/themed/test_theme/webroot/img/test.jpg b/lib/Cake/tests/test_app/views/themed/test_theme/webroot/img/test.jpg
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/webroot/img/test.jpg
rename to lib/Cake/tests/test_app/views/themed/test_theme/webroot/img/test.jpg
diff --git a/cake/tests/test_app/views/themed/test_theme/webroot/js/one/theme_one.js b/lib/Cake/tests/test_app/views/themed/test_theme/webroot/js/one/theme_one.js
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/webroot/js/one/theme_one.js
rename to lib/Cake/tests/test_app/views/themed/test_theme/webroot/js/one/theme_one.js
diff --git a/cake/tests/test_app/views/themed/test_theme/webroot/js/theme.js b/lib/Cake/tests/test_app/views/themed/test_theme/webroot/js/theme.js
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/webroot/js/theme.js
rename to lib/Cake/tests/test_app/views/themed/test_theme/webroot/js/theme.js
diff --git a/cake/tests/test_app/views/themed/test_theme/webroot/pdfs/theme_test.pdf b/lib/Cake/tests/test_app/views/themed/test_theme/webroot/pdfs/theme_test.pdf
similarity index 100%
rename from cake/tests/test_app/views/themed/test_theme/webroot/pdfs/theme_test.pdf
rename to lib/Cake/tests/test_app/views/themed/test_theme/webroot/pdfs/theme_test.pdf
diff --git a/cake/tests/test_app/webroot/theme/test_theme/css/theme_webroot.css b/lib/Cake/tests/test_app/webroot/theme/test_theme/css/theme_webroot.css
similarity index 100%
rename from cake/tests/test_app/webroot/theme/test_theme/css/theme_webroot.css
rename to lib/Cake/tests/test_app/webroot/theme/test_theme/css/theme_webroot.css
diff --git a/cake/tests/test_app/webroot/theme/test_theme/css/webroot_test.css b/lib/Cake/tests/test_app/webroot/theme/test_theme/css/webroot_test.css
similarity index 100%
rename from cake/tests/test_app/webroot/theme/test_theme/css/webroot_test.css
rename to lib/Cake/tests/test_app/webroot/theme/test_theme/css/webroot_test.css
diff --git a/cake/tests/test_app/webroot/theme/test_theme/img/cake.power.gif b/lib/Cake/tests/test_app/webroot/theme/test_theme/img/cake.power.gif
similarity index 100%
rename from cake/tests/test_app/webroot/theme/test_theme/img/cake.power.gif
rename to lib/Cake/tests/test_app/webroot/theme/test_theme/img/cake.power.gif
diff --git a/cake/tests/test_app/webroot/theme/test_theme/img/test.jpg b/lib/Cake/tests/test_app/webroot/theme/test_theme/img/test.jpg
similarity index 100%
rename from cake/tests/test_app/webroot/theme/test_theme/img/test.jpg
rename to lib/Cake/tests/test_app/webroot/theme/test_theme/img/test.jpg