From da7c53b37455677ed32f0ae8e0f5228c8561d1a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 3 Dec 2010 16:54:50 -0430 Subject: [PATCH 001/668] Beging of an experiment: a class utoloader for cakephp through emulating the keyword "use" of php 5.3 --- cake/libs/app.php | 19 +++++++++++++++++++ cake/libs/dispatcher.php | 13 ++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/cake/libs/app.php b/cake/libs/app.php index f18bb0719..66df9c93b 100644 --- a/cake/libs/app.php +++ b/cake/libs/app.php @@ -201,6 +201,12 @@ class App { */ private static $__objects = array(); +/** + * Holds the location of each class + * + */ + private static $__classMap = array(); + /** * Used to read information stored path * @@ -430,6 +436,17 @@ class App { self::$__objects[$type] = $values; } + public static function uses($className, $location) { + self::$__classMap[$className] = $location; + } + + public static function load($className) { + if (isset(self::$__classMap[$className])) { + return App::import(self::$__classMap[$className], $className, false); + } + 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. @@ -887,3 +904,5 @@ class App { } } } + +spl_autoload_register(array('App', 'load')); \ No newline at end of file diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index cb14d18ba..1a3738e89 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -24,10 +24,12 @@ /** * 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', 'Core'); +App::uses('CakeRequest', 'Core'); +App::uses('CakeResponse', 'Core'); +App::uses('Controller', 'Controller'); +App::uses('View', 'View'); +App::uses('Debugger', 'Core'); /** * Dispatcher converts Requests into controller actions. It uses the dispatched Request @@ -270,9 +272,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)); From fd639cc956bcede06cce8354370e13c64a26021d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 3 Dec 2010 17:09:50 -0430 Subject: [PATCH 002/668] Replacing use of App::import in favor of App::uses in controller class declaration --- cake/libs/controller/controller.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index d4341655b..a5c1ba8a1 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -21,10 +21,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', 'Core'); +App::uses('ClassRegistry', 'Core'); +App::uses('ComponentCollection', 'Controller'); +App::uses('View', 'View'); /** * Controller From 1d129840f613bdb80f847353c0756184ac38fa2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 3 Dec 2010 18:08:52 -0430 Subject: [PATCH 003/668] Changing more App::import calls for App::uses --- cake/libs/cake_request.php | 2 +- cake/libs/cake_session.php | 1 - cake/libs/controller/component.php | 2 +- cake/libs/controller/component_collection.php | 2 +- cake/libs/controller/components/auth.php | 6 +++--- cake/libs/controller/components/cookie.php | 2 +- cake/libs/controller/components/email.php | 2 +- cake/libs/controller/components/request_handler.php | 5 ++--- cake/libs/controller/components/security.php | 4 ++-- cake/libs/controller/components/session.php | 5 ++--- cake/libs/controller/scaffold.php | 2 +- cake/libs/debugger.php | 8 ++------ cake/libs/dispatcher.php | 2 +- cake/libs/http_socket.php | 4 ++-- cake/libs/i18n.php | 4 ++-- cake/libs/l10n.php | 2 +- cake/libs/model/behavior_collection.php | 2 +- cake/libs/model/cake_schema.php | 4 ++-- cake/libs/model/connection_manager.php | 4 ++-- cake/libs/router.php | 4 ++-- 20 files changed, 30 insertions(+), 37 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 7a464f742..088e0b968 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Set'); +App::uses('Set', 'Core'); /** * A class that helps wrap Request information and particulars about a single request. diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index aa4b0a95c..5c078c7dd 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -141,7 +141,6 @@ class CakeSession { * @param boolean $start Should session be started right now */ public static function init($base = null, $start = true) { - App::import('Core', 'Security'); self::$time = time(); $checkAgent = Configure::read('Session.checkAgent'); diff --git a/cake/libs/controller/component.php b/cake/libs/controller/component.php index c0d4b57a6..8ce908cda 100644 --- a/cake/libs/controller/component.php +++ b/cake/libs/controller/component.php @@ -16,7 +16,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/component_collection.php b/cake/libs/controller/component_collection.php index 90ec17f17..9aa589566 100644 --- a/cake/libs/controller/component_collection.php +++ b/cake/libs/controller/component_collection.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', 'ObjectCollection'); +App::uses('ObjectCollection', 'Core'); class ComponentCollection extends ObjectCollection { diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index a41d88e54..b09faa2f4 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -20,8 +20,9 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Router', false); -App::import('Core', 'Security', false); +App::uses('Router', 'Core'); +App::uses('Security', 'Core'); +App::uses('Debugger', 'Core'); /** * Authentication control component class @@ -287,7 +288,6 @@ class AuthComponent extends Component { } } if (Configure::read('debug') > 0) { - App::import('Debugger'); Debugger::checkSecurityKeys(); } } diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php index bff3b7137..2efec17c3 100644 --- a/cake/libs/controller/components/cookie.php +++ b/cake/libs/controller/components/cookie.php @@ -21,7 +21,7 @@ /** * Load Security class */ -App::import('Core', 'Security'); +App::uses('Security', 'Core'); /** * Cookie Component. diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index a4cb6dd02..965084589 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -17,7 +17,7 @@ * @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('Multibyte', 'Core'); /** * EmailComponent diff --git a/cake/libs/controller/components/request_handler.php b/cake/libs/controller/components/request_handler.php index b68e5e33e..4928c945a 100644 --- a/cake/libs/controller/components/request_handler.php +++ b/cake/libs/controller/components/request_handler.php @@ -20,6 +20,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Xml', 'Core'); + /** * Request object for handling HTTP requests * @@ -172,9 +174,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'))); diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index 49632a1c6..c4f8299c4 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -17,8 +17,8 @@ * @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('String', 'Core'); +App::uses('Security', 'Core'); /** * SecurityComponent diff --git a/cake/libs/controller/components/session.php b/cake/libs/controller/components/session.php index 77ab43a4d..9406e9447 100644 --- a/cake/libs/controller/components/session.php +++ b/cake/libs/controller/components/session.php @@ -17,9 +17,8 @@ * @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('CakeSession', 'Core'); /** * Session Component. diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 581d788c0..b0c8995af 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -19,7 +19,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/cake/libs/debugger.php b/cake/libs/debugger.php index f07ab78c6..a6f060df7 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -24,12 +24,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', 'Core'); +App::uses('String', 'Core'); /** * Provide custom logging and error handling. diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index 1a3738e89..2b4453546 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -28,6 +28,7 @@ App::uses('Router', 'Core'); App::uses('CakeRequest', 'Core'); App::uses('CakeResponse', 'Core'); App::uses('Controller', 'Controller'); +App::uses('Scaffold', 'Controller'); App::uses('View', 'View'); App::uses('Debugger', 'Core'); @@ -163,7 +164,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( diff --git a/cake/libs/http_socket.php b/cake/libs/http_socket.php index aaf3b504c..40f66204b 100644 --- a/cake/libs/http_socket.php +++ b/cake/libs/http_socket.php @@ -17,8 +17,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', 'Core'); +App::uses('Router', 'Core'); /** * Cake network socket connection class. diff --git a/cake/libs/i18n.php b/cake/libs/i18n.php index 05ec9c9e8..bab553d1a 100644 --- a/cake/libs/i18n.php +++ b/cake/libs/i18n.php @@ -21,8 +21,8 @@ /** * Included libraries. */ -App::import('Core', 'L10n'); -App::import('Core', 'Multibyte'); +App::uses('L10n', 'Core'); +App::uses('Multibyte', 'Core'); /** * I18n handles translation of Text and time format strings. diff --git a/cake/libs/l10n.php b/cake/libs/l10n.php index 4f5868412..1844507c3 100644 --- a/cake/libs/l10n.php +++ b/cake/libs/l10n.php @@ -17,7 +17,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', 'Core'); /** * Localization diff --git a/cake/libs/model/behavior_collection.php b/cake/libs/model/behavior_collection.php index 3ce783c76..39f2e37d3 100644 --- a/cake/libs/model/behavior_collection.php +++ b/cake/libs/model/behavior_collection.php @@ -19,7 +19,7 @@ * @since CakePHP(tm) v 1.2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'ObjectCollection'); +App::uses('ObjectCollection', 'Core'); /** * Model behavior collection class. diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index dbf5d3c3f..360de5717 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -17,8 +17,8 @@ * @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', 'Core'); +App::uses('ConnectionManager', 'Core'); /** * Base Class for Schema management diff --git a/cake/libs/model/connection_manager.php b/cake/libs/model/connection_manager.php index 40dc1e2bf..59dd5d37f 100644 --- a/cake/libs/model/connection_manager.php +++ b/cake/libs/model/connection_manager.php @@ -19,8 +19,6 @@ * @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'; -include_once CONFIGS . 'database.php'; /** * Manages loaded instances of DataSource objects @@ -59,6 +57,7 @@ class ConnectionManager { * */ function __construct() { + include_once CONFIGS . 'database.php'; if (class_exists('DATABASE_CONFIG')) { $this->config = new DATABASE_CONFIG(); $this->_getConnectionObjects(); @@ -102,6 +101,7 @@ class ConnectionManager { $conn = $_this->_connectionsEnum[$name]; $class = $conn['classname']; + require LIBS . 'model' . DS . 'datasources' . DS . 'datasource.php'; if ($_this->loadDataSource($name) === null) { trigger_error(sprintf(__("ConnectionManager::getDataSource - Could not load class %s"), $class), E_USER_ERROR); $null = null; diff --git a/cake/libs/router.php b/cake/libs/router.php index b51f02134..3840fdce6 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -18,8 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'CakeRequest'); -App::import('Core', 'route/CakeRoute'); +App::uses('CakeRequest', 'Core'); +App::uses('CakeRoute', 'Core'); /** * Parses the request URL into controller, action, and parameters. From b1ec3043bc656dd7cc6c7e3e05f2b730d188e04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 3 Dec 2010 18:37:21 -0430 Subject: [PATCH 004/668] Replacing App::import in favor of App::uses where possible --- cake/console/templates/skel/app_helper.php | 2 +- cake/libs/cake_socket.php | 2 +- cake/libs/model/behaviors/translate.php | 5 ++--- cake/libs/model/datasources/dbo_source.php | 2 +- cake/libs/model/db_acl.php | 2 +- cake/libs/model/model.php | 14 +++++++------- cake/libs/route/plugin_short_route.php | 2 +- cake/libs/route/redirect_route.php | 5 +++-- cake/libs/router.php | 4 ++-- cake/libs/security.php | 5 ++--- cake/libs/set.php | 5 ++--- cake/libs/validation.php | 5 ++--- cake/libs/view/helper.php | 4 +--- cake/libs/view/helper_collection.php | 2 +- cake/libs/view/helpers/app_helper.php | 2 +- cake/libs/view/helpers/jquery_engine.php | 3 ++- cake/libs/view/helpers/js.php | 3 ++- cake/libs/view/helpers/mootools_engine.php | 2 +- cake/libs/view/helpers/prototype_engine.php | 2 +- cake/libs/view/helpers/rss.php | 2 +- cake/libs/view/helpers/text.php | 8 ++------ cake/libs/view/media.php | 4 ++-- cake/libs/view/scaffold.php | 2 +- cake/libs/view/theme.php | 2 +- cake/libs/view/view.php | 4 ++-- 25 files changed, 43 insertions(+), 50 deletions(-) diff --git a/cake/console/templates/skel/app_helper.php b/cake/console/templates/skel/app_helper.php index 2dd482b90..5d9323d09 100644 --- a/cake/console/templates/skel/app_helper.php +++ b/cake/console/templates/skel/app_helper.php @@ -20,7 +20,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', 'Helper'); /** * This is a placeholder class. diff --git a/cake/libs/cake_socket.php b/cake/libs/cake_socket.php index 3bcb7ca0a..e5be4cbe5 100644 --- a/cake/libs/cake_socket.php +++ b/cake/libs/cake_socket.php @@ -17,7 +17,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', 'Core'); /** * Cake network socket connection class. diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 9e5a3c799..d7ea5ecf0 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -18,6 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('I18n', 'Core'); + /** * Translate behavior * @@ -346,9 +348,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/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 2e4387852..fbcf5c3af 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -17,7 +17,7 @@ * @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('String', 'Core'); /** * DboSource diff --git a/cake/libs/model/db_acl.php b/cake/libs/model/db_acl.php index b9bd815b0..a07730061 100644 --- a/cake/libs/model/db_acl.php +++ b/cake/libs/model/db_acl.php @@ -23,7 +23,7 @@ /** * Load Model and AppModel */ -App::import('Model', 'App'); +App::uses('AppModel', 'Model'); /** * ACL Node diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index b34d175e0..1ea708a2b 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -23,12 +23,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', 'Core'); +App::uses('Validation', 'Core'); +App::uses('String', 'Core'); +App::uses('BehaviorCollection', 'Model'); +App::uses('ModelBehavior', 'Model'); +App::uses('ConnectionManager', 'Model'); +App::uses('Xml', 'Core'); /** * Object-relational mapper. @@ -822,7 +823,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/route/plugin_short_route.php b/cake/libs/route/plugin_short_route.php index 1c1c4330b..062cfcbfb 100644 --- a/cake/libs/route/plugin_short_route.php +++ b/cake/libs/route/plugin_short_route.php @@ -1,5 +1,5 @@ $value) { $plugins[$key] = Inflector::underscore($value); } diff --git a/cake/libs/security.php b/cake/libs/security.php index 348402de2..2cbe838b0 100644 --- a/cake/libs/security.php +++ b/cake/libs/security.php @@ -18,6 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('String', 'Core'); + /** * Security Library contains utility methods related to security * @@ -59,9 +61,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/cake/libs/set.php index 4938308cd..7a86facdf 100644 --- a/cake/libs/set.php +++ b/cake/libs/set.php @@ -18,6 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('String', 'Core'); + /** * Class used for manipulation of arrays. * @@ -582,9 +584,6 @@ class Set { } if (!is_array($path)) { - if (!class_exists('String')) { - App::import('Core', 'String'); - } $path = String::tokenize($path, '.', '{', '}'); } $tmp = array(); diff --git a/cake/libs/validation.php b/cake/libs/validation.php index 7297491bd..00e7e8fe1 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -17,9 +17,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', 'Core'); /** * Offers different validation methods. diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 20e41953c..7bec00a20 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -20,9 +20,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('Router')) { - App::import('Core', 'Router'); -} +App::uses('Router', 'Core'); /** * Abstract base class for all other Helpers in CakePHP. diff --git a/cake/libs/view/helper_collection.php b/cake/libs/view/helper_collection.php index 18b700812..66200a44b 100644 --- a/cake/libs/view/helper_collection.php +++ b/cake/libs/view/helper_collection.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', 'ObjectCollection'); +App::uses('ObjectCollection', 'Core'); class HelperCollection extends ObjectCollection { diff --git a/cake/libs/view/helpers/app_helper.php b/cake/libs/view/helpers/app_helper.php index d09503bb0..cdde4bc60 100644 --- a/cake/libs/view/helpers/app_helper.php +++ b/cake/libs/view/helpers/app_helper.php @@ -20,7 +20,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/libs/view/helpers/jquery_engine.php b/cake/libs/view/helpers/jquery_engine.php index f09c70c33..ce9c017db 100644 --- a/cake/libs/view/helpers/jquery_engine.php +++ b/cake/libs/view/helpers/jquery_engine.php @@ -22,7 +22,8 @@ * @subpackage cake.view.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Js'); + +App::uses('JsHelper', 'Helper'); class JqueryEngineHelper extends JsBaseEngineHelper { /** diff --git a/cake/libs/view/helpers/js.php b/cake/libs/view/helpers/js.php index c4809c30c..a8a91adb8 100644 --- a/cake/libs/view/helpers/js.php +++ b/cake/libs/view/helpers/js.php @@ -18,6 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Multibyte', 'Core'); + /** * Javascript Generator helper class for easy use of JavaScript. * @@ -665,7 +667,6 @@ abstract class JsBaseEngineHelper extends AppHelper { * @return string Escaped string. */ public function escape($string) { - App::import('Core', 'Multibyte'); return $this->_utf8ToHex($string); } diff --git a/cake/libs/view/helpers/mootools_engine.php b/cake/libs/view/helpers/mootools_engine.php index bd0b676dd..ec226d500 100644 --- a/cake/libs/view/helpers/mootools_engine.php +++ b/cake/libs/view/helpers/mootools_engine.php @@ -25,7 +25,7 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Js'); +App::uses('JsHelper', 'Helper'); class MootoolsEngineHelper extends JsBaseEngineHelper { /** diff --git a/cake/libs/view/helpers/prototype_engine.php b/cake/libs/view/helpers/prototype_engine.php index 7f3e230b4..779fb5c45 100644 --- a/cake/libs/view/helpers/prototype_engine.php +++ b/cake/libs/view/helpers/prototype_engine.php @@ -20,7 +20,7 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Js'); +App::uses('JsHelper', 'Helper'); class PrototypeEngineHelper extends JsBaseEngineHelper { /** diff --git a/cake/libs/view/helpers/rss.php b/cake/libs/view/helpers/rss.php index ae1ab6239..d85eb7a23 100644 --- a/cake/libs/view/helpers/rss.php +++ b/cake/libs/view/helpers/rss.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Xml'); +App::uses('Xml', 'Core'); /** * RSS Helper class for easy output RSS structures. diff --git a/cake/libs/view/helpers/text.php b/cake/libs/view/helpers/text.php index 3f6933bbd..c87455035 100644 --- a/cake/libs/view/helpers/text.php +++ b/cake/libs/view/helpers/text.php @@ -24,12 +24,8 @@ * Included libraries. * */ -if (!class_exists('HtmlHelper')) { - App::import('Helper', 'Html'); -} -if (!class_exists('Multibyte')) { - App::import('Core', 'Multibyte'); -} +App::uses('HtmlHelper', 'Helper'); +App::uses('Multibyte', 'Core'); /** * Text helper library. diff --git a/cake/libs/view/media.php b/cake/libs/view/media.php index 5bc0d179e..856e8d920 100644 --- a/cake/libs/view/media.php +++ b/cake/libs/view/media.php @@ -17,7 +17,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', 'Core'); class MediaView extends View { /** @@ -45,7 +46,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/cake/libs/view/scaffold.php index 032676985..88015a97c 100644 --- a/cake/libs/view/scaffold.php +++ b/cake/libs/view/scaffold.php @@ -19,7 +19,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. diff --git a/cake/libs/view/theme.php b/cake/libs/view/theme.php index 80e56ae42..02cba797f 100644 --- a/cake/libs/view/theme.php +++ b/cake/libs/view/theme.php @@ -17,7 +17,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 diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 557c69674..a9b5481e5 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -21,8 +21,8 @@ /** * Included libraries. */ -App::import('View', 'HelperCollection', false); -App::import('View', 'Helper', false); +App::uses('HelperCollection', 'View'); +App::uses('Helper', 'View'); /** * View, the V in the MVC triad. From c57dd6f0f1b72d97b4656af3b69a9c318a005a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 3 Dec 2010 19:38:57 -0430 Subject: [PATCH 005/668] Starting to move files to match the PHP standards group file naming standard --- cake/libs/dispatcher.php => lib/Cake/Routing/Dispatcher.php | 0 {cake => lib/Cake}/basics.php | 0 {cake => lib/Cake}/bootstrap.php | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename cake/libs/dispatcher.php => lib/Cake/Routing/Dispatcher.php (100%) rename {cake => lib/Cake}/basics.php (100%) rename {cake => lib/Cake}/bootstrap.php (100%) diff --git a/cake/libs/dispatcher.php b/lib/Cake/Routing/Dispatcher.php similarity index 100% rename from cake/libs/dispatcher.php rename to lib/Cake/Routing/Dispatcher.php diff --git a/cake/basics.php b/lib/Cake/basics.php similarity index 100% rename from cake/basics.php rename to lib/Cake/basics.php diff --git a/cake/bootstrap.php b/lib/Cake/bootstrap.php similarity index 100% rename from cake/bootstrap.php rename to lib/Cake/bootstrap.php From 96cb90a82bfaa3ee772e91faa24e6bb263939e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 3 Dec 2010 19:48:44 -0430 Subject: [PATCH 006/668] Chanigng some constants and commenting code to start testing --- lib/Cake/bootstrap.php | 230 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 220 insertions(+), 10 deletions(-) diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index acfc7bb2f..e596aa359 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -24,16 +24,226 @@ if (!defined('E_DEPRECATED')) { } error_reporting(E_ALL & ~E_DEPRECATED); -require CORE_PATH . 'cake' . DS . 'basics.php'; -require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php'; -require LIBS . 'error' . DS . 'exceptions.php'; -require LIBS . 'object.php'; -require LIBS . 'inflector.php'; +/** + * If the index.php file is used instead of an .htaccess file + * or if the user can not set the web root to use the public + * directory we will define ROOT there, otherwise we set it + * here. + */ + if (!defined('ROOT')) { + define('ROOT', '../'); + } + if (!defined('WEBROOT_DIR')) { + define('WEBROOT_DIR', 'webroot'); + } + +/** + * Path to the cake directory. + */ + define('CAKE', CORE_PATH . 'lib' . DS . 'Cake' . DS); + +/** + * Path to the application's directory. + */ +if (!defined('APP')) { + define('APP', ROOT.DS.APP_DIR.DS); +} + +/** + * Path to the application's models directory. + */ + define('MODELS', APP.'models'.DS); + +/** + * Path to model behaviors directory. + */ + define('BEHAVIORS', MODELS.'behaviors'.DS); + +/** + * Path to the application's controllers directory. + */ + define('CONTROLLERS', APP.'controllers'.DS); + +/** + * Path to the application's components directory. + */ + define('COMPONENTS', CONTROLLERS.'components'.DS); + +/** + * Path to the application's libs directory. + */ + define('APPLIBS', APP.'libs'.DS); + +/** + * Path to the application's views directory. + */ + define('VIEWS', APP.'views'.DS); + +/** + * Path to the application's helpers directory. + */ + define('HELPERS', VIEWS.'helpers'.DS); + +/** + * Path to the application's view's layouts directory. + */ + define('LAYOUTS', VIEWS.'layouts'.DS); + +/** + * Path to the application's view's elements directory. + * It's supposed to hold pieces of PHP/HTML that are used on multiple pages + * and are not linked to a particular layout (like polls, footers and so on). + */ + define('ELEMENTS', VIEWS.'elements'.DS); + +/** + * Path to the configuration files directory. + */ +if (!defined('CONFIGS')) { + define('CONFIGS', APP.'config'.DS); +} + +/** + * Path to the libs directory. + */ + define('LIBS', CAKE); + +/** + * Path to the public CSS directory. + */ + define('CSS', WWW_ROOT.'css'.DS); + +/** + * Path to the public JavaScript directory. + */ + define('JS', WWW_ROOT.'js'.DS); + +/** + * Path to the public images directory. + */ + define('IMAGES', WWW_ROOT.'img'.DS); + +/** + * Path to the console libs direcotry. + */ + define('CONSOLE_LIBS', CAKE.'console'.DS.'libs'.DS); + +/** + * Path to the tests directory. + */ +if (!defined('TESTS')) { + define('TESTS', APP.'tests'.DS); +} + +/** + * Path to the core tests directory. + */ +if (!defined('CAKE_TESTS')) { + define('CAKE_TESTS', CAKE.'tests'.DS); +} + +/** + * Path to the test suite. + */ + define('CAKE_TESTS_LIB', CAKE_TESTS.'lib'.DS); + +/** + * Path to the controller test directory. + */ + define('CONTROLLER_TESTS', TESTS.'cases'.DS.'controllers'.DS); + +/** + * Path to the components test directory. + */ + define('COMPONENT_TESTS', TESTS.'cases'.DS.'components'.DS); + +/** + * Path to the helpers test directory. + */ + define('HELPER_TESTS', TESTS.'cases'.DS.'views'.DS.'helpers'.DS); + +/** + * Path to the models' test directory. + */ + define('MODEL_TESTS', TESTS.'cases'.DS.'models'.DS); + +/** + * Path to the lib test directory. + */ + define('LIB_TESTS', CAKE_TESTS.'cases'.DS.'lib'.DS); + +/** + * Path to the temporary files directory. + */ +if (!defined('TMP')) { + define('TMP', APP.'tmp'.DS); +} + +/** + * Path to the logs directory. + */ + define('LOGS', TMP.'logs'.DS); + +/** + * Path to the cache files directory. It can be shared between hosts in a multi-server setup. + */ + define('CACHE', TMP.'cache'.DS); + +/** + * Path to the vendors directory. + */ +if (!defined('VENDORS')) { + define('VENDORS', CAKE_CORE_INCLUDE_PATH.DS.'vendors'.DS); +} + +/** + * Web path to the public images directory. + */ +if (!defined('IMAGES_URL')) { + define('IMAGES_URL', 'img/'); +} + +/** + * Web path to the CSS files directory. + */ +if (!defined('CSS_URL')) { + define('CSS_URL', 'css/'); +} + +/** + * Web path to the js files directory. + */ +if (!defined('JS_URL')) { + define('JS_URL', 'js/'); +} + + +require LIBS . 'basics.php'; require LIBS . 'app.php'; -require LIBS . 'configure.php'; -require LIBS . 'set.php'; -require LIBS . 'cache.php'; -require LIBS . 'error' . DS . 'error_handler.php'; +//require LIBS . 'error' . DS . 'exceptions.php'; +//require LIBS . 'object.php'; +//require LIBS . 'inflector.php'; +// +//require LIBS . 'configure.php'; +//require LIBS . 'set.php'; +//require LIBS . 'cache.php'; +//require LIBS . 'error' . DS . 'error_handler.php'; -Configure::bootstrap(isset($boot) ? $boot : true); +//Configure::bootstrap(isset($boot) ? $boot : true); +/** + * Full url prefix + */ +if (!defined('FULL_BASE_URL')) { + $s = null; + if (env('HTTPS')) { + $s ='s'; + } + + $httpHost = env('HTTP_HOST'); + + if (isset($httpHost)) { + define('FULL_BASE_URL', 'http'.$s.'://'.$httpHost); + } + unset($httpHost, $s); +} \ No newline at end of file From ca34b22dbb73ecf9793d6a296bd4086e2c3d9f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 3 Dec 2010 20:15:54 -0430 Subject: [PATCH 007/668] Renaming more core classes, next step would be to tweek the autoloader to find only on Cake/ "namespace" (for now) --- cake/libs/app.php => lib/Cake/Core/App.php | 0 cake/libs/router.php => lib/Cake/Routing/Router.php | 0 cake/libs/folder.php => lib/Cake/Utility/Folder.php | 0 cake/libs/inflector.php => lib/Cake/Utility/Inflector.php | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename cake/libs/app.php => lib/Cake/Core/App.php (100%) rename cake/libs/router.php => lib/Cake/Routing/Router.php (100%) rename cake/libs/folder.php => lib/Cake/Utility/Folder.php (100%) rename cake/libs/inflector.php => lib/Cake/Utility/Inflector.php (100%) diff --git a/cake/libs/app.php b/lib/Cake/Core/App.php similarity index 100% rename from cake/libs/app.php rename to lib/Cake/Core/App.php diff --git a/cake/libs/router.php b/lib/Cake/Routing/Router.php similarity index 100% rename from cake/libs/router.php rename to lib/Cake/Routing/Router.php 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 From 3c23080dd23f979e437edcafb4c24ca0a5478cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 3 Dec 2010 20:53:47 -0430 Subject: [PATCH 008/668] Moving more classes to the new schema, slowly uncommenting code and implementing new class loader --- cake/libs/cache.php => lib/Cake/Cache/Cache.php | 0 lib/Cake/Core/App.php | 7 +++++-- .../configure.php => lib/Cake/Core/Configure.php | 0 .../Cake/Network/CakeRequest.php | 0 lib/Cake/Routing/Dispatcher.php | 6 +++--- lib/Cake/bootstrap.php | 12 ++++++++---- 6 files changed, 16 insertions(+), 9 deletions(-) rename cake/libs/cache.php => lib/Cake/Cache/Cache.php (100%) rename cake/libs/configure.php => lib/Cake/Core/Configure.php (100%) rename cake/libs/cake_request.php => lib/Cake/Network/CakeRequest.php (100%) diff --git a/cake/libs/cache.php b/lib/Cake/Cache/Cache.php similarity index 100% rename from cake/libs/cache.php rename to lib/Cake/Cache/Cache.php diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 66df9c93b..5caf05e40 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -442,7 +442,10 @@ class App { public static function load($className) { if (isset(self::$__classMap[$className])) { - return App::import(self::$__classMap[$className], $className, false); + $file = LIBS . self::$__classMap[$className] . DS . $className . '.php'; + if (file_exists($file)) { + return include $file; + } } return false; } @@ -606,7 +609,7 @@ class App { } if (empty(self::$__paths)) { - self::$__paths = Cache::read('dir_map', '_cake_core_'); + //self::$__paths = Cache::read('dir_map', '_cake_core_'); } foreach (self::$search as $path) { diff --git a/cake/libs/configure.php b/lib/Cake/Core/Configure.php similarity index 100% rename from cake/libs/configure.php rename to lib/Cake/Core/Configure.php diff --git a/cake/libs/cake_request.php b/lib/Cake/Network/CakeRequest.php similarity index 100% rename from cake/libs/cake_request.php rename to lib/Cake/Network/CakeRequest.php diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index 2b4453546..d1c396148 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -24,9 +24,9 @@ /** * List of helpers to include */ -App::uses('Router', 'Core'); -App::uses('CakeRequest', 'Core'); -App::uses('CakeResponse', 'Core'); +App::uses('Router', 'Routing'); +App::uses('CakeRequest', 'Network'); +App::uses('CakeResponse', 'Network'); App::uses('Controller', 'Controller'); App::uses('Scaffold', 'Controller'); App::uses('View', 'View'); diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index e596aa359..5a6a2e697 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -219,17 +219,21 @@ if (!defined('JS_URL')) { require LIBS . 'basics.php'; -require LIBS . 'app.php'; +require LIBS . 'Utility' . DS . 'Inflector.php'; +require LIBS . 'Utility' . DS . 'Folder.php'; +require LIBS . 'Core' . DS .'App.php'; + +App::uses('Configure', 'Core'); +App::uses('Cache', 'Cache'); + //require LIBS . 'error' . DS . 'exceptions.php'; //require LIBS . 'object.php'; -//require LIBS . 'inflector.php'; -// //require LIBS . 'configure.php'; //require LIBS . 'set.php'; //require LIBS . 'cache.php'; //require LIBS . 'error' . DS . 'error_handler.php'; -//Configure::bootstrap(isset($boot) ? $boot : true); +Configure::bootstrap(isset($boot) ? $boot : true); /** * Full url prefix From 73ad5385eb9a5ee1d0466458703013e5f60ea2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 02:16:51 -0430 Subject: [PATCH 009/668] Moving more classes to the new layout, it is time to bring the debugger up --- lib/Cake/Cache/Cache.php | 25 +++---------------- .../Cake/Cache/Engine/ApcEngine.php | 0 .../Cake/Cache/Engine/FileEngine.php | 0 .../Cake/Cache/Engine/MemcacheEngine.php | 0 .../Cake/Cache/Engine/XcacheEngine.php | 0 .../Cake/Error/ErrorHandler.php | 0 .../error => lib/Cake/Error}/exceptions.php | 0 lib/Cake/bootstrap.php | 7 +++--- 8 files changed, 8 insertions(+), 24 deletions(-) rename cake/libs/cache/apc.php => lib/Cake/Cache/Engine/ApcEngine.php (100%) rename cake/libs/cache/file.php => lib/Cake/Cache/Engine/FileEngine.php (100%) rename cake/libs/cache/memcache.php => lib/Cake/Cache/Engine/MemcacheEngine.php (100%) rename cake/libs/cache/xcache.php => lib/Cake/Cache/Engine/XcacheEngine.php (100%) rename cake/libs/error/error_handler.php => lib/Cake/Error/ErrorHandler.php (100%) rename {cake/libs/error => lib/Cake/Error}/exceptions.php (100%) diff --git a/lib/Cake/Cache/Cache.php b/lib/Cake/Cache/Cache.php index 259bdc490..4dd4e019f 100644 --- a/lib/Cake/Cache/Cache.php +++ b/lib/Cake/Cache/Cache.php @@ -19,6 +19,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Inflector', 'Utility'); + /** * Caching for CakePHP. * @@ -109,7 +111,8 @@ class Cache { list($plugin, $class) = pluginSplit($config['engine']); $cacheClass = $class . 'Engine'; - if (!class_exists($cacheClass) && self::_loadEngine($class, $plugin) === false) { + App::uses($cacheClass, 'Cache/Engine'); + if (!class_exists($cacheClass)) { return false; } $cacheClass = $class . 'Engine'; @@ -151,26 +154,6 @@ class Cache { return true; } -/** - * Tries to find and include a file for a cache engine and returns object instance - * - * @param $name Name of the engine (without 'Engine') - * @return mixed $engine object or null - */ - protected static function _loadEngine($name, $plugin = null) { - if ($plugin) { - return App::import('Lib', $plugin . '.cache' . DS . $name, false); - } else { - $core = App::core(); - $path = $core['libs'][0] . 'cache' . DS . strtolower($name) . '.php'; - if (file_exists($path)) { - require $path; - return true; - } - return App::import('Lib', 'cache' . DS . $name, false); - } - } - /** * Temporarily change the settings on a cache config. The settings will persist for the next write * operation (write, decrement, increment, clear). Any reads that are done before the write, will diff --git a/cake/libs/cache/apc.php b/lib/Cake/Cache/Engine/ApcEngine.php similarity index 100% rename from cake/libs/cache/apc.php rename to lib/Cake/Cache/Engine/ApcEngine.php diff --git a/cake/libs/cache/file.php b/lib/Cake/Cache/Engine/FileEngine.php similarity index 100% rename from cake/libs/cache/file.php rename to lib/Cake/Cache/Engine/FileEngine.php diff --git a/cake/libs/cache/memcache.php b/lib/Cake/Cache/Engine/MemcacheEngine.php similarity index 100% rename from cake/libs/cache/memcache.php rename to lib/Cake/Cache/Engine/MemcacheEngine.php diff --git a/cake/libs/cache/xcache.php b/lib/Cake/Cache/Engine/XcacheEngine.php similarity index 100% rename from cake/libs/cache/xcache.php rename to lib/Cake/Cache/Engine/XcacheEngine.php diff --git a/cake/libs/error/error_handler.php b/lib/Cake/Error/ErrorHandler.php similarity index 100% rename from cake/libs/error/error_handler.php rename to lib/Cake/Error/ErrorHandler.php diff --git a/cake/libs/error/exceptions.php b/lib/Cake/Error/exceptions.php similarity index 100% rename from cake/libs/error/exceptions.php rename to lib/Cake/Error/exceptions.php diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index 5a6a2e697..93532e608 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -219,14 +219,15 @@ if (!defined('JS_URL')) { require LIBS . 'basics.php'; -require LIBS . 'Utility' . DS . 'Inflector.php'; -require LIBS . 'Utility' . DS . 'Folder.php'; require LIBS . 'Core' . DS .'App.php'; +require LIBS . 'Error' . DS . 'exceptions.php'; +App::uses('ErrorHandler', 'Error'); App::uses('Configure', 'Core'); App::uses('Cache', 'Cache'); -//require LIBS . 'error' . DS . 'exceptions.php'; + + //require LIBS . 'object.php'; //require LIBS . 'configure.php'; //require LIBS . 'set.php'; From b4387d2f515a548fb714cf4c064672b2bdb71784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 02:34:30 -0430 Subject: [PATCH 010/668] More replacements to get class loaded using the new file scheme --- cake/libs/controller/components/auth.php | 4 ++-- .../Cake/Controller/ComponentCollection.php | 0 .../controller.php => lib/Cake/Controller/Controller.php | 0 lib/Cake/Core/App.php | 8 ++------ cake/libs/object.php => lib/Cake/Core/Object.php | 0 lib/Cake/Error/ErrorHandler.php | 8 ++------ lib/Cake/Routing/Dispatcher.php | 2 +- .../Cake/Routing/Route/CakeRoute.php | 0 lib/Cake/Routing/Router.php | 4 ++-- cake/libs/debugger.php => lib/Cake/Utility/Debugger.php | 4 ++-- cake/libs/string.php => lib/Cake/Utility/String.php | 0 lib/Cake/bootstrap.php | 9 +-------- 12 files changed, 12 insertions(+), 27 deletions(-) rename cake/libs/controller/component_collection.php => lib/Cake/Controller/ComponentCollection.php (100%) rename cake/libs/controller/controller.php => lib/Cake/Controller/Controller.php (100%) rename cake/libs/object.php => lib/Cake/Core/Object.php (100%) rename cake/libs/route/cake_route.php => lib/Cake/Routing/Route/CakeRoute.php (100%) rename cake/libs/debugger.php => lib/Cake/Utility/Debugger.php (99%) rename cake/libs/string.php => lib/Cake/Utility/String.php (100%) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index b09faa2f4..4aa3478ae 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -20,9 +20,9 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Router', 'Core'); +App::uses('Router', 'Routing'); App::uses('Security', 'Core'); -App::uses('Debugger', 'Core'); +App::uses('Debugger', 'Utility'); /** * Authentication control component class diff --git a/cake/libs/controller/component_collection.php b/lib/Cake/Controller/ComponentCollection.php similarity index 100% rename from cake/libs/controller/component_collection.php rename to lib/Cake/Controller/ComponentCollection.php diff --git a/cake/libs/controller/controller.php b/lib/Cake/Controller/Controller.php similarity index 100% rename from cake/libs/controller/controller.php rename to lib/Cake/Controller/Controller.php diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 5caf05e40..a363ad407 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -629,9 +629,7 @@ class App { } if (!isset(self::$__paths[$path])) { - if (!class_exists('Folder')) { - require LIBS . 'folder.php'; - } + App::uses('Folder', 'Utility'); $Folder = new Folder(); $directories = $Folder->tree($path, array('.svn', '.git', 'CVS', 'tests', 'templates'), 'dir'); sort($directories); @@ -865,9 +863,7 @@ class App { * @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'; - } + App::uses('Folder', 'Utility'); $items = array(); $Folder = new Folder($path); $contents = $Folder->read(false, true); diff --git a/cake/libs/object.php b/lib/Cake/Core/Object.php similarity index 100% rename from cake/libs/object.php rename to lib/Cake/Core/Object.php diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 85cea7ec4..732b6328d 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -20,6 +20,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Debugger', 'Utility'); + /** * * Error Handler provides basic error and exception handling for your application. It captures and @@ -143,9 +145,6 @@ class ErrorHandler { $debug = Configure::read('debug'); if ($debug) { - if (!class_exists('Debugger')) { - require LIBS . 'debugger.php'; - } $data = array( 'level' => $log, 'code' => $code, @@ -164,9 +163,6 @@ class ErrorHandler { } $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/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index d1c396148..1fd36319c 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -30,7 +30,7 @@ App::uses('CakeResponse', 'Network'); App::uses('Controller', 'Controller'); App::uses('Scaffold', 'Controller'); App::uses('View', 'View'); -App::uses('Debugger', 'Core'); +App::uses('Debugger', 'Utility'); /** * Dispatcher converts Requests into controller actions. It uses the dispatched Request 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/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 340d04261..3824fdd0c 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -18,8 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('CakeRequest', 'Core'); -App::uses('CakeRoute', 'Core'); +App::uses('CakeRequest', 'Network'); +App::uses('CakeRoute', 'Routing/Route'); /** * Parses the request URL into controller, action, and parameters. diff --git a/cake/libs/debugger.php b/lib/Cake/Utility/Debugger.php similarity index 99% rename from cake/libs/debugger.php rename to lib/Cake/Utility/Debugger.php index a6f060df7..d1900500a 100644 --- a/cake/libs/debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -24,8 +24,8 @@ * Included libraries. * */ -App::uses('CakeLog', 'Core'); -App::uses('String', 'Core'); +App::uses('CakeLog', 'Log'); +App::uses('String', 'Utility'); /** * Provide custom logging and error handling. 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/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index 93532e608..1e649440e 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -225,14 +225,7 @@ require LIBS . 'Error' . DS . 'exceptions.php'; App::uses('ErrorHandler', 'Error'); App::uses('Configure', 'Core'); App::uses('Cache', 'Cache'); - - - -//require LIBS . 'object.php'; -//require LIBS . 'configure.php'; -//require LIBS . 'set.php'; -//require LIBS . 'cache.php'; -//require LIBS . 'error' . DS . 'error_handler.php'; +App::uses('Object', 'Core'); Configure::bootstrap(isset($boot) ? $boot : true); From fbbb5c9337de2cfffa9dca839f51655acd7b3401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 02:45:22 -0430 Subject: [PATCH 011/668] Moving more clases to the new layout while trying to make controller related classes load --- .../Cake/Controller/Component/AclComponent.php | 0 .../Cake/Controller/Component/AuthComponent.php | 0 .../Cake/Controller/Component/CookieComponent.php | 0 .../Cake/Controller/Component/EmailComponent.php | 0 .../Controller/Component/RequestHandlerComponent.php | 0 .../Cake/Controller/Component/SecurityComponent.php | 0 .../Cake/Controller/Component/SessionComponent.php | 0 lib/Cake/Controller/ComponentCollection.php | 9 ++------- lib/Cake/Controller/Controller.php | 2 +- .../Cake/Network/CakeResponse.php | 0 .../Cake/Utility/ObjectCollection.php | 0 11 files changed, 3 insertions(+), 8 deletions(-) rename cake/libs/controller/components/acl.php => lib/Cake/Controller/Component/AclComponent.php (100%) rename cake/libs/controller/components/auth.php => lib/Cake/Controller/Component/AuthComponent.php (100%) rename cake/libs/controller/components/cookie.php => lib/Cake/Controller/Component/CookieComponent.php (100%) rename cake/libs/controller/components/email.php => lib/Cake/Controller/Component/EmailComponent.php (100%) rename cake/libs/controller/components/request_handler.php => lib/Cake/Controller/Component/RequestHandlerComponent.php (100%) rename cake/libs/controller/components/security.php => lib/Cake/Controller/Component/SecurityComponent.php (100%) rename cake/libs/controller/components/session.php => lib/Cake/Controller/Component/SessionComponent.php (100%) rename cake/libs/cake_response.php => lib/Cake/Network/CakeResponse.php (100%) rename cake/libs/object_collection.php => lib/Cake/Utility/ObjectCollection.php (100%) diff --git a/cake/libs/controller/components/acl.php b/lib/Cake/Controller/Component/AclComponent.php similarity index 100% rename from cake/libs/controller/components/acl.php rename to lib/Cake/Controller/Component/AclComponent.php diff --git a/cake/libs/controller/components/auth.php b/lib/Cake/Controller/Component/AuthComponent.php similarity index 100% rename from cake/libs/controller/components/auth.php rename to lib/Cake/Controller/Component/AuthComponent.php diff --git a/cake/libs/controller/components/cookie.php b/lib/Cake/Controller/Component/CookieComponent.php similarity index 100% rename from cake/libs/controller/components/cookie.php rename to lib/Cake/Controller/Component/CookieComponent.php diff --git a/cake/libs/controller/components/email.php b/lib/Cake/Controller/Component/EmailComponent.php similarity index 100% rename from cake/libs/controller/components/email.php rename to lib/Cake/Controller/Component/EmailComponent.php diff --git a/cake/libs/controller/components/request_handler.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php similarity index 100% rename from cake/libs/controller/components/request_handler.php rename to lib/Cake/Controller/Component/RequestHandlerComponent.php diff --git a/cake/libs/controller/components/security.php b/lib/Cake/Controller/Component/SecurityComponent.php similarity index 100% rename from cake/libs/controller/components/security.php rename to lib/Cake/Controller/Component/SecurityComponent.php diff --git a/cake/libs/controller/components/session.php b/lib/Cake/Controller/Component/SessionComponent.php similarity index 100% rename from cake/libs/controller/components/session.php rename to lib/Cake/Controller/Component/SessionComponent.php diff --git a/lib/Cake/Controller/ComponentCollection.php b/lib/Cake/Controller/ComponentCollection.php index 9aa589566..f17a1f729 100644 --- a/lib/Cake/Controller/ComponentCollection.php +++ b/lib/Cake/Controller/ComponentCollection.php @@ -16,7 +16,7 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('ObjectCollection', 'Core'); +App::uses('ObjectCollection', 'Utility'); class ComponentCollection extends ObjectCollection { @@ -70,13 +70,8 @@ class ComponentCollection extends ObjectCollection { return $this->_loaded[$name]; } $componentClass = $name . 'Component'; + App::uses($componentClass, 'Controller/Component'); if (!class_exists($componentClass)) { - if (!App::import('Component', $component)) { - throw new MissingComponentFileException(array( - 'file' => Inflector::underscore($component) . '.php', - 'class' => $componentClass - )); - } if (!class_exists($componentClass)) { throw new MissingComponentFileException(array( 'file' => Inflector::underscore($component) . '.php', diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index a5c1ba8a1..21fce12ee 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -21,7 +21,7 @@ /** * Include files */ -App::uses('CakeResponse', 'Core'); +App::uses('CakeResponse', 'Network'); App::uses('ClassRegistry', 'Core'); App::uses('ComponentCollection', 'Controller'); App::uses('View', 'View'); 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/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 From c641baaf161c013e5b60e54576836663045c7243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 02:49:44 -0430 Subject: [PATCH 012/668] Loading component classes ang beginnings of session loading --- .../component.php => lib/Cake/Controller/Component.php | 0 lib/Cake/Controller/Component/SessionComponent.php | 2 +- lib/Cake/Controller/ComponentCollection.php | 1 + cake/libs/cake_session.php => lib/Cake/Model/CakeSession.php | 0 4 files changed, 2 insertions(+), 1 deletion(-) rename cake/libs/controller/component.php => lib/Cake/Controller/Component.php (100%) rename cake/libs/cake_session.php => lib/Cake/Model/CakeSession.php (100%) diff --git a/cake/libs/controller/component.php b/lib/Cake/Controller/Component.php similarity index 100% rename from cake/libs/controller/component.php rename to lib/Cake/Controller/Component.php diff --git a/lib/Cake/Controller/Component/SessionComponent.php b/lib/Cake/Controller/Component/SessionComponent.php index 9406e9447..855cbcd20 100644 --- a/lib/Cake/Controller/Component/SessionComponent.php +++ b/lib/Cake/Controller/Component/SessionComponent.php @@ -18,7 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('CakeSession', 'Core'); +App::uses('CakeSession', 'Model'); /** * Session Component. diff --git a/lib/Cake/Controller/ComponentCollection.php b/lib/Cake/Controller/ComponentCollection.php index f17a1f729..fa4226b63 100644 --- a/lib/Cake/Controller/ComponentCollection.php +++ b/lib/Cake/Controller/ComponentCollection.php @@ -17,6 +17,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::uses('ObjectCollection', 'Utility'); +App::uses('Component', 'Controller'); class ComponentCollection extends ObjectCollection { diff --git a/cake/libs/cake_session.php b/lib/Cake/Model/CakeSession.php similarity index 100% rename from cake/libs/cake_session.php rename to lib/Cake/Model/CakeSession.php From ec93152c9a069268dfaf6c7bea9651cf237f2b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 02:51:42 -0430 Subject: [PATCH 013/668] Loading the set class successfully --- lib/Cake/Model/CakeSession.php | 2 ++ cake/libs/set.php => lib/Cake/Utility/Set.php | 0 2 files changed, 2 insertions(+) rename cake/libs/set.php => lib/Cake/Utility/Set.php (100%) diff --git a/lib/Cake/Model/CakeSession.php b/lib/Cake/Model/CakeSession.php index 5c078c7dd..df323a60e 100644 --- a/lib/Cake/Model/CakeSession.php +++ b/lib/Cake/Model/CakeSession.php @@ -23,6 +23,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Set', 'Utility'); + /** * Session class for Cake. * diff --git a/cake/libs/set.php b/lib/Cake/Utility/Set.php similarity index 100% rename from cake/libs/set.php rename to lib/Cake/Utility/Set.php From fa83ecda5bacc4ae6cfe3704ff30bd5164800571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 02:57:20 -0430 Subject: [PATCH 014/668] Beginnings of model loading --- lib/Cake/Controller/Controller.php | 2 +- lib/Cake/Core/App.php | 4 +--- cake/libs/model/model.php => lib/Cake/Model/Model.php | 0 .../class_registry.php => lib/Cake/Utility/ClassRegistry.php | 0 lib/Cake/Utility/Set.php | 2 +- 5 files changed, 3 insertions(+), 5 deletions(-) rename cake/libs/model/model.php => lib/Cake/Model/Model.php (100%) rename cake/libs/class_registry.php => lib/Cake/Utility/ClassRegistry.php (100%) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 21fce12ee..ffa3e14eb 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -22,7 +22,7 @@ * Include files */ App::uses('CakeResponse', 'Network'); -App::uses('ClassRegistry', 'Core'); +App::uses('ClassRegistry', 'Utility'); App::uses('ComponentCollection', 'Controller'); App::uses('View', 'View'); diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index a363ad407..4242a47d9 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -733,9 +733,7 @@ class App { switch ($load) { case 'model': - if (!class_exists('Model')) { - require LIBS . 'model' . DS . 'model.php'; - } + App::uses('Model', 'Model'); if (!class_exists('AppModel')) { App::import($type, 'AppModel', false); } diff --git a/cake/libs/model/model.php b/lib/Cake/Model/Model.php similarity index 100% rename from cake/libs/model/model.php rename to lib/Cake/Model/Model.php diff --git a/cake/libs/class_registry.php b/lib/Cake/Utility/ClassRegistry.php similarity index 100% rename from cake/libs/class_registry.php rename to lib/Cake/Utility/ClassRegistry.php diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 7a86facdf..95b499161 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -18,7 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('String', 'Core'); +App::uses('String', 'Utility'); /** * Class used for manipulation of arrays. From 4bb6d583b76a7fb6325f851effb6230c9d8103f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 03:00:03 -0430 Subject: [PATCH 015/668] More work towards model loading --- .../Cake/Model/BehaviorCollection.php | 0 .../Cake/Model/ConnectionManager.php | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename cake/libs/model/behavior_collection.php => lib/Cake/Model/BehaviorCollection.php (100%) rename cake/libs/model/connection_manager.php => lib/Cake/Model/ConnectionManager.php (100%) diff --git a/cake/libs/model/behavior_collection.php b/lib/Cake/Model/BehaviorCollection.php similarity index 100% rename from cake/libs/model/behavior_collection.php rename to lib/Cake/Model/BehaviorCollection.php diff --git a/cake/libs/model/connection_manager.php b/lib/Cake/Model/ConnectionManager.php similarity index 100% rename from cake/libs/model/connection_manager.php rename to lib/Cake/Model/ConnectionManager.php From 592abb569c6b71805bd426e74208dc08981df3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 11:16:42 -0430 Subject: [PATCH 016/668] More work towards loading datasources --- lib/Cake/Model/ConnectionManager.php | 3 ++- .../datasource.php => lib/Cake/Model/Datasource/DataSource.php | 0 .../dbo_source.php => lib/Cake/Model/Datasource/DboSource.php | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename cake/libs/model/datasources/datasource.php => lib/Cake/Model/Datasource/DataSource.php (100%) rename cake/libs/model/datasources/dbo_source.php => lib/Cake/Model/Datasource/DboSource.php (100%) diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index 59dd5d37f..e07371a03 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -20,6 +20,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('DataSource', 'Model/Datasource'); + /** * Manages loaded instances of DataSource objects * @@ -101,7 +103,6 @@ class ConnectionManager { $conn = $_this->_connectionsEnum[$name]; $class = $conn['classname']; - require LIBS . 'model' . DS . 'datasources' . DS . 'datasource.php'; if ($_this->loadDataSource($name) === null) { trigger_error(sprintf(__("ConnectionManager::getDataSource - Could not load class %s"), $class), E_USER_ERROR); $null = null; 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_source.php b/lib/Cake/Model/Datasource/DboSource.php similarity index 100% rename from cake/libs/model/datasources/dbo_source.php rename to lib/Cake/Model/Datasource/DboSource.php From be1263d4760238c290016dce621c082666de7cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 11:52:23 -0430 Subject: [PATCH 017/668] Moving the first database driver to the correct folder to start testing --- lib/Cake/Model/ConnectionManager.php | 9 +++------ .../Cake/Model/Datasource/Database/Mysql.php | 0 2 files changed, 3 insertions(+), 6 deletions(-) rename cake/libs/model/datasources/dbo/dbo_mysql.php => lib/Cake/Model/Datasource/Database/Mysql.php (100%) diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index e07371a03..b6ff55252 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -165,14 +165,11 @@ class ConnectionManager { return false; } - if (!empty($conn['parent'])) { - $_this->loadDataSource($conn['parent']); - } - $conn = array_merge(array('plugin' => null, 'classname' => null, 'parent' => null), $conn); - $class = "{$conn['plugin']}.{$conn['classname']}"; + $class = trim("{$conn['plugin']}.{$conn['classname']}", '.'); - if (!App::import('Datasource', $class, !is_null($conn['plugin']))) { + App::uses($class, 'Model/Datasource'); + if (class_exists($class)) { trigger_error(sprintf(__('ConnectionManager::loadDataSource - Unable to import DataSource class %s'), $class), E_USER_ERROR); return null; } diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php similarity index 100% rename from cake/libs/model/datasources/dbo/dbo_mysql.php rename to lib/Cake/Model/Datasource/Database/Mysql.php From 7dc8d5e74678b56ce7958511897a8170857478ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 12:24:15 -0430 Subject: [PATCH 018/668] Simplifying datasources loading, it now requires datasources to be configured with the 'datasource' array key, which is a relative path from Model/Datasource/ --- lib/Cake/Model/ConnectionManager.php | 49 +++++++------------- lib/Cake/Model/Datasource/Database/Mysql.php | 4 +- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index b6ff55252..4f67db5f5 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -161,15 +161,20 @@ class ConnectionManager { $conn = $_this->_connectionsEnum[$connName]; } - if (class_exists($conn['classname'])) { + if (class_exists($conn['classname'], false)) { return false; } - $conn = array_merge(array('plugin' => null, 'classname' => null, 'parent' => null), $conn); - $class = trim("{$conn['plugin']}.{$conn['classname']}", '.'); + $plugin = $package = null; + if (!empty($conn['plugin'])) { + $plugin .= '.'; + } + if (!empty($conn['package'])) { + $package = '/' . $conn['package']; + } - App::uses($class, 'Model/Datasource'); - if (class_exists($class)) { + App::uses($conn['classname'], $plugin . 'Model/Datasource' . $package); + if (!class_exists($conn['classname'])) { trigger_error(sprintf(__('ConnectionManager::loadDataSource - Unable to import DataSource class %s'), $class), E_USER_ERROR); return null; } @@ -230,36 +235,14 @@ 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; + $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'); } /** diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 069cf089a..882aa61e0 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -18,6 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('DboSource', 'Model/Datasource'); + /** * MySQL DBO driver object * @@ -26,7 +28,7 @@ * @package cake * @subpackage cake.cake.libs.model.datasources.dbo */ -class DboMysql extends DboSource { +class Mysql extends DboSource { /** * Datasource description From be9bcb3627c81575b701419bd8fbc27e63c66ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 13:31:04 -0430 Subject: [PATCH 019/668] Moving view clasess to their new home --- cake/libs/view/helper.php => lib/Cake/View/Helper.php | 0 .../helpers/app_helper.php => lib/Cake/View/Helper/AppHelper.php | 0 .../helpers/cache.php => lib/Cake/View/Helper/CacheHelper.php | 0 .../view/helpers/form.php => lib/Cake/View/Helper/FormHelper.php | 0 .../view/helpers/html.php => lib/Cake/View/Helper/HtmlHelper.php | 0 .../Cake/View/Helper/JqueryEngineHelper.php | 0 .../libs/view/helpers/js.php => lib/Cake/View/Helper/JsHelper.php | 0 .../Cake/View/Helper/MootoolsEngineHelper.php | 0 .../helpers/number.php => lib/Cake/View/Helper/NumberHelper.php | 0 .../paginator.php => lib/Cake/View/Helper/PaginatorHelper.php | 0 .../Cake/View/Helper/PrototypeEngineHelper.php | 0 .../view/helpers/rss.php => lib/Cake/View/Helper/RssHelper.php | 0 .../helpers/session.php => lib/Cake/View/Helper/SessionHelper.php | 0 .../view/helpers/text.php => lib/Cake/View/Helper/TextHelper.php | 0 .../view/helpers/time.php => lib/Cake/View/Helper/TimeHelper.php | 0 .../helper_collection.php => lib/Cake/View/HelperCollection.php | 0 cake/libs/view/media.php => lib/Cake/View/MediaView.php | 0 cake/libs/view/theme.php => lib/Cake/View/ThemeView.php | 0 cake/libs/view/view.php => lib/Cake/View/View.php | 0 19 files changed, 0 insertions(+), 0 deletions(-) rename cake/libs/view/helper.php => lib/Cake/View/Helper.php (100%) rename cake/libs/view/helpers/app_helper.php => lib/Cake/View/Helper/AppHelper.php (100%) rename cake/libs/view/helpers/cache.php => lib/Cake/View/Helper/CacheHelper.php (100%) rename cake/libs/view/helpers/form.php => lib/Cake/View/Helper/FormHelper.php (100%) rename cake/libs/view/helpers/html.php => lib/Cake/View/Helper/HtmlHelper.php (100%) rename cake/libs/view/helpers/jquery_engine.php => lib/Cake/View/Helper/JqueryEngineHelper.php (100%) rename cake/libs/view/helpers/js.php => lib/Cake/View/Helper/JsHelper.php (100%) rename cake/libs/view/helpers/mootools_engine.php => lib/Cake/View/Helper/MootoolsEngineHelper.php (100%) rename cake/libs/view/helpers/number.php => lib/Cake/View/Helper/NumberHelper.php (100%) rename cake/libs/view/helpers/paginator.php => lib/Cake/View/Helper/PaginatorHelper.php (100%) rename cake/libs/view/helpers/prototype_engine.php => lib/Cake/View/Helper/PrototypeEngineHelper.php (100%) rename cake/libs/view/helpers/rss.php => lib/Cake/View/Helper/RssHelper.php (100%) rename cake/libs/view/helpers/session.php => lib/Cake/View/Helper/SessionHelper.php (100%) rename cake/libs/view/helpers/text.php => lib/Cake/View/Helper/TextHelper.php (100%) rename cake/libs/view/helpers/time.php => lib/Cake/View/Helper/TimeHelper.php (100%) rename cake/libs/view/helper_collection.php => lib/Cake/View/HelperCollection.php (100%) rename cake/libs/view/media.php => lib/Cake/View/MediaView.php (100%) rename cake/libs/view/theme.php => lib/Cake/View/ThemeView.php (100%) rename cake/libs/view/view.php => lib/Cake/View/View.php (100%) diff --git a/cake/libs/view/helper.php b/lib/Cake/View/Helper.php similarity index 100% rename from cake/libs/view/helper.php rename to lib/Cake/View/Helper.php diff --git a/cake/libs/view/helpers/app_helper.php b/lib/Cake/View/Helper/AppHelper.php similarity index 100% rename from cake/libs/view/helpers/app_helper.php rename to lib/Cake/View/Helper/AppHelper.php diff --git a/cake/libs/view/helpers/cache.php b/lib/Cake/View/Helper/CacheHelper.php similarity index 100% rename from cake/libs/view/helpers/cache.php rename to lib/Cake/View/Helper/CacheHelper.php diff --git a/cake/libs/view/helpers/form.php b/lib/Cake/View/Helper/FormHelper.php similarity index 100% rename from cake/libs/view/helpers/form.php rename to lib/Cake/View/Helper/FormHelper.php diff --git a/cake/libs/view/helpers/html.php b/lib/Cake/View/Helper/HtmlHelper.php similarity index 100% rename from cake/libs/view/helpers/html.php rename to lib/Cake/View/Helper/HtmlHelper.php diff --git a/cake/libs/view/helpers/jquery_engine.php b/lib/Cake/View/Helper/JqueryEngineHelper.php similarity index 100% rename from cake/libs/view/helpers/jquery_engine.php rename to lib/Cake/View/Helper/JqueryEngineHelper.php diff --git a/cake/libs/view/helpers/js.php b/lib/Cake/View/Helper/JsHelper.php similarity index 100% rename from cake/libs/view/helpers/js.php rename to lib/Cake/View/Helper/JsHelper.php diff --git a/cake/libs/view/helpers/mootools_engine.php b/lib/Cake/View/Helper/MootoolsEngineHelper.php similarity index 100% rename from cake/libs/view/helpers/mootools_engine.php rename to lib/Cake/View/Helper/MootoolsEngineHelper.php diff --git a/cake/libs/view/helpers/number.php b/lib/Cake/View/Helper/NumberHelper.php similarity index 100% rename from cake/libs/view/helpers/number.php rename to lib/Cake/View/Helper/NumberHelper.php diff --git a/cake/libs/view/helpers/paginator.php b/lib/Cake/View/Helper/PaginatorHelper.php similarity index 100% rename from cake/libs/view/helpers/paginator.php rename to lib/Cake/View/Helper/PaginatorHelper.php diff --git a/cake/libs/view/helpers/prototype_engine.php b/lib/Cake/View/Helper/PrototypeEngineHelper.php similarity index 100% rename from cake/libs/view/helpers/prototype_engine.php rename to lib/Cake/View/Helper/PrototypeEngineHelper.php diff --git a/cake/libs/view/helpers/rss.php b/lib/Cake/View/Helper/RssHelper.php similarity index 100% rename from cake/libs/view/helpers/rss.php rename to lib/Cake/View/Helper/RssHelper.php diff --git a/cake/libs/view/helpers/session.php b/lib/Cake/View/Helper/SessionHelper.php similarity index 100% rename from cake/libs/view/helpers/session.php rename to lib/Cake/View/Helper/SessionHelper.php diff --git a/cake/libs/view/helpers/text.php b/lib/Cake/View/Helper/TextHelper.php similarity index 100% rename from cake/libs/view/helpers/text.php rename to lib/Cake/View/Helper/TextHelper.php diff --git a/cake/libs/view/helpers/time.php b/lib/Cake/View/Helper/TimeHelper.php similarity index 100% rename from cake/libs/view/helpers/time.php rename to lib/Cake/View/Helper/TimeHelper.php diff --git a/cake/libs/view/helper_collection.php b/lib/Cake/View/HelperCollection.php similarity index 100% rename from cake/libs/view/helper_collection.php rename to lib/Cake/View/HelperCollection.php diff --git a/cake/libs/view/media.php b/lib/Cake/View/MediaView.php similarity index 100% rename from cake/libs/view/media.php rename to lib/Cake/View/MediaView.php diff --git a/cake/libs/view/theme.php b/lib/Cake/View/ThemeView.php similarity index 100% rename from cake/libs/view/theme.php rename to lib/Cake/View/ThemeView.php diff --git a/cake/libs/view/view.php b/lib/Cake/View/View.php similarity index 100% rename from cake/libs/view/view.php rename to lib/Cake/View/View.php From f3eb2159eb5790a3de7b809865b703aac5458332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 13:40:24 -0430 Subject: [PATCH 020/668] Making helpers load --- lib/Cake/View/Helper/CacheHelper.php | 2 ++ lib/Cake/View/Helper/FormHelper.php | 2 ++ lib/Cake/View/Helper/HtmlHelper.php | 3 +++ lib/Cake/View/Helper/JsHelper.php | 1 + lib/Cake/View/Helper/MootoolsEngineHelper.php | 1 + lib/Cake/View/Helper/NumberHelper.php | 2 ++ lib/Cake/View/Helper/PaginatorHelper.php | 2 ++ lib/Cake/View/Helper/PrototypeEngineHelper.php | 1 + lib/Cake/View/Helper/RssHelper.php | 4 +++- lib/Cake/View/Helper/SessionHelper.php | 7 ++++--- lib/Cake/View/Helper/TextHelper.php | 3 ++- lib/Cake/View/Helper/TimeHelper.php | 2 ++ lib/Cake/View/HelperCollection.php | 17 +++++------------ lib/Cake/View/View.php | 1 - 14 files changed, 30 insertions(+), 18 deletions(-) diff --git a/lib/Cake/View/Helper/CacheHelper.php b/lib/Cake/View/Helper/CacheHelper.php index 6a1c430ea..d69c4b8f1 100644 --- a/lib/Cake/View/Helper/CacheHelper.php +++ b/lib/Cake/View/Helper/CacheHelper.php @@ -18,6 +18,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/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 0fe0e0ad2..efce3d6a1 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -20,6 +20,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppHelper', 'View/Helper'); + /** * Form helper library. * diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 2509e8d56..cacc7f1ee 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -17,6 +17,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. * diff --git a/lib/Cake/View/Helper/JsHelper.php b/lib/Cake/View/Helper/JsHelper.php index a8a91adb8..7a605b423 100644 --- a/lib/Cake/View/Helper/JsHelper.php +++ b/lib/Cake/View/Helper/JsHelper.php @@ -18,6 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppHelper', 'View/Helper'); App::uses('Multibyte', 'Core'); /** diff --git a/lib/Cake/View/Helper/MootoolsEngineHelper.php b/lib/Cake/View/Helper/MootoolsEngineHelper.php index ec226d500..d513527b1 100644 --- a/lib/Cake/View/Helper/MootoolsEngineHelper.php +++ b/lib/Cake/View/Helper/MootoolsEngineHelper.php @@ -25,6 +25,7 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + App::uses('JsHelper', 'Helper'); class MootoolsEngineHelper extends JsBaseEngineHelper { diff --git a/lib/Cake/View/Helper/NumberHelper.php b/lib/Cake/View/Helper/NumberHelper.php index b7d612471..dfd404ee7 100644 --- a/lib/Cake/View/Helper/NumberHelper.php +++ b/lib/Cake/View/Helper/NumberHelper.php @@ -20,6 +20,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppHelper', 'View/Helper'); + /** * Number helper library. * diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index 5816c6b6a..dca0562eb 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -18,6 +18,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. * diff --git a/lib/Cake/View/Helper/PrototypeEngineHelper.php b/lib/Cake/View/Helper/PrototypeEngineHelper.php index 779fb5c45..8781ba880 100644 --- a/lib/Cake/View/Helper/PrototypeEngineHelper.php +++ b/lib/Cake/View/Helper/PrototypeEngineHelper.php @@ -20,6 +20,7 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + App::uses('JsHelper', 'Helper'); class PrototypeEngineHelper extends JsBaseEngineHelper { diff --git a/lib/Cake/View/Helper/RssHelper.php b/lib/Cake/View/Helper/RssHelper.php index d85eb7a23..17ebe8628 100644 --- a/lib/Cake/View/Helper/RssHelper.php +++ b/lib/Cake/View/Helper/RssHelper.php @@ -17,7 +17,9 @@ * @since CakePHP(tm) v 1.2 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Xml', 'Core'); + +App::uses('AppHelper', 'View/Helper'); +App::uses('Xml', 'Utility'); /** * RSS Helper class for easy output RSS structures. diff --git a/lib/Cake/View/Helper/SessionHelper.php b/lib/Cake/View/Helper/SessionHelper.php index 0f6aa002d..997e2c422 100644 --- a/lib/Cake/View/Helper/SessionHelper.php +++ b/lib/Cake/View/Helper/SessionHelper.php @@ -17,9 +17,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'); + /** * Session Helper. * diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index c87455035..11b04c0a2 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -24,8 +24,9 @@ * Included libraries. * */ +App::uses('AppHelper', 'View/Helper'); App::uses('HtmlHelper', 'Helper'); -App::uses('Multibyte', 'Core'); +App::uses('Multibyte', 'Utility'); /** * Text helper library. diff --git a/lib/Cake/View/Helper/TimeHelper.php b/lib/Cake/View/Helper/TimeHelper.php index df1a34051..4c1d8aec3 100644 --- a/lib/Cake/View/Helper/TimeHelper.php +++ b/lib/Cake/View/Helper/TimeHelper.php @@ -18,6 +18,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/lib/Cake/View/HelperCollection.php b/lib/Cake/View/HelperCollection.php index 66200a44b..99e709c03 100644 --- a/lib/Cake/View/HelperCollection.php +++ b/lib/Cake/View/HelperCollection.php @@ -54,19 +54,12 @@ class HelperCollection extends ObjectCollection { return $this->_loaded[$name]; } $helperClass = $name . 'Helper'; + App::uses($helperClass, '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' => Inflector::underscore($name) . '.php' + )); } $this->_loaded[$name] = new $helperClass($this->_View, $settings); diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index a9b5481e5..9ca29b464 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -22,7 +22,6 @@ * Included libraries. */ App::uses('HelperCollection', 'View'); -App::uses('Helper', 'View'); /** * View, the V in the MVC triad. From 6b40c9c85426b2228311dace1536282a607881b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 13:45:07 -0430 Subject: [PATCH 021/668] Moving I18n related classes to the new folder schema --- cake/libs/validation.php | 2 +- .../Controller/Component/EmailComponent.php | 2 +- cake/libs/i18n.php => lib/Cake/I18n/I18n.php | 0 cake/libs/l10n.php => lib/Cake/I18n/L10n.php | 0 .../Cake/I18n/Multibyte.php | 0 lib/Cake/View/Helper/JsHelper.php | 2 +- lib/Cake/View/Helper/TextHelper.php | 2 +- lib/Cake/basics.php | 28 +++++-------------- 8 files changed, 11 insertions(+), 25 deletions(-) rename cake/libs/i18n.php => lib/Cake/I18n/I18n.php (100%) rename cake/libs/l10n.php => lib/Cake/I18n/L10n.php (100%) rename cake/libs/multibyte.php => lib/Cake/I18n/Multibyte.php (100%) diff --git a/cake/libs/validation.php b/cake/libs/validation.php index 00e7e8fe1..d4db77ed2 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -18,7 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Multibyte', 'Core'); +App::uses('Multibyte', 'I18n'); /** * Offers different validation methods. diff --git a/lib/Cake/Controller/Component/EmailComponent.php b/lib/Cake/Controller/Component/EmailComponent.php index 965084589..47ab6775b 100755 --- a/lib/Cake/Controller/Component/EmailComponent.php +++ b/lib/Cake/Controller/Component/EmailComponent.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0.3467 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Multibyte', 'Core'); +App::uses('Multibyte', 'I18n'); /** * EmailComponent diff --git a/cake/libs/i18n.php b/lib/Cake/I18n/I18n.php similarity index 100% rename from cake/libs/i18n.php rename to lib/Cake/I18n/I18n.php diff --git a/cake/libs/l10n.php b/lib/Cake/I18n/L10n.php similarity index 100% rename from cake/libs/l10n.php rename to lib/Cake/I18n/L10n.php diff --git a/cake/libs/multibyte.php b/lib/Cake/I18n/Multibyte.php similarity index 100% rename from cake/libs/multibyte.php rename to lib/Cake/I18n/Multibyte.php diff --git a/lib/Cake/View/Helper/JsHelper.php b/lib/Cake/View/Helper/JsHelper.php index 7a605b423..e07c5779c 100644 --- a/lib/Cake/View/Helper/JsHelper.php +++ b/lib/Cake/View/Helper/JsHelper.php @@ -19,7 +19,7 @@ */ App::uses('AppHelper', 'View/Helper'); -App::uses('Multibyte', 'Core'); +App::uses('Multibyte', 'I18n'); /** * Javascript Generator helper class for easy use of JavaScript. diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 11b04c0a2..1d836ae70 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -26,7 +26,7 @@ */ App::uses('AppHelper', 'View/Helper'); App::uses('HtmlHelper', 'Helper'); -App::uses('Multibyte', 'Utility'); +App::uses('Multibyte', 'I18n'); /** * Text helper library. diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index ca935acde..1b1fbc5a5 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -469,9 +469,7 @@ if (!function_exists('sortByKey')) { if (!$singular) { return; } - if (!class_exists('I18n')) { - App::import('Core', 'i18n'); - } + App::uses('I18n', 'I18n'); return I18n::translate($singular); } @@ -489,9 +487,7 @@ if (!function_exists('sortByKey')) { if (!$singular) { return; } - if (!class_exists('I18n')) { - App::import('Core', 'i18n'); - } + App::uses('I18n', 'I18n'); return I18n::translate($singular, $plural, null, 6, $count); } @@ -507,9 +503,7 @@ if (!function_exists('sortByKey')) { if (!$msg) { return; } - if (!class_exists('I18n')) { - App::import('Core', 'i18n'); - } + App::uses('I18n', 'I18n'); return I18n::translate($msg, null, $domain); } @@ -529,9 +523,7 @@ if (!function_exists('sortByKey')) { if (!$singular) { return; } - if (!class_exists('I18n')) { - App::import('Core', 'i18n'); - } + App::uses('I18n', 'I18n'); return I18n::translate($singular, $plural, $domain, 6, $count); } @@ -562,9 +554,7 @@ if (!function_exists('sortByKey')) { if (!$msg) { return; } - if (!class_exists('I18n')) { - App::import('Core', 'i18n'); - } + App::uses('I18n', 'I18n'); return I18n::translate($msg, null, $domain, $category); } @@ -599,9 +589,7 @@ if (!function_exists('sortByKey')) { if (!$singular) { return; } - if (!class_exists('I18n')) { - App::import('Core', 'i18n'); - } + App::uses('I18n', 'I18n'); return I18n::translate($singular, $plural, $domain, $category, $count); } @@ -628,9 +616,7 @@ if (!function_exists('sortByKey')) { if (!$msg) { return; } - if (!class_exists('I18n')) { - App::import('Core', 'i18n'); - } + App::uses('I18n', 'I18n'); return I18n::translate($msg, null, null, $category); } From ff8b1a10413c34781a52e2a6fa1b0d6df6569fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 13:50:26 -0430 Subject: [PATCH 022/668] Stating to move loggers to the new folder --- lib/Cake/Error/ErrorHandler.php | 7 +------ lib/Cake/I18n/I18n.php | 4 ++-- cake/libs/cake_log.php => lib/Cake/Log/CakeLog.php | 0 .../log/file_log.php => lib/Cake/Log/Engine/FileLog.php | 0 4 files changed, 3 insertions(+), 8 deletions(-) rename cake/libs/cake_log.php => lib/Cake/Log/CakeLog.php (100%) rename cake/libs/log/file_log.php => lib/Cake/Log/Engine/FileLog.php (100%) diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 732b6328d..7dcdb6931 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -21,6 +21,7 @@ */ App::uses('Debugger', 'Utility'); +App::uses('CakeLog', 'Log'); /** * @@ -109,9 +110,6 @@ class ErrorHandler { App::import('Core', 'error/ExceptionRenderer'); $config = Configure::read('Exception'); if (!empty($config['log'])) { - if (!class_exists('CakeLog')) { - require LIBS . 'cake_log.php'; - } CakeLog::write(LOG_ERR, '[' . get_class($exception) . '] ' . $exception->getMessage()); } if ($config['renderer'] !== 'ExceptionRenderer') { @@ -158,9 +156,6 @@ 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'])) { $trace = Debugger::trace(array('start' => 1, 'format' => 'log')); diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index bab553d1a..b85d9b75b 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -21,8 +21,8 @@ /** * Included libraries. */ -App::uses('L10n', 'Core'); -App::uses('Multibyte', 'Core'); +App::uses('L10n', 'I18n'); +App::uses('Multibyte', 'I18n'); /** * I18n handles translation of Text and time format strings. diff --git a/cake/libs/cake_log.php b/lib/Cake/Log/CakeLog.php similarity index 100% rename from cake/libs/cake_log.php rename to lib/Cake/Log/CakeLog.php diff --git a/cake/libs/log/file_log.php b/lib/Cake/Log/Engine/FileLog.php similarity index 100% rename from cake/libs/log/file_log.php rename to lib/Cake/Log/Engine/FileLog.php From 80452397b6a65619b7d6d43914e5b1d546f25f00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 13:56:26 -0430 Subject: [PATCH 023/668] Changing the way loggers are loaded, this will probable need some changes on userland --- lib/Cake/Log/CakeLog.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/Cake/Log/CakeLog.php b/lib/Cake/Log/CakeLog.php index f1c5b32cf..f09f9c79b 100644 --- a/lib/Cake/Log/CakeLog.php +++ b/lib/Cake/Log/CakeLog.php @@ -124,15 +124,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 Exception(sprintf(__('Could not load class %s'), $loggerName)); } @@ -165,9 +159,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)); } From e3f85ccda895e49e6a642f4256a365a7d45b468f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 14:06:30 -0430 Subject: [PATCH 024/668] loading the ExceptionRenderer --- lib/Cake/Error/ErrorHandler.php | 2 +- .../Cake/Error/ExceptionRenderer.php | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename cake/libs/error/exception_renderer.php => lib/Cake/Error/ExceptionRenderer.php (100%) diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 7dcdb6931..5124136c2 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -22,6 +22,7 @@ App::uses('Debugger', 'Utility'); App::uses('CakeLog', 'Log'); +App::uses('ExceptionRenderer', 'Error'); /** * @@ -107,7 +108,6 @@ 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'])) { CakeLog::write(LOG_ERR, '[' . get_class($exception) . '] ' . $exception->getMessage()); diff --git a/cake/libs/error/exception_renderer.php b/lib/Cake/Error/ExceptionRenderer.php similarity index 100% rename from cake/libs/error/exception_renderer.php rename to lib/Cake/Error/ExceptionRenderer.php From e425b68a867cbd9a4532bd7c4677131ae6155ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 15:11:15 -0430 Subject: [PATCH 025/668] Loading the CakeErrorController --- .../Cake/Controller/CakeErrorController.php | 0 lib/Cake/Error/ExceptionRenderer.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename cake/libs/controller/cake_error_controller.php => lib/Cake/Controller/CakeErrorController.php (100%) 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/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 0d6c71b83..1ea26c502 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -141,7 +141,7 @@ class ExceptionRenderer { */ protected function _getController($exception) { static $__previousError = null; - App::import('Controller', 'CakeError'); + App::uses('CakeErrorController', 'Controller'); if ($__previousError != $exception) { $__previousError = $exception; From 377cbc546b1f204f5b8070f22ef8f367be97acdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 22:06:53 -0430 Subject: [PATCH 026/668] Fixing some errors in loading view classes --- .../Cake/Controller/AppController.php | 0 lib/Cake/Core/App.php | 2 +- lib/Cake/Core/Object.php | 2 ++ lib/Cake/View/Helper/PaginatorHelper.php | 4 +--- 4 files changed, 4 insertions(+), 4 deletions(-) rename cake/libs/controller/app_controller.php => lib/Cake/Controller/AppController.php (100%) diff --git a/cake/libs/controller/app_controller.php b/lib/Cake/Controller/AppController.php similarity index 100% rename from cake/libs/controller/app_controller.php rename to lib/Cake/Controller/AppController.php diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 4242a47d9..eb7d0319f 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -609,7 +609,7 @@ class App { } if (empty(self::$__paths)) { - //self::$__paths = Cache::read('dir_map', '_cake_core_'); + self::$__paths = Cache::read('dir_map', '_cake_core_'); } foreach (self::$search as $path) { diff --git a/lib/Cake/Core/Object.php b/lib/Cake/Core/Object.php index 0f1d49030..e1f232728 100644 --- a/lib/Cake/Core/Object.php +++ b/lib/Cake/Core/Object.php @@ -21,6 +21,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. * diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index dca0562eb..7d19d4753 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -96,9 +96,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 Exception(sprintf( From 02495188ef6203a5f2cfc84f945e029308f11ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 4 Dec 2010 22:59:55 -0430 Subject: [PATCH 027/668] Moving the pages controller --- .../Cake/Controller/PagesController.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cake/libs/controller/pages_controller.php => lib/Cake/Controller/PagesController.php (100%) diff --git a/cake/libs/controller/pages_controller.php b/lib/Cake/Controller/PagesController.php similarity index 100% rename from cake/libs/controller/pages_controller.php rename to lib/Cake/Controller/PagesController.php From fcd23b09789b7daab393e2346a0b50c418c18c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 5 Dec 2010 10:54:42 -0430 Subject: [PATCH 028/668] Starting to change the class loading for app classes --- lib/Cake/Controller/PagesController.php | 2 + lib/Cake/Core/App.php | 62 ++++++++++--------- .../Cake/Model/AppModel.php | 0 lib/Cake/Routing/Dispatcher.php | 12 ++-- lib/Cake/Utility/ClassRegistry.php | 13 ++-- lib/Cake/View/View.php | 2 +- lib/Cake/bootstrap.php | 2 + 7 files changed, 51 insertions(+), 42 deletions(-) rename cake/libs/model/app_model.php => lib/Cake/Model/AppModel.php (100%) diff --git a/lib/Cake/Controller/PagesController.php b/lib/Cake/Controller/PagesController.php index bc7a380e7..60d9e0290 100644 --- a/lib/Cake/Controller/PagesController.php +++ b/lib/Cake/Controller/PagesController.php @@ -20,6 +20,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('AppController', 'Controller'); + /** * Static content controller * diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index eb7d0319f..b85aa9921 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -207,6 +207,12 @@ class App { */ private static $__classMap = array(); +/** + * Holds the possible paths for each package name + * + */ + private static $__packages = array(); + /** * Used to read information stored path * @@ -218,10 +224,10 @@ class App { * @return string array */ public static function path($type) { - if (!isset(self::${$type})) { + if (!isset(self::$__packages[$type])) { return array(); } - return self::${$type}; + return self::$__packages[$type]; } /** @@ -234,14 +240,14 @@ class App { */ 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), + 'Model' => array(MODELS), + 'Model/Behavior' => array(BEHAVIORS), + 'Datasource' => array(MODELS . 'datasources'), + 'Controller' => array(CONTROLLERS), + 'Controller/Component' => array(COMPONENTS), 'libs' => array(APPLIBS), - 'views' => array(VIEWS), - 'helpers' => array(HELPERS), + 'View' => array(VIEWS), + 'View/Helper' => array(HELPERS), 'locales' => array(APP . 'locale' . DS), 'shells' => array( APP . 'console' . DS . 'shells' . DS, @@ -254,7 +260,7 @@ class App { if ($reset == true) { foreach ($paths as $type => $new) { - self::${$type} = (array)$new; + self::$__packages[$type] = (array)$new; } return $paths; } @@ -263,27 +269,19 @@ class App { $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(self::$__packages[$type]) || empty($paths)) { + self::$__packages[$type] = $default; } if (!empty($paths[$type])) { $path = array_flip(array_flip(array_merge( - (array)$paths[$type], self::${$type}, $merge + (array)$paths[$type], self::$__packages[$type], $merge ))); - self::${$type} = array_values($path); + self::$__packages[$type] = array_values($path); } else { - $path = array_flip(array_flip(array_merge(self::${$type}, $merge))); - self::${$type} = array_values($path); + $path = array_flip(array_flip(self::$__packages[$type])); + self::$__packages[$type] = array_values($path); } } } @@ -442,9 +440,15 @@ class App { public static function load($className) { if (isset(self::$__classMap[$className])) { - $file = LIBS . self::$__classMap[$className] . DS . $className . '.php'; - if (file_exists($file)) { - return include $file; + $package = self::$__classMap[$className]; + $paths = self::path($package); + $paths[] = LIBS . self::$__classMap[$className] . DS; + + foreach ($paths as $path) { + $file = $path . $className . '.php'; + if (file_exists($file)) { + return include $file; + } } } return false; @@ -900,6 +904,4 @@ class App { Cache::write('object_map', self::$__objects, '_cake_core_'); } } -} - -spl_autoload_register(array('App', 'load')); \ No newline at end of file +} \ No newline at end of file diff --git a/cake/libs/model/app_model.php b/lib/Cake/Model/AppModel.php similarity index 100% rename from cake/libs/model/app_model.php rename to lib/Cake/Model/AppModel.php diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index 1fd36319c..251b56f6e 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -223,10 +223,7 @@ class Dispatcher { if (!$ctrlClass) { return false; } - $ctrlClass .= 'Controller'; - if (class_exists($ctrlClass)) { - return new $ctrlClass($request); - } + return new $ctrlClass($request); } /** @@ -245,8 +242,11 @@ 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($class, $pluginPath . 'Controller'); + if (class_exists($class)) { + return $class; } } return false; diff --git a/lib/Cake/Utility/ClassRegistry.php b/lib/Cake/Utility/ClassRegistry.php index cc2ebeb3b..a80abdc98 100644 --- a/lib/Cake/Utility/ClassRegistry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -134,14 +134,17 @@ class ClassRegistry { return $model; } - if (class_exists($class) || App::import($type, $pluginPath . $class)) { + App::uses('Model', 'Model'); + App::uses('AppModel', 'Model'); + App::uses($class, $pluginPath . $type); + if (class_exists($class)) { ${$class} = new $class($settings); } elseif ($type === 'Model') { - if ($plugin && class_exists($plugin . 'AppModel')) { - $appModel = $plugin . 'AppModel'; - } else { + //if ($plugin && class_exists($plugin . 'AppModel')) { + // $appModel = $plugin . 'AppModel'; + //} else { $appModel = 'AppModel'; - } + //} $settings['name'] = $class; ${$class} = new $appModel($settings); } diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index 9ca29b464..c080ccc65 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -799,7 +799,7 @@ class View extends Object { return $this->__paths; } $paths = array(); - $viewPaths = App::path('views'); + $viewPaths = App::path('View'); $corePaths = array_flip(App::core('views')); if (!empty($plugin)) { diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index 1e649440e..f7ca698e3 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -222,6 +222,8 @@ require LIBS . 'basics.php'; require LIBS . 'Core' . DS .'App.php'; require LIBS . 'Error' . DS . 'exceptions.php'; +spl_autoload_register(array('App', 'load')); + App::uses('ErrorHandler', 'Error'); App::uses('Configure', 'Core'); App::uses('Cache', 'Cache'); From 0596f5a2453b1d3de72856c5c0e8dc04e71ffcbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 5 Dec 2010 12:00:36 -0430 Subject: [PATCH 029/668] Adding cache support for class loader --- lib/Cake/Core/App.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index b85aa9921..fb4bdb9b3 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -440,6 +440,11 @@ class App { public static function load($className) { if (isset(self::$__classMap[$className])) { + + if ($file = self::__mapped($className)) { + return include $file; + } + $package = self::$__classMap[$className]; $paths = self::path($package); $paths[] = LIBS . self::$__classMap[$className] . DS; @@ -447,6 +452,7 @@ class App { foreach ($paths as $path) { $file = $path . $className . '.php'; if (file_exists($file)) { + self::__map($file, $className); return include $file; } } @@ -678,16 +684,15 @@ class App { * * @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) { + private static function __map($file, $name, $plugin = null) { if ($plugin) { - self::$__map['Plugin'][$plugin][$type][$name] = $file; + self::$__map['Plugin'][$plugin][$name] = $file; } else { - self::$__map[$type][$name] = $file; + self::$__map[$name] = $file; } } @@ -695,21 +700,20 @@ class App { * 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) { + private static function __mapped($name, $plugin = null) { if ($plugin) { - if (isset(self::$__map['Plugin'][$plugin][$type]) && isset(self::$__map['Plugin'][$plugin][$type][$name])) { - return self::$__map['Plugin'][$plugin][$type][$name]; + if (isset(self::$__map['Plugin'][$plugin][$name])) { + return self::$__map['Plugin'][$plugin][$name]; } return false; } - if (isset(self::$__map[$type]) && isset(self::$__map[$type][$name])) { - return self::$__map[$type][$name]; + if (isset(self::$__map[$name])) { + return self::$__map[$name]; } return false; } @@ -897,9 +901,6 @@ class App { */ 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_'); } From c542ac20c9940e147e3bd02278e26b8f4c9a75ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 5 Dec 2010 13:07:01 -0430 Subject: [PATCH 030/668] Moving core view to the new folder and allowing the view class to find those views --- lib/Cake/Core/App.php | 4 ++-- lib/Cake/Utility/ClassRegistry.php | 8 ++++---- .../view/scaffold.php => lib/Cake/View/ScaffoldView.php | 0 lib/Cake/View/View.php | 3 ++- .../Cake/View}/elements/email/html/default.ctp | 0 .../Cake/View}/elements/email/text/default.ctp | 0 .../Cake/View}/elements/exception_stack_trace.ctp | 0 {cake/libs/view => lib/Cake/View}/elements/sql_dump.ctp | 0 {cake/libs/view => lib/Cake/View}/errors/error400.ctp | 0 {cake/libs/view => lib/Cake/View}/errors/error500.ctp | 0 .../libs/view => lib/Cake/View}/errors/missing_action.ctp | 0 .../Cake/View}/errors/missing_behavior_class.ctp | 0 .../Cake/View}/errors/missing_behavior_file.ctp | 0 .../Cake/View}/errors/missing_component_class.ctp | 0 .../Cake/View}/errors/missing_component_file.ctp | 0 .../view => lib/Cake/View}/errors/missing_connection.ctp | 0 .../view => lib/Cake/View}/errors/missing_controller.ctp | 0 .../view => lib/Cake/View}/errors/missing_database.ctp | 0 .../Cake/View}/errors/missing_helper_class.ctp | 0 .../view => lib/Cake/View}/errors/missing_helper_file.ctp | 0 .../libs/view => lib/Cake/View}/errors/missing_layout.ctp | 0 .../libs/view => lib/Cake/View}/errors/missing_table.ctp | 0 {cake/libs/view => lib/Cake/View}/errors/missing_view.ctp | 0 .../libs/view => lib/Cake/View}/errors/private_action.ctp | 0 .../libs/view => lib/Cake/View}/errors/scaffold_error.ctp | 0 {cake/libs/view => lib/Cake/View}/layouts/ajax.ctp | 0 {cake/libs/view => lib/Cake/View}/layouts/default.ctp | 0 .../view => lib/Cake/View}/layouts/email/html/default.ctp | 0 .../view => lib/Cake/View}/layouts/email/text/default.ctp | 0 {cake/libs/view => lib/Cake/View}/layouts/flash.ctp | 0 {cake/libs/view => lib/Cake/View}/layouts/js/default.ctp | 0 {cake/libs/view => lib/Cake/View}/layouts/rss/default.ctp | 0 {cake/libs/view => lib/Cake/View}/layouts/xml/default.ctp | 0 {cake/libs/view => lib/Cake/View}/pages/home.ctp | 0 {cake/libs/view => lib/Cake/View}/scaffolds/edit.ctp | 0 {cake/libs/view => lib/Cake/View}/scaffolds/index.ctp | 0 {cake/libs/view => lib/Cake/View}/scaffolds/view.ctp | 0 37 files changed, 8 insertions(+), 7 deletions(-) rename cake/libs/view/scaffold.php => lib/Cake/View/ScaffoldView.php (100%) rename {cake/libs/view => lib/Cake/View}/elements/email/html/default.ctp (100%) rename {cake/libs/view => lib/Cake/View}/elements/email/text/default.ctp (100%) rename {cake/libs/view => lib/Cake/View}/elements/exception_stack_trace.ctp (100%) rename {cake/libs/view => lib/Cake/View}/elements/sql_dump.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/error400.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/error500.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_action.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_behavior_class.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_behavior_file.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_component_class.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_component_file.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_connection.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_controller.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_database.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_helper_class.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_helper_file.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_layout.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_table.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_view.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/private_action.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/scaffold_error.ctp (100%) rename {cake/libs/view => lib/Cake/View}/layouts/ajax.ctp (100%) rename {cake/libs/view => lib/Cake/View}/layouts/default.ctp (100%) rename {cake/libs/view => lib/Cake/View}/layouts/email/html/default.ctp (100%) rename {cake/libs/view => lib/Cake/View}/layouts/email/text/default.ctp (100%) rename {cake/libs/view => lib/Cake/View}/layouts/flash.ctp (100%) rename {cake/libs/view => lib/Cake/View}/layouts/js/default.ctp (100%) rename {cake/libs/view => lib/Cake/View}/layouts/rss/default.ctp (100%) rename {cake/libs/view => lib/Cake/View}/layouts/xml/default.ctp (100%) rename {cake/libs/view => lib/Cake/View}/pages/home.ctp (100%) rename {cake/libs/view => lib/Cake/View}/scaffolds/edit.ctp (100%) rename {cake/libs/view => lib/Cake/View}/scaffolds/index.ctp (100%) rename {cake/libs/view => lib/Cake/View}/scaffolds/view.ctp (100%) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index fb4bdb9b3..6f04c7798 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -330,7 +330,7 @@ class App { static $paths = false; if (!$paths) { $paths = array(); - $libs = dirname(__FILE__) . DS; + $libs = LIBS; $cake = dirname($libs) . DS; $path = dirname($cake) . DS; @@ -341,7 +341,7 @@ class App { $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['views'][] = $libs . 'View' . DS; $paths['helpers'][] = $libs . 'view' . DS . 'helpers' . DS; $paths['plugins'][] = $path . 'plugins' . DS; $paths['vendors'][] = $path . 'vendors' . DS; diff --git a/lib/Cake/Utility/ClassRegistry.php b/lib/Cake/Utility/ClassRegistry.php index a80abdc98..9762462ea 100644 --- a/lib/Cake/Utility/ClassRegistry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -140,11 +140,11 @@ class ClassRegistry { if (class_exists($class)) { ${$class} = new $class($settings); } elseif ($type === 'Model') { - //if ($plugin && class_exists($plugin . 'AppModel')) { - // $appModel = $plugin . 'AppModel'; - //} else { + if ($plugin && class_exists($plugin . 'AppModel')) { + $appModel = $plugin . 'AppModel'; + } else { $appModel = 'AppModel'; - //} + } $settings['name'] = $class; ${$class} = new $appModel($settings); } diff --git a/cake/libs/view/scaffold.php b/lib/Cake/View/ScaffoldView.php similarity index 100% rename from cake/libs/view/scaffold.php rename to lib/Cake/View/ScaffoldView.php diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index c080ccc65..b0676d666 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -811,7 +811,8 @@ class View extends Object { } $paths[] = App::pluginPath($plugin) . 'views' . DS; } - $this->__paths = array_merge($paths, $viewPaths); + + $this->__paths = array_merge($paths, $viewPaths, array_flip($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_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 100% rename from cake/libs/view/pages/home.ctp rename to lib/Cake/View/pages/home.ctp diff --git a/cake/libs/view/scaffolds/edit.ctp b/lib/Cake/View/scaffolds/edit.ctp similarity index 100% rename from cake/libs/view/scaffolds/edit.ctp rename to lib/Cake/View/scaffolds/edit.ctp diff --git a/cake/libs/view/scaffolds/index.ctp b/lib/Cake/View/scaffolds/index.ctp similarity index 100% rename from cake/libs/view/scaffolds/index.ctp rename to lib/Cake/View/scaffolds/index.ctp diff --git a/cake/libs/view/scaffolds/view.ctp b/lib/Cake/View/scaffolds/view.ctp similarity index 100% rename from cake/libs/view/scaffolds/view.ctp rename to lib/Cake/View/scaffolds/view.ctp From b19b25a78872d6bf06f0eaba28daf4b23972638d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 5 Dec 2010 13:21:28 -0430 Subject: [PATCH 031/668] Moving some spare clases to the corresponding packages --- .../controller/scaffold.php => lib/Cake/Controller/Scaffold.php | 0 cake/libs/cake_socket.php => lib/Cake/Network/CakeSocket.php | 0 cake/libs/http_socket.php => lib/Cake/Network/HttpSocket.php | 0 cake/libs/file.php => lib/Cake/Utility/File.php | 0 cake/libs/magic_db.php => lib/Cake/Utility/MagicDb.php | 0 cake/libs/sanitize.php => lib/Cake/Utility/Sanitize.php | 0 cake/libs/security.php => lib/Cake/Utility/Security.php | 0 cake/libs/validation.php => lib/Cake/Utility/Validation.php | 0 cake/libs/xml.php => lib/Cake/Utility/Xml.php | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename cake/libs/controller/scaffold.php => lib/Cake/Controller/Scaffold.php (100%) rename cake/libs/cake_socket.php => lib/Cake/Network/CakeSocket.php (100%) rename cake/libs/http_socket.php => lib/Cake/Network/HttpSocket.php (100%) rename cake/libs/file.php => lib/Cake/Utility/File.php (100%) rename cake/libs/magic_db.php => lib/Cake/Utility/MagicDb.php (100%) rename cake/libs/sanitize.php => lib/Cake/Utility/Sanitize.php (100%) rename cake/libs/security.php => lib/Cake/Utility/Security.php (100%) rename cake/libs/validation.php => lib/Cake/Utility/Validation.php (100%) rename cake/libs/xml.php => lib/Cake/Utility/Xml.php (100%) diff --git a/cake/libs/controller/scaffold.php b/lib/Cake/Controller/Scaffold.php similarity index 100% rename from cake/libs/controller/scaffold.php rename to lib/Cake/Controller/Scaffold.php diff --git a/cake/libs/cake_socket.php b/lib/Cake/Network/CakeSocket.php similarity index 100% rename from cake/libs/cake_socket.php rename to lib/Cake/Network/CakeSocket.php diff --git a/cake/libs/http_socket.php b/lib/Cake/Network/HttpSocket.php similarity index 100% rename from cake/libs/http_socket.php rename to lib/Cake/Network/HttpSocket.php diff --git a/cake/libs/file.php b/lib/Cake/Utility/File.php similarity index 100% rename from cake/libs/file.php rename to lib/Cake/Utility/File.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/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 100% rename from cake/libs/security.php rename to lib/Cake/Utility/Security.php diff --git a/cake/libs/validation.php b/lib/Cake/Utility/Validation.php similarity index 100% rename from cake/libs/validation.php rename to lib/Cake/Utility/Validation.php 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 From 2fed702c5787efbbfb6f4f918b319deea0bae212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 5 Dec 2010 15:00:02 -0430 Subject: [PATCH 032/668] Moving more model classes to the new package --- cake/libs/model/cake_schema.php => lib/Cake/Model/CakeSchema.php | 0 .../dbo_mssql.php => lib/Cake/Model/Datasource/Database/Mssql.php | 0 .../Cake/Model/Datasource/Database/Oracle.php | 0 .../Cake/Model/Datasource/Database/Postgres.php | 0 .../Cake/Model/Datasource/Database/Sqlite.php | 0 cake/libs/model/db_acl.php => lib/Cake/Model/DbAcl.php | 0 .../model/model_behavior.php => lib/Cake/Model/ModelBehavior.php | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename cake/libs/model/cake_schema.php => lib/Cake/Model/CakeSchema.php (100%) rename cake/libs/model/datasources/dbo/dbo_mssql.php => lib/Cake/Model/Datasource/Database/Mssql.php (100%) rename cake/libs/model/datasources/dbo/dbo_oracle.php => lib/Cake/Model/Datasource/Database/Oracle.php (100%) rename cake/libs/model/datasources/dbo/dbo_postgres.php => lib/Cake/Model/Datasource/Database/Postgres.php (100%) rename cake/libs/model/datasources/dbo/dbo_sqlite.php => lib/Cake/Model/Datasource/Database/Sqlite.php (100%) rename cake/libs/model/db_acl.php => lib/Cake/Model/DbAcl.php (100%) rename cake/libs/model/model_behavior.php => lib/Cake/Model/ModelBehavior.php (100%) diff --git a/cake/libs/model/cake_schema.php b/lib/Cake/Model/CakeSchema.php similarity index 100% rename from cake/libs/model/cake_schema.php rename to lib/Cake/Model/CakeSchema.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_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 100% rename from cake/libs/model/datasources/dbo/dbo_postgres.php rename to lib/Cake/Model/Datasource/Database/Postgres.php diff --git a/cake/libs/model/datasources/dbo/dbo_sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php similarity index 100% rename from cake/libs/model/datasources/dbo/dbo_sqlite.php rename to lib/Cake/Model/Datasource/Database/Sqlite.php diff --git a/cake/libs/model/db_acl.php b/lib/Cake/Model/DbAcl.php similarity index 100% rename from cake/libs/model/db_acl.php rename to lib/Cake/Model/DbAcl.php 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 From 5c0c9841e24ac2283f0c4bf2cd5d4eb44ab601dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 5 Dec 2010 20:38:17 -0430 Subject: [PATCH 033/668] Removing dead code --- lib/Cake/Core/App.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 6f04c7798..2d9003566 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -265,9 +265,6 @@ class App { return $paths; } - $core = self::core(); - $app = array('models' => true, 'controllers' => true, 'helpers' => true); - foreach ($defaults as $type => $default) { if (empty(self::$__packages[$type]) || empty($paths)) { From d311cf237b572d7aed87eb97cc788addfbfafc81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 5 Dec 2010 23:50:05 -0430 Subject: [PATCH 034/668] Moving behaviors --- .../behaviors/acl.php => lib/Cake/Model/Behavior/AclBehavior.php | 0 .../Cake/Model/Behavior/ContainableBehavior.php | 0 .../Cake/Model/Behavior/TranslateBehavior.php | 0 .../tree.php => lib/Cake/Model/Behavior/TreeBehavior.php | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename cake/libs/model/behaviors/acl.php => lib/Cake/Model/Behavior/AclBehavior.php (100%) rename cake/libs/model/behaviors/containable.php => lib/Cake/Model/Behavior/ContainableBehavior.php (100%) rename cake/libs/model/behaviors/translate.php => lib/Cake/Model/Behavior/TranslateBehavior.php (100%) rename cake/libs/model/behaviors/tree.php => lib/Cake/Model/Behavior/TreeBehavior.php (100%) 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 100% rename from cake/libs/model/behaviors/translate.php rename to lib/Cake/Model/Behavior/TranslateBehavior.php 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 From 88a4a6609ed2355b5043150067fee6d364b21a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 6 Dec 2010 00:10:56 -0430 Subject: [PATCH 035/668] Moving the config folder --- cake/config/paths.php | 231 -------------------- {cake/libs => lib/Cake}/config/ini_file.php | 0 2 files changed, 231 deletions(-) delete mode 100644 cake/config/paths.php rename {cake/libs => lib/Cake}/config/ini_file.php (100%) diff --git a/cake/config/paths.php b/cake/config/paths.php deleted file mode 100644 index e8ac21c49..000000000 --- a/cake/config/paths.php +++ /dev/null @@ -1,231 +0,0 @@ - Date: Mon, 6 Dec 2010 09:38:06 -0430 Subject: [PATCH 036/668] A couple of micro-optimizations found using a profileA couple of micro-optimizations found using a profilerr --- lib/Cake/Controller/Controller.php | 11 ++++------- lib/Cake/Model/CakeSession.php | 11 ++++++----- lib/Cake/Utility/Set.php | 9 ++++++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index ed0ac3e6a..7d7c58bb5 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -300,18 +300,15 @@ 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); + if (empty($this->uses)) { + $this->modelClass = Inflector::singularize($this->name); + } $this->modelKey = Inflector::underscore($this->modelClass); $this->Components = new ComponentCollection(); diff --git a/lib/Cake/Model/CakeSession.php b/lib/Cake/Model/CakeSession.php index 973a655af..fd67272ad 100644 --- a/lib/Cake/Model/CakeSession.php +++ b/lib/Cake/Model/CakeSession.php @@ -345,11 +345,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']); } /** @@ -672,14 +673,14 @@ class CakeSession { * @return void */ protected static function _checkValid() { - 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/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 95b499161..37a1836d4 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -583,12 +583,14 @@ class Set { return $data; } - if (!is_array($path)) { + if (is_string($path) && strpos($path, '{') !== false) { $path = String::tokenize($path, '.', '{', '}'); + } else { + $path = explode('.', $path); } $tmp = array(); - if (!is_array($path) || empty($path)) { + if (empty($path)) { return null; } @@ -662,11 +664,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])) { From 2ce2ea222cac122b055c285868df11de422efc37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 6 Dec 2010 09:44:43 -0430 Subject: [PATCH 037/668] Moving config readers to their new package --- .../Cake/Configure/IniReader.php | 0 .../Cake/Configure/PhpReader.php | 0 lib/Cake/config/ini_file.php | 101 ------------------ 3 files changed, 101 deletions(-) rename cake/libs/config/ini_reader.php => lib/Cake/Configure/IniReader.php (100%) rename cake/libs/config/php_reader.php => lib/Cake/Configure/PhpReader.php (100%) delete mode 100644 lib/Cake/config/ini_file.php diff --git a/cake/libs/config/ini_reader.php b/lib/Cake/Configure/IniReader.php similarity index 100% rename from cake/libs/config/ini_reader.php rename to lib/Cake/Configure/IniReader.php diff --git a/cake/libs/config/php_reader.php b/lib/Cake/Configure/PhpReader.php similarity index 100% rename from cake/libs/config/php_reader.php rename to lib/Cake/Configure/PhpReader.php diff --git a/lib/Cake/config/ini_file.php b/lib/Cake/config/ini_file.php deleted file mode 100644 index 722dbcb08..000000000 --- a/lib/Cake/config/ini_file.php +++ /dev/null @@ -1,101 +0,0 @@ -_values = $contents[$section]; - } else { - $this->_values = $contents; - } - } - -/** - * Get the contents of the ini file as a plain array. - * - * @return array - */ - public function asArray() { - return $this->_values; - } - -/** - * Part of ArrayAccess implementation. - * - * @param string $name - */ - public function offsetExists($name) { - return isset($this->_values[$name]); - } - -/** - * Part of ArrayAccess implementation. - * - * @param string $name - */ - public function offsetGet($name) { - if (!isset($this->_values[$name])) { - return null; - } - return $this->_values[$name]; - } - -/** - * Part of ArrayAccess implementation. - * - * @param string $name - */ - public function offsetSet($name, $value) { - throw new LogicException('You cannot modify an IniFile parse result.'); - } - -/** - * Part of ArrayAccess implementation. - * - * @param string $name - */ - public function offsetUnset($name) { - unset($this->_values[$name]); - } -} \ No newline at end of file From 66744c68b03cf19cefbb55e2baa0c1a53b9181c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 6 Dec 2010 22:47:43 -0430 Subject: [PATCH 038/668] Making ConnectionManager an static object instead of a singleton --- lib/Cake/Model/ConnectionManager.php | 109 ++++++++++++++------------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index 9e435902e..de3a4e90c 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -36,7 +36,7 @@ class ConnectionManager { * @var DATABASE_CONFIG * @access public */ - public $config = null; + public static $config = null; /** * Holds instances DataSource objects @@ -44,7 +44,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 @@ -52,33 +52,27 @@ 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(); + self::_getConnectionObjects(); } - } - -/** - * 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,32 +81,33 @@ class ConnectionManager { * @param string $name The name of the DataSource, as defined in app/config/database.php * @return object Instance */ - public static function &getDataSource($name) { - $_this = ConnectionManager::getInstance(); + public static function getDataSource($name) { + if (empty(self::$_init)) { + self::init(); + } - if (!empty($_this->_dataSources[$name])) { - $return = $_this->_dataSources[$name]; + if (!empty(self::$_dataSources[$name])) { + $return = self::$_dataSources[$name]; return $return; } - if (empty($_this->_connectionsEnum[$name])) { + if (empty(self::$_connectionsEnum[$name])) { trigger_error(__("ConnectionManager::getDataSource - Non-existent data source %s", $name), E_USER_ERROR); $null = null; return $null; } - $conn = $_this->_connectionsEnum[$name]; + $conn = self::$_connectionsEnum[$name]; $class = $conn['classname']; - if ($_this->loadDataSource($name) === null) { + if (self::loadDataSource($name) === null) { trigger_error(__("ConnectionManager::getDataSource - Could not load class %s", $class), E_USER_ERROR); $null = null; return $null; } - $_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 $return; + return self::$_dataSources[$name]; } /** @@ -121,8 +116,10 @@ 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); } /** @@ -135,8 +132,10 @@ class ConnectionManager { * in the ConnectionManager. */ public static function getSourceName(&$source) { - $_this = ConnectionManager::getInstance(); - foreach ($_this->_dataSources as $name => $ds) { + if (empty(self::$_init)) { + self::init(); + } + foreach (self::$_dataSources as $name => $ds) { if ($ds == $source) { return $name; } @@ -153,12 +152,14 @@ class ConnectionManager { * @return boolean True on success, null on failure or false if the class is already loaded */ 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'], false)) { @@ -188,8 +189,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 self::$_connectionsEnum; } /** @@ -199,16 +202,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; } @@ -217,12 +222,12 @@ class ConnectionManager { * * @return void */ - protected function _getConnectionObjects() { - $connections = get_object_vars($this->config); + protected static function _getConnectionObjects() { + $connections = get_object_vars(self::$config); if ($connections != null) { foreach ($connections as $name => $config) { - $this->_connectionsEnum[$name] = $this->__connectionData($config); + self::$_connectionsEnum[$name] = self::_connectionData($config); } } else { throw new MissingConnectionException(array('class' => 'ConnectionManager')); @@ -234,7 +239,7 @@ class ConnectionManager { * * @return array An indexed array with: filename, classname, plugin and parent */ - private function __connectionData($config) { + private static function _connectionData($config) { $package = $classname = $plugin = null; list($plugin, $classname) = pluginSplit($config['datasource']); @@ -249,7 +254,7 @@ class ConnectionManager { * Destructor. * */ - function __destruct() { + public static function shutdown() { if (Configure::read('Session.defaults') == 'database' && function_exists('session_write_close')) { session_write_close(); } From 513eb5342629e9a8767192ed143a0266c6888b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 6 Dec 2010 22:48:30 -0430 Subject: [PATCH 039/668] Fixing package location in DboSource --- lib/Cake/Model/Datasource/DboSource.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 339d4d05f..a11f4fcd8 100755 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('String', 'Core'); +App::uses('String', 'Utility'); /** * DboSource From 1d67d1611c5eddb471ac7bcf163618560c03a907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 6 Dec 2010 22:49:15 -0430 Subject: [PATCH 040/668] Micro optimizations in Helper class, as those functions are calles very often the may sum up some milliseconds --- lib/Cake/View/Helper.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index 389b3845a..25f62f2be 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -257,11 +257,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)) { @@ -347,18 +345,19 @@ class Helper extends Object { * @return string Composed attributes. */ public function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { - if (is_array($options)) { - $options = array_merge(array('escape' => true), $options); + if (!is_string($options)) { + $options = $options + array('escape' => true); if (!is_array($exclude)) { $exclude = array(); } - $filtered = array_diff_key($options, array_merge(array_flip($exclude), array('escape' => true))); + + $exclude = array('escape' => true) + array_flip($exclude); $escape = $options['escape']; $attributes = array(); - foreach ($filtered as $key => $value) { - if ($value !== false && $value !== null) { + foreach ($options as $key => $value) { + if (!isset($exclude[$key]) && $value !== false && $value !== null) { $attributes[] = $this->__formatAttribute($key, $value, $escape); } } @@ -381,13 +380,20 @@ class Helper extends Object { function __formatAttribute($key, $value, $escape = true) { $attribute = ''; $attributeFormat = '%s="%s"'; - $minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', - 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize'); + static $minimizedAttributes = array(); + if (empty($minimizedAttributes)) { + $minimizedAttributes = array_flip(array( + 'compact', 'checked', 'declare', 'readonly', 'disabled', + 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', + 'multiple', 'noresize' + )); + } + if (is_array($value)) { $value = ''; } - if (in_array($key, $minimizedAttributes)) { + if (isset($minimizedAttributes[$key])) { if ($value === 1 || $value === true || $value === 'true' || $value === '1' || $value == $key) { $attribute = sprintf($attributeFormat, $key, $key); } From c431ddd22c973c1b797df8edf5e98de2e59578cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 6 Dec 2010 22:57:09 -0430 Subject: [PATCH 041/668] Refactoring Dispatcher::_isPrivate to directly check for controller methods, doing in in the controller could be unnecessary --- lib/Cake/Controller/Controller.php | 7 ++----- lib/Cake/Routing/Dispatcher.php | 4 ++-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 2580f53d0..c423a9227 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -308,15 +308,12 @@ class Controller extends Object { } if (empty($this->uses)) { $this->modelClass = Inflector::singularize($this->name); + } else { + $this->modelClass = current($this->uses); } $this->modelKey = Inflector::underscore($this->modelClass); $this->Components = new ComponentCollection(); - $childMethods = get_class_methods($this); - $parentMethods = get_class_methods('Controller'); - - $this->methods = array_diff($childMethods, $parentMethods); - if ($request instanceof CakeRequest) { $this->_setRequest($request); } diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index 251b56f6e..4f56056c8 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -143,7 +143,7 @@ class Dispatcher { $privateAction = in_array($prefix, $prefixes); } } - return $privateAction; + return $privateAction && ! in_array($request->params['action'], get_class_methods('Controller')); } /** @@ -160,7 +160,7 @@ class Dispatcher { $controller->constructClasses(); $controller->startupProcess(); - $methods = array_flip($controller->methods); + $methods = array_flip(get_class_methods($controller)); if (!isset($methods[$request->params['action']])) { if ($controller->scaffold !== false) { From 6de52f795f6d07b330fc097e7613c70febf9a3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 6 Dec 2010 23:15:18 -0430 Subject: [PATCH 042/668] Completing the round of micro optimization, it was fun while it lasted --- lib/Cake/Network/CakeRequest.php | 2 +- lib/Cake/Routing/Dispatcher.php | 3 ++- lib/Cake/Utility/Set.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 67003f142..5ac7a4922 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -16,7 +16,7 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Set', 'Core'); +App::uses('Set', 'Utility'); /** * A class that helps wrap Request information and particulars about a single request. diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index 4f56056c8..b52123a6d 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -143,7 +143,8 @@ class Dispatcher { $privateAction = in_array($prefix, $prefixes); } } - return $privateAction && ! in_array($request->params['action'], get_class_methods('Controller')); + + return $privateAction || in_array($request->params['action'], get_class_methods('Controller')); } /** diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 37a1836d4..ff2af8519 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -46,7 +46,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])) { $r[$key] = Set::merge($r[$key], $val); } elseif (is_int($key)) { $r[] = $val; From 9e6475400564d86bfe4dd0dc7a7213dc092f5cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 00:00:20 -0430 Subject: [PATCH 043/668] Adding check to no overwrite cache if it has not been modified --- lib/Cake/Core/App.php | 9 ++++++++- .../Cake/Model/Datasource/Session/CacheSession.php | 0 .../Cake/Model/Datasource/Session/DatabaseSession.php | 0 .../Cake/Routing/Route/PluginShortRoute.php | 0 .../Cake/Routing/Route/RedirectRoute.php | 0 5 files changed, 8 insertions(+), 1 deletion(-) rename cake/libs/session/cache_session.php => lib/Cake/Model/Datasource/Session/CacheSession.php (100%) rename cake/libs/session/database_session.php => lib/Cake/Model/Datasource/Session/DatabaseSession.php (100%) rename cake/libs/route/plugin_short_route.php => lib/Cake/Routing/Route/PluginShortRoute.php (100%) rename cake/libs/route/redirect_route.php => lib/Cake/Routing/Route/RedirectRoute.php (100%) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 2d9003566..91b2e3f1d 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -213,6 +213,12 @@ class App { */ private static $__packages = array(); +/** + * Inicates whether the cache should be stored again because of an addition to it + * + */ + private static $_cacheChange = false; + /** * Used to read information stored path * @@ -691,6 +697,7 @@ class App { } else { self::$__map[$name] = $file; } + self::$_cacheChange = true; } /** @@ -897,7 +904,7 @@ class App { * @return void */ public static function shutdown() { - if (self::$__cache) { + if (self::$__cache && self::$_cacheChange) { Cache::write('file_map', array_filter(self::$__map), '_cake_core_'); Cache::write('object_map', self::$__objects, '_cake_core_'); } 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/route/plugin_short_route.php b/lib/Cake/Routing/Route/PluginShortRoute.php similarity index 100% rename from cake/libs/route/plugin_short_route.php rename to lib/Cake/Routing/Route/PluginShortRoute.php diff --git a/cake/libs/route/redirect_route.php b/lib/Cake/Routing/Route/RedirectRoute.php similarity index 100% rename from cake/libs/route/redirect_route.php rename to lib/Cake/Routing/Route/RedirectRoute.php From 0732552739be6f029a017a26de3b6fc7a3e07982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 00:02:42 -0430 Subject: [PATCH 044/668] Movig CakeSession to a better suited package --- lib/Cake/Controller/Component/SessionComponent.php | 2 +- lib/Cake/Model/{ => Datasource}/CakeSession.php | 0 lib/Cake/View/Helper/SessionHelper.php | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename lib/Cake/Model/{ => Datasource}/CakeSession.php (100%) diff --git a/lib/Cake/Controller/Component/SessionComponent.php b/lib/Cake/Controller/Component/SessionComponent.php index 855cbcd20..5e326d5e8 100644 --- a/lib/Cake/Controller/Component/SessionComponent.php +++ b/lib/Cake/Controller/Component/SessionComponent.php @@ -18,7 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('CakeSession', 'Model'); +App::uses('CakeSession', 'Model/Datasource'); /** * Session Component. diff --git a/lib/Cake/Model/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php similarity index 100% rename from lib/Cake/Model/CakeSession.php rename to lib/Cake/Model/Datasource/CakeSession.php diff --git a/lib/Cake/View/Helper/SessionHelper.php b/lib/Cake/View/Helper/SessionHelper.php index 997e2c422..67d09f056 100644 --- a/lib/Cake/View/Helper/SessionHelper.php +++ b/lib/Cake/View/Helper/SessionHelper.php @@ -19,7 +19,7 @@ */ App::uses('AppHelper', 'View/Helper'); -App::uses('CakeSession', 'Model'); +App::uses('CakeSession', 'Model/Datasource'); /** * Session Helper. From 322093a0220167f249e916f11826a39393a748d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 00:17:50 -0430 Subject: [PATCH 045/668] Separating cache storing in App shutdown --- lib/Cake/Core/App.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 91b2e3f1d..1410637ba 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -214,11 +214,17 @@ class App { private static $__packages = array(); /** - * Inicates whether the cache should be stored again because of an addition to it + * 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 * @@ -420,6 +426,7 @@ class App { self::$__cache = true; } self::$__objects[$name] = $objects; + self::$_objectCacheChange = true; } return self::$__objects[$name]; @@ -906,6 +913,8 @@ class App { 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_'); } } From 1c0a4c9e0a5181a1f7b9a3e551a62b73b7a3811c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 00:47:53 -0430 Subject: [PATCH 046/668] Starting to move console classes --- .../app_shell.php => lib/Cake/Console/AppShell.php | 0 .../Cake/Console/Command/AclShell.php | 0 .../Cake/Console/Command/ApiShell.php | 0 .../Cake/Console/Command/BakeShell.php | 0 .../Cake/Console/Command/CommandListShell.php | 0 .../Cake/Console/Command/ConsoleShell.php | 0 .../Cake/Console/Command/I18nShell.php | 0 .../Cake/Console/Command/SchemaShell.php | 0 .../Cake/Console/Command/Task/BakeTask.php | 0 .../Cake/Console/Command/Task/ControllerTask.php | 0 .../Cake/Console/Command/Task/DbConfigTask.php | 0 .../Cake/Console/Command/Task/ExtractTask.php | 0 .../Cake/Console/Command/Task/FixtureTask.php | 0 .../Cake/Console/Command/Task/ModelTask.php | 0 .../Cake/Console/Command/Task/PluginTask.php | 0 .../Cake/Console/Command/Task/ProjectTask.php | 0 .../Cake/Console/Command/Task/TemplateTask.php | 0 .../Cake/Console/Command/Task/TestTask.php | 0 .../Cake/Console/Command/Task/ViewTask.php | 0 .../Cake/Console/Command/TestSuiteShell.php | 0 .../Cake/Console/ConsoleErrorHandler.php | 0 .../Cake/Console/ConsoleInput.php | 0 .../Cake/Console/ConsoleInputArgument.php | 0 .../Cake/Console/ConsoleInputOption.php | 0 .../Cake/Console/ConsoleInputSubcommand.php | 0 .../Cake/Console/ConsoleOptionParser.php | 0 .../Cake/Console/ConsoleOutput.php | 0 .../Cake/Console/HelpFormatter.php | 0 .../shells/shell.php => lib/Cake/Console/Shell.php | 0 .../Cake/Console/ShellDispatcher.php | 0 .../Cake/Console/TaskCollection.php | 0 {cake/console => lib/Cake/Console}/cake | 0 {cake/console => lib/Cake/Console}/cake.bat | 0 {cake/console => lib/Cake/Console}/cake.php | 0 .../default/actions/controller_actions.ctp | 0 .../templates/default/classes/controller.ctp | 0 .../Console}/templates/default/classes/fixture.ctp | 0 .../Console}/templates/default/classes/model.ctp | 0 .../Console}/templates/default/classes/test.ctp | 0 .../Cake/Console}/templates/default/views/form.ctp | 0 .../Cake/Console}/templates/default/views/home.ctp | 0 .../Cake/Console}/templates/default/views/index.ctp | 0 .../Cake/Console}/templates/default/views/view.ctp | 0 .../Cake/Console}/templates/skel/.htaccess | 0 .../Cake/Console}/templates/skel/app_controller.php | 0 .../Cake/Console}/templates/skel/app_helper.php | 0 .../Cake/Console}/templates/skel/app_model.php | 0 .../Cake/Console}/templates/skel/config/acl.ini.php | 0 .../Console}/templates/skel/config/bootstrap.php | 0 .../Cake/Console}/templates/skel/config/core.php | 0 .../templates/skel/config/database.php.default | 0 .../Cake/Console}/templates/skel/config/routes.php | 0 .../templates/skel/config/schema/db_acl.php | 0 .../templates/skel/config/schema/db_acl.sql | 0 .../Console}/templates/skel/config/schema/i18n.php | 0 .../Console}/templates/skel/config/schema/i18n.sql | 0 .../templates/skel/config/schema/sessions.php | 0 .../templates/skel/config/schema/sessions.sql | 0 .../Cake/Console}/templates/skel/console/cake | 0 .../Cake/Console}/templates/skel/console/cake.bat | 0 .../Cake/Console}/templates/skel/console/cake.php | 0 .../templates/skel/console/shells/tasks/empty | 0 .../templates/skel/controllers/components/empty | 0 .../templates/skel/controllers/pages_controller.php | 0 .../Cake/Console}/templates/skel/index.php | 0 .../Cake/Console}/templates/skel/libs/empty | 0 .../templates/skel/locale/eng/LC_MESSAGES/empty | 0 .../Console}/templates/skel/models/behaviors/empty | 0 .../templates/skel/models/datasources/empty | 0 .../Cake/Console}/templates/skel/plugins/empty | 0 .../templates/skel/tests/cases/behaviors/empty | 0 .../templates/skel/tests/cases/components/empty | 0 .../templates/skel/tests/cases/controllers/empty | 0 .../templates/skel/tests/cases/datasources/empty | 0 .../templates/skel/tests/cases/helpers/empty | 0 .../templates/skel/tests/cases/models/empty | 0 .../templates/skel/tests/cases/shells/empty | 0 .../Console}/templates/skel/tests/fixtures/empty | 0 .../Console}/templates/skel/tmp/cache/models/empty | 0 .../templates/skel/tmp/cache/persistent/empty | 0 .../Console}/templates/skel/tmp/cache/views/empty | 0 .../Cake/Console}/templates/skel/tmp/logs/empty | 0 .../Cake/Console}/templates/skel/tmp/sessions/empty | 0 .../Cake/Console}/templates/skel/tmp/tests/empty | 0 .../Cake/Console}/templates/skel/vendors/empty | 0 .../skel/views/elements/email/html/default.ctp | 0 .../skel/views/elements/email/text/default.ctp | 0 .../Console}/templates/skel/views/elements/empty | 0 .../Cake/Console}/templates/skel/views/errors/empty | 0 .../Console}/templates/skel/views/helpers/empty | 0 .../Console}/templates/skel/views/layouts/ajax.ctp | 0 .../templates/skel/views/layouts/default.ctp | 0 .../skel/views/layouts/email/html/default.ctp | 0 .../skel/views/layouts/email/text/default.ctp | 0 .../Console}/templates/skel/views/layouts/flash.ctp | 0 .../templates/skel/views/layouts/js/default.ctp | 0 .../templates/skel/views/layouts/rss/default.ctp | 0 .../templates/skel/views/layouts/xml/default.ctp | 0 .../Cake/Console}/templates/skel/views/pages/empty | 0 .../Console}/templates/skel/views/scaffolds/empty | 0 .../Cake/Console}/templates/skel/webroot/.htaccess | 0 .../Cake/Console}/templates/skel/webroot/css.php | 0 .../templates/skel/webroot/css/cake.generic.css | 0 .../Console}/templates/skel/webroot/favicon.ico | Bin .../templates/skel/webroot/img/cake.icon.png | Bin .../templates/skel/webroot/img/cake.power.gif | Bin .../Cake/Console}/templates/skel/webroot/index.php | 0 .../Cake/Console}/templates/skel/webroot/js/empty | 0 .../Cake/Console}/templates/skel/webroot/test.php | 0 109 files changed, 0 insertions(+), 0 deletions(-) rename cake/console/shells/app_shell.php => lib/Cake/Console/AppShell.php (100%) rename cake/console/shells/acl.php => lib/Cake/Console/Command/AclShell.php (100%) rename cake/console/shells/api.php => lib/Cake/Console/Command/ApiShell.php (100%) rename cake/console/shells/bake.php => lib/Cake/Console/Command/BakeShell.php (100%) rename cake/console/shells/command_list.php => lib/Cake/Console/Command/CommandListShell.php (100%) rename cake/console/shells/console.php => lib/Cake/Console/Command/ConsoleShell.php (100%) rename cake/console/shells/i18n.php => lib/Cake/Console/Command/I18nShell.php (100%) rename cake/console/shells/schema.php => lib/Cake/Console/Command/SchemaShell.php (100%) rename cake/console/shells/tasks/bake.php => lib/Cake/Console/Command/Task/BakeTask.php (100%) rename cake/console/shells/tasks/controller.php => lib/Cake/Console/Command/Task/ControllerTask.php (100%) rename cake/console/shells/tasks/db_config.php => lib/Cake/Console/Command/Task/DbConfigTask.php (100%) rename cake/console/shells/tasks/extract.php => lib/Cake/Console/Command/Task/ExtractTask.php (100%) rename cake/console/shells/tasks/fixture.php => lib/Cake/Console/Command/Task/FixtureTask.php (100%) rename cake/console/shells/tasks/model.php => lib/Cake/Console/Command/Task/ModelTask.php (100%) rename cake/console/shells/tasks/plugin.php => lib/Cake/Console/Command/Task/PluginTask.php (100%) rename cake/console/shells/tasks/project.php => lib/Cake/Console/Command/Task/ProjectTask.php (100%) rename cake/console/shells/tasks/template.php => lib/Cake/Console/Command/Task/TemplateTask.php (100%) rename cake/console/shells/tasks/test.php => lib/Cake/Console/Command/Task/TestTask.php (100%) rename cake/console/shells/tasks/view.php => lib/Cake/Console/Command/Task/ViewTask.php (100%) rename cake/console/shells/testsuite.php => lib/Cake/Console/Command/TestSuiteShell.php (100%) rename cake/console/libs/console_error_handler.php => lib/Cake/Console/ConsoleErrorHandler.php (100%) rename cake/console/libs/console_input.php => lib/Cake/Console/ConsoleInput.php (100%) rename cake/console/libs/console_input_argument.php => lib/Cake/Console/ConsoleInputArgument.php (100%) rename cake/console/libs/console_input_option.php => lib/Cake/Console/ConsoleInputOption.php (100%) rename cake/console/libs/console_input_subcommand.php => lib/Cake/Console/ConsoleInputSubcommand.php (100%) rename cake/console/libs/console_option_parser.php => lib/Cake/Console/ConsoleOptionParser.php (100%) rename cake/console/libs/console_output.php => lib/Cake/Console/ConsoleOutput.php (100%) rename cake/console/libs/help_formatter.php => lib/Cake/Console/HelpFormatter.php (100%) rename cake/console/shells/shell.php => lib/Cake/Console/Shell.php (100%) rename cake/console/shell_dispatcher.php => lib/Cake/Console/ShellDispatcher.php (100%) rename cake/console/libs/task_collection.php => lib/Cake/Console/TaskCollection.php (100%) rename {cake/console => lib/Cake/Console}/cake (100%) rename {cake/console => lib/Cake/Console}/cake.bat (100%) rename {cake/console => lib/Cake/Console}/cake.php (100%) rename {cake/console => lib/Cake/Console}/templates/default/actions/controller_actions.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/default/classes/controller.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/default/classes/fixture.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/default/classes/model.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/default/classes/test.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/default/views/form.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/default/views/home.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/default/views/index.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/default/views/view.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/.htaccess (100%) rename {cake/console => lib/Cake/Console}/templates/skel/app_controller.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/app_helper.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/app_model.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/acl.ini.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/bootstrap.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/core.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/database.php.default (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/routes.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/schema/db_acl.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/schema/db_acl.sql (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/schema/i18n.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/schema/i18n.sql (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/schema/sessions.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/config/schema/sessions.sql (100%) rename {cake/console => lib/Cake/Console}/templates/skel/console/cake (100%) rename {cake/console => lib/Cake/Console}/templates/skel/console/cake.bat (100%) rename {cake/console => lib/Cake/Console}/templates/skel/console/cake.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/console/shells/tasks/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/controllers/components/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/controllers/pages_controller.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/index.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/libs/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/locale/eng/LC_MESSAGES/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/models/behaviors/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/models/datasources/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/plugins/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tests/cases/behaviors/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tests/cases/components/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tests/cases/controllers/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tests/cases/datasources/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tests/cases/helpers/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tests/cases/models/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tests/cases/shells/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tests/fixtures/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tmp/cache/models/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tmp/cache/persistent/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tmp/cache/views/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tmp/logs/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tmp/sessions/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/tmp/tests/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/vendors/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/elements/email/html/default.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/elements/email/text/default.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/elements/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/errors/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/helpers/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/layouts/ajax.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/layouts/default.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/layouts/email/html/default.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/layouts/email/text/default.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/layouts/flash.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/layouts/js/default.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/layouts/rss/default.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/layouts/xml/default.ctp (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/pages/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/views/scaffolds/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/webroot/.htaccess (100%) rename {cake/console => lib/Cake/Console}/templates/skel/webroot/css.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/webroot/css/cake.generic.css (100%) rename {cake/console => lib/Cake/Console}/templates/skel/webroot/favicon.ico (100%) rename {cake/console => lib/Cake/Console}/templates/skel/webroot/img/cake.icon.png (100%) rename {cake/console => lib/Cake/Console}/templates/skel/webroot/img/cake.power.gif (100%) rename {cake/console => lib/Cake/Console}/templates/skel/webroot/index.php (100%) rename {cake/console => lib/Cake/Console}/templates/skel/webroot/js/empty (100%) rename {cake/console => lib/Cake/Console}/templates/skel/webroot/test.php (100%) diff --git a/cake/console/shells/app_shell.php b/lib/Cake/Console/AppShell.php similarity index 100% rename from cake/console/shells/app_shell.php rename to lib/Cake/Console/AppShell.php diff --git a/cake/console/shells/acl.php b/lib/Cake/Console/Command/AclShell.php similarity index 100% rename from cake/console/shells/acl.php rename to lib/Cake/Console/Command/AclShell.php diff --git a/cake/console/shells/api.php b/lib/Cake/Console/Command/ApiShell.php similarity index 100% rename from cake/console/shells/api.php rename to lib/Cake/Console/Command/ApiShell.php diff --git a/cake/console/shells/bake.php b/lib/Cake/Console/Command/BakeShell.php similarity index 100% rename from cake/console/shells/bake.php rename to lib/Cake/Console/Command/BakeShell.php diff --git a/cake/console/shells/command_list.php b/lib/Cake/Console/Command/CommandListShell.php similarity index 100% rename from cake/console/shells/command_list.php rename to lib/Cake/Console/Command/CommandListShell.php diff --git a/cake/console/shells/console.php b/lib/Cake/Console/Command/ConsoleShell.php similarity index 100% rename from cake/console/shells/console.php rename to lib/Cake/Console/Command/ConsoleShell.php 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 100% rename from cake/console/shells/schema.php rename to lib/Cake/Console/Command/SchemaShell.php 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 100% rename from cake/console/shells/tasks/controller.php rename to lib/Cake/Console/Command/Task/ControllerTask.php diff --git a/cake/console/shells/tasks/db_config.php b/lib/Cake/Console/Command/Task/DbConfigTask.php similarity index 100% rename from cake/console/shells/tasks/db_config.php rename to lib/Cake/Console/Command/Task/DbConfigTask.php diff --git a/cake/console/shells/tasks/extract.php b/lib/Cake/Console/Command/Task/ExtractTask.php similarity index 100% rename from cake/console/shells/tasks/extract.php rename to lib/Cake/Console/Command/Task/ExtractTask.php diff --git a/cake/console/shells/tasks/fixture.php b/lib/Cake/Console/Command/Task/FixtureTask.php similarity index 100% rename from cake/console/shells/tasks/fixture.php rename to lib/Cake/Console/Command/Task/FixtureTask.php diff --git a/cake/console/shells/tasks/model.php b/lib/Cake/Console/Command/Task/ModelTask.php similarity index 100% rename from cake/console/shells/tasks/model.php rename to lib/Cake/Console/Command/Task/ModelTask.php diff --git a/cake/console/shells/tasks/plugin.php b/lib/Cake/Console/Command/Task/PluginTask.php similarity index 100% rename from cake/console/shells/tasks/plugin.php rename to lib/Cake/Console/Command/Task/PluginTask.php diff --git a/cake/console/shells/tasks/project.php b/lib/Cake/Console/Command/Task/ProjectTask.php similarity index 100% rename from cake/console/shells/tasks/project.php rename to lib/Cake/Console/Command/Task/ProjectTask.php diff --git a/cake/console/shells/tasks/template.php b/lib/Cake/Console/Command/Task/TemplateTask.php similarity index 100% rename from cake/console/shells/tasks/template.php rename to lib/Cake/Console/Command/Task/TemplateTask.php diff --git a/cake/console/shells/tasks/test.php b/lib/Cake/Console/Command/Task/TestTask.php similarity index 100% rename from cake/console/shells/tasks/test.php rename to lib/Cake/Console/Command/Task/TestTask.php diff --git a/cake/console/shells/tasks/view.php b/lib/Cake/Console/Command/Task/ViewTask.php similarity index 100% rename from cake/console/shells/tasks/view.php rename to lib/Cake/Console/Command/Task/ViewTask.php diff --git a/cake/console/shells/testsuite.php b/lib/Cake/Console/Command/TestSuiteShell.php similarity index 100% rename from cake/console/shells/testsuite.php rename to lib/Cake/Console/Command/TestSuiteShell.php diff --git a/cake/console/libs/console_error_handler.php b/lib/Cake/Console/ConsoleErrorHandler.php similarity index 100% rename from cake/console/libs/console_error_handler.php rename to lib/Cake/Console/ConsoleErrorHandler.php diff --git a/cake/console/libs/console_input.php b/lib/Cake/Console/ConsoleInput.php similarity index 100% rename from cake/console/libs/console_input.php rename to lib/Cake/Console/ConsoleInput.php diff --git a/cake/console/libs/console_input_argument.php b/lib/Cake/Console/ConsoleInputArgument.php similarity index 100% rename from cake/console/libs/console_input_argument.php rename to lib/Cake/Console/ConsoleInputArgument.php diff --git a/cake/console/libs/console_input_option.php b/lib/Cake/Console/ConsoleInputOption.php similarity index 100% rename from cake/console/libs/console_input_option.php rename to lib/Cake/Console/ConsoleInputOption.php diff --git a/cake/console/libs/console_input_subcommand.php b/lib/Cake/Console/ConsoleInputSubcommand.php similarity index 100% rename from cake/console/libs/console_input_subcommand.php rename to lib/Cake/Console/ConsoleInputSubcommand.php diff --git a/cake/console/libs/console_option_parser.php b/lib/Cake/Console/ConsoleOptionParser.php similarity index 100% rename from cake/console/libs/console_option_parser.php rename to lib/Cake/Console/ConsoleOptionParser.php diff --git a/cake/console/libs/console_output.php b/lib/Cake/Console/ConsoleOutput.php similarity index 100% rename from cake/console/libs/console_output.php rename to lib/Cake/Console/ConsoleOutput.php diff --git a/cake/console/libs/help_formatter.php b/lib/Cake/Console/HelpFormatter.php similarity index 100% rename from cake/console/libs/help_formatter.php rename to lib/Cake/Console/HelpFormatter.php diff --git a/cake/console/shells/shell.php b/lib/Cake/Console/Shell.php similarity index 100% rename from cake/console/shells/shell.php rename to lib/Cake/Console/Shell.php diff --git a/cake/console/shell_dispatcher.php b/lib/Cake/Console/ShellDispatcher.php similarity index 100% rename from cake/console/shell_dispatcher.php rename to lib/Cake/Console/ShellDispatcher.php diff --git a/cake/console/libs/task_collection.php b/lib/Cake/Console/TaskCollection.php similarity index 100% rename from cake/console/libs/task_collection.php rename to lib/Cake/Console/TaskCollection.php diff --git a/cake/console/cake b/lib/Cake/Console/cake similarity index 100% rename from cake/console/cake rename to lib/Cake/Console/cake diff --git a/cake/console/cake.bat b/lib/Cake/Console/cake.bat similarity index 100% rename from cake/console/cake.bat rename to lib/Cake/Console/cake.bat diff --git a/cake/console/cake.php b/lib/Cake/Console/cake.php similarity index 100% rename from cake/console/cake.php rename to lib/Cake/Console/cake.php diff --git a/cake/console/templates/default/actions/controller_actions.ctp b/lib/Cake/Console/templates/default/actions/controller_actions.ctp similarity index 100% rename from cake/console/templates/default/actions/controller_actions.ctp rename to lib/Cake/Console/templates/default/actions/controller_actions.ctp diff --git a/cake/console/templates/default/classes/controller.ctp b/lib/Cake/Console/templates/default/classes/controller.ctp similarity index 100% rename from cake/console/templates/default/classes/controller.ctp rename to lib/Cake/Console/templates/default/classes/controller.ctp diff --git a/cake/console/templates/default/classes/fixture.ctp b/lib/Cake/Console/templates/default/classes/fixture.ctp similarity index 100% rename from cake/console/templates/default/classes/fixture.ctp rename to lib/Cake/Console/templates/default/classes/fixture.ctp diff --git a/cake/console/templates/default/classes/model.ctp b/lib/Cake/Console/templates/default/classes/model.ctp similarity index 100% rename from cake/console/templates/default/classes/model.ctp rename to lib/Cake/Console/templates/default/classes/model.ctp diff --git a/cake/console/templates/default/classes/test.ctp b/lib/Cake/Console/templates/default/classes/test.ctp similarity index 100% rename from cake/console/templates/default/classes/test.ctp rename to lib/Cake/Console/templates/default/classes/test.ctp diff --git a/cake/console/templates/default/views/form.ctp b/lib/Cake/Console/templates/default/views/form.ctp similarity index 100% rename from cake/console/templates/default/views/form.ctp rename to lib/Cake/Console/templates/default/views/form.ctp diff --git a/cake/console/templates/default/views/home.ctp b/lib/Cake/Console/templates/default/views/home.ctp similarity index 100% rename from cake/console/templates/default/views/home.ctp rename to lib/Cake/Console/templates/default/views/home.ctp diff --git a/cake/console/templates/default/views/index.ctp b/lib/Cake/Console/templates/default/views/index.ctp similarity index 100% rename from cake/console/templates/default/views/index.ctp rename to lib/Cake/Console/templates/default/views/index.ctp diff --git a/cake/console/templates/default/views/view.ctp b/lib/Cake/Console/templates/default/views/view.ctp similarity index 100% rename from cake/console/templates/default/views/view.ctp rename to lib/Cake/Console/templates/default/views/view.ctp diff --git a/cake/console/templates/skel/.htaccess b/lib/Cake/Console/templates/skel/.htaccess similarity index 100% rename from cake/console/templates/skel/.htaccess rename to lib/Cake/Console/templates/skel/.htaccess diff --git a/cake/console/templates/skel/app_controller.php b/lib/Cake/Console/templates/skel/app_controller.php similarity index 100% rename from cake/console/templates/skel/app_controller.php rename to lib/Cake/Console/templates/skel/app_controller.php diff --git a/cake/console/templates/skel/app_helper.php b/lib/Cake/Console/templates/skel/app_helper.php similarity index 100% rename from cake/console/templates/skel/app_helper.php rename to lib/Cake/Console/templates/skel/app_helper.php diff --git a/cake/console/templates/skel/app_model.php b/lib/Cake/Console/templates/skel/app_model.php similarity index 100% rename from cake/console/templates/skel/app_model.php rename to lib/Cake/Console/templates/skel/app_model.php diff --git a/cake/console/templates/skel/config/acl.ini.php b/lib/Cake/Console/templates/skel/config/acl.ini.php similarity index 100% rename from cake/console/templates/skel/config/acl.ini.php rename to lib/Cake/Console/templates/skel/config/acl.ini.php diff --git a/cake/console/templates/skel/config/bootstrap.php b/lib/Cake/Console/templates/skel/config/bootstrap.php similarity index 100% rename from cake/console/templates/skel/config/bootstrap.php rename to lib/Cake/Console/templates/skel/config/bootstrap.php diff --git a/cake/console/templates/skel/config/core.php b/lib/Cake/Console/templates/skel/config/core.php similarity index 100% rename from cake/console/templates/skel/config/core.php rename to lib/Cake/Console/templates/skel/config/core.php diff --git a/cake/console/templates/skel/config/database.php.default b/lib/Cake/Console/templates/skel/config/database.php.default similarity index 100% rename from cake/console/templates/skel/config/database.php.default rename to lib/Cake/Console/templates/skel/config/database.php.default 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/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/controllers/pages_controller.php b/lib/Cake/Console/templates/skel/controllers/pages_controller.php similarity index 100% rename from cake/console/templates/skel/controllers/pages_controller.php rename to lib/Cake/Console/templates/skel/controllers/pages_controller.php 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/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/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 100% rename from cake/console/templates/skel/webroot/index.php rename to lib/Cake/Console/templates/skel/webroot/index.php 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 100% rename from cake/console/templates/skel/webroot/test.php rename to lib/Cake/Console/templates/skel/webroot/test.php From e3690ebccba6f8b29f50c4ffbc69d7869a805112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 01:26:10 -0430 Subject: [PATCH 047/668] Making shells run again --- lib/Cake/Console/Command/CommandListShell.php | 8 ++++---- lib/Cake/Console/ConsoleErrorHandler.php | 4 ++-- lib/Cake/Console/ConsoleOptionParser.php | 9 +++++---- lib/Cake/Console/Shell.php | 9 +++++---- lib/Cake/Console/ShellDispatcher.php | 13 +++++-------- lib/Cake/Console/TaskCollection.php | 2 +- lib/Cake/Console/cake.php | 2 +- lib/Cake/Core/App.php | 2 +- lib/Cake/Core/Configure.php | 2 +- lib/Cake/I18n/L10n.php | 2 +- lib/Cake/bootstrap.php | 4 ++-- {cake => lib/Cake}/config/config.php | 0 .../Cake}/config/unicode/casefolding/0080_00ff.php | 0 .../Cake}/config/unicode/casefolding/0100_017f.php | 0 .../Cake}/config/unicode/casefolding/0180_024F.php | 0 .../Cake}/config/unicode/casefolding/0250_02af.php | 0 .../Cake}/config/unicode/casefolding/0370_03ff.php | 0 .../Cake}/config/unicode/casefolding/0400_04ff.php | 0 .../Cake}/config/unicode/casefolding/0500_052f.php | 0 .../Cake}/config/unicode/casefolding/0530_058f.php | 0 .../Cake}/config/unicode/casefolding/1e00_1eff.php | 0 .../Cake}/config/unicode/casefolding/1f00_1fff.php | 0 .../Cake}/config/unicode/casefolding/2100_214f.php | 0 .../Cake}/config/unicode/casefolding/2150_218f.php | 0 .../Cake}/config/unicode/casefolding/2460_24ff.php | 0 .../Cake}/config/unicode/casefolding/2c00_2c5f.php | 0 .../Cake}/config/unicode/casefolding/2c60_2c7f.php | 0 .../Cake}/config/unicode/casefolding/2c80_2cff.php | 0 .../Cake}/config/unicode/casefolding/ff00_ffef.php | 0 29 files changed, 28 insertions(+), 29 deletions(-) rename {cake => lib/Cake}/config/config.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/0080_00ff.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/0100_017f.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/0180_024F.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/0250_02af.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/0370_03ff.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/0400_04ff.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/0500_052f.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/0530_058f.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/1e00_1eff.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/1f00_1fff.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/2100_214f.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/2150_218f.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/2460_24ff.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/2c00_2c5f.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/2c60_2c7f.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/2c80_2cff.php (100%) rename {cake => lib/Cake}/config/unicode/casefolding/ff00_ffef.php (100%) diff --git a/lib/Cake/Console/Command/CommandListShell.php b/lib/Cake/Console/Command/CommandListShell.php index cd05af4ba..4df4dc847 100644 --- a/lib/Cake/Console/Command/CommandListShell.php +++ b/lib/Cake/Console/Command/CommandListShell.php @@ -18,6 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Shell', 'Console'); + /** * Shows a list of commands available from the console. * @@ -111,10 +113,8 @@ class CommandListShell extends Shell { continue; } foreach ($shells as $shell) { - if ($shell !== 'shell.php' && $shell !== 'app_shell.php') { - $shell = str_replace('.php', '', $shell); - $shellList[$shell][$type] = $type; - } + $shell = str_replace('Shell.php', '', $shell); + $shellList[$shell][$type] = $type; } } return $shellList; diff --git a/lib/Cake/Console/ConsoleErrorHandler.php b/lib/Cake/Console/ConsoleErrorHandler.php index 120c09d74..9eaebb2e5 100644 --- a/lib/Cake/Console/ConsoleErrorHandler.php +++ b/lib/Cake/Console/ConsoleErrorHandler.php @@ -17,8 +17,8 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'ErrorHandler'); -require_once 'console_output.php'; +App::uses('ErrorHandler', 'Error'); +App::uses('ConsoleOutput', 'Console'); /** * Error Handler for Cake console. Does simple printing of the diff --git a/lib/Cake/Console/ConsoleOptionParser.php b/lib/Cake/Console/ConsoleOptionParser.php index 8a9f8af65..8eec763d6 100644 --- a/lib/Cake/Console/ConsoleOptionParser.php +++ b/lib/Cake/Console/ConsoleOptionParser.php @@ -17,10 +17,11 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once CONSOLE_LIBS . 'console_input_option.php'; -require_once CONSOLE_LIBS . 'console_input_argument.php'; -require_once CONSOLE_LIBS . 'console_input_subcommand.php'; -require_once CONSOLE_LIBS . 'help_formatter.php'; +App::uses('TaskCollection', 'Console'); +App::uses('ConsoleOutput', 'Console'); +App::uses('ConsoleInput', 'Console'); +App::uses('ConsoleInputOption', 'Console'); +App::uses('ConsoleOptionParser', 'Console'); /** * Handles parsing the ARGV in the command line and provides support diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 55c81f94d..4f40bc8de 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -17,10 +17,11 @@ * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once CONSOLE_LIBS . 'task_collection.php'; -require_once CONSOLE_LIBS . 'console_output.php'; -require_once CONSOLE_LIBS . 'console_input.php'; -require_once CONSOLE_LIBS . 'console_option_parser.php'; + +App::uses('TaskCollection', 'Console'); +App::uses('ConsoleOutput', 'Console'); +App::uses('ConsoleInput', 'Console'); +App::uses('ConsoleOptionParser', 'Console'); /** * Base class for command-line utilities for automating programmer chores. diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index a80407613..ad75dd1d7 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -133,13 +133,13 @@ class ShellDispatcher { } $boot = file_exists(ROOT . DS . APP_DIR . DS . 'config' . DS . 'bootstrap.php'); - require CORE_PATH . 'cake' . DS . 'bootstrap.php'; + require CORE_PATH . 'Cake' . DS . 'bootstrap.php'; if (!file_exists(APP_PATH . 'config' . DS . 'core.php')) { include_once CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'templates' . DS . 'skel' . DS . 'config' . DS . 'core.php'; App::build(); } - require_once CONSOLE_LIBS . 'console_error_handler.php'; + require_once CONSOLE_LIBS . 'ConsoleErrorHandler.php'; set_exception_handler(array('ConsoleErrorHandler', 'handleException')); set_error_handler(array('ConsoleErrorHandler', 'handleError'), Configure::read('Error.level')); @@ -209,14 +209,11 @@ class ShellDispatcher { protected function _getShell($shell) { list($plugin, $shell) = pluginSplit($shell, true); - $loaded = App::import('Shell', $plugin . $shell); $class = Inflector::camelize($shell) . 'Shell'; - - if (!$loaded) { - throw new MissingShellFileException(array('shell' => $shell)); - } + $loaded = App::uses($class, $plugin . 'Console/Command'); + if (!class_exists($class)) { - throw new MissingShellClassException(array('shell' => $class)); + throw new MissingShellFileException(array('shell' => $shell)); } $Shell = new $class(); return $Shell; diff --git a/lib/Cake/Console/TaskCollection.php b/lib/Cake/Console/TaskCollection.php index d28b13b6d..00a1c4b54 100644 --- a/lib/Cake/Console/TaskCollection.php +++ b/lib/Cake/Console/TaskCollection.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', 'ObjectCollection'); +App::uses('ObjectCollection', 'Utility'); class TaskCollection extends ObjectCollection { /** diff --git a/lib/Cake/Console/cake.php b/lib/Cake/Console/cake.php index 02468c38f..fc0c0b484 100644 --- a/lib/Cake/Console/cake.php +++ b/lib/Cake/Console/cake.php @@ -20,7 +20,7 @@ * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'shell_dispatcher.php'); +require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'ShellDispatcher.php'); return ShellDispatcher::run($argv); diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 1410637ba..444f99057 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -354,7 +354,7 @@ class App { $paths['helpers'][] = $libs . 'view' . DS . 'helpers' . DS; $paths['plugins'][] = $path . 'plugins' . DS; $paths['vendors'][] = $path . 'vendors' . DS; - $paths['shells'][] = $cake . 'console' . DS . 'shells' . DS; + $paths['shells'][] = $libs . 'Console' . DS . 'Command' . DS; // Provide BC path to vendors/shells $paths['shells'][] = $path . 'vendors' . DS . 'shells' . DS; } diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index fca858832..243956433 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -345,7 +345,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/lib/Cake/I18n/L10n.php b/lib/Cake/I18n/L10n.php index 1844507c3..08b25ca92 100644 --- a/lib/Cake/I18n/L10n.php +++ b/lib/Cake/I18n/L10n.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0.4116 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('CakeRequest', 'Core'); +App::uses('CakeRequest', 'Network'); /** * Localization diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index f7ca698e3..a6b0099f6 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -40,7 +40,7 @@ error_reporting(E_ALL & ~E_DEPRECATED); /** * Path to the cake directory. */ - define('CAKE', CORE_PATH . 'lib' . DS . 'Cake' . DS); + define('CAKE', CORE_PATH . 'Cake' . DS); /** * Path to the application's directory. @@ -126,7 +126,7 @@ if (!defined('CONFIGS')) { /** * Path to the console libs direcotry. */ - define('CONSOLE_LIBS', CAKE.'console'.DS.'libs'.DS); + define('CONSOLE_LIBS', CAKE . 'Console' . DS); /** * Path to the tests directory. diff --git a/cake/config/config.php b/lib/Cake/config/config.php similarity index 100% rename from cake/config/config.php rename to lib/Cake/config/config.php diff --git a/cake/config/unicode/casefolding/0080_00ff.php b/lib/Cake/config/unicode/casefolding/0080_00ff.php similarity index 100% rename from cake/config/unicode/casefolding/0080_00ff.php rename to lib/Cake/config/unicode/casefolding/0080_00ff.php diff --git a/cake/config/unicode/casefolding/0100_017f.php b/lib/Cake/config/unicode/casefolding/0100_017f.php similarity index 100% rename from cake/config/unicode/casefolding/0100_017f.php rename to lib/Cake/config/unicode/casefolding/0100_017f.php diff --git a/cake/config/unicode/casefolding/0180_024F.php b/lib/Cake/config/unicode/casefolding/0180_024F.php similarity index 100% rename from cake/config/unicode/casefolding/0180_024F.php rename to lib/Cake/config/unicode/casefolding/0180_024F.php diff --git a/cake/config/unicode/casefolding/0250_02af.php b/lib/Cake/config/unicode/casefolding/0250_02af.php similarity index 100% rename from cake/config/unicode/casefolding/0250_02af.php rename to lib/Cake/config/unicode/casefolding/0250_02af.php diff --git a/cake/config/unicode/casefolding/0370_03ff.php b/lib/Cake/config/unicode/casefolding/0370_03ff.php similarity index 100% rename from cake/config/unicode/casefolding/0370_03ff.php rename to lib/Cake/config/unicode/casefolding/0370_03ff.php diff --git a/cake/config/unicode/casefolding/0400_04ff.php b/lib/Cake/config/unicode/casefolding/0400_04ff.php similarity index 100% rename from cake/config/unicode/casefolding/0400_04ff.php rename to lib/Cake/config/unicode/casefolding/0400_04ff.php diff --git a/cake/config/unicode/casefolding/0500_052f.php b/lib/Cake/config/unicode/casefolding/0500_052f.php similarity index 100% rename from cake/config/unicode/casefolding/0500_052f.php rename to lib/Cake/config/unicode/casefolding/0500_052f.php diff --git a/cake/config/unicode/casefolding/0530_058f.php b/lib/Cake/config/unicode/casefolding/0530_058f.php similarity index 100% rename from cake/config/unicode/casefolding/0530_058f.php rename to lib/Cake/config/unicode/casefolding/0530_058f.php diff --git a/cake/config/unicode/casefolding/1e00_1eff.php b/lib/Cake/config/unicode/casefolding/1e00_1eff.php similarity index 100% rename from cake/config/unicode/casefolding/1e00_1eff.php rename to lib/Cake/config/unicode/casefolding/1e00_1eff.php diff --git a/cake/config/unicode/casefolding/1f00_1fff.php b/lib/Cake/config/unicode/casefolding/1f00_1fff.php similarity index 100% rename from cake/config/unicode/casefolding/1f00_1fff.php rename to lib/Cake/config/unicode/casefolding/1f00_1fff.php diff --git a/cake/config/unicode/casefolding/2100_214f.php b/lib/Cake/config/unicode/casefolding/2100_214f.php similarity index 100% rename from cake/config/unicode/casefolding/2100_214f.php rename to lib/Cake/config/unicode/casefolding/2100_214f.php diff --git a/cake/config/unicode/casefolding/2150_218f.php b/lib/Cake/config/unicode/casefolding/2150_218f.php similarity index 100% rename from cake/config/unicode/casefolding/2150_218f.php rename to lib/Cake/config/unicode/casefolding/2150_218f.php diff --git a/cake/config/unicode/casefolding/2460_24ff.php b/lib/Cake/config/unicode/casefolding/2460_24ff.php similarity index 100% rename from cake/config/unicode/casefolding/2460_24ff.php rename to lib/Cake/config/unicode/casefolding/2460_24ff.php diff --git a/cake/config/unicode/casefolding/2c00_2c5f.php b/lib/Cake/config/unicode/casefolding/2c00_2c5f.php similarity index 100% rename from cake/config/unicode/casefolding/2c00_2c5f.php rename to lib/Cake/config/unicode/casefolding/2c00_2c5f.php diff --git a/cake/config/unicode/casefolding/2c60_2c7f.php b/lib/Cake/config/unicode/casefolding/2c60_2c7f.php similarity index 100% rename from cake/config/unicode/casefolding/2c60_2c7f.php rename to lib/Cake/config/unicode/casefolding/2c60_2c7f.php diff --git a/cake/config/unicode/casefolding/2c80_2cff.php b/lib/Cake/config/unicode/casefolding/2c80_2cff.php similarity index 100% rename from cake/config/unicode/casefolding/2c80_2cff.php rename to lib/Cake/config/unicode/casefolding/2c80_2cff.php diff --git a/cake/config/unicode/casefolding/ff00_ffef.php b/lib/Cake/config/unicode/casefolding/ff00_ffef.php similarity index 100% rename from cake/config/unicode/casefolding/ff00_ffef.php rename to lib/Cake/config/unicode/casefolding/ff00_ffef.php From b5122e6e8120a83b41878715acb0814125130fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 01:44:17 -0430 Subject: [PATCH 048/668] Fixing more console classes --- lib/Cake/Console/Command/CommandListShell.php | 2 -- lib/Cake/Console/Command/Task/ModelTask.php | 5 ++--- lib/Cake/Console/ConsoleOptionParser.php | 1 + lib/Cake/Console/HelpFormatter.php | 2 +- lib/Cake/Console/Shell.php | 1 + lib/Cake/Console/ShellDispatcher.php | 5 ++++- lib/Cake/Console/TaskCollection.php | 4 +--- lib/Cake/Model/Model.php | 8 ++++---- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Cake/Console/Command/CommandListShell.php b/lib/Cake/Console/Command/CommandListShell.php index 4df4dc847..65a576b48 100644 --- a/lib/Cake/Console/Command/CommandListShell.php +++ b/lib/Cake/Console/Command/CommandListShell.php @@ -18,8 +18,6 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Shell', 'Console'); - /** * Shows a list of commands available from the console. * diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 7616ef14c..c893de33a 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -18,7 +18,8 @@ * @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'); /** * Task class for creating and updating model files. @@ -791,7 +792,6 @@ class ModelTask extends BakeTask { if (!isset($useDbConfig)) { $useDbConfig = $this->connection; } - App::import('Model', 'ConnectionManager', false); $db = ConnectionManager::getDataSource($useDbConfig); $useTable = Inflector::tableize($modelName); @@ -820,7 +820,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/lib/Cake/Console/ConsoleOptionParser.php b/lib/Cake/Console/ConsoleOptionParser.php index 8eec763d6..179999a1b 100644 --- a/lib/Cake/Console/ConsoleOptionParser.php +++ b/lib/Cake/Console/ConsoleOptionParser.php @@ -21,6 +21,7 @@ App::uses('TaskCollection', 'Console'); App::uses('ConsoleOutput', 'Console'); App::uses('ConsoleInput', 'Console'); App::uses('ConsoleInputOption', 'Console'); +App::uses('ConsoleInputArgument', 'Console'); App::uses('ConsoleOptionParser', 'Console'); /** diff --git a/lib/Cake/Console/HelpFormatter.php b/lib/Cake/Console/HelpFormatter.php index 002689899..0b7add61d 100644 --- a/lib/Cake/Console/HelpFormatter.php +++ b/lib/Cake/Console/HelpFormatter.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'String', false); +App::import('String', 'Utility'); /** * HelpFormatter formats help for console shells. Can format to either diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 4f40bc8de..ff671ef34 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -21,6 +21,7 @@ App::uses('TaskCollection', 'Console'); App::uses('ConsoleOutput', 'Console'); App::uses('ConsoleInput', 'Console'); +App::uses('ConsoleInputSubcommand', 'Console'); App::uses('ConsoleOptionParser', 'Console'); /** diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index ad75dd1d7..45b07f0c5 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -209,8 +209,11 @@ class ShellDispatcher { protected function _getShell($shell) { list($plugin, $shell) = pluginSplit($shell, true); + $class = Inflector::camelize($shell) . 'Shell'; - $loaded = App::uses($class, $plugin . 'Console/Command'); + + App::uses('Shell', 'Console'); + App::uses($class, $plugin . 'Console/Command'); if (!class_exists($class)) { throw new MissingShellFileException(array('shell' => $shell)); diff --git a/lib/Cake/Console/TaskCollection.php b/lib/Cake/Console/TaskCollection.php index 00a1c4b54..b681d571d 100644 --- a/lib/Cake/Console/TaskCollection.php +++ b/lib/Cake/Console/TaskCollection.php @@ -61,10 +61,8 @@ class TaskCollection extends ObjectCollection { } $taskFile = Inflector::underscore($name); $taskClass = $name . 'Task'; + App::uses($taskClass, 'Console/Command/Task'); if (!class_exists($taskClass)) { - if (!App::import('Shell', $plugin . $this->taskPathPrefix . $name)) { - throw new MissingTaskFileException($taskFile . '.php'); - } if (!class_exists($taskClass)) { throw new MissingTaskClassException($taskClass); } diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 9cb46a682..3c3f234e9 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -23,13 +23,13 @@ /** * Included libs */ -App::uses('ClassRegistry', 'Core'); -App::uses('Validation', 'Core'); -App::uses('String', 'Core'); +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', 'Core'); +App::uses('Xml', 'Utility'); /** * Object-relational mapper. From 66145db2a9653f507cb2b894d67fd54ad76a130e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 19:50:56 -0430 Subject: [PATCH 049/668] Fixing class loading for bake tasks --- lib/Cake/Console/Command/Task/ControllerTask.php | 2 +- lib/Cake/Console/Command/Task/ExtractTask.php | 2 +- lib/Cake/Console/Command/Task/FixtureTask.php | 4 +++- lib/Cake/Console/Command/Task/ProjectTask.php | 3 ++- lib/Cake/Console/Command/Task/TemplateTask.php | 3 ++- lib/Cake/Console/Command/Task/TestTask.php | 4 ++-- lib/Cake/Console/Command/Task/ViewTask.php | 5 +++-- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 6ec3c4371..46f512365 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -18,7 +18,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. diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index 34c24314e..89af9153c 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -17,7 +17,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 * diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index 3bf60f3ae..cc081c84c 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -17,7 +17,9 @@ * @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'); + /** * Task class for creating and updating fixtures files. * diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index bb2a8f34b..4a5538220 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -18,7 +18,8 @@ * @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'); /** * Task class for creating new project apps and plugins diff --git a/lib/Cake/Console/Command/Task/TemplateTask.php b/lib/Cake/Console/Command/Task/TemplateTask.php index 85eed96c6..b30881581 100644 --- a/lib/Cake/Console/Command/Task/TemplateTask.php +++ b/lib/Cake/Console/Command/Task/TemplateTask.php @@ -17,7 +17,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 { diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index 093457421..3a52b6569 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -18,8 +18,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/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index bf8777238..fc3baa8ae 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -17,8 +17,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. From 1c368abc1a3b10aa657b9877e0fc64140babc11a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 19:51:26 -0430 Subject: [PATCH 050/668] Adding back cache loading for "objects" in App class --- lib/Cake/Core/App.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 444f99057..f22d8925d 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -609,6 +609,7 @@ class App { */ 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')); } From 09120b715c75ff7bf9c4ab103fa2ed1474570f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 19:58:09 -0430 Subject: [PATCH 051/668] Modifying index.php so the framework is able to bootstrap itself again --- app/webroot/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/webroot/index.php b/app/webroot/index.php index 719f172c4..70991f787 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -50,7 +50,7 @@ * */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT); + define('CAKE_CORE_INCLUDE_PATH', ROOT . DS .'lib'); } /** @@ -74,7 +74,7 @@ if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { return; } else { - require LIBS . 'dispatcher.php'; + require LIBS . 'Routing' . DS .'Dispatcher.php'; $Dispatcher = new Dispatcher(); $Dispatcher->dispatch(new CakeRequest(isset($_GET['url']) ? $_GET['url'] : null)); } From 7828f7d2fb0e37af468af304c329c7a4ca4df949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 19:59:07 -0430 Subject: [PATCH 052/668] Lazy loading connections in ConnectionManager, changing some class names and imports --- lib/Cake/Model/ConnectionManager.php | 16 ++++++++-------- lib/Cake/Model/Datasource/CakeSession.php | 5 +---- lib/Cake/Model/Datasource/Database/Sqlite.php | 4 +++- lib/Cake/Utility/File.php | 4 +--- lib/Cake/View/pages/home.ctp | 11 ++++------- 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index de3a4e90c..208d6ba9d 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -69,7 +69,6 @@ class ConnectionManager { include_once CONFIGS . 'database.php'; if (class_exists('DATABASE_CONFIG')) { self::$config = new DATABASE_CONFIG(); - self::_getConnectionObjects(); } register_shutdown_function('ConnectionManager::shutdown'); self::$_init = true; @@ -91,11 +90,16 @@ class ConnectionManager { return $return; } + if (empty(self::$_connectionsEnum[$name])) { + self::_getConnectionObject($name); + } + if (empty(self::$_connectionsEnum[$name])) { trigger_error(__("ConnectionManager::getDataSource - Non-existent data source %s", $name), E_USER_ERROR); $null = null; return $null; } + $conn = self::$_connectionsEnum[$name]; $class = $conn['classname']; @@ -222,13 +226,9 @@ class ConnectionManager { * * @return void */ - protected static function _getConnectionObjects() { - $connections = get_object_vars(self::$config); - - if ($connections != null) { - foreach ($connections as $name => $config) { - self::$_connectionsEnum[$name] = self::_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')); } diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index fd67272ad..589153383 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -559,10 +559,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 Exception(__('Could not load %s to handle the session.', $class)); } diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index e4a50b4c2..817e00cf1 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -18,6 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('DboSource', 'Model/Datasource'); + /** * DBO implementation for the SQLite3 DBMS. * @@ -26,7 +28,7 @@ * @package datasources * @subpackage cake.cake.libs.model.datasources.dbo */ -class DboSqlite extends DboSource { +class Sqlite extends DboSource { /** * Datasource Description diff --git a/lib/Cake/Utility/File.php b/lib/Cake/Utility/File.php index 663004840..2d9e268d7 100644 --- a/lib/Cake/Utility/File.php +++ b/lib/Cake/Utility/File.php @@ -22,9 +22,7 @@ * Included libraries. * */ -if (!class_exists('Folder')) { - require LIBS . 'folder.php'; -} +App::uses('File', 'Utility'); /** * Convenience class for reading, writing and appending to files. diff --git a/lib/Cake/View/pages/home.ctp b/lib/Cake/View/pages/home.ctp index 95ead2a18..81a6d5818 100644 --- a/lib/Cake/View/pages/home.ctp +++ b/lib/Cake/View/pages/home.ctp @@ -72,7 +72,7 @@ endif; ?>

'; __('PCRE has not been compiled with Unicode support.'); @@ -83,15 +83,12 @@ endif; ?> getDataSource('default'); + App::uses('ConnectionManager', 'Model'); + $connected = ConnectionManager::getDataSource('default'); ?>

isConnected()): + if ($connected && $connected->isConnected()): echo ''; echo __('Cake is able to connect to the database.'); echo ''; From 02ad0495593b361a262a99ed520140c799789877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 7 Dec 2010 20:42:50 -0430 Subject: [PATCH 053/668] Fixing more shells, and updating code in home.ctp --- lib/Cake/Console/Command/ConsoleShell.php | 17 ++++++++--------- lib/Cake/Console/Command/SchemaShell.php | 4 ++-- lib/Cake/Console/ConsoleOptionParser.php | 1 + lib/Cake/Console/HelpFormatter.php | 2 +- lib/Cake/Model/CakeSchema.php | 5 +++-- lib/Cake/Utility/File.php | 2 +- lib/Cake/View/pages/home.ctp | 4 ++-- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/Cake/Console/Command/ConsoleShell.php b/lib/Cake/Console/Command/ConsoleShell.php index 20ab1615d..404c348ed 100644 --- a/lib/Cake/Console/Command/ConsoleShell.php +++ b/lib/Cake/Console/Command/ConsoleShell.php @@ -53,7 +53,7 @@ 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); @@ -335,21 +335,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/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 969fad12a..280a86c69 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -20,8 +20,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/lib/Cake/Console/ConsoleOptionParser.php b/lib/Cake/Console/ConsoleOptionParser.php index 179999a1b..fabad4c5b 100644 --- a/lib/Cake/Console/ConsoleOptionParser.php +++ b/lib/Cake/Console/ConsoleOptionParser.php @@ -23,6 +23,7 @@ App::uses('ConsoleInput', 'Console'); App::uses('ConsoleInputOption', 'Console'); App::uses('ConsoleInputArgument', 'Console'); App::uses('ConsoleOptionParser', 'Console'); +App::uses('HelpFormatter', 'Console'); /** * Handles parsing the ARGV in the command line and provides support diff --git a/lib/Cake/Console/HelpFormatter.php b/lib/Cake/Console/HelpFormatter.php index 0b7add61d..40f3b3cc8 100644 --- a/lib/Cake/Console/HelpFormatter.php +++ b/lib/Cake/Console/HelpFormatter.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('String', 'Utility'); +App::uses('String', 'Utility'); /** * HelpFormatter formats help for console shells. Can format to either diff --git a/lib/Cake/Model/CakeSchema.php b/lib/Cake/Model/CakeSchema.php index bfe7c3ffe..17bc19f84 100644 --- a/lib/Cake/Model/CakeSchema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -17,8 +17,9 @@ * @since CakePHP(tm) v 1.2.0.5550 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Model', 'Core'); -App::uses('ConnectionManager', 'Core'); +App::uses('Model', 'Model'); +App::uses('AppModel', 'Model'); +App::uses('ConnectionManager', 'Model'); /** * Base Class for Schema management diff --git a/lib/Cake/Utility/File.php b/lib/Cake/Utility/File.php index 2d9e268d7..a7778ceda 100644 --- a/lib/Cake/Utility/File.php +++ b/lib/Cake/Utility/File.php @@ -22,7 +22,7 @@ * Included libraries. * */ -App::uses('File', 'Utility'); +App::uses('Folder', 'Utility'); /** * Convenience class for reading, writing and appending to files. diff --git a/lib/Cake/View/pages/home.ctp b/lib/Cake/View/pages/home.ctp index 81a6d5818..d861c5c12 100644 --- a/lib/Cake/View/pages/home.ctp +++ b/lib/Cake/View/pages/home.ctp @@ -16,14 +16,14 @@ * @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; ?>

0): +if (Configure::read('debug') > 0): Debugger::checkSecurityKeys(); endif; ?> From 4c9ad2dec8b5c12ecb3f20db7f067a3315b145e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 8 Dec 2010 00:34:45 -0430 Subject: [PATCH 054/668] Starting the tedious process of moving the testsuite and tests --- .../lib/cake_test_case.php => lib/Cake/TestSuite/CakeTestCase.php | 0 .../cake_test_suite.php => lib/Cake/TestSuite/CakeTestSuite.php | 0 .../Cake/TestSuite/CakeTestSuiteDispatcher.php | 0 .../Cake/TestSuite/CakeWebTestCase.php | 0 .../Cake/TestSuite/Coverage/BaseCoverageReport.php | 0 .../Cake/TestSuite/Coverage/HtmlCoverageReport.php | 0 .../Cake/TestSuite/Coverage/TextCoverageReport.php | 0 .../Cake/TestSuite/Fixture/CakeFixtureManager.php | 0 .../Cake/TestSuite/Fixture/CakeTestFixture.php | 0 .../Cake/TestSuite/Fixture/CakeTestModel.php | 0 .../Cake/TestSuite/Reporter/CakeBaseReporter.php | 0 .../Cake/TestSuite/Reporter/CakeHtmlReporter.php | 0 .../Cake/TestSuite/Reporter/CakeTextReporter.php | 0 .../lib/test_manager.php => lib/Cake/TestSuite/TestManager.php | 0 .../lib/test_runner.php => lib/Cake/TestSuite/TestRunner.php | 0 {cake/tests/lib => lib/Cake/TestSuite}/templates/footer.php | 0 {cake/tests/lib => lib/Cake/TestSuite}/templates/header.php | 0 {cake/tests/lib => lib/Cake/TestSuite}/templates/menu.php | 0 .../lib => lib/Cake/TestSuite}/templates/missing_conenction.php | 0 {cake/tests/lib => lib/Cake/TestSuite}/templates/phpunit.php | 0 {cake/tests/lib => lib/Cake/TestSuite}/templates/xdebug.php | 0 21 files changed, 0 insertions(+), 0 deletions(-) rename cake/tests/lib/cake_test_case.php => lib/Cake/TestSuite/CakeTestCase.php (100%) rename cake/tests/lib/cake_test_suite.php => lib/Cake/TestSuite/CakeTestSuite.php (100%) rename cake/tests/lib/cake_test_suite_dispatcher.php => lib/Cake/TestSuite/CakeTestSuiteDispatcher.php (100%) rename cake/tests/lib/cake_web_test_case.php => lib/Cake/TestSuite/CakeWebTestCase.php (100%) rename cake/tests/lib/coverage/base_coverage_report.php => lib/Cake/TestSuite/Coverage/BaseCoverageReport.php (100%) rename cake/tests/lib/coverage/html_coverage_report.php => lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php (100%) rename cake/tests/lib/coverage/text_coverage_report.php => lib/Cake/TestSuite/Coverage/TextCoverageReport.php (100%) rename cake/tests/lib/cake_fixture_manager.php => lib/Cake/TestSuite/Fixture/CakeFixtureManager.php (100%) rename cake/tests/lib/cake_test_fixture.php => lib/Cake/TestSuite/Fixture/CakeTestFixture.php (100%) rename cake/tests/lib/cake_test_model.php => lib/Cake/TestSuite/Fixture/CakeTestModel.php (100%) rename cake/tests/lib/reporter/cake_base_reporter.php => lib/Cake/TestSuite/Reporter/CakeBaseReporter.php (100%) rename cake/tests/lib/reporter/cake_html_reporter.php => lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php (100%) rename cake/tests/lib/reporter/cake_text_reporter.php => lib/Cake/TestSuite/Reporter/CakeTextReporter.php (100%) rename cake/tests/lib/test_manager.php => lib/Cake/TestSuite/TestManager.php (100%) rename cake/tests/lib/test_runner.php => lib/Cake/TestSuite/TestRunner.php (100%) rename {cake/tests/lib => lib/Cake/TestSuite}/templates/footer.php (100%) rename {cake/tests/lib => lib/Cake/TestSuite}/templates/header.php (100%) rename {cake/tests/lib => lib/Cake/TestSuite}/templates/menu.php (100%) rename {cake/tests/lib => lib/Cake/TestSuite}/templates/missing_conenction.php (100%) rename {cake/tests/lib => lib/Cake/TestSuite}/templates/phpunit.php (100%) rename {cake/tests/lib => lib/Cake/TestSuite}/templates/xdebug.php (100%) diff --git a/cake/tests/lib/cake_test_case.php b/lib/Cake/TestSuite/CakeTestCase.php similarity index 100% rename from cake/tests/lib/cake_test_case.php rename to lib/Cake/TestSuite/CakeTestCase.php 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_dispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php similarity index 100% rename from cake/tests/lib/cake_test_suite_dispatcher.php rename to lib/Cake/TestSuite/CakeTestSuiteDispatcher.php diff --git a/cake/tests/lib/cake_web_test_case.php b/lib/Cake/TestSuite/CakeWebTestCase.php similarity index 100% rename from cake/tests/lib/cake_web_test_case.php rename to lib/Cake/TestSuite/CakeWebTestCase.php diff --git a/cake/tests/lib/coverage/base_coverage_report.php b/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php similarity index 100% rename from cake/tests/lib/coverage/base_coverage_report.php rename to lib/Cake/TestSuite/Coverage/BaseCoverageReport.php diff --git a/cake/tests/lib/coverage/html_coverage_report.php b/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php similarity index 100% rename from cake/tests/lib/coverage/html_coverage_report.php rename to lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php 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 100% rename from cake/tests/lib/cake_fixture_manager.php rename to lib/Cake/TestSuite/Fixture/CakeFixtureManager.php diff --git a/cake/tests/lib/cake_test_fixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php similarity index 100% rename from cake/tests/lib/cake_test_fixture.php rename to lib/Cake/TestSuite/Fixture/CakeTestFixture.php diff --git a/cake/tests/lib/cake_test_model.php b/lib/Cake/TestSuite/Fixture/CakeTestModel.php similarity index 100% rename from cake/tests/lib/cake_test_model.php rename to lib/Cake/TestSuite/Fixture/CakeTestModel.php 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 100% rename from cake/tests/lib/reporter/cake_html_reporter.php rename to lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php 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/test_manager.php b/lib/Cake/TestSuite/TestManager.php similarity index 100% rename from cake/tests/lib/test_manager.php rename to lib/Cake/TestSuite/TestManager.php diff --git a/cake/tests/lib/test_runner.php b/lib/Cake/TestSuite/TestRunner.php similarity index 100% rename from cake/tests/lib/test_runner.php rename to lib/Cake/TestSuite/TestRunner.php diff --git a/cake/tests/lib/templates/footer.php b/lib/Cake/TestSuite/templates/footer.php similarity index 100% rename from cake/tests/lib/templates/footer.php rename to lib/Cake/TestSuite/templates/footer.php 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 From 4a287faa1e6b0251e3efab0074ce514d143f3b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 8 Dec 2010 01:36:38 -0430 Subject: [PATCH 055/668] Moving the tests folder --- {cake => lib/Cake}/tests/cases/basics.test.php | 0 .../Cake}/tests/cases/console/all_console.test.php | 0 .../tests/cases/console/all_console_libs.test.php | 0 .../Cake}/tests/cases/console/all_shells.test.php | 0 .../Cake}/tests/cases/console/all_tasks.test.php | 0 .../console/libs/console_error_handler.test.php | 0 .../console/libs/console_option_parser.test.php | 0 .../cases/console/libs/console_output.test.php | 0 .../cases/console/libs/help_formatter.test.php | 0 .../cases/console/libs/task_collection.test.php | 0 .../tests/cases/console/shell_dispatcher.test.php | 0 .../Cake}/tests/cases/console/shells/acl.test.php | 0 .../Cake}/tests/cases/console/shells/api.test.php | 0 .../Cake}/tests/cases/console/shells/bake.test.php | 0 .../cases/console/shells/command_list.test.php | 0 .../tests/cases/console/shells/schema.test.php | 0 .../Cake}/tests/cases/console/shells/shell.test.php | 0 .../cases/console/shells/tasks/controller.test.php | 0 .../cases/console/shells/tasks/db_config.test.php | 0 .../cases/console/shells/tasks/extract.test.php | 0 .../cases/console/shells/tasks/fixture.test.php | 0 .../tests/cases/console/shells/tasks/model.test.php | 0 .../cases/console/shells/tasks/plugin.test.php | 0 .../cases/console/shells/tasks/project.test.php | 0 .../cases/console/shells/tasks/template.test.php | 0 .../tests/cases/console/shells/tasks/test.test.php | 0 .../tests/cases/console/shells/tasks/view.test.php | 0 .../tests/cases/console/shells/testsuite.test.php | 0 .../Cake}/tests/cases/libs/all_behaviors.test.php | 0 .../tests/cases/libs/all_cache_engines.test.php | 0 .../Cake}/tests/cases/libs/all_components.test.php | 0 .../Cake}/tests/cases/libs/all_configure.test.php | 0 .../Cake}/tests/cases/libs/all_controllers.test.php | 0 .../Cake}/tests/cases/libs/all_database.test.php | 0 .../Cake}/tests/cases/libs/all_error.test.php | 0 .../Cake}/tests/cases/libs/all_helpers.test.php | 0 .../Cake}/tests/cases/libs/all_js_helpers.test.php | 0 .../Cake}/tests/cases/libs/all_libs.test.php | 0 .../tests/cases/libs/all_localization.test.php | 0 .../Cake}/tests/cases/libs/all_model.test.php | 0 .../Cake}/tests/cases/libs/all_routing.test.php | 0 .../Cake}/tests/cases/libs/all_socket.test.php | 0 .../Cake}/tests/cases/libs/all_test_suite.test.php | 0 .../Cake}/tests/cases/libs/all_tests.test.php | 0 .../Cake}/tests/cases/libs/all_views.test.php | 0 .../Cake}/tests/cases/libs/all_xml.test.php | 0 {cake => lib/Cake}/tests/cases/libs/app.test.php | 0 {cake => lib/Cake}/tests/cases/libs/cache.test.php | 0 .../Cake}/tests/cases/libs/cache/apc.test.php | 0 .../Cake}/tests/cases/libs/cache/file.test.php | 0 .../Cake}/tests/cases/libs/cache/memcache.test.php | 0 .../Cake}/tests/cases/libs/cache/xcache.test.php | 0 .../Cake}/tests/cases/libs/cake_log.test.php | 0 .../Cake}/tests/cases/libs/cake_request.test.php | 0 .../Cake}/tests/cases/libs/cake_response.test.php | 0 .../Cake}/tests/cases/libs/cake_session.test.php | 0 .../Cake}/tests/cases/libs/cake_socket.test.php | 0 .../Cake}/tests/cases/libs/cake_test_case.test.php | 0 .../tests/cases/libs/cake_test_fixture.test.php | 0 .../Cake}/tests/cases/libs/class_registry.test.php | 0 .../tests/cases/libs/config/ini_reader.test.php | 0 .../tests/cases/libs/config/php_reader.test.php | 0 .../Cake}/tests/cases/libs/configure.test.php | 0 .../tests/cases/libs/controller/component.test.php | 0 .../libs/controller/component_collection.test.php | 0 .../cases/libs/controller/components/acl.test.php | 0 .../cases/libs/controller/components/auth.test.php | 0 .../libs/controller/components/cookie.test.php | 0 .../cases/libs/controller/components/email.test.php | 0 .../controller/components/request_handler.test.php | 0 .../libs/controller/components/security.test.php | 0 .../libs/controller/components/session.test.php | 0 .../tests/cases/libs/controller/controller.test.php | 0 .../libs/controller/controller_merge_vars.test.php | 0 .../cases/libs/controller/pages_controller.test.php | 0 .../tests/cases/libs/controller/scaffold.test.php | 0 .../Cake}/tests/cases/libs/debugger.test.php | 0 .../Cake}/tests/cases/libs/dispatcher.test.php | 0 .../tests/cases/libs/error/error_handler.test.php | 0 .../cases/libs/error/exception_renderer.test.php | 0 {cake => lib/Cake}/tests/cases/libs/file.test.php | 0 {cake => lib/Cake}/tests/cases/libs/folder.test.php | 0 .../tests/cases/libs/html_coverage_report.test.php | 0 .../Cake}/tests/cases/libs/http_socket.test.php | 0 {cake => lib/Cake}/tests/cases/libs/i18n.test.php | 0 .../Cake}/tests/cases/libs/inflector.test.php | 0 {cake => lib/Cake}/tests/cases/libs/l10n.test.php | 0 .../Cake}/tests/cases/libs/log/file_log.test.php | 0 .../Cake}/tests/cases/libs/magic_db.test.php | 0 .../cases/libs/model/behavior_collection.test.php | 0 .../tests/cases/libs/model/behaviors/acl.test.php | 0 .../cases/libs/model/behaviors/containable.test.php | 0 .../cases/libs/model/behaviors/translate.test.php | 0 .../tests/cases/libs/model/behaviors/tree.test.php | 0 .../tests/cases/libs/model/cake_schema.test.php | 0 .../cases/libs/model/connection_manager.test.php | 0 .../libs/model/datasources/dbo/dbo_mssql.test.php | 0 .../libs/model/datasources/dbo/dbo_mysql.test.php | 0 .../libs/model/datasources/dbo/dbo_oracle.test.php | 0 .../model/datasources/dbo/dbo_postgres.test.php | 0 .../libs/model/datasources/dbo/dbo_sqlite.test.php | 0 .../libs/model/datasources/dbo_source.test.php | 0 .../Cake}/tests/cases/libs/model/db_acl.test.php | 0 .../Cake}/tests/cases/libs/model/model.test.php | 0 .../tests/cases/libs/model/model_delete.test.php | 0 .../cases/libs/model/model_integration.test.php | 0 .../tests/cases/libs/model/model_read.test.php | 0 .../cases/libs/model/model_validation.test.php | 0 .../tests/cases/libs/model/model_write.test.php | 0 .../Cake}/tests/cases/libs/model/models.php | 0 .../Cake}/tests/cases/libs/multibyte.test.php | 0 {cake => lib/Cake}/tests/cases/libs/object.test.php | 0 .../tests/cases/libs/object_collection.test.php | 0 .../tests/cases/libs/route/cake_route.test.php | 0 .../cases/libs/route/plugin_short_route.test.php | 0 .../tests/cases/libs/route/redirect_route.test.php | 0 {cake => lib/Cake}/tests/cases/libs/router.test.php | 0 .../Cake}/tests/cases/libs/sanitize.test.php | 0 .../Cake}/tests/cases/libs/security.test.php | 0 .../tests/cases/libs/session/cache_session.test.php | 0 .../cases/libs/session/database_session.test.php | 0 {cake => lib/Cake}/tests/cases/libs/set.test.php | 0 {cake => lib/Cake}/tests/cases/libs/string.test.php | 0 .../Cake}/tests/cases/libs/test_manager.test.php | 0 .../Cake}/tests/cases/libs/validation.test.php | 0 .../Cake}/tests/cases/libs/view/helper.test.php | 0 .../cases/libs/view/helper_collection.test.php | 0 .../tests/cases/libs/view/helpers/cache.test.php | 0 .../tests/cases/libs/view/helpers/form.test.php | 0 .../tests/cases/libs/view/helpers/html.test.php | 0 .../cases/libs/view/helpers/jquery_engine.test.php | 0 .../Cake}/tests/cases/libs/view/helpers/js.test.php | 0 .../libs/view/helpers/mootools_engine.test.php | 0 .../tests/cases/libs/view/helpers/number.test.php | 0 .../cases/libs/view/helpers/paginator.test.php | 0 .../libs/view/helpers/prototype_engine.test.php | 0 .../tests/cases/libs/view/helpers/rss.test.php | 0 .../tests/cases/libs/view/helpers/session.test.php | 0 .../tests/cases/libs/view/helpers/text.test.php | 0 .../tests/cases/libs/view/helpers/time.test.php | 0 .../Cake}/tests/cases/libs/view/media.test.php | 0 .../Cake}/tests/cases/libs/view/theme.test.php | 0 .../Cake}/tests/cases/libs/view/view.test.php | 0 {cake => lib/Cake}/tests/cases/libs/xml.test.php | 0 .../Cake}/tests/fixtures/account_fixture.php | 0 .../Cake}/tests/fixtures/aco_action_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/aco_fixture.php | 0 .../Cake}/tests/fixtures/aco_two_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/ad_fixture.php | 0 .../Cake}/tests/fixtures/advertisement_fixture.php | 0 .../Cake}/tests/fixtures/after_tree_fixture.php | 0 .../tests/fixtures/another_article_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/apple_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/aro_fixture.php | 0 .../Cake}/tests/fixtures/aro_two_fixture.php | 0 .../Cake}/tests/fixtures/aros_aco_fixture.php | 0 .../Cake}/tests/fixtures/aros_aco_two_fixture.php | 0 .../tests/fixtures/article_featured_fixture.php | 0 .../fixtures/article_featureds_tags_fixture.php | 0 .../Cake}/tests/fixtures/article_fixture.php | 0 .../Cake}/tests/fixtures/articles_tag_fixture.php | 0 .../Cake}/tests/fixtures/assert_tags_test_case.php | 0 .../Cake}/tests/fixtures/attachment_fixture.php | 0 .../fixtures/auth_user_custom_field_fixture.php | 0 .../Cake}/tests/fixtures/auth_user_fixture.php | 0 .../Cake}/tests/fixtures/author_fixture.php | 0 .../Cake}/tests/fixtures/bake_article_fixture.php | 0 .../fixtures/bake_articles_bake_tag_fixture.php | 0 .../Cake}/tests/fixtures/bake_comment_fixture.php | 0 .../Cake}/tests/fixtures/bake_tag_fixture.php | 0 .../Cake}/tests/fixtures/basket_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/bid_fixture.php | 0 .../Cake}/tests/fixtures/binary_test_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/book_fixture.php | 0 .../tests/fixtures/cache_test_model_fixture.php | 0 .../Cake}/tests/fixtures/callback_fixture.php | 0 .../Cake}/tests/fixtures/campaign_fixture.php | 0 .../Cake}/tests/fixtures/category_fixture.php | 0 .../tests/fixtures/category_thread_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/cd_fixture.php | 0 .../Cake}/tests/fixtures/comment_fixture.php | 0 .../tests/fixtures/content_account_fixture.php | 0 .../Cake}/tests/fixtures/content_fixture.php | 0 .../tests/fixtures/counter_cache_post_fixture.php | 0 ...r_cache_post_nonstandard_primary_key_fixture.php | 0 .../tests/fixtures/counter_cache_user_fixture.php | 0 ...r_cache_user_nonstandard_primary_key_fixture.php | 0 .../Cake}/tests/fixtures/data_test_fixture.php | 0 .../Cake}/tests/fixtures/datatype_fixture.php | 0 .../Cake}/tests/fixtures/dependency_fixture.php | 0 .../Cake}/tests/fixtures/device_fixture.php | 0 .../tests/fixtures/device_type_category_fixture.php | 0 .../Cake}/tests/fixtures/device_type_fixture.php | 0 .../tests/fixtures/document_directory_fixture.php | 0 .../Cake}/tests/fixtures/document_fixture.php | 0 .../fixtures/exterior_type_category_fixture.php | 0 .../Cake}/tests/fixtures/feature_set_fixture.php | 0 .../Cake}/tests/fixtures/featured_fixture.php | 0 .../Cake}/tests/fixtures/film_file_fixture.php | 0 .../Cake}/tests/fixtures/fixturized_test_case.php | 0 .../Cake}/tests/fixtures/flag_tree_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/fruit_fixture.php | 0 .../tests/fixtures/fruits_uuid_tag_fixture.php | 0 .../tests/fixtures/group_update_all_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/home_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/image_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/item_fixture.php | 0 .../tests/fixtures/items_portfolio_fixture.php | 0 .../Cake}/tests/fixtures/join_a_b_fixture.php | 0 .../Cake}/tests/fixtures/join_a_c_fixture.php | 0 .../Cake}/tests/fixtures/join_a_fixture.php | 0 .../Cake}/tests/fixtures/join_b_fixture.php | 0 .../Cake}/tests/fixtures/join_c_fixture.php | 0 .../Cake}/tests/fixtures/join_thing_fixture.php | 0 .../Cake}/tests/fixtures/message_fixture.php | 0 .../fixtures/my_categories_my_products_fixture.php | 0 .../fixtures/my_categories_my_users_fixture.php | 0 .../Cake}/tests/fixtures/my_category_fixture.php | 0 .../Cake}/tests/fixtures/my_product_fixture.php | 0 .../Cake}/tests/fixtures/my_user_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/node_fixture.php | 0 .../Cake}/tests/fixtures/number_tree_fixture.php | 0 .../tests/fixtures/number_tree_two_fixture.php | 0 .../tests/fixtures/numeric_article_fixture.php | 0 .../tests/fixtures/overall_favorite_fixture.php | 0 .../Cake}/tests/fixtures/person_fixture.php | 0 .../Cake}/tests/fixtures/portfolio_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/post_fixture.php | 0 .../Cake}/tests/fixtures/posts_tag_fixture.php | 0 .../Cake}/tests/fixtures/primary_model_fixture.php | 0 .../Cake}/tests/fixtures/product_fixture.php | 0 .../tests/fixtures/product_update_all_fixture.php | 0 .../Cake}/tests/fixtures/project_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/rss.xml | 0 {cake => lib/Cake}/tests/fixtures/sample.xml | 0 .../Cake}/tests/fixtures/sample_fixture.php | 0 .../tests/fixtures/secondary_model_fixture.php | 0 .../Cake}/tests/fixtures/session_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/soap_request.xml | 0 {cake => lib/Cake}/tests/fixtures/soap_response.xml | 0 .../Cake}/tests/fixtures/something_else_fixture.php | 0 .../Cake}/tests/fixtures/something_fixture.php | 0 .../Cake}/tests/fixtures/stories_tag_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/story_fixture.php | 0 .../Cake}/tests/fixtures/syfile_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/tag_fixture.php | 0 .../tests/fixtures/test_plugin_article_fixture.php | 0 .../tests/fixtures/test_plugin_comment_fixture.php | 0 .../tests/fixtures/the_paper_monkies_fixture.php | 0 .../Cake}/tests/fixtures/thread_fixture.php | 0 .../tests/fixtures/translate_article_fixture.php | 0 .../Cake}/tests/fixtures/translate_fixture.php | 0 .../tests/fixtures/translate_table_fixture.php | 0 .../fixtures/translate_with_prefix_fixture.php | 0 .../tests/fixtures/translated_article_fixture.php | 0 .../tests/fixtures/translated_item_fixture.php | 0 .../tests/fixtures/unconventional_tree_fixture.php | 0 .../tests/fixtures/underscore_field_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/user_fixture.php | 0 {cake => lib/Cake}/tests/fixtures/uuid_fixture.php | 0 .../Cake}/tests/fixtures/uuid_tag_fixture.php | 0 .../Cake}/tests/fixtures/uuid_tree_fixture.php | 0 .../Cake}/tests/fixtures/uuiditem_fixture.php | 0 .../fixtures/uuiditems_uuidportfolio_fixture.php | 0 .../uuiditems_uuidportfolio_numericid_fixture.php | 0 .../Cake}/tests/fixtures/uuidportfolio_fixture.php | 0 .../Cake}/tests/test_app/config/acl.ini.php | 0 {cake => lib/Cake}/tests/test_app/config/empty.php | 0 {cake => lib/Cake}/tests/test_app/config/nested.ini | 0 .../Cake}/tests/test_app/config/var_test.php | 0 .../Cake}/tests/test_app/console/shells/sample.php | 0 .../Cake}/tests/test_app/console/shells/tasks/empty | 0 .../console/templates/test/classes/test_object.ctp | 0 .../tests/test_app/controllers/components/empty | 0 .../test_app/controllers/tests_apps_controller.php | 0 .../controllers/tests_apps_posts_controller.php | 0 .../tests/test_app/libs/cache/test_app_cache.php | 0 {cake => lib/Cake}/tests/test_app/libs/library.php | 0 .../Cake}/tests/test_app/libs/log/test_app_log.php | 0 .../test_app/libs/session/test_app_lib_session.php | 0 .../locale/cache_test_po/LC_MESSAGES/default.po | 0 .../locale/cache_test_po/LC_MESSAGES/dom1.po | 0 .../locale/cache_test_po/LC_MESSAGES/dom2.po | 0 .../Cake}/tests/test_app/locale/ja_jp/LC_TIME | 0 .../tests/test_app/locale/po/LC_MESSAGES/default.po | 0 .../tests/test_app/locale/po/LC_MONETARY/default.po | 0 {cake => lib/Cake}/tests/test_app/locale/po/LC_TIME | 0 .../test_app/locale/rule_0_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_0_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_0_po/LC_MESSAGES/core.po | 0 .../locale/rule_0_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_10_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_10_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_10_po/LC_MESSAGES/core.po | 0 .../locale/rule_10_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_11_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_11_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_11_po/LC_MESSAGES/core.po | 0 .../locale/rule_11_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_12_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_12_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_12_po/LC_MESSAGES/core.po | 0 .../locale/rule_12_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_13_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_13_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_13_po/LC_MESSAGES/core.po | 0 .../locale/rule_13_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_14_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_14_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_14_po/LC_MESSAGES/core.po | 0 .../locale/rule_14_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_1_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_1_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_1_po/LC_MESSAGES/core.po | 0 .../locale/rule_1_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_2_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_2_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_2_po/LC_MESSAGES/core.po | 0 .../locale/rule_2_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_3_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_3_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_3_po/LC_MESSAGES/core.po | 0 .../locale/rule_3_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_4_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_4_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_4_po/LC_MESSAGES/core.po | 0 .../locale/rule_4_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_5_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_5_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_5_po/LC_MESSAGES/core.po | 0 .../locale/rule_5_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_6_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_6_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_6_po/LC_MESSAGES/core.po | 0 .../locale/rule_6_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_7_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_7_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_7_po/LC_MESSAGES/core.po | 0 .../locale/rule_7_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_8_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_8_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_8_po/LC_MESSAGES/core.po | 0 .../locale/rule_8_po/LC_MESSAGES/default.po | 0 .../test_app/locale/rule_9_mo/LC_MESSAGES/core.mo | Bin .../locale/rule_9_mo/LC_MESSAGES/default.mo | Bin .../test_app/locale/rule_9_po/LC_MESSAGES/core.po | 0 .../locale/rule_9_po/LC_MESSAGES/default.po | 0 .../Cake}/tests/test_app/locale/time_test/LC_TIME | 0 .../Cake}/tests/test_app/models/behaviors/empty | 0 .../models/behaviors/persister_one_behavior.php | 0 .../models/behaviors/persister_two_behavior.php | 0 .../Cake}/tests/test_app/models/comment.php | 0 .../models/datasources/test/test_local_driver.php | 0 .../models/datasources/test2_other_source.php | 0 .../test_app/models/datasources/test2_source.php | 0 .../Cake}/tests/test_app/models/persister_one.php | 0 .../Cake}/tests/test_app/models/persister_two.php | 0 {cake => lib/Cake}/tests/test_app/models/post.php | 0 .../plugins/plugin_js/webroot/js/one/plugin_one.js | 0 .../plugins/plugin_js/webroot/js/plugin_js.js | 0 .../test_app/plugins/test_plugin/config/load.php | 0 .../plugins/test_plugin/config/more.load.php | 0 .../plugins/test_plugin/config/schema/schema.php | 0 .../plugins/test_plugin/console/shells/example.php | 0 .../plugins/test_plugin/console/shells/tasks/empty | 0 .../test_plugin/console/shells/tasks/other_task.php | 0 .../plugins/test_plugin/console/templates/empty | 0 .../controllers/components/other_component.php | 0 .../controllers/components/plugins_component.php | 0 .../components/test_plugin_component.php | 0 .../components/test_plugin_other_component.php | 0 .../controllers/test_plugin_controller.php | 0 .../test_plugin/controllers/tests_controller.php | 0 .../test_plugin/libs/cache/test_plugin_cache.php | 0 .../test_plugin/libs/log/test_plugin_log.php | 0 .../libs/session/test_plugin_session.php | 0 .../test_plugin/libs/test_plugin_library.php | 0 .../locale/po/LC_MESSAGES/test_plugin.po | 0 .../locale/po/LC_MONETARY/test_plugin.po | 0 .../models/behaviors/test_plugin_persister_one.php | 0 .../models/behaviors/test_plugin_persister_two.php | 0 .../models/datasources/dbo/dbo_dummy.php | 0 .../models/datasources/test/test_driver.php | 0 .../models/datasources/test_other_source.php | 0 .../test_plugin/models/datasources/test_source.php | 0 .../test_plugin/models/test_plugin_auth_user.php | 0 .../test_plugin/models/test_plugin_authors.php | 0 .../test_plugin/models/test_plugin_comment.php | 0 .../plugins/test_plugin/models/test_plugin_post.php | 0 .../test_plugin/test_plugin_app_controller.php | 0 .../plugins/test_plugin/test_plugin_app_model.php | 0 .../test_plugin/vendors/sample/sample_plugin.php | 0 .../plugins/test_plugin/vendors/welcome.php | 0 .../test_plugin/views/elements/plugin_element.ctp | 0 .../views/elements/test_plugin_element.ctp | 0 .../test_plugin/views/helpers/other_helper.php | 0 .../test_plugin/views/helpers/plugged_helper.php | 0 .../test_plugin/views/helpers/test_plugin_app.php | 0 .../plugins/test_plugin/views/layouts/default.ctp | 0 .../plugins/test_plugin/views/tests/index.ctp | 0 .../test_plugin/views/tests/scaffold.edit.ctp | 0 .../test_plugin/webroot/css/test_plugin_asset.css | 0 .../plugins/test_plugin/webroot/css/theme_one.htc | 0 .../test_plugin/webroot/css/unknown.extension | 0 .../test_plugin/webroot/flash/plugin_test.swf | 0 .../plugins/test_plugin/webroot/img/cake.icon.gif | Bin .../test_plugin/webroot/js/test_plugin/test.js | 0 .../test_plugin/webroot/pdfs/plugin_test.pdf | Bin .../test_app/plugins/test_plugin/webroot/root.js | 0 .../test_plugin_two/console/shells/example.php | 0 .../test_plugin_two/console/shells/tasks/empty | 0 .../test_plugin_two/console/shells/welcome.php | 0 .../plugins/test_plugin_two/console/templates/empty | 0 {cake => lib/Cake}/tests/test_app/tmp/dir_map | 0 .../Cake}/tests/test_app/vendors/Test/MyTest.php | 0 .../Cake}/tests/test_app/vendors/Test/hello.php | 0 .../Cake}/tests/test_app/vendors/css/test_asset.css | 0 .../Cake}/tests/test_app/vendors/img/test.jpg | Bin .../vendors/sample/configure_test_vendor_sample.php | 0 .../tests/test_app/vendors/somename/some.name.php | 0 .../Cake}/tests/test_app/vendors/welcome.php | 0 .../test_app/views/elements/email/html/custom.ctp | 0 .../test_app/views/elements/email/html/default.ctp | 0 .../test_app/views/elements/email/text/custom.ctp | 0 .../test_app/views/elements/email/text/default.ctp | 0 .../test_app/views/elements/email/text/wide.ctp | 0 .../Cake}/tests/test_app/views/elements/empty | 0 .../views/elements/nocache/contains_nocache.ctp | 0 .../tests/test_app/views/elements/nocache/plain.ctp | 0 .../tests/test_app/views/elements/nocache/sub1.ctp | 0 .../tests/test_app/views/elements/nocache/sub2.ctp | 0 .../test_app/views/elements/session_helper.ctp | 0 .../tests/test_app/views/elements/test_element.ctp | 0 .../Cake}/tests/test_app/views/errors/empty | 0 .../Cake}/tests/test_app/views/helpers/banana.php | 0 .../Cake}/tests/test_app/views/helpers/empty | 0 .../Cake}/tests/test_app/views/layouts/ajax.ctp | 0 .../Cake}/tests/test_app/views/layouts/ajax2.ctp | 0 .../test_app/views/layouts/cache_empty_sections.ctp | 0 .../tests/test_app/views/layouts/cache_layout.ctp | 0 .../Cake}/tests/test_app/views/layouts/default.ctp | 0 .../test_app/views/layouts/email/html/default.ctp | 0 .../test_app/views/layouts/email/html/thin.ctp | 0 .../test_app/views/layouts/email/text/default.ctp | 0 .../Cake}/tests/test_app/views/layouts/flash.ctp | 0 .../tests/test_app/views/layouts/js/default.ctp | 0 .../tests/test_app/views/layouts/multi_cache.ctp | 0 .../tests/test_app/views/layouts/rss/default.ctp | 0 .../tests/test_app/views/layouts/xml/default.ctp | 0 {cake => lib/Cake}/tests/test_app/views/pages/empty | 0 .../Cake}/tests/test_app/views/pages/extract.ctp | 0 .../Cake}/tests/test_app/views/pages/home.ctp | 0 .../test_app/views/posts/cache_empty_sections.ctp | 0 .../Cake}/tests/test_app/views/posts/cache_form.ctp | 0 .../tests/test_app/views/posts/helper_overwrite.ctp | 0 .../Cake}/tests/test_app/views/posts/index.ctp | 0 .../tests/test_app/views/posts/multiple_nocache.ctp | 0 .../views/posts/nocache_multiple_element.ctp | 0 .../tests/test_app/views/posts/scaffold.edit.ctp | 0 .../test_app/views/posts/sequencial_nocache.ctp | 0 .../test_app/views/posts/test_nocache_tags.ctp | 0 .../Cake}/tests/test_app/views/scaffolds/empty | 0 .../Cake}/tests/test_app/views/tests_apps/index.ctp | 0 .../themed/test_theme/elements/test_element.ctp | 0 .../views/themed/test_theme/layouts/default.ctp | 0 .../plugins/test_plugin/layouts/plugin_default.ctp | 0 .../test_theme/plugins/test_plugin/tests/index.ctp | 0 .../views/themed/test_theme/posts/index.ctp | 0 .../themed/test_theme/posts/scaffold.index.ctp | 0 .../themed/test_theme/webroot/css/test_asset.css | 0 .../themed/test_theme/webroot/css/theme_webroot.css | 0 .../themed/test_theme/webroot/flash/theme_test.swf | 0 .../themed/test_theme/webroot/img/cake.power.gif | Bin .../views/themed/test_theme/webroot/img/test.jpg | Bin .../themed/test_theme/webroot/js/one/theme_one.js | 0 .../views/themed/test_theme/webroot/js/theme.js | 0 .../themed/test_theme/webroot/pdfs/theme_test.pdf | Bin .../webroot/theme/test_theme/css/theme_webroot.css | 0 .../webroot/theme/test_theme/css/webroot_test.css | 0 .../webroot/theme/test_theme/img/cake.power.gif | Bin .../test_app/webroot/theme/test_theme/img/test.jpg | Bin 481 files changed, 0 insertions(+), 0 deletions(-) rename {cake => lib/Cake}/tests/cases/basics.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/all_console.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/all_console_libs.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/all_shells.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/all_tasks.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/libs/console_error_handler.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/libs/console_option_parser.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/libs/console_output.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/libs/help_formatter.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/libs/task_collection.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shell_dispatcher.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/acl.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/api.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/bake.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/command_list.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/schema.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/shell.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/tasks/controller.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/tasks/db_config.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/tasks/extract.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/tasks/fixture.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/tasks/model.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/tasks/plugin.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/tasks/project.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/tasks/template.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/tasks/test.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/tasks/view.test.php (100%) rename {cake => lib/Cake}/tests/cases/console/shells/testsuite.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_behaviors.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_cache_engines.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_components.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_configure.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_controllers.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_database.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_error.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_helpers.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_js_helpers.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_libs.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_localization.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_model.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_routing.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_socket.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_test_suite.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_tests.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_views.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/all_xml.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/app.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cache.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cache/apc.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cache/file.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cache/memcache.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cache/xcache.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cake_log.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cake_request.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cake_response.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cake_session.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cake_socket.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cake_test_case.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/cake_test_fixture.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/class_registry.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/config/ini_reader.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/config/php_reader.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/configure.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/component.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/component_collection.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/acl.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/auth.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/cookie.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/email.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/request_handler.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/security.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/session.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/controller.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/controller_merge_vars.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/pages_controller.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/scaffold.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/debugger.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/dispatcher.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/error/error_handler.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/error/exception_renderer.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/file.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/folder.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/html_coverage_report.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/http_socket.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/i18n.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/inflector.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/l10n.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/log/file_log.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/magic_db.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/behavior_collection.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/behaviors/acl.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/behaviors/containable.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/behaviors/translate.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/behaviors/tree.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/cake_schema.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/connection_manager.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/datasources/dbo_source.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/db_acl.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/model.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/model_delete.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/model_integration.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/model_read.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/model_validation.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/model_write.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/model/models.php (100%) rename {cake => lib/Cake}/tests/cases/libs/multibyte.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/object.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/object_collection.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/route/cake_route.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/route/plugin_short_route.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/route/redirect_route.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/router.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/sanitize.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/security.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/session/cache_session.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/session/database_session.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/set.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/string.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/test_manager.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/validation.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helper.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helper_collection.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/cache.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/form.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/html.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/jquery_engine.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/js.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/mootools_engine.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/number.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/paginator.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/prototype_engine.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/rss.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/session.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/text.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/helpers/time.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/media.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/theme.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/view/view.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/xml.test.php (100%) rename {cake => lib/Cake}/tests/fixtures/account_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/aco_action_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/aco_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/aco_two_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/ad_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/advertisement_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/after_tree_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/another_article_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/apple_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/aro_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/aro_two_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/aros_aco_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/aros_aco_two_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/article_featured_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/article_featureds_tags_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/article_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/articles_tag_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/assert_tags_test_case.php (100%) rename {cake => lib/Cake}/tests/fixtures/attachment_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/auth_user_custom_field_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/auth_user_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/author_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/bake_article_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/bake_articles_bake_tag_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/bake_comment_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/bake_tag_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/basket_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/bid_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/binary_test_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/book_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/cache_test_model_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/callback_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/campaign_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/category_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/category_thread_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/cd_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/comment_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/content_account_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/content_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/counter_cache_post_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/counter_cache_user_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/data_test_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/datatype_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/dependency_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/device_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/device_type_category_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/device_type_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/document_directory_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/document_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/exterior_type_category_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/feature_set_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/featured_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/film_file_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/fixturized_test_case.php (100%) rename {cake => lib/Cake}/tests/fixtures/flag_tree_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/fruit_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/fruits_uuid_tag_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/group_update_all_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/home_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/image_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/item_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/items_portfolio_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/join_a_b_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/join_a_c_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/join_a_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/join_b_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/join_c_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/join_thing_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/message_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/my_categories_my_products_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/my_categories_my_users_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/my_category_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/my_product_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/my_user_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/node_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/number_tree_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/number_tree_two_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/numeric_article_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/overall_favorite_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/person_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/portfolio_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/post_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/posts_tag_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/primary_model_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/product_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/product_update_all_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/project_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/rss.xml (100%) rename {cake => lib/Cake}/tests/fixtures/sample.xml (100%) rename {cake => lib/Cake}/tests/fixtures/sample_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/secondary_model_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/session_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/soap_request.xml (100%) rename {cake => lib/Cake}/tests/fixtures/soap_response.xml (100%) rename {cake => lib/Cake}/tests/fixtures/something_else_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/something_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/stories_tag_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/story_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/syfile_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/tag_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/test_plugin_article_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/test_plugin_comment_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/the_paper_monkies_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/thread_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/translate_article_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/translate_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/translate_table_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/translate_with_prefix_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/translated_article_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/translated_item_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/unconventional_tree_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/underscore_field_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/user_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/uuid_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/uuid_tag_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/uuid_tree_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/uuiditem_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/uuiditems_uuidportfolio_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php (100%) rename {cake => lib/Cake}/tests/fixtures/uuidportfolio_fixture.php (100%) rename {cake => lib/Cake}/tests/test_app/config/acl.ini.php (100%) rename {cake => lib/Cake}/tests/test_app/config/empty.php (100%) rename {cake => lib/Cake}/tests/test_app/config/nested.ini (100%) rename {cake => lib/Cake}/tests/test_app/config/var_test.php (100%) rename {cake => lib/Cake}/tests/test_app/console/shells/sample.php (100%) rename {cake => lib/Cake}/tests/test_app/console/shells/tasks/empty (100%) rename {cake => lib/Cake}/tests/test_app/console/templates/test/classes/test_object.ctp (100%) rename {cake => lib/Cake}/tests/test_app/controllers/components/empty (100%) rename {cake => lib/Cake}/tests/test_app/controllers/tests_apps_controller.php (100%) rename {cake => lib/Cake}/tests/test_app/controllers/tests_apps_posts_controller.php (100%) rename {cake => lib/Cake}/tests/test_app/libs/cache/test_app_cache.php (100%) rename {cake => lib/Cake}/tests/test_app/libs/library.php (100%) rename {cake => lib/Cake}/tests/test_app/libs/log/test_app_log.php (100%) rename {cake => lib/Cake}/tests/test_app/libs/session/test_app_lib_session.php (100%) rename {cake => lib/Cake}/tests/test_app/locale/cache_test_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom1.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom2.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/ja_jp/LC_TIME (100%) rename {cake => lib/Cake}/tests/test_app/locale/po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/po/LC_MONETARY/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/po/LC_TIME (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_0_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_0_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_0_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_0_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_10_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_10_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_10_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_10_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_11_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_11_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_11_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_11_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_12_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_12_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_12_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_12_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_13_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_13_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_13_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_13_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_14_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_14_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_14_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_14_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_1_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_1_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_1_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_1_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_2_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_2_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_2_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_2_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_3_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_3_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_3_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_3_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_4_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_4_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_4_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_4_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_5_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_5_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_5_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_5_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_6_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_6_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_6_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_6_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_7_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_7_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_7_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_7_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_8_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_8_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_8_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_8_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_9_mo/LC_MESSAGES/core.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_9_mo/LC_MESSAGES/default.mo (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_9_po/LC_MESSAGES/core.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/rule_9_po/LC_MESSAGES/default.po (100%) rename {cake => lib/Cake}/tests/test_app/locale/time_test/LC_TIME (100%) rename {cake => lib/Cake}/tests/test_app/models/behaviors/empty (100%) rename {cake => lib/Cake}/tests/test_app/models/behaviors/persister_one_behavior.php (100%) rename {cake => lib/Cake}/tests/test_app/models/behaviors/persister_two_behavior.php (100%) rename {cake => lib/Cake}/tests/test_app/models/comment.php (100%) rename {cake => lib/Cake}/tests/test_app/models/datasources/test/test_local_driver.php (100%) rename {cake => lib/Cake}/tests/test_app/models/datasources/test2_other_source.php (100%) rename {cake => lib/Cake}/tests/test_app/models/datasources/test2_source.php (100%) rename {cake => lib/Cake}/tests/test_app/models/persister_one.php (100%) rename {cake => lib/Cake}/tests/test_app/models/persister_two.php (100%) rename {cake => lib/Cake}/tests/test_app/models/post.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/plugin_js/webroot/js/one/plugin_one.js (100%) rename {cake => lib/Cake}/tests/test_app/plugins/plugin_js/webroot/js/plugin_js.js (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/config/load.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/config/more.load.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/config/schema/schema.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/console/shells/example.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/console/shells/tasks/empty (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/console/shells/tasks/other_task.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/console/templates/empty (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/controllers/components/other_component.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/controllers/test_plugin_controller.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/controllers/tests_controller.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/libs/session/test_plugin_session.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/locale/po/LC_MESSAGES/test_plugin.po (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/locale/po/LC_MONETARY/test_plugin.po (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_one.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_two.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/models/datasources/dbo/dbo_dummy.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/models/datasources/test/test_driver.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/models/datasources/test_other_source.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/models/datasources/test_source.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/models/test_plugin_authors.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/models/test_plugin_comment.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/models/test_plugin_post.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/test_plugin_app_model.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/vendors/welcome.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/views/elements/plugin_element.ctp (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/views/elements/test_plugin_element.ctp (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/views/helpers/test_plugin_app.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/views/layouts/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/views/tests/index.ctp (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/views/tests/scaffold.edit.ctp (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/webroot/css/test_plugin_asset.css (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/webroot/css/theme_one.htc (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/webroot/css/unknown.extension (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/webroot/flash/plugin_test.swf (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/webroot/img/cake.icon.gif (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/webroot/js/test_plugin/test.js (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/webroot/pdfs/plugin_test.pdf (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/webroot/root.js (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin_two/console/shells/example.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin_two/console/shells/tasks/empty (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin_two/console/shells/welcome.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin_two/console/templates/empty (100%) rename {cake => lib/Cake}/tests/test_app/tmp/dir_map (100%) rename {cake => lib/Cake}/tests/test_app/vendors/Test/MyTest.php (100%) rename {cake => lib/Cake}/tests/test_app/vendors/Test/hello.php (100%) rename {cake => lib/Cake}/tests/test_app/vendors/css/test_asset.css (100%) rename {cake => lib/Cake}/tests/test_app/vendors/img/test.jpg (100%) rename {cake => lib/Cake}/tests/test_app/vendors/sample/configure_test_vendor_sample.php (100%) rename {cake => lib/Cake}/tests/test_app/vendors/somename/some.name.php (100%) rename {cake => lib/Cake}/tests/test_app/vendors/welcome.php (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/email/html/custom.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/email/html/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/email/text/custom.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/email/text/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/email/text/wide.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/empty (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/nocache/contains_nocache.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/nocache/plain.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/nocache/sub1.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/nocache/sub2.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/session_helper.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/test_element.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/errors/empty (100%) rename {cake => lib/Cake}/tests/test_app/views/helpers/banana.php (100%) rename {cake => lib/Cake}/tests/test_app/views/helpers/empty (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/ajax.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/ajax2.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/cache_empty_sections.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/cache_layout.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/email/html/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/email/html/thin.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/email/text/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/flash.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/js/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/multi_cache.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/rss/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/xml/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/pages/empty (100%) rename {cake => lib/Cake}/tests/test_app/views/pages/extract.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/pages/home.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/posts/cache_empty_sections.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/posts/cache_form.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/posts/helper_overwrite.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/posts/index.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/posts/multiple_nocache.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/posts/nocache_multiple_element.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/posts/scaffold.edit.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/posts/sequencial_nocache.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/posts/test_nocache_tags.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/scaffolds/empty (100%) rename {cake => lib/Cake}/tests/test_app/views/tests_apps/index.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/elements/test_element.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/layouts/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/plugins/test_plugin/layouts/plugin_default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/plugins/test_plugin/tests/index.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/posts/index.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/posts/scaffold.index.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/webroot/css/test_asset.css (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/webroot/css/theme_webroot.css (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/webroot/flash/theme_test.swf (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/webroot/img/cake.power.gif (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/webroot/img/test.jpg (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/webroot/js/one/theme_one.js (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/webroot/js/theme.js (100%) rename {cake => lib/Cake}/tests/test_app/views/themed/test_theme/webroot/pdfs/theme_test.pdf (100%) rename {cake => lib/Cake}/tests/test_app/webroot/theme/test_theme/css/theme_webroot.css (100%) rename {cake => lib/Cake}/tests/test_app/webroot/theme/test_theme/css/webroot_test.css (100%) rename {cake => lib/Cake}/tests/test_app/webroot/theme/test_theme/img/cake.power.gif (100%) rename {cake => lib/Cake}/tests/test_app/webroot/theme/test_theme/img/test.jpg (100%) diff --git a/cake/tests/cases/basics.test.php b/lib/Cake/tests/cases/basics.test.php similarity index 100% rename from cake/tests/cases/basics.test.php rename to lib/Cake/tests/cases/basics.test.php 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 100% 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 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 100% 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 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 100% rename from cake/tests/cases/console/libs/console_output.test.php rename to lib/Cake/tests/cases/console/libs/console_output.test.php 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 100% rename from cake/tests/cases/console/libs/help_formatter.test.php rename to lib/Cake/tests/cases/console/libs/help_formatter.test.php diff --git a/cake/tests/cases/console/libs/task_collection.test.php b/lib/Cake/tests/cases/console/libs/task_collection.test.php similarity index 100% rename from cake/tests/cases/console/libs/task_collection.test.php rename to lib/Cake/tests/cases/console/libs/task_collection.test.php diff --git a/cake/tests/cases/console/shell_dispatcher.test.php b/lib/Cake/tests/cases/console/shell_dispatcher.test.php similarity index 100% rename from cake/tests/cases/console/shell_dispatcher.test.php rename to lib/Cake/tests/cases/console/shell_dispatcher.test.php diff --git a/cake/tests/cases/console/shells/acl.test.php b/lib/Cake/tests/cases/console/shells/acl.test.php similarity index 100% rename from cake/tests/cases/console/shells/acl.test.php rename to lib/Cake/tests/cases/console/shells/acl.test.php diff --git a/cake/tests/cases/console/shells/api.test.php b/lib/Cake/tests/cases/console/shells/api.test.php similarity index 100% rename from cake/tests/cases/console/shells/api.test.php rename to lib/Cake/tests/cases/console/shells/api.test.php diff --git a/cake/tests/cases/console/shells/bake.test.php b/lib/Cake/tests/cases/console/shells/bake.test.php similarity index 100% rename from cake/tests/cases/console/shells/bake.test.php rename to lib/Cake/tests/cases/console/shells/bake.test.php 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 100% rename from cake/tests/cases/console/shells/command_list.test.php rename to lib/Cake/tests/cases/console/shells/command_list.test.php diff --git a/cake/tests/cases/console/shells/schema.test.php b/lib/Cake/tests/cases/console/shells/schema.test.php similarity index 100% rename from cake/tests/cases/console/shells/schema.test.php rename to lib/Cake/tests/cases/console/shells/schema.test.php diff --git a/cake/tests/cases/console/shells/shell.test.php b/lib/Cake/tests/cases/console/shells/shell.test.php similarity index 100% rename from cake/tests/cases/console/shells/shell.test.php rename to lib/Cake/tests/cases/console/shells/shell.test.php 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 100% rename from cake/tests/cases/console/shells/tasks/controller.test.php rename to lib/Cake/tests/cases/console/shells/tasks/controller.test.php 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 100% 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 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 100% rename from cake/tests/cases/console/shells/tasks/extract.test.php rename to lib/Cake/tests/cases/console/shells/tasks/extract.test.php 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 100% rename from cake/tests/cases/console/shells/tasks/fixture.test.php rename to lib/Cake/tests/cases/console/shells/tasks/fixture.test.php 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 100% rename from cake/tests/cases/console/shells/tasks/model.test.php rename to lib/Cake/tests/cases/console/shells/tasks/model.test.php 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 100% rename from cake/tests/cases/console/shells/tasks/plugin.test.php rename to lib/Cake/tests/cases/console/shells/tasks/plugin.test.php 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 100% rename from cake/tests/cases/console/shells/tasks/project.test.php rename to lib/Cake/tests/cases/console/shells/tasks/project.test.php 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 100% rename from cake/tests/cases/console/shells/tasks/template.test.php rename to lib/Cake/tests/cases/console/shells/tasks/template.test.php 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 100% rename from cake/tests/cases/console/shells/tasks/test.test.php rename to lib/Cake/tests/cases/console/shells/tasks/test.test.php 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 100% rename from cake/tests/cases/console/shells/tasks/view.test.php rename to lib/Cake/tests/cases/console/shells/tasks/view.test.php diff --git a/cake/tests/cases/console/shells/testsuite.test.php b/lib/Cake/tests/cases/console/shells/testsuite.test.php similarity index 100% rename from cake/tests/cases/console/shells/testsuite.test.php rename to lib/Cake/tests/cases/console/shells/testsuite.test.php 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/cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php similarity index 100% rename from cake/tests/cases/libs/app.test.php rename to lib/Cake/tests/cases/libs/app.test.php diff --git a/cake/tests/cases/libs/cache.test.php b/lib/Cake/tests/cases/libs/cache.test.php similarity index 100% rename from cake/tests/cases/libs/cache.test.php rename to lib/Cake/tests/cases/libs/cache.test.php diff --git a/cake/tests/cases/libs/cache/apc.test.php b/lib/Cake/tests/cases/libs/cache/apc.test.php similarity index 100% rename from cake/tests/cases/libs/cache/apc.test.php rename to lib/Cake/tests/cases/libs/cache/apc.test.php diff --git a/cake/tests/cases/libs/cache/file.test.php b/lib/Cake/tests/cases/libs/cache/file.test.php similarity index 100% rename from cake/tests/cases/libs/cache/file.test.php rename to lib/Cake/tests/cases/libs/cache/file.test.php diff --git a/cake/tests/cases/libs/cache/memcache.test.php b/lib/Cake/tests/cases/libs/cache/memcache.test.php similarity index 100% rename from cake/tests/cases/libs/cache/memcache.test.php rename to lib/Cake/tests/cases/libs/cache/memcache.test.php diff --git a/cake/tests/cases/libs/cache/xcache.test.php b/lib/Cake/tests/cases/libs/cache/xcache.test.php similarity index 100% rename from cake/tests/cases/libs/cache/xcache.test.php rename to lib/Cake/tests/cases/libs/cache/xcache.test.php diff --git a/cake/tests/cases/libs/cake_log.test.php b/lib/Cake/tests/cases/libs/cake_log.test.php similarity index 100% rename from cake/tests/cases/libs/cake_log.test.php rename to lib/Cake/tests/cases/libs/cake_log.test.php diff --git a/cake/tests/cases/libs/cake_request.test.php b/lib/Cake/tests/cases/libs/cake_request.test.php similarity index 100% rename from cake/tests/cases/libs/cake_request.test.php rename to lib/Cake/tests/cases/libs/cake_request.test.php diff --git a/cake/tests/cases/libs/cake_response.test.php b/lib/Cake/tests/cases/libs/cake_response.test.php similarity index 100% rename from cake/tests/cases/libs/cake_response.test.php rename to lib/Cake/tests/cases/libs/cake_response.test.php diff --git a/cake/tests/cases/libs/cake_session.test.php b/lib/Cake/tests/cases/libs/cake_session.test.php similarity index 100% rename from cake/tests/cases/libs/cake_session.test.php rename to lib/Cake/tests/cases/libs/cake_session.test.php diff --git a/cake/tests/cases/libs/cake_socket.test.php b/lib/Cake/tests/cases/libs/cake_socket.test.php similarity index 100% rename from cake/tests/cases/libs/cake_socket.test.php rename to lib/Cake/tests/cases/libs/cake_socket.test.php 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 100% rename from cake/tests/cases/libs/cake_test_case.test.php rename to lib/Cake/tests/cases/libs/cake_test_case.test.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 100% rename from cake/tests/cases/libs/cake_test_fixture.test.php rename to lib/Cake/tests/cases/libs/cake_test_fixture.test.php diff --git a/cake/tests/cases/libs/class_registry.test.php b/lib/Cake/tests/cases/libs/class_registry.test.php similarity index 100% rename from cake/tests/cases/libs/class_registry.test.php rename to lib/Cake/tests/cases/libs/class_registry.test.php 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 100% rename from cake/tests/cases/libs/config/ini_reader.test.php rename to lib/Cake/tests/cases/libs/config/ini_reader.test.php 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 100% rename from cake/tests/cases/libs/config/php_reader.test.php rename to lib/Cake/tests/cases/libs/config/php_reader.test.php diff --git a/cake/tests/cases/libs/configure.test.php b/lib/Cake/tests/cases/libs/configure.test.php similarity index 100% rename from cake/tests/cases/libs/configure.test.php rename to lib/Cake/tests/cases/libs/configure.test.php diff --git a/cake/tests/cases/libs/controller/component.test.php b/lib/Cake/tests/cases/libs/controller/component.test.php similarity index 100% rename from cake/tests/cases/libs/controller/component.test.php rename to lib/Cake/tests/cases/libs/controller/component.test.php 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 100% rename from cake/tests/cases/libs/controller/component_collection.test.php rename to lib/Cake/tests/cases/libs/controller/component_collection.test.php 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 100% rename from cake/tests/cases/libs/controller/components/acl.test.php rename to lib/Cake/tests/cases/libs/controller/components/acl.test.php 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 100% rename from cake/tests/cases/libs/controller/components/auth.test.php rename to lib/Cake/tests/cases/libs/controller/components/auth.test.php 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 100% rename from cake/tests/cases/libs/controller/components/cookie.test.php rename to lib/Cake/tests/cases/libs/controller/components/cookie.test.php 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 100% rename from cake/tests/cases/libs/controller/components/email.test.php rename to lib/Cake/tests/cases/libs/controller/components/email.test.php 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 100% 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 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 100% rename from cake/tests/cases/libs/controller/components/security.test.php rename to lib/Cake/tests/cases/libs/controller/components/security.test.php 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 100% rename from cake/tests/cases/libs/controller/components/session.test.php rename to lib/Cake/tests/cases/libs/controller/components/session.test.php diff --git a/cake/tests/cases/libs/controller/controller.test.php b/lib/Cake/tests/cases/libs/controller/controller.test.php similarity index 100% rename from cake/tests/cases/libs/controller/controller.test.php rename to lib/Cake/tests/cases/libs/controller/controller.test.php 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 100% 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 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 100% rename from cake/tests/cases/libs/controller/pages_controller.test.php rename to lib/Cake/tests/cases/libs/controller/pages_controller.test.php diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/lib/Cake/tests/cases/libs/controller/scaffold.test.php similarity index 100% rename from cake/tests/cases/libs/controller/scaffold.test.php rename to lib/Cake/tests/cases/libs/controller/scaffold.test.php diff --git a/cake/tests/cases/libs/debugger.test.php b/lib/Cake/tests/cases/libs/debugger.test.php similarity index 100% rename from cake/tests/cases/libs/debugger.test.php rename to lib/Cake/tests/cases/libs/debugger.test.php diff --git a/cake/tests/cases/libs/dispatcher.test.php b/lib/Cake/tests/cases/libs/dispatcher.test.php similarity index 100% rename from cake/tests/cases/libs/dispatcher.test.php rename to lib/Cake/tests/cases/libs/dispatcher.test.php 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 100% rename from cake/tests/cases/libs/error/error_handler.test.php rename to lib/Cake/tests/cases/libs/error/error_handler.test.php 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 100% rename from cake/tests/cases/libs/error/exception_renderer.test.php rename to lib/Cake/tests/cases/libs/error/exception_renderer.test.php diff --git a/cake/tests/cases/libs/file.test.php b/lib/Cake/tests/cases/libs/file.test.php similarity index 100% rename from cake/tests/cases/libs/file.test.php rename to lib/Cake/tests/cases/libs/file.test.php diff --git a/cake/tests/cases/libs/folder.test.php b/lib/Cake/tests/cases/libs/folder.test.php similarity index 100% rename from cake/tests/cases/libs/folder.test.php rename to lib/Cake/tests/cases/libs/folder.test.php 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 100% rename from cake/tests/cases/libs/html_coverage_report.test.php rename to lib/Cake/tests/cases/libs/html_coverage_report.test.php diff --git a/cake/tests/cases/libs/http_socket.test.php b/lib/Cake/tests/cases/libs/http_socket.test.php similarity index 100% rename from cake/tests/cases/libs/http_socket.test.php rename to lib/Cake/tests/cases/libs/http_socket.test.php diff --git a/cake/tests/cases/libs/i18n.test.php b/lib/Cake/tests/cases/libs/i18n.test.php similarity index 100% rename from cake/tests/cases/libs/i18n.test.php rename to lib/Cake/tests/cases/libs/i18n.test.php diff --git a/cake/tests/cases/libs/inflector.test.php b/lib/Cake/tests/cases/libs/inflector.test.php similarity index 100% rename from cake/tests/cases/libs/inflector.test.php rename to lib/Cake/tests/cases/libs/inflector.test.php diff --git a/cake/tests/cases/libs/l10n.test.php b/lib/Cake/tests/cases/libs/l10n.test.php similarity index 100% rename from cake/tests/cases/libs/l10n.test.php rename to lib/Cake/tests/cases/libs/l10n.test.php 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 100% rename from cake/tests/cases/libs/log/file_log.test.php rename to lib/Cake/tests/cases/libs/log/file_log.test.php 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 100% rename from cake/tests/cases/libs/model/behavior_collection.test.php rename to lib/Cake/tests/cases/libs/model/behavior_collection.test.php 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 100% rename from cake/tests/cases/libs/model/behaviors/acl.test.php rename to lib/Cake/tests/cases/libs/model/behaviors/acl.test.php 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 100% rename from cake/tests/cases/libs/model/behaviors/containable.test.php rename to lib/Cake/tests/cases/libs/model/behaviors/containable.test.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 100% rename from cake/tests/cases/libs/model/behaviors/translate.test.php rename to lib/Cake/tests/cases/libs/model/behaviors/translate.test.php 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 100% rename from cake/tests/cases/libs/model/behaviors/tree.test.php rename to lib/Cake/tests/cases/libs/model/behaviors/tree.test.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 100% rename from cake/tests/cases/libs/model/cake_schema.test.php rename to lib/Cake/tests/cases/libs/model/cake_schema.test.php 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 100% rename from cake/tests/cases/libs/model/connection_manager.test.php rename to lib/Cake/tests/cases/libs/model/connection_manager.test.php 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 100% 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 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 100% 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 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 100% 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 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 100% 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 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 100% rename from cake/tests/cases/libs/model/db_acl.test.php rename to lib/Cake/tests/cases/libs/model/db_acl.test.php diff --git a/cake/tests/cases/libs/model/model.test.php b/lib/Cake/tests/cases/libs/model/model.test.php similarity index 100% rename from cake/tests/cases/libs/model/model.test.php rename to lib/Cake/tests/cases/libs/model/model.test.php 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 100% rename from cake/tests/cases/libs/model/model_integration.test.php rename to lib/Cake/tests/cases/libs/model/model_integration.test.php 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 100% rename from cake/tests/cases/libs/model/model_read.test.php rename to lib/Cake/tests/cases/libs/model/model_read.test.php 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 100% rename from cake/tests/cases/libs/model/model_write.test.php rename to lib/Cake/tests/cases/libs/model/model_write.test.php 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 100% rename from cake/tests/cases/libs/multibyte.test.php rename to lib/Cake/tests/cases/libs/multibyte.test.php diff --git a/cake/tests/cases/libs/object.test.php b/lib/Cake/tests/cases/libs/object.test.php similarity index 100% rename from cake/tests/cases/libs/object.test.php rename to lib/Cake/tests/cases/libs/object.test.php diff --git a/cake/tests/cases/libs/object_collection.test.php b/lib/Cake/tests/cases/libs/object_collection.test.php similarity index 100% rename from cake/tests/cases/libs/object_collection.test.php rename to lib/Cake/tests/cases/libs/object_collection.test.php 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 100% rename from cake/tests/cases/libs/route/cake_route.test.php rename to lib/Cake/tests/cases/libs/route/cake_route.test.php diff --git a/cake/tests/cases/libs/route/plugin_short_route.test.php b/lib/Cake/tests/cases/libs/route/plugin_short_route.test.php similarity index 100% rename from cake/tests/cases/libs/route/plugin_short_route.test.php rename to lib/Cake/tests/cases/libs/route/plugin_short_route.test.php diff --git a/cake/tests/cases/libs/route/redirect_route.test.php b/lib/Cake/tests/cases/libs/route/redirect_route.test.php similarity index 100% rename from cake/tests/cases/libs/route/redirect_route.test.php rename to lib/Cake/tests/cases/libs/route/redirect_route.test.php diff --git a/cake/tests/cases/libs/router.test.php b/lib/Cake/tests/cases/libs/router.test.php similarity index 100% rename from cake/tests/cases/libs/router.test.php rename to lib/Cake/tests/cases/libs/router.test.php diff --git a/cake/tests/cases/libs/sanitize.test.php b/lib/Cake/tests/cases/libs/sanitize.test.php similarity index 100% rename from cake/tests/cases/libs/sanitize.test.php rename to lib/Cake/tests/cases/libs/sanitize.test.php diff --git a/cake/tests/cases/libs/security.test.php b/lib/Cake/tests/cases/libs/security.test.php similarity index 100% rename from cake/tests/cases/libs/security.test.php rename to lib/Cake/tests/cases/libs/security.test.php 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 100% rename from cake/tests/cases/libs/session/cache_session.test.php rename to lib/Cake/tests/cases/libs/session/cache_session.test.php 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 100% rename from cake/tests/cases/libs/session/database_session.test.php rename to lib/Cake/tests/cases/libs/session/database_session.test.php diff --git a/cake/tests/cases/libs/set.test.php b/lib/Cake/tests/cases/libs/set.test.php similarity index 100% rename from cake/tests/cases/libs/set.test.php rename to lib/Cake/tests/cases/libs/set.test.php diff --git a/cake/tests/cases/libs/string.test.php b/lib/Cake/tests/cases/libs/string.test.php similarity index 100% rename from cake/tests/cases/libs/string.test.php rename to lib/Cake/tests/cases/libs/string.test.php diff --git a/cake/tests/cases/libs/test_manager.test.php b/lib/Cake/tests/cases/libs/test_manager.test.php similarity index 100% rename from cake/tests/cases/libs/test_manager.test.php rename to lib/Cake/tests/cases/libs/test_manager.test.php diff --git a/cake/tests/cases/libs/validation.test.php b/lib/Cake/tests/cases/libs/validation.test.php similarity index 100% rename from cake/tests/cases/libs/validation.test.php rename to lib/Cake/tests/cases/libs/validation.test.php diff --git a/cake/tests/cases/libs/view/helper.test.php b/lib/Cake/tests/cases/libs/view/helper.test.php similarity index 100% rename from cake/tests/cases/libs/view/helper.test.php rename to lib/Cake/tests/cases/libs/view/helper.test.php diff --git a/cake/tests/cases/libs/view/helper_collection.test.php b/lib/Cake/tests/cases/libs/view/helper_collection.test.php similarity index 100% rename from cake/tests/cases/libs/view/helper_collection.test.php rename to lib/Cake/tests/cases/libs/view/helper_collection.test.php diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/lib/Cake/tests/cases/libs/view/helpers/cache.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/cache.test.php rename to lib/Cake/tests/cases/libs/view/helpers/cache.test.php diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/lib/Cake/tests/cases/libs/view/helpers/form.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/form.test.php rename to lib/Cake/tests/cases/libs/view/helpers/form.test.php diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/lib/Cake/tests/cases/libs/view/helpers/html.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/html.test.php rename to lib/Cake/tests/cases/libs/view/helpers/html.test.php diff --git a/cake/tests/cases/libs/view/helpers/jquery_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/jquery_engine.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/jquery_engine.test.php rename to lib/Cake/tests/cases/libs/view/helpers/jquery_engine.test.php diff --git a/cake/tests/cases/libs/view/helpers/js.test.php b/lib/Cake/tests/cases/libs/view/helpers/js.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/js.test.php rename to lib/Cake/tests/cases/libs/view/helpers/js.test.php diff --git a/cake/tests/cases/libs/view/helpers/mootools_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/mootools_engine.test.php rename to lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php diff --git a/cake/tests/cases/libs/view/helpers/number.test.php b/lib/Cake/tests/cases/libs/view/helpers/number.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/number.test.php rename to lib/Cake/tests/cases/libs/view/helpers/number.test.php diff --git a/cake/tests/cases/libs/view/helpers/paginator.test.php b/lib/Cake/tests/cases/libs/view/helpers/paginator.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/paginator.test.php rename to lib/Cake/tests/cases/libs/view/helpers/paginator.test.php diff --git a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/prototype_engine.test.php rename to lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php diff --git a/cake/tests/cases/libs/view/helpers/rss.test.php b/lib/Cake/tests/cases/libs/view/helpers/rss.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/rss.test.php rename to lib/Cake/tests/cases/libs/view/helpers/rss.test.php diff --git a/cake/tests/cases/libs/view/helpers/session.test.php b/lib/Cake/tests/cases/libs/view/helpers/session.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/session.test.php rename to lib/Cake/tests/cases/libs/view/helpers/session.test.php diff --git a/cake/tests/cases/libs/view/helpers/text.test.php b/lib/Cake/tests/cases/libs/view/helpers/text.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/text.test.php rename to lib/Cake/tests/cases/libs/view/helpers/text.test.php diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/lib/Cake/tests/cases/libs/view/helpers/time.test.php similarity index 100% rename from cake/tests/cases/libs/view/helpers/time.test.php rename to lib/Cake/tests/cases/libs/view/helpers/time.test.php diff --git a/cake/tests/cases/libs/view/media.test.php b/lib/Cake/tests/cases/libs/view/media.test.php similarity index 100% rename from cake/tests/cases/libs/view/media.test.php rename to lib/Cake/tests/cases/libs/view/media.test.php diff --git a/cake/tests/cases/libs/view/theme.test.php b/lib/Cake/tests/cases/libs/view/theme.test.php similarity index 100% rename from cake/tests/cases/libs/view/theme.test.php rename to lib/Cake/tests/cases/libs/view/theme.test.php diff --git a/cake/tests/cases/libs/view/view.test.php b/lib/Cake/tests/cases/libs/view/view.test.php similarity index 100% rename from cake/tests/cases/libs/view/view.test.php rename to lib/Cake/tests/cases/libs/view/view.test.php diff --git a/cake/tests/cases/libs/xml.test.php b/lib/Cake/tests/cases/libs/xml.test.php similarity index 100% rename from cake/tests/cases/libs/xml.test.php rename to lib/Cake/tests/cases/libs/xml.test.php diff --git a/cake/tests/fixtures/account_fixture.php b/lib/Cake/tests/fixtures/account_fixture.php similarity index 100% rename from cake/tests/fixtures/account_fixture.php rename to lib/Cake/tests/fixtures/account_fixture.php diff --git a/cake/tests/fixtures/aco_action_fixture.php b/lib/Cake/tests/fixtures/aco_action_fixture.php similarity index 100% rename from cake/tests/fixtures/aco_action_fixture.php rename to lib/Cake/tests/fixtures/aco_action_fixture.php diff --git a/cake/tests/fixtures/aco_fixture.php b/lib/Cake/tests/fixtures/aco_fixture.php similarity index 100% rename from cake/tests/fixtures/aco_fixture.php rename to lib/Cake/tests/fixtures/aco_fixture.php diff --git a/cake/tests/fixtures/aco_two_fixture.php b/lib/Cake/tests/fixtures/aco_two_fixture.php similarity index 100% rename from cake/tests/fixtures/aco_two_fixture.php rename to lib/Cake/tests/fixtures/aco_two_fixture.php diff --git a/cake/tests/fixtures/ad_fixture.php b/lib/Cake/tests/fixtures/ad_fixture.php similarity index 100% rename from cake/tests/fixtures/ad_fixture.php rename to lib/Cake/tests/fixtures/ad_fixture.php diff --git a/cake/tests/fixtures/advertisement_fixture.php b/lib/Cake/tests/fixtures/advertisement_fixture.php similarity index 100% rename from cake/tests/fixtures/advertisement_fixture.php rename to lib/Cake/tests/fixtures/advertisement_fixture.php diff --git a/cake/tests/fixtures/after_tree_fixture.php b/lib/Cake/tests/fixtures/after_tree_fixture.php similarity index 100% rename from cake/tests/fixtures/after_tree_fixture.php rename to lib/Cake/tests/fixtures/after_tree_fixture.php diff --git a/cake/tests/fixtures/another_article_fixture.php b/lib/Cake/tests/fixtures/another_article_fixture.php similarity index 100% rename from cake/tests/fixtures/another_article_fixture.php rename to lib/Cake/tests/fixtures/another_article_fixture.php diff --git a/cake/tests/fixtures/apple_fixture.php b/lib/Cake/tests/fixtures/apple_fixture.php similarity index 100% rename from cake/tests/fixtures/apple_fixture.php rename to lib/Cake/tests/fixtures/apple_fixture.php diff --git a/cake/tests/fixtures/aro_fixture.php b/lib/Cake/tests/fixtures/aro_fixture.php similarity index 100% rename from cake/tests/fixtures/aro_fixture.php rename to lib/Cake/tests/fixtures/aro_fixture.php diff --git a/cake/tests/fixtures/aro_two_fixture.php b/lib/Cake/tests/fixtures/aro_two_fixture.php similarity index 100% rename from cake/tests/fixtures/aro_two_fixture.php rename to lib/Cake/tests/fixtures/aro_two_fixture.php diff --git a/cake/tests/fixtures/aros_aco_fixture.php b/lib/Cake/tests/fixtures/aros_aco_fixture.php similarity index 100% rename from cake/tests/fixtures/aros_aco_fixture.php rename to lib/Cake/tests/fixtures/aros_aco_fixture.php diff --git a/cake/tests/fixtures/aros_aco_two_fixture.php b/lib/Cake/tests/fixtures/aros_aco_two_fixture.php similarity index 100% rename from cake/tests/fixtures/aros_aco_two_fixture.php rename to lib/Cake/tests/fixtures/aros_aco_two_fixture.php diff --git a/cake/tests/fixtures/article_featured_fixture.php b/lib/Cake/tests/fixtures/article_featured_fixture.php similarity index 100% rename from cake/tests/fixtures/article_featured_fixture.php rename to lib/Cake/tests/fixtures/article_featured_fixture.php diff --git a/cake/tests/fixtures/article_featureds_tags_fixture.php b/lib/Cake/tests/fixtures/article_featureds_tags_fixture.php similarity index 100% rename from cake/tests/fixtures/article_featureds_tags_fixture.php rename to lib/Cake/tests/fixtures/article_featureds_tags_fixture.php diff --git a/cake/tests/fixtures/article_fixture.php b/lib/Cake/tests/fixtures/article_fixture.php similarity index 100% rename from cake/tests/fixtures/article_fixture.php rename to lib/Cake/tests/fixtures/article_fixture.php diff --git a/cake/tests/fixtures/articles_tag_fixture.php b/lib/Cake/tests/fixtures/articles_tag_fixture.php similarity index 100% rename from cake/tests/fixtures/articles_tag_fixture.php rename to lib/Cake/tests/fixtures/articles_tag_fixture.php diff --git a/cake/tests/fixtures/assert_tags_test_case.php b/lib/Cake/tests/fixtures/assert_tags_test_case.php similarity index 100% rename from cake/tests/fixtures/assert_tags_test_case.php rename to lib/Cake/tests/fixtures/assert_tags_test_case.php diff --git a/cake/tests/fixtures/attachment_fixture.php b/lib/Cake/tests/fixtures/attachment_fixture.php similarity index 100% rename from cake/tests/fixtures/attachment_fixture.php rename to lib/Cake/tests/fixtures/attachment_fixture.php diff --git a/cake/tests/fixtures/auth_user_custom_field_fixture.php b/lib/Cake/tests/fixtures/auth_user_custom_field_fixture.php similarity index 100% rename from cake/tests/fixtures/auth_user_custom_field_fixture.php rename to lib/Cake/tests/fixtures/auth_user_custom_field_fixture.php diff --git a/cake/tests/fixtures/auth_user_fixture.php b/lib/Cake/tests/fixtures/auth_user_fixture.php similarity index 100% rename from cake/tests/fixtures/auth_user_fixture.php rename to lib/Cake/tests/fixtures/auth_user_fixture.php diff --git a/cake/tests/fixtures/author_fixture.php b/lib/Cake/tests/fixtures/author_fixture.php similarity index 100% rename from cake/tests/fixtures/author_fixture.php rename to lib/Cake/tests/fixtures/author_fixture.php diff --git a/cake/tests/fixtures/bake_article_fixture.php b/lib/Cake/tests/fixtures/bake_article_fixture.php similarity index 100% rename from cake/tests/fixtures/bake_article_fixture.php rename to lib/Cake/tests/fixtures/bake_article_fixture.php diff --git a/cake/tests/fixtures/bake_articles_bake_tag_fixture.php b/lib/Cake/tests/fixtures/bake_articles_bake_tag_fixture.php similarity index 100% rename from cake/tests/fixtures/bake_articles_bake_tag_fixture.php rename to lib/Cake/tests/fixtures/bake_articles_bake_tag_fixture.php diff --git a/cake/tests/fixtures/bake_comment_fixture.php b/lib/Cake/tests/fixtures/bake_comment_fixture.php similarity index 100% rename from cake/tests/fixtures/bake_comment_fixture.php rename to lib/Cake/tests/fixtures/bake_comment_fixture.php diff --git a/cake/tests/fixtures/bake_tag_fixture.php b/lib/Cake/tests/fixtures/bake_tag_fixture.php similarity index 100% rename from cake/tests/fixtures/bake_tag_fixture.php rename to lib/Cake/tests/fixtures/bake_tag_fixture.php diff --git a/cake/tests/fixtures/basket_fixture.php b/lib/Cake/tests/fixtures/basket_fixture.php similarity index 100% rename from cake/tests/fixtures/basket_fixture.php rename to lib/Cake/tests/fixtures/basket_fixture.php diff --git a/cake/tests/fixtures/bid_fixture.php b/lib/Cake/tests/fixtures/bid_fixture.php similarity index 100% rename from cake/tests/fixtures/bid_fixture.php rename to lib/Cake/tests/fixtures/bid_fixture.php diff --git a/cake/tests/fixtures/binary_test_fixture.php b/lib/Cake/tests/fixtures/binary_test_fixture.php similarity index 100% rename from cake/tests/fixtures/binary_test_fixture.php rename to lib/Cake/tests/fixtures/binary_test_fixture.php diff --git a/cake/tests/fixtures/book_fixture.php b/lib/Cake/tests/fixtures/book_fixture.php similarity index 100% rename from cake/tests/fixtures/book_fixture.php rename to lib/Cake/tests/fixtures/book_fixture.php diff --git a/cake/tests/fixtures/cache_test_model_fixture.php b/lib/Cake/tests/fixtures/cache_test_model_fixture.php similarity index 100% rename from cake/tests/fixtures/cache_test_model_fixture.php rename to lib/Cake/tests/fixtures/cache_test_model_fixture.php diff --git a/cake/tests/fixtures/callback_fixture.php b/lib/Cake/tests/fixtures/callback_fixture.php similarity index 100% rename from cake/tests/fixtures/callback_fixture.php rename to lib/Cake/tests/fixtures/callback_fixture.php diff --git a/cake/tests/fixtures/campaign_fixture.php b/lib/Cake/tests/fixtures/campaign_fixture.php similarity index 100% rename from cake/tests/fixtures/campaign_fixture.php rename to lib/Cake/tests/fixtures/campaign_fixture.php diff --git a/cake/tests/fixtures/category_fixture.php b/lib/Cake/tests/fixtures/category_fixture.php similarity index 100% rename from cake/tests/fixtures/category_fixture.php rename to lib/Cake/tests/fixtures/category_fixture.php diff --git a/cake/tests/fixtures/category_thread_fixture.php b/lib/Cake/tests/fixtures/category_thread_fixture.php similarity index 100% rename from cake/tests/fixtures/category_thread_fixture.php rename to lib/Cake/tests/fixtures/category_thread_fixture.php diff --git a/cake/tests/fixtures/cd_fixture.php b/lib/Cake/tests/fixtures/cd_fixture.php similarity index 100% rename from cake/tests/fixtures/cd_fixture.php rename to lib/Cake/tests/fixtures/cd_fixture.php diff --git a/cake/tests/fixtures/comment_fixture.php b/lib/Cake/tests/fixtures/comment_fixture.php similarity index 100% rename from cake/tests/fixtures/comment_fixture.php rename to lib/Cake/tests/fixtures/comment_fixture.php diff --git a/cake/tests/fixtures/content_account_fixture.php b/lib/Cake/tests/fixtures/content_account_fixture.php similarity index 100% rename from cake/tests/fixtures/content_account_fixture.php rename to lib/Cake/tests/fixtures/content_account_fixture.php diff --git a/cake/tests/fixtures/content_fixture.php b/lib/Cake/tests/fixtures/content_fixture.php similarity index 100% rename from cake/tests/fixtures/content_fixture.php rename to lib/Cake/tests/fixtures/content_fixture.php diff --git a/cake/tests/fixtures/counter_cache_post_fixture.php b/lib/Cake/tests/fixtures/counter_cache_post_fixture.php similarity index 100% rename from cake/tests/fixtures/counter_cache_post_fixture.php rename to lib/Cake/tests/fixtures/counter_cache_post_fixture.php diff --git a/cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php b/lib/Cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php similarity index 100% rename from cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php rename to lib/Cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php diff --git a/cake/tests/fixtures/counter_cache_user_fixture.php b/lib/Cake/tests/fixtures/counter_cache_user_fixture.php similarity index 100% rename from cake/tests/fixtures/counter_cache_user_fixture.php rename to lib/Cake/tests/fixtures/counter_cache_user_fixture.php diff --git a/cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php b/lib/Cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php similarity index 100% rename from cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php rename to lib/Cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php diff --git a/cake/tests/fixtures/data_test_fixture.php b/lib/Cake/tests/fixtures/data_test_fixture.php similarity index 100% rename from cake/tests/fixtures/data_test_fixture.php rename to lib/Cake/tests/fixtures/data_test_fixture.php diff --git a/cake/tests/fixtures/datatype_fixture.php b/lib/Cake/tests/fixtures/datatype_fixture.php similarity index 100% rename from cake/tests/fixtures/datatype_fixture.php rename to lib/Cake/tests/fixtures/datatype_fixture.php diff --git a/cake/tests/fixtures/dependency_fixture.php b/lib/Cake/tests/fixtures/dependency_fixture.php similarity index 100% rename from cake/tests/fixtures/dependency_fixture.php rename to lib/Cake/tests/fixtures/dependency_fixture.php diff --git a/cake/tests/fixtures/device_fixture.php b/lib/Cake/tests/fixtures/device_fixture.php similarity index 100% rename from cake/tests/fixtures/device_fixture.php rename to lib/Cake/tests/fixtures/device_fixture.php diff --git a/cake/tests/fixtures/device_type_category_fixture.php b/lib/Cake/tests/fixtures/device_type_category_fixture.php similarity index 100% rename from cake/tests/fixtures/device_type_category_fixture.php rename to lib/Cake/tests/fixtures/device_type_category_fixture.php diff --git a/cake/tests/fixtures/device_type_fixture.php b/lib/Cake/tests/fixtures/device_type_fixture.php similarity index 100% rename from cake/tests/fixtures/device_type_fixture.php rename to lib/Cake/tests/fixtures/device_type_fixture.php diff --git a/cake/tests/fixtures/document_directory_fixture.php b/lib/Cake/tests/fixtures/document_directory_fixture.php similarity index 100% rename from cake/tests/fixtures/document_directory_fixture.php rename to lib/Cake/tests/fixtures/document_directory_fixture.php diff --git a/cake/tests/fixtures/document_fixture.php b/lib/Cake/tests/fixtures/document_fixture.php similarity index 100% rename from cake/tests/fixtures/document_fixture.php rename to lib/Cake/tests/fixtures/document_fixture.php diff --git a/cake/tests/fixtures/exterior_type_category_fixture.php b/lib/Cake/tests/fixtures/exterior_type_category_fixture.php similarity index 100% rename from cake/tests/fixtures/exterior_type_category_fixture.php rename to lib/Cake/tests/fixtures/exterior_type_category_fixture.php diff --git a/cake/tests/fixtures/feature_set_fixture.php b/lib/Cake/tests/fixtures/feature_set_fixture.php similarity index 100% rename from cake/tests/fixtures/feature_set_fixture.php rename to lib/Cake/tests/fixtures/feature_set_fixture.php diff --git a/cake/tests/fixtures/featured_fixture.php b/lib/Cake/tests/fixtures/featured_fixture.php similarity index 100% rename from cake/tests/fixtures/featured_fixture.php rename to lib/Cake/tests/fixtures/featured_fixture.php diff --git a/cake/tests/fixtures/film_file_fixture.php b/lib/Cake/tests/fixtures/film_file_fixture.php similarity index 100% rename from cake/tests/fixtures/film_file_fixture.php rename to lib/Cake/tests/fixtures/film_file_fixture.php diff --git a/cake/tests/fixtures/fixturized_test_case.php b/lib/Cake/tests/fixtures/fixturized_test_case.php similarity index 100% rename from cake/tests/fixtures/fixturized_test_case.php rename to lib/Cake/tests/fixtures/fixturized_test_case.php diff --git a/cake/tests/fixtures/flag_tree_fixture.php b/lib/Cake/tests/fixtures/flag_tree_fixture.php similarity index 100% rename from cake/tests/fixtures/flag_tree_fixture.php rename to lib/Cake/tests/fixtures/flag_tree_fixture.php diff --git a/cake/tests/fixtures/fruit_fixture.php b/lib/Cake/tests/fixtures/fruit_fixture.php similarity index 100% rename from cake/tests/fixtures/fruit_fixture.php rename to lib/Cake/tests/fixtures/fruit_fixture.php diff --git a/cake/tests/fixtures/fruits_uuid_tag_fixture.php b/lib/Cake/tests/fixtures/fruits_uuid_tag_fixture.php similarity index 100% rename from cake/tests/fixtures/fruits_uuid_tag_fixture.php rename to lib/Cake/tests/fixtures/fruits_uuid_tag_fixture.php diff --git a/cake/tests/fixtures/group_update_all_fixture.php b/lib/Cake/tests/fixtures/group_update_all_fixture.php similarity index 100% rename from cake/tests/fixtures/group_update_all_fixture.php rename to lib/Cake/tests/fixtures/group_update_all_fixture.php diff --git a/cake/tests/fixtures/home_fixture.php b/lib/Cake/tests/fixtures/home_fixture.php similarity index 100% rename from cake/tests/fixtures/home_fixture.php rename to lib/Cake/tests/fixtures/home_fixture.php diff --git a/cake/tests/fixtures/image_fixture.php b/lib/Cake/tests/fixtures/image_fixture.php similarity index 100% rename from cake/tests/fixtures/image_fixture.php rename to lib/Cake/tests/fixtures/image_fixture.php diff --git a/cake/tests/fixtures/item_fixture.php b/lib/Cake/tests/fixtures/item_fixture.php similarity index 100% rename from cake/tests/fixtures/item_fixture.php rename to lib/Cake/tests/fixtures/item_fixture.php diff --git a/cake/tests/fixtures/items_portfolio_fixture.php b/lib/Cake/tests/fixtures/items_portfolio_fixture.php similarity index 100% rename from cake/tests/fixtures/items_portfolio_fixture.php rename to lib/Cake/tests/fixtures/items_portfolio_fixture.php diff --git a/cake/tests/fixtures/join_a_b_fixture.php b/lib/Cake/tests/fixtures/join_a_b_fixture.php similarity index 100% rename from cake/tests/fixtures/join_a_b_fixture.php rename to lib/Cake/tests/fixtures/join_a_b_fixture.php diff --git a/cake/tests/fixtures/join_a_c_fixture.php b/lib/Cake/tests/fixtures/join_a_c_fixture.php similarity index 100% rename from cake/tests/fixtures/join_a_c_fixture.php rename to lib/Cake/tests/fixtures/join_a_c_fixture.php diff --git a/cake/tests/fixtures/join_a_fixture.php b/lib/Cake/tests/fixtures/join_a_fixture.php similarity index 100% rename from cake/tests/fixtures/join_a_fixture.php rename to lib/Cake/tests/fixtures/join_a_fixture.php diff --git a/cake/tests/fixtures/join_b_fixture.php b/lib/Cake/tests/fixtures/join_b_fixture.php similarity index 100% rename from cake/tests/fixtures/join_b_fixture.php rename to lib/Cake/tests/fixtures/join_b_fixture.php diff --git a/cake/tests/fixtures/join_c_fixture.php b/lib/Cake/tests/fixtures/join_c_fixture.php similarity index 100% rename from cake/tests/fixtures/join_c_fixture.php rename to lib/Cake/tests/fixtures/join_c_fixture.php diff --git a/cake/tests/fixtures/join_thing_fixture.php b/lib/Cake/tests/fixtures/join_thing_fixture.php similarity index 100% rename from cake/tests/fixtures/join_thing_fixture.php rename to lib/Cake/tests/fixtures/join_thing_fixture.php diff --git a/cake/tests/fixtures/message_fixture.php b/lib/Cake/tests/fixtures/message_fixture.php similarity index 100% rename from cake/tests/fixtures/message_fixture.php rename to lib/Cake/tests/fixtures/message_fixture.php diff --git a/cake/tests/fixtures/my_categories_my_products_fixture.php b/lib/Cake/tests/fixtures/my_categories_my_products_fixture.php similarity index 100% rename from cake/tests/fixtures/my_categories_my_products_fixture.php rename to lib/Cake/tests/fixtures/my_categories_my_products_fixture.php diff --git a/cake/tests/fixtures/my_categories_my_users_fixture.php b/lib/Cake/tests/fixtures/my_categories_my_users_fixture.php similarity index 100% rename from cake/tests/fixtures/my_categories_my_users_fixture.php rename to lib/Cake/tests/fixtures/my_categories_my_users_fixture.php diff --git a/cake/tests/fixtures/my_category_fixture.php b/lib/Cake/tests/fixtures/my_category_fixture.php similarity index 100% rename from cake/tests/fixtures/my_category_fixture.php rename to lib/Cake/tests/fixtures/my_category_fixture.php diff --git a/cake/tests/fixtures/my_product_fixture.php b/lib/Cake/tests/fixtures/my_product_fixture.php similarity index 100% rename from cake/tests/fixtures/my_product_fixture.php rename to lib/Cake/tests/fixtures/my_product_fixture.php diff --git a/cake/tests/fixtures/my_user_fixture.php b/lib/Cake/tests/fixtures/my_user_fixture.php similarity index 100% rename from cake/tests/fixtures/my_user_fixture.php rename to lib/Cake/tests/fixtures/my_user_fixture.php diff --git a/cake/tests/fixtures/node_fixture.php b/lib/Cake/tests/fixtures/node_fixture.php similarity index 100% rename from cake/tests/fixtures/node_fixture.php rename to lib/Cake/tests/fixtures/node_fixture.php diff --git a/cake/tests/fixtures/number_tree_fixture.php b/lib/Cake/tests/fixtures/number_tree_fixture.php similarity index 100% rename from cake/tests/fixtures/number_tree_fixture.php rename to lib/Cake/tests/fixtures/number_tree_fixture.php diff --git a/cake/tests/fixtures/number_tree_two_fixture.php b/lib/Cake/tests/fixtures/number_tree_two_fixture.php similarity index 100% rename from cake/tests/fixtures/number_tree_two_fixture.php rename to lib/Cake/tests/fixtures/number_tree_two_fixture.php diff --git a/cake/tests/fixtures/numeric_article_fixture.php b/lib/Cake/tests/fixtures/numeric_article_fixture.php similarity index 100% rename from cake/tests/fixtures/numeric_article_fixture.php rename to lib/Cake/tests/fixtures/numeric_article_fixture.php diff --git a/cake/tests/fixtures/overall_favorite_fixture.php b/lib/Cake/tests/fixtures/overall_favorite_fixture.php similarity index 100% rename from cake/tests/fixtures/overall_favorite_fixture.php rename to lib/Cake/tests/fixtures/overall_favorite_fixture.php diff --git a/cake/tests/fixtures/person_fixture.php b/lib/Cake/tests/fixtures/person_fixture.php similarity index 100% rename from cake/tests/fixtures/person_fixture.php rename to lib/Cake/tests/fixtures/person_fixture.php diff --git a/cake/tests/fixtures/portfolio_fixture.php b/lib/Cake/tests/fixtures/portfolio_fixture.php similarity index 100% rename from cake/tests/fixtures/portfolio_fixture.php rename to lib/Cake/tests/fixtures/portfolio_fixture.php diff --git a/cake/tests/fixtures/post_fixture.php b/lib/Cake/tests/fixtures/post_fixture.php similarity index 100% rename from cake/tests/fixtures/post_fixture.php rename to lib/Cake/tests/fixtures/post_fixture.php diff --git a/cake/tests/fixtures/posts_tag_fixture.php b/lib/Cake/tests/fixtures/posts_tag_fixture.php similarity index 100% rename from cake/tests/fixtures/posts_tag_fixture.php rename to lib/Cake/tests/fixtures/posts_tag_fixture.php diff --git a/cake/tests/fixtures/primary_model_fixture.php b/lib/Cake/tests/fixtures/primary_model_fixture.php similarity index 100% rename from cake/tests/fixtures/primary_model_fixture.php rename to lib/Cake/tests/fixtures/primary_model_fixture.php diff --git a/cake/tests/fixtures/product_fixture.php b/lib/Cake/tests/fixtures/product_fixture.php similarity index 100% rename from cake/tests/fixtures/product_fixture.php rename to lib/Cake/tests/fixtures/product_fixture.php diff --git a/cake/tests/fixtures/product_update_all_fixture.php b/lib/Cake/tests/fixtures/product_update_all_fixture.php similarity index 100% rename from cake/tests/fixtures/product_update_all_fixture.php rename to lib/Cake/tests/fixtures/product_update_all_fixture.php diff --git a/cake/tests/fixtures/project_fixture.php b/lib/Cake/tests/fixtures/project_fixture.php similarity index 100% rename from cake/tests/fixtures/project_fixture.php rename to lib/Cake/tests/fixtures/project_fixture.php diff --git a/cake/tests/fixtures/rss.xml b/lib/Cake/tests/fixtures/rss.xml similarity index 100% rename from cake/tests/fixtures/rss.xml rename to lib/Cake/tests/fixtures/rss.xml diff --git a/cake/tests/fixtures/sample.xml b/lib/Cake/tests/fixtures/sample.xml similarity index 100% rename from cake/tests/fixtures/sample.xml rename to lib/Cake/tests/fixtures/sample.xml diff --git a/cake/tests/fixtures/sample_fixture.php b/lib/Cake/tests/fixtures/sample_fixture.php similarity index 100% rename from cake/tests/fixtures/sample_fixture.php rename to lib/Cake/tests/fixtures/sample_fixture.php diff --git a/cake/tests/fixtures/secondary_model_fixture.php b/lib/Cake/tests/fixtures/secondary_model_fixture.php similarity index 100% rename from cake/tests/fixtures/secondary_model_fixture.php rename to lib/Cake/tests/fixtures/secondary_model_fixture.php diff --git a/cake/tests/fixtures/session_fixture.php b/lib/Cake/tests/fixtures/session_fixture.php similarity index 100% rename from cake/tests/fixtures/session_fixture.php rename to lib/Cake/tests/fixtures/session_fixture.php diff --git a/cake/tests/fixtures/soap_request.xml b/lib/Cake/tests/fixtures/soap_request.xml similarity index 100% rename from cake/tests/fixtures/soap_request.xml rename to lib/Cake/tests/fixtures/soap_request.xml diff --git a/cake/tests/fixtures/soap_response.xml b/lib/Cake/tests/fixtures/soap_response.xml similarity index 100% rename from cake/tests/fixtures/soap_response.xml rename to lib/Cake/tests/fixtures/soap_response.xml diff --git a/cake/tests/fixtures/something_else_fixture.php b/lib/Cake/tests/fixtures/something_else_fixture.php similarity index 100% rename from cake/tests/fixtures/something_else_fixture.php rename to lib/Cake/tests/fixtures/something_else_fixture.php diff --git a/cake/tests/fixtures/something_fixture.php b/lib/Cake/tests/fixtures/something_fixture.php similarity index 100% rename from cake/tests/fixtures/something_fixture.php rename to lib/Cake/tests/fixtures/something_fixture.php diff --git a/cake/tests/fixtures/stories_tag_fixture.php b/lib/Cake/tests/fixtures/stories_tag_fixture.php similarity index 100% rename from cake/tests/fixtures/stories_tag_fixture.php rename to lib/Cake/tests/fixtures/stories_tag_fixture.php diff --git a/cake/tests/fixtures/story_fixture.php b/lib/Cake/tests/fixtures/story_fixture.php similarity index 100% rename from cake/tests/fixtures/story_fixture.php rename to lib/Cake/tests/fixtures/story_fixture.php diff --git a/cake/tests/fixtures/syfile_fixture.php b/lib/Cake/tests/fixtures/syfile_fixture.php similarity index 100% rename from cake/tests/fixtures/syfile_fixture.php rename to lib/Cake/tests/fixtures/syfile_fixture.php diff --git a/cake/tests/fixtures/tag_fixture.php b/lib/Cake/tests/fixtures/tag_fixture.php similarity index 100% rename from cake/tests/fixtures/tag_fixture.php rename to lib/Cake/tests/fixtures/tag_fixture.php diff --git a/cake/tests/fixtures/test_plugin_article_fixture.php b/lib/Cake/tests/fixtures/test_plugin_article_fixture.php similarity index 100% rename from cake/tests/fixtures/test_plugin_article_fixture.php rename to lib/Cake/tests/fixtures/test_plugin_article_fixture.php diff --git a/cake/tests/fixtures/test_plugin_comment_fixture.php b/lib/Cake/tests/fixtures/test_plugin_comment_fixture.php similarity index 100% rename from cake/tests/fixtures/test_plugin_comment_fixture.php rename to lib/Cake/tests/fixtures/test_plugin_comment_fixture.php diff --git a/cake/tests/fixtures/the_paper_monkies_fixture.php b/lib/Cake/tests/fixtures/the_paper_monkies_fixture.php similarity index 100% rename from cake/tests/fixtures/the_paper_monkies_fixture.php rename to lib/Cake/tests/fixtures/the_paper_monkies_fixture.php diff --git a/cake/tests/fixtures/thread_fixture.php b/lib/Cake/tests/fixtures/thread_fixture.php similarity index 100% rename from cake/tests/fixtures/thread_fixture.php rename to lib/Cake/tests/fixtures/thread_fixture.php diff --git a/cake/tests/fixtures/translate_article_fixture.php b/lib/Cake/tests/fixtures/translate_article_fixture.php similarity index 100% rename from cake/tests/fixtures/translate_article_fixture.php rename to lib/Cake/tests/fixtures/translate_article_fixture.php diff --git a/cake/tests/fixtures/translate_fixture.php b/lib/Cake/tests/fixtures/translate_fixture.php similarity index 100% rename from cake/tests/fixtures/translate_fixture.php rename to lib/Cake/tests/fixtures/translate_fixture.php diff --git a/cake/tests/fixtures/translate_table_fixture.php b/lib/Cake/tests/fixtures/translate_table_fixture.php similarity index 100% rename from cake/tests/fixtures/translate_table_fixture.php rename to lib/Cake/tests/fixtures/translate_table_fixture.php diff --git a/cake/tests/fixtures/translate_with_prefix_fixture.php b/lib/Cake/tests/fixtures/translate_with_prefix_fixture.php similarity index 100% rename from cake/tests/fixtures/translate_with_prefix_fixture.php rename to lib/Cake/tests/fixtures/translate_with_prefix_fixture.php diff --git a/cake/tests/fixtures/translated_article_fixture.php b/lib/Cake/tests/fixtures/translated_article_fixture.php similarity index 100% rename from cake/tests/fixtures/translated_article_fixture.php rename to lib/Cake/tests/fixtures/translated_article_fixture.php diff --git a/cake/tests/fixtures/translated_item_fixture.php b/lib/Cake/tests/fixtures/translated_item_fixture.php similarity index 100% rename from cake/tests/fixtures/translated_item_fixture.php rename to lib/Cake/tests/fixtures/translated_item_fixture.php diff --git a/cake/tests/fixtures/unconventional_tree_fixture.php b/lib/Cake/tests/fixtures/unconventional_tree_fixture.php similarity index 100% rename from cake/tests/fixtures/unconventional_tree_fixture.php rename to lib/Cake/tests/fixtures/unconventional_tree_fixture.php diff --git a/cake/tests/fixtures/underscore_field_fixture.php b/lib/Cake/tests/fixtures/underscore_field_fixture.php similarity index 100% rename from cake/tests/fixtures/underscore_field_fixture.php rename to lib/Cake/tests/fixtures/underscore_field_fixture.php diff --git a/cake/tests/fixtures/user_fixture.php b/lib/Cake/tests/fixtures/user_fixture.php similarity index 100% rename from cake/tests/fixtures/user_fixture.php rename to lib/Cake/tests/fixtures/user_fixture.php diff --git a/cake/tests/fixtures/uuid_fixture.php b/lib/Cake/tests/fixtures/uuid_fixture.php similarity index 100% rename from cake/tests/fixtures/uuid_fixture.php rename to lib/Cake/tests/fixtures/uuid_fixture.php diff --git a/cake/tests/fixtures/uuid_tag_fixture.php b/lib/Cake/tests/fixtures/uuid_tag_fixture.php similarity index 100% rename from cake/tests/fixtures/uuid_tag_fixture.php rename to lib/Cake/tests/fixtures/uuid_tag_fixture.php diff --git a/cake/tests/fixtures/uuid_tree_fixture.php b/lib/Cake/tests/fixtures/uuid_tree_fixture.php similarity index 100% rename from cake/tests/fixtures/uuid_tree_fixture.php rename to lib/Cake/tests/fixtures/uuid_tree_fixture.php diff --git a/cake/tests/fixtures/uuiditem_fixture.php b/lib/Cake/tests/fixtures/uuiditem_fixture.php similarity index 100% rename from cake/tests/fixtures/uuiditem_fixture.php rename to lib/Cake/tests/fixtures/uuiditem_fixture.php diff --git a/cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php b/lib/Cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php similarity index 100% rename from cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php rename to lib/Cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php diff --git a/cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php b/lib/Cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php similarity index 100% rename from cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php rename to lib/Cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php diff --git a/cake/tests/fixtures/uuidportfolio_fixture.php b/lib/Cake/tests/fixtures/uuidportfolio_fixture.php similarity index 100% rename from cake/tests/fixtures/uuidportfolio_fixture.php rename to lib/Cake/tests/fixtures/uuidportfolio_fixture.php diff --git a/cake/tests/test_app/config/acl.ini.php b/lib/Cake/tests/test_app/config/acl.ini.php similarity index 100% rename from cake/tests/test_app/config/acl.ini.php rename to lib/Cake/tests/test_app/config/acl.ini.php diff --git a/cake/tests/test_app/config/empty.php b/lib/Cake/tests/test_app/config/empty.php similarity index 100% rename from cake/tests/test_app/config/empty.php rename to lib/Cake/tests/test_app/config/empty.php diff --git a/cake/tests/test_app/config/nested.ini b/lib/Cake/tests/test_app/config/nested.ini similarity index 100% rename from cake/tests/test_app/config/nested.ini rename to lib/Cake/tests/test_app/config/nested.ini diff --git a/cake/tests/test_app/config/var_test.php b/lib/Cake/tests/test_app/config/var_test.php similarity index 100% rename from cake/tests/test_app/config/var_test.php rename to lib/Cake/tests/test_app/config/var_test.php diff --git a/cake/tests/test_app/console/shells/sample.php b/lib/Cake/tests/test_app/console/shells/sample.php similarity index 100% rename from cake/tests/test_app/console/shells/sample.php rename to lib/Cake/tests/test_app/console/shells/sample.php diff --git a/cake/tests/test_app/console/shells/tasks/empty b/lib/Cake/tests/test_app/console/shells/tasks/empty similarity index 100% rename from cake/tests/test_app/console/shells/tasks/empty rename to lib/Cake/tests/test_app/console/shells/tasks/empty diff --git a/cake/tests/test_app/console/templates/test/classes/test_object.ctp b/lib/Cake/tests/test_app/console/templates/test/classes/test_object.ctp similarity index 100% rename from cake/tests/test_app/console/templates/test/classes/test_object.ctp rename to lib/Cake/tests/test_app/console/templates/test/classes/test_object.ctp diff --git a/cake/tests/test_app/controllers/components/empty b/lib/Cake/tests/test_app/controllers/components/empty similarity index 100% rename from cake/tests/test_app/controllers/components/empty rename to lib/Cake/tests/test_app/controllers/components/empty diff --git a/cake/tests/test_app/controllers/tests_apps_controller.php b/lib/Cake/tests/test_app/controllers/tests_apps_controller.php similarity index 100% rename from cake/tests/test_app/controllers/tests_apps_controller.php rename to lib/Cake/tests/test_app/controllers/tests_apps_controller.php diff --git a/cake/tests/test_app/controllers/tests_apps_posts_controller.php b/lib/Cake/tests/test_app/controllers/tests_apps_posts_controller.php similarity index 100% rename from cake/tests/test_app/controllers/tests_apps_posts_controller.php rename to lib/Cake/tests/test_app/controllers/tests_apps_posts_controller.php diff --git a/cake/tests/test_app/libs/cache/test_app_cache.php b/lib/Cake/tests/test_app/libs/cache/test_app_cache.php similarity index 100% rename from cake/tests/test_app/libs/cache/test_app_cache.php rename to lib/Cake/tests/test_app/libs/cache/test_app_cache.php diff --git a/cake/tests/test_app/libs/library.php b/lib/Cake/tests/test_app/libs/library.php similarity index 100% rename from cake/tests/test_app/libs/library.php rename to lib/Cake/tests/test_app/libs/library.php diff --git a/cake/tests/test_app/libs/log/test_app_log.php b/lib/Cake/tests/test_app/libs/log/test_app_log.php similarity index 100% rename from cake/tests/test_app/libs/log/test_app_log.php rename to lib/Cake/tests/test_app/libs/log/test_app_log.php diff --git a/cake/tests/test_app/libs/session/test_app_lib_session.php b/lib/Cake/tests/test_app/libs/session/test_app_lib_session.php similarity index 100% rename from cake/tests/test_app/libs/session/test_app_lib_session.php rename to lib/Cake/tests/test_app/libs/session/test_app_lib_session.php diff --git a/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom1.po b/lib/Cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom1.po similarity index 100% rename from cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom1.po rename to lib/Cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom1.po diff --git a/cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom2.po b/lib/Cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom2.po similarity index 100% rename from cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom2.po rename to lib/Cake/tests/test_app/locale/cache_test_po/LC_MESSAGES/dom2.po diff --git a/cake/tests/test_app/locale/ja_jp/LC_TIME b/lib/Cake/tests/test_app/locale/ja_jp/LC_TIME similarity index 100% rename from cake/tests/test_app/locale/ja_jp/LC_TIME rename to lib/Cake/tests/test_app/locale/ja_jp/LC_TIME diff --git a/cake/tests/test_app/locale/po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/po/LC_MONETARY/default.po b/lib/Cake/tests/test_app/locale/po/LC_MONETARY/default.po similarity index 100% rename from cake/tests/test_app/locale/po/LC_MONETARY/default.po rename to lib/Cake/tests/test_app/locale/po/LC_MONETARY/default.po diff --git a/cake/tests/test_app/locale/po/LC_TIME b/lib/Cake/tests/test_app/locale/po/LC_TIME similarity index 100% rename from cake/tests/test_app/locale/po/LC_TIME rename to lib/Cake/tests/test_app/locale/po/LC_TIME diff --git a/cake/tests/test_app/locale/rule_0_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_0_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_0_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_0_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_0_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_0_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_0_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_0_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_0_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_0_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_0_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_0_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_0_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_0_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_0_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_0_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_10_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_10_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_10_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_10_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_10_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_10_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_10_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_10_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_10_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_10_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_10_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_10_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_10_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_10_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_10_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_10_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_11_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_11_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_11_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_11_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_11_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_11_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_11_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_11_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_11_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_11_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_11_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_11_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_11_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_11_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_11_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_11_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_12_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_12_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_12_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_12_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_12_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_12_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_12_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_12_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_12_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_12_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_12_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_12_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_12_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_12_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_12_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_12_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_13_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_13_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_13_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_13_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_13_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_13_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_13_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_13_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_13_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_13_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_13_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_13_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_13_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_13_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_13_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_13_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_14_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_14_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_14_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_14_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_14_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_14_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_14_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_14_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_14_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_14_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_14_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_14_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_14_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_14_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_14_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_14_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_1_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_1_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_1_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_1_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_1_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_1_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_1_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_1_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_1_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_1_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_1_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_1_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_1_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_1_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_1_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_1_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_2_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_2_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_2_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_2_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_2_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_2_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_2_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_2_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_2_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_2_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_2_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_2_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_2_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_2_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_2_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_2_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_3_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_3_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_3_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_3_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_3_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_3_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_3_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_3_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_3_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_3_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_3_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_3_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_3_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_3_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_3_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_3_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_4_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_4_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_4_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_4_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_4_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_4_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_4_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_4_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_4_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_4_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_4_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_4_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_4_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_4_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_4_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_4_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_5_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_5_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_5_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_5_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_5_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_5_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_5_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_5_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_5_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_5_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_5_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_5_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_5_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_5_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_5_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_5_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_6_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_6_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_6_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_6_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_6_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_6_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_6_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_6_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_6_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_6_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_6_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_6_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_6_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_6_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_6_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_6_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_7_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_7_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_7_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_7_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_7_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_7_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_7_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_7_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_7_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_7_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_7_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_7_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_7_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_7_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_7_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_7_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_8_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_8_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_8_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_8_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_8_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_8_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_8_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_8_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_8_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_8_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_8_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_8_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_8_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_8_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_8_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_8_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/rule_9_mo/LC_MESSAGES/core.mo b/lib/Cake/tests/test_app/locale/rule_9_mo/LC_MESSAGES/core.mo similarity index 100% rename from cake/tests/test_app/locale/rule_9_mo/LC_MESSAGES/core.mo rename to lib/Cake/tests/test_app/locale/rule_9_mo/LC_MESSAGES/core.mo diff --git a/cake/tests/test_app/locale/rule_9_mo/LC_MESSAGES/default.mo b/lib/Cake/tests/test_app/locale/rule_9_mo/LC_MESSAGES/default.mo similarity index 100% rename from cake/tests/test_app/locale/rule_9_mo/LC_MESSAGES/default.mo rename to lib/Cake/tests/test_app/locale/rule_9_mo/LC_MESSAGES/default.mo diff --git a/cake/tests/test_app/locale/rule_9_po/LC_MESSAGES/core.po b/lib/Cake/tests/test_app/locale/rule_9_po/LC_MESSAGES/core.po similarity index 100% rename from cake/tests/test_app/locale/rule_9_po/LC_MESSAGES/core.po rename to lib/Cake/tests/test_app/locale/rule_9_po/LC_MESSAGES/core.po diff --git a/cake/tests/test_app/locale/rule_9_po/LC_MESSAGES/default.po b/lib/Cake/tests/test_app/locale/rule_9_po/LC_MESSAGES/default.po similarity index 100% rename from cake/tests/test_app/locale/rule_9_po/LC_MESSAGES/default.po rename to lib/Cake/tests/test_app/locale/rule_9_po/LC_MESSAGES/default.po diff --git a/cake/tests/test_app/locale/time_test/LC_TIME b/lib/Cake/tests/test_app/locale/time_test/LC_TIME similarity index 100% rename from cake/tests/test_app/locale/time_test/LC_TIME rename to lib/Cake/tests/test_app/locale/time_test/LC_TIME diff --git a/cake/tests/test_app/models/behaviors/empty b/lib/Cake/tests/test_app/models/behaviors/empty similarity index 100% rename from cake/tests/test_app/models/behaviors/empty rename to lib/Cake/tests/test_app/models/behaviors/empty diff --git a/cake/tests/test_app/models/behaviors/persister_one_behavior.php b/lib/Cake/tests/test_app/models/behaviors/persister_one_behavior.php similarity index 100% rename from cake/tests/test_app/models/behaviors/persister_one_behavior.php rename to lib/Cake/tests/test_app/models/behaviors/persister_one_behavior.php diff --git a/cake/tests/test_app/models/behaviors/persister_two_behavior.php b/lib/Cake/tests/test_app/models/behaviors/persister_two_behavior.php similarity index 100% rename from cake/tests/test_app/models/behaviors/persister_two_behavior.php rename to lib/Cake/tests/test_app/models/behaviors/persister_two_behavior.php diff --git a/cake/tests/test_app/models/comment.php b/lib/Cake/tests/test_app/models/comment.php similarity index 100% rename from cake/tests/test_app/models/comment.php rename to lib/Cake/tests/test_app/models/comment.php diff --git a/cake/tests/test_app/models/datasources/test/test_local_driver.php b/lib/Cake/tests/test_app/models/datasources/test/test_local_driver.php similarity index 100% rename from cake/tests/test_app/models/datasources/test/test_local_driver.php rename to lib/Cake/tests/test_app/models/datasources/test/test_local_driver.php diff --git a/cake/tests/test_app/models/datasources/test2_other_source.php b/lib/Cake/tests/test_app/models/datasources/test2_other_source.php similarity index 100% rename from cake/tests/test_app/models/datasources/test2_other_source.php rename to lib/Cake/tests/test_app/models/datasources/test2_other_source.php diff --git a/cake/tests/test_app/models/datasources/test2_source.php b/lib/Cake/tests/test_app/models/datasources/test2_source.php similarity index 100% rename from cake/tests/test_app/models/datasources/test2_source.php rename to lib/Cake/tests/test_app/models/datasources/test2_source.php diff --git a/cake/tests/test_app/models/persister_one.php b/lib/Cake/tests/test_app/models/persister_one.php similarity index 100% rename from cake/tests/test_app/models/persister_one.php rename to lib/Cake/tests/test_app/models/persister_one.php diff --git a/cake/tests/test_app/models/persister_two.php b/lib/Cake/tests/test_app/models/persister_two.php similarity index 100% rename from cake/tests/test_app/models/persister_two.php rename to lib/Cake/tests/test_app/models/persister_two.php diff --git a/cake/tests/test_app/models/post.php b/lib/Cake/tests/test_app/models/post.php similarity index 100% rename from cake/tests/test_app/models/post.php rename to lib/Cake/tests/test_app/models/post.php diff --git a/cake/tests/test_app/plugins/plugin_js/webroot/js/one/plugin_one.js b/lib/Cake/tests/test_app/plugins/plugin_js/webroot/js/one/plugin_one.js similarity index 100% rename from cake/tests/test_app/plugins/plugin_js/webroot/js/one/plugin_one.js rename to lib/Cake/tests/test_app/plugins/plugin_js/webroot/js/one/plugin_one.js diff --git a/cake/tests/test_app/plugins/plugin_js/webroot/js/plugin_js.js b/lib/Cake/tests/test_app/plugins/plugin_js/webroot/js/plugin_js.js similarity index 100% rename from cake/tests/test_app/plugins/plugin_js/webroot/js/plugin_js.js rename to lib/Cake/tests/test_app/plugins/plugin_js/webroot/js/plugin_js.js diff --git a/cake/tests/test_app/plugins/test_plugin/config/load.php b/lib/Cake/tests/test_app/plugins/test_plugin/config/load.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/config/load.php rename to lib/Cake/tests/test_app/plugins/test_plugin/config/load.php diff --git a/cake/tests/test_app/plugins/test_plugin/config/more.load.php b/lib/Cake/tests/test_app/plugins/test_plugin/config/more.load.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/config/more.load.php rename to lib/Cake/tests/test_app/plugins/test_plugin/config/more.load.php diff --git a/cake/tests/test_app/plugins/test_plugin/config/schema/schema.php b/lib/Cake/tests/test_app/plugins/test_plugin/config/schema/schema.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/config/schema/schema.php rename to lib/Cake/tests/test_app/plugins/test_plugin/config/schema/schema.php diff --git a/cake/tests/test_app/plugins/test_plugin/console/shells/example.php b/lib/Cake/tests/test_app/plugins/test_plugin/console/shells/example.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/console/shells/example.php rename to lib/Cake/tests/test_app/plugins/test_plugin/console/shells/example.php diff --git a/cake/tests/test_app/plugins/test_plugin/console/shells/tasks/empty b/lib/Cake/tests/test_app/plugins/test_plugin/console/shells/tasks/empty similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/console/shells/tasks/empty rename to lib/Cake/tests/test_app/plugins/test_plugin/console/shells/tasks/empty diff --git a/cake/tests/test_app/plugins/test_plugin/console/shells/tasks/other_task.php b/lib/Cake/tests/test_app/plugins/test_plugin/console/shells/tasks/other_task.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/console/shells/tasks/other_task.php rename to lib/Cake/tests/test_app/plugins/test_plugin/console/shells/tasks/other_task.php diff --git a/cake/tests/test_app/plugins/test_plugin/console/templates/empty b/lib/Cake/tests/test_app/plugins/test_plugin/console/templates/empty similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/console/templates/empty rename to lib/Cake/tests/test_app/plugins/test_plugin/console/templates/empty diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php b/lib/Cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php rename to lib/Cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php b/lib/Cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php rename to lib/Cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php b/lib/Cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php rename to lib/Cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php b/lib/Cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php rename to lib/Cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/test_plugin_controller.php b/lib/Cake/tests/test_app/plugins/test_plugin/controllers/test_plugin_controller.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/controllers/test_plugin_controller.php rename to lib/Cake/tests/test_app/plugins/test_plugin/controllers/test_plugin_controller.php diff --git a/cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php b/lib/Cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php rename to lib/Cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php diff --git a/cake/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php b/lib/Cake/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php rename to lib/Cake/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php diff --git a/cake/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php b/lib/Cake/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php rename to lib/Cake/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php diff --git a/cake/tests/test_app/plugins/test_plugin/libs/session/test_plugin_session.php b/lib/Cake/tests/test_app/plugins/test_plugin/libs/session/test_plugin_session.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/libs/session/test_plugin_session.php rename to lib/Cake/tests/test_app/plugins/test_plugin/libs/session/test_plugin_session.php diff --git a/cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php b/lib/Cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php rename to lib/Cake/tests/test_app/plugins/test_plugin/libs/test_plugin_library.php diff --git a/cake/tests/test_app/plugins/test_plugin/locale/po/LC_MESSAGES/test_plugin.po b/lib/Cake/tests/test_app/plugins/test_plugin/locale/po/LC_MESSAGES/test_plugin.po similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/locale/po/LC_MESSAGES/test_plugin.po rename to lib/Cake/tests/test_app/plugins/test_plugin/locale/po/LC_MESSAGES/test_plugin.po diff --git a/cake/tests/test_app/plugins/test_plugin/locale/po/LC_MONETARY/test_plugin.po b/lib/Cake/tests/test_app/plugins/test_plugin/locale/po/LC_MONETARY/test_plugin.po similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/locale/po/LC_MONETARY/test_plugin.po rename to lib/Cake/tests/test_app/plugins/test_plugin/locale/po/LC_MONETARY/test_plugin.po diff --git a/cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_one.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_one.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_one.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_one.php diff --git a/cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_two.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_two.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_two.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/behaviors/test_plugin_persister_two.php diff --git a/cake/tests/test_app/plugins/test_plugin/models/datasources/dbo/dbo_dummy.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/dbo/dbo_dummy.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/models/datasources/dbo/dbo_dummy.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/dbo/dbo_dummy.php diff --git a/cake/tests/test_app/plugins/test_plugin/models/datasources/test/test_driver.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/test/test_driver.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/models/datasources/test/test_driver.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/test/test_driver.php diff --git a/cake/tests/test_app/plugins/test_plugin/models/datasources/test_other_source.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/test_other_source.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/models/datasources/test_other_source.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/test_other_source.php diff --git a/cake/tests/test_app/plugins/test_plugin/models/datasources/test_source.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/test_source.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/models/datasources/test_source.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/test_source.php diff --git a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/test_plugin_auth_user.php diff --git a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_authors.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/test_plugin_authors.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/models/test_plugin_authors.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/test_plugin_authors.php diff --git a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_comment.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/test_plugin_comment.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/models/test_plugin_comment.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/test_plugin_comment.php diff --git a/cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php diff --git a/cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php b/lib/Cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php rename to lib/Cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php diff --git a/cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php b/lib/Cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php rename to lib/Cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php diff --git a/cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php b/lib/Cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php rename to lib/Cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php diff --git a/cake/tests/test_app/plugins/test_plugin/vendors/welcome.php b/lib/Cake/tests/test_app/plugins/test_plugin/vendors/welcome.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/vendors/welcome.php rename to lib/Cake/tests/test_app/plugins/test_plugin/vendors/welcome.php diff --git a/cake/tests/test_app/plugins/test_plugin/views/elements/plugin_element.ctp b/lib/Cake/tests/test_app/plugins/test_plugin/views/elements/plugin_element.ctp similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/views/elements/plugin_element.ctp rename to lib/Cake/tests/test_app/plugins/test_plugin/views/elements/plugin_element.ctp diff --git a/cake/tests/test_app/plugins/test_plugin/views/elements/test_plugin_element.ctp b/lib/Cake/tests/test_app/plugins/test_plugin/views/elements/test_plugin_element.ctp similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/views/elements/test_plugin_element.ctp rename to lib/Cake/tests/test_app/plugins/test_plugin/views/elements/test_plugin_element.ctp diff --git a/cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php b/lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php rename to lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php diff --git a/cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php b/lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php rename to lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php diff --git a/cake/tests/test_app/plugins/test_plugin/views/helpers/test_plugin_app.php b/lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/test_plugin_app.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/views/helpers/test_plugin_app.php rename to lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/test_plugin_app.php diff --git a/cake/tests/test_app/plugins/test_plugin/views/layouts/default.ctp b/lib/Cake/tests/test_app/plugins/test_plugin/views/layouts/default.ctp similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/views/layouts/default.ctp rename to lib/Cake/tests/test_app/plugins/test_plugin/views/layouts/default.ctp diff --git a/cake/tests/test_app/plugins/test_plugin/views/tests/index.ctp b/lib/Cake/tests/test_app/plugins/test_plugin/views/tests/index.ctp similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/views/tests/index.ctp rename to lib/Cake/tests/test_app/plugins/test_plugin/views/tests/index.ctp diff --git a/cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.edit.ctp b/lib/Cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.edit.ctp similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.edit.ctp rename to lib/Cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.edit.ctp diff --git a/cake/tests/test_app/plugins/test_plugin/webroot/css/test_plugin_asset.css b/lib/Cake/tests/test_app/plugins/test_plugin/webroot/css/test_plugin_asset.css similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/webroot/css/test_plugin_asset.css rename to lib/Cake/tests/test_app/plugins/test_plugin/webroot/css/test_plugin_asset.css diff --git a/cake/tests/test_app/plugins/test_plugin/webroot/css/theme_one.htc b/lib/Cake/tests/test_app/plugins/test_plugin/webroot/css/theme_one.htc similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/webroot/css/theme_one.htc rename to lib/Cake/tests/test_app/plugins/test_plugin/webroot/css/theme_one.htc diff --git a/cake/tests/test_app/plugins/test_plugin/webroot/css/unknown.extension b/lib/Cake/tests/test_app/plugins/test_plugin/webroot/css/unknown.extension similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/webroot/css/unknown.extension rename to lib/Cake/tests/test_app/plugins/test_plugin/webroot/css/unknown.extension diff --git a/cake/tests/test_app/plugins/test_plugin/webroot/flash/plugin_test.swf b/lib/Cake/tests/test_app/plugins/test_plugin/webroot/flash/plugin_test.swf similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/webroot/flash/plugin_test.swf rename to lib/Cake/tests/test_app/plugins/test_plugin/webroot/flash/plugin_test.swf diff --git a/cake/tests/test_app/plugins/test_plugin/webroot/img/cake.icon.gif b/lib/Cake/tests/test_app/plugins/test_plugin/webroot/img/cake.icon.gif similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/webroot/img/cake.icon.gif rename to lib/Cake/tests/test_app/plugins/test_plugin/webroot/img/cake.icon.gif diff --git a/cake/tests/test_app/plugins/test_plugin/webroot/js/test_plugin/test.js b/lib/Cake/tests/test_app/plugins/test_plugin/webroot/js/test_plugin/test.js similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/webroot/js/test_plugin/test.js rename to lib/Cake/tests/test_app/plugins/test_plugin/webroot/js/test_plugin/test.js diff --git a/cake/tests/test_app/plugins/test_plugin/webroot/pdfs/plugin_test.pdf b/lib/Cake/tests/test_app/plugins/test_plugin/webroot/pdfs/plugin_test.pdf similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/webroot/pdfs/plugin_test.pdf rename to lib/Cake/tests/test_app/plugins/test_plugin/webroot/pdfs/plugin_test.pdf diff --git a/cake/tests/test_app/plugins/test_plugin/webroot/root.js b/lib/Cake/tests/test_app/plugins/test_plugin/webroot/root.js similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/webroot/root.js rename to lib/Cake/tests/test_app/plugins/test_plugin/webroot/root.js diff --git a/cake/tests/test_app/plugins/test_plugin_two/console/shells/example.php b/lib/Cake/tests/test_app/plugins/test_plugin_two/console/shells/example.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin_two/console/shells/example.php rename to lib/Cake/tests/test_app/plugins/test_plugin_two/console/shells/example.php diff --git a/cake/tests/test_app/plugins/test_plugin_two/console/shells/tasks/empty b/lib/Cake/tests/test_app/plugins/test_plugin_two/console/shells/tasks/empty similarity index 100% rename from cake/tests/test_app/plugins/test_plugin_two/console/shells/tasks/empty rename to lib/Cake/tests/test_app/plugins/test_plugin_two/console/shells/tasks/empty diff --git a/cake/tests/test_app/plugins/test_plugin_two/console/shells/welcome.php b/lib/Cake/tests/test_app/plugins/test_plugin_two/console/shells/welcome.php similarity index 100% rename from cake/tests/test_app/plugins/test_plugin_two/console/shells/welcome.php rename to lib/Cake/tests/test_app/plugins/test_plugin_two/console/shells/welcome.php diff --git a/cake/tests/test_app/plugins/test_plugin_two/console/templates/empty b/lib/Cake/tests/test_app/plugins/test_plugin_two/console/templates/empty similarity index 100% rename from cake/tests/test_app/plugins/test_plugin_two/console/templates/empty rename to lib/Cake/tests/test_app/plugins/test_plugin_two/console/templates/empty diff --git a/cake/tests/test_app/tmp/dir_map b/lib/Cake/tests/test_app/tmp/dir_map similarity index 100% rename from cake/tests/test_app/tmp/dir_map rename to lib/Cake/tests/test_app/tmp/dir_map diff --git a/cake/tests/test_app/vendors/Test/MyTest.php b/lib/Cake/tests/test_app/vendors/Test/MyTest.php similarity index 100% rename from cake/tests/test_app/vendors/Test/MyTest.php rename to lib/Cake/tests/test_app/vendors/Test/MyTest.php diff --git a/cake/tests/test_app/vendors/Test/hello.php b/lib/Cake/tests/test_app/vendors/Test/hello.php similarity index 100% rename from cake/tests/test_app/vendors/Test/hello.php rename to lib/Cake/tests/test_app/vendors/Test/hello.php diff --git a/cake/tests/test_app/vendors/css/test_asset.css b/lib/Cake/tests/test_app/vendors/css/test_asset.css similarity index 100% rename from cake/tests/test_app/vendors/css/test_asset.css rename to lib/Cake/tests/test_app/vendors/css/test_asset.css diff --git a/cake/tests/test_app/vendors/img/test.jpg b/lib/Cake/tests/test_app/vendors/img/test.jpg similarity index 100% rename from cake/tests/test_app/vendors/img/test.jpg rename to lib/Cake/tests/test_app/vendors/img/test.jpg diff --git a/cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php b/lib/Cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php similarity index 100% rename from cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php rename to lib/Cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php diff --git a/cake/tests/test_app/vendors/somename/some.name.php b/lib/Cake/tests/test_app/vendors/somename/some.name.php similarity index 100% rename from cake/tests/test_app/vendors/somename/some.name.php rename to lib/Cake/tests/test_app/vendors/somename/some.name.php diff --git a/cake/tests/test_app/vendors/welcome.php b/lib/Cake/tests/test_app/vendors/welcome.php similarity index 100% rename from cake/tests/test_app/vendors/welcome.php rename to lib/Cake/tests/test_app/vendors/welcome.php diff --git a/cake/tests/test_app/views/elements/email/html/custom.ctp b/lib/Cake/tests/test_app/views/elements/email/html/custom.ctp similarity index 100% rename from cake/tests/test_app/views/elements/email/html/custom.ctp rename to lib/Cake/tests/test_app/views/elements/email/html/custom.ctp diff --git a/cake/tests/test_app/views/elements/email/html/default.ctp b/lib/Cake/tests/test_app/views/elements/email/html/default.ctp similarity index 100% rename from cake/tests/test_app/views/elements/email/html/default.ctp rename to lib/Cake/tests/test_app/views/elements/email/html/default.ctp diff --git a/cake/tests/test_app/views/elements/email/text/custom.ctp b/lib/Cake/tests/test_app/views/elements/email/text/custom.ctp similarity index 100% rename from cake/tests/test_app/views/elements/email/text/custom.ctp rename to lib/Cake/tests/test_app/views/elements/email/text/custom.ctp diff --git a/cake/tests/test_app/views/elements/email/text/default.ctp b/lib/Cake/tests/test_app/views/elements/email/text/default.ctp similarity index 100% rename from cake/tests/test_app/views/elements/email/text/default.ctp rename to lib/Cake/tests/test_app/views/elements/email/text/default.ctp diff --git a/cake/tests/test_app/views/elements/email/text/wide.ctp b/lib/Cake/tests/test_app/views/elements/email/text/wide.ctp similarity index 100% rename from cake/tests/test_app/views/elements/email/text/wide.ctp rename to lib/Cake/tests/test_app/views/elements/email/text/wide.ctp diff --git a/cake/tests/test_app/views/elements/empty b/lib/Cake/tests/test_app/views/elements/empty similarity index 100% rename from cake/tests/test_app/views/elements/empty rename to lib/Cake/tests/test_app/views/elements/empty diff --git a/cake/tests/test_app/views/elements/nocache/contains_nocache.ctp b/lib/Cake/tests/test_app/views/elements/nocache/contains_nocache.ctp similarity index 100% rename from cake/tests/test_app/views/elements/nocache/contains_nocache.ctp rename to lib/Cake/tests/test_app/views/elements/nocache/contains_nocache.ctp diff --git a/cake/tests/test_app/views/elements/nocache/plain.ctp b/lib/Cake/tests/test_app/views/elements/nocache/plain.ctp similarity index 100% rename from cake/tests/test_app/views/elements/nocache/plain.ctp rename to lib/Cake/tests/test_app/views/elements/nocache/plain.ctp diff --git a/cake/tests/test_app/views/elements/nocache/sub1.ctp b/lib/Cake/tests/test_app/views/elements/nocache/sub1.ctp similarity index 100% rename from cake/tests/test_app/views/elements/nocache/sub1.ctp rename to lib/Cake/tests/test_app/views/elements/nocache/sub1.ctp diff --git a/cake/tests/test_app/views/elements/nocache/sub2.ctp b/lib/Cake/tests/test_app/views/elements/nocache/sub2.ctp similarity index 100% rename from cake/tests/test_app/views/elements/nocache/sub2.ctp rename to lib/Cake/tests/test_app/views/elements/nocache/sub2.ctp diff --git a/cake/tests/test_app/views/elements/session_helper.ctp b/lib/Cake/tests/test_app/views/elements/session_helper.ctp similarity index 100% rename from cake/tests/test_app/views/elements/session_helper.ctp rename to lib/Cake/tests/test_app/views/elements/session_helper.ctp diff --git a/cake/tests/test_app/views/elements/test_element.ctp b/lib/Cake/tests/test_app/views/elements/test_element.ctp similarity index 100% rename from cake/tests/test_app/views/elements/test_element.ctp rename to lib/Cake/tests/test_app/views/elements/test_element.ctp diff --git a/cake/tests/test_app/views/errors/empty b/lib/Cake/tests/test_app/views/errors/empty similarity index 100% rename from cake/tests/test_app/views/errors/empty rename to lib/Cake/tests/test_app/views/errors/empty diff --git a/cake/tests/test_app/views/helpers/banana.php b/lib/Cake/tests/test_app/views/helpers/banana.php similarity index 100% rename from cake/tests/test_app/views/helpers/banana.php rename to lib/Cake/tests/test_app/views/helpers/banana.php diff --git a/cake/tests/test_app/views/helpers/empty b/lib/Cake/tests/test_app/views/helpers/empty similarity index 100% rename from cake/tests/test_app/views/helpers/empty rename to lib/Cake/tests/test_app/views/helpers/empty diff --git a/cake/tests/test_app/views/layouts/ajax.ctp b/lib/Cake/tests/test_app/views/layouts/ajax.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/ajax.ctp rename to lib/Cake/tests/test_app/views/layouts/ajax.ctp diff --git a/cake/tests/test_app/views/layouts/ajax2.ctp b/lib/Cake/tests/test_app/views/layouts/ajax2.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/ajax2.ctp rename to lib/Cake/tests/test_app/views/layouts/ajax2.ctp diff --git a/cake/tests/test_app/views/layouts/cache_empty_sections.ctp b/lib/Cake/tests/test_app/views/layouts/cache_empty_sections.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/cache_empty_sections.ctp rename to lib/Cake/tests/test_app/views/layouts/cache_empty_sections.ctp diff --git a/cake/tests/test_app/views/layouts/cache_layout.ctp b/lib/Cake/tests/test_app/views/layouts/cache_layout.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/cache_layout.ctp rename to lib/Cake/tests/test_app/views/layouts/cache_layout.ctp diff --git a/cake/tests/test_app/views/layouts/default.ctp b/lib/Cake/tests/test_app/views/layouts/default.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/default.ctp rename to lib/Cake/tests/test_app/views/layouts/default.ctp diff --git a/cake/tests/test_app/views/layouts/email/html/default.ctp b/lib/Cake/tests/test_app/views/layouts/email/html/default.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/email/html/default.ctp rename to lib/Cake/tests/test_app/views/layouts/email/html/default.ctp diff --git a/cake/tests/test_app/views/layouts/email/html/thin.ctp b/lib/Cake/tests/test_app/views/layouts/email/html/thin.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/email/html/thin.ctp rename to lib/Cake/tests/test_app/views/layouts/email/html/thin.ctp diff --git a/cake/tests/test_app/views/layouts/email/text/default.ctp b/lib/Cake/tests/test_app/views/layouts/email/text/default.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/email/text/default.ctp rename to lib/Cake/tests/test_app/views/layouts/email/text/default.ctp diff --git a/cake/tests/test_app/views/layouts/flash.ctp b/lib/Cake/tests/test_app/views/layouts/flash.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/flash.ctp rename to lib/Cake/tests/test_app/views/layouts/flash.ctp diff --git a/cake/tests/test_app/views/layouts/js/default.ctp b/lib/Cake/tests/test_app/views/layouts/js/default.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/js/default.ctp rename to lib/Cake/tests/test_app/views/layouts/js/default.ctp diff --git a/cake/tests/test_app/views/layouts/multi_cache.ctp b/lib/Cake/tests/test_app/views/layouts/multi_cache.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/multi_cache.ctp rename to lib/Cake/tests/test_app/views/layouts/multi_cache.ctp diff --git a/cake/tests/test_app/views/layouts/rss/default.ctp b/lib/Cake/tests/test_app/views/layouts/rss/default.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/rss/default.ctp rename to lib/Cake/tests/test_app/views/layouts/rss/default.ctp diff --git a/cake/tests/test_app/views/layouts/xml/default.ctp b/lib/Cake/tests/test_app/views/layouts/xml/default.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/xml/default.ctp rename to lib/Cake/tests/test_app/views/layouts/xml/default.ctp diff --git a/cake/tests/test_app/views/pages/empty b/lib/Cake/tests/test_app/views/pages/empty similarity index 100% rename from cake/tests/test_app/views/pages/empty rename to lib/Cake/tests/test_app/views/pages/empty diff --git a/cake/tests/test_app/views/pages/extract.ctp b/lib/Cake/tests/test_app/views/pages/extract.ctp similarity index 100% rename from cake/tests/test_app/views/pages/extract.ctp rename to lib/Cake/tests/test_app/views/pages/extract.ctp diff --git a/cake/tests/test_app/views/pages/home.ctp b/lib/Cake/tests/test_app/views/pages/home.ctp similarity index 100% rename from cake/tests/test_app/views/pages/home.ctp rename to lib/Cake/tests/test_app/views/pages/home.ctp diff --git a/cake/tests/test_app/views/posts/cache_empty_sections.ctp b/lib/Cake/tests/test_app/views/posts/cache_empty_sections.ctp similarity index 100% rename from cake/tests/test_app/views/posts/cache_empty_sections.ctp rename to lib/Cake/tests/test_app/views/posts/cache_empty_sections.ctp diff --git a/cake/tests/test_app/views/posts/cache_form.ctp b/lib/Cake/tests/test_app/views/posts/cache_form.ctp similarity index 100% rename from cake/tests/test_app/views/posts/cache_form.ctp rename to lib/Cake/tests/test_app/views/posts/cache_form.ctp diff --git a/cake/tests/test_app/views/posts/helper_overwrite.ctp b/lib/Cake/tests/test_app/views/posts/helper_overwrite.ctp similarity index 100% rename from cake/tests/test_app/views/posts/helper_overwrite.ctp rename to lib/Cake/tests/test_app/views/posts/helper_overwrite.ctp diff --git a/cake/tests/test_app/views/posts/index.ctp b/lib/Cake/tests/test_app/views/posts/index.ctp similarity index 100% rename from cake/tests/test_app/views/posts/index.ctp rename to lib/Cake/tests/test_app/views/posts/index.ctp diff --git a/cake/tests/test_app/views/posts/multiple_nocache.ctp b/lib/Cake/tests/test_app/views/posts/multiple_nocache.ctp similarity index 100% rename from cake/tests/test_app/views/posts/multiple_nocache.ctp rename to lib/Cake/tests/test_app/views/posts/multiple_nocache.ctp diff --git a/cake/tests/test_app/views/posts/nocache_multiple_element.ctp b/lib/Cake/tests/test_app/views/posts/nocache_multiple_element.ctp similarity index 100% rename from cake/tests/test_app/views/posts/nocache_multiple_element.ctp rename to lib/Cake/tests/test_app/views/posts/nocache_multiple_element.ctp diff --git a/cake/tests/test_app/views/posts/scaffold.edit.ctp b/lib/Cake/tests/test_app/views/posts/scaffold.edit.ctp similarity index 100% rename from cake/tests/test_app/views/posts/scaffold.edit.ctp rename to lib/Cake/tests/test_app/views/posts/scaffold.edit.ctp diff --git a/cake/tests/test_app/views/posts/sequencial_nocache.ctp b/lib/Cake/tests/test_app/views/posts/sequencial_nocache.ctp similarity index 100% rename from cake/tests/test_app/views/posts/sequencial_nocache.ctp rename to lib/Cake/tests/test_app/views/posts/sequencial_nocache.ctp diff --git a/cake/tests/test_app/views/posts/test_nocache_tags.ctp b/lib/Cake/tests/test_app/views/posts/test_nocache_tags.ctp similarity index 100% rename from cake/tests/test_app/views/posts/test_nocache_tags.ctp rename to lib/Cake/tests/test_app/views/posts/test_nocache_tags.ctp 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/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 From 848461f7a0d82e39b06969f9adf5728be97e5b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 8 Dec 2010 01:49:36 -0430 Subject: [PATCH 056/668] Making the testsuite run again --- lib/Cake/Console/Command/Task/ExtractTask.php | 2 +- lib/Cake/Console/Command/TestSuiteShell.php | 10 +++++----- lib/Cake/Model/ConnectionManager.php | 2 +- lib/Cake/TestSuite/CakeTestCase.php | 6 +++--- .../TestSuite/Fixture/CakeFixtureManager.php | 19 ++----------------- lib/Cake/TestSuite/Fixture/CakeTestModel.php | 3 ++- lib/Cake/TestSuite/TestManager.php | 10 +++++----- lib/Cake/TestSuite/TestRunner.php | 2 +- lib/Cake/tests/cases/libs/xml.test.php | 3 ++- 9 files changed, 22 insertions(+), 35 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index 89af9153c..e79df6b8d 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -114,7 +114,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/lib/Cake/Console/Command/TestSuiteShell.php b/lib/Cake/Console/Command/TestSuiteShell.php index 8814242a2..3b3b1f901 100644 --- a/lib/Cake/Console/Command/TestSuiteShell.php +++ b/lib/Cake/Console/Command/TestSuiteShell.php @@ -19,6 +19,11 @@ * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('CakeTestSuiteDispatcher', 'TestSuite'); +App::uses('TestRunner', 'TestSuite'); +App::uses('TestManager', 'TestSuite'); + class TestSuiteShell extends Shell { /** @@ -155,8 +160,6 @@ class TestSuiteShell extends Shell { * @return void */ public function initialize() { - require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_dispatcher.php'; - $corePath = App::core('cake'); if (isset($corePath[0])) { define('TEST_CAKE_CORE_INCLUDE_PATH', rtrim($corePath[0], DS) . DS); @@ -166,7 +169,6 @@ class TestSuiteShell extends Shell { $this->_dispatcher = new CakeTestSuiteDispatcher(); $this->_dispatcher->loadTestFramework(); - require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php'; } /** @@ -252,8 +254,6 @@ class TestSuiteShell extends Shell { * @return void */ protected function run($runnerArgs, $options = array()) { - require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_runner.php'; - restore_error_handler(); restore_error_handler(); diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index 208d6ba9d..324dcf554 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -230,7 +230,7 @@ class ConnectionManager { if (!empty(self::$config->{$name})) { self::$_connectionsEnum[$name] = self::_connectionData(self::$config->{$name}); } else { - throw new MissingConnectionException(array('class' => 'ConnectionManager')); + throw new MissingConnectionException(array('class' => $name)); } } diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 184dc7912..95819c5e1 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -20,9 +20,9 @@ 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('CakeTestModel', 'TestSuite/Fixture'); +App::uses('CakeTestFixture', 'TestSuite/Fixture'); /** * CakeTestCase class diff --git a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php index 099da5557..ea09473e7 100644 --- a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php +++ b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php @@ -55,7 +55,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; @@ -81,22 +81,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; diff --git a/lib/Cake/TestSuite/Fixture/CakeTestModel.php b/lib/Cake/TestSuite/Fixture/CakeTestModel.php index 819c3cbe2..6c7d3d4b3 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestModel.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestModel.php @@ -17,7 +17,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/lib/Cake/TestSuite/TestManager.php b/lib/Cake/TestSuite/TestManager.php index f4f5b4571..cf56a20b7 100644 --- a/lib/Cake/TestSuite/TestManager.php +++ b/lib/Cake/TestSuite/TestManager.php @@ -17,13 +17,15 @@ * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -define('CORE_TEST_CASES', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases'); -define('CORE_TEST_GROUPS', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'groups'); +define('CORE_TEST_CASES', LIBS . 'tests' . DS . 'cases'); +define('CORE_TEST_GROUPS', LIBS . 'tests' . DS . 'groups'); define('APP_TEST_CASES', TESTS . 'cases'); define('APP_TEST_GROUPS', TESTS . 'groups'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); -require_once CAKE_TESTS_LIB . 'cake_test_suite.php'; +App::uses('CakeTestSuite', 'TestSuite'); +App::uses('CakeTestCase', 'TestSuite'); +App::uses('CakeFixtureManager', 'TestSuite/Fixture'); /** * TestManager is the base class that handles loading and initiating the running @@ -88,8 +90,6 @@ class TestManager { * @return void */ public function __construct($params = array()) { - require_once(CAKE_TESTS_LIB . 'cake_test_case.php'); - $this->params = $params; if (isset($params['app'])) { $this->appTest = true; diff --git a/lib/Cake/TestSuite/TestRunner.php b/lib/Cake/TestSuite/TestRunner.php index c2ca7f809..afd299e3a 100644 --- a/lib/Cake/TestSuite/TestRunner.php +++ b/lib/Cake/TestSuite/TestRunner.php @@ -20,7 +20,7 @@ require 'PHPUnit/TextUI/Command.php'; -require_once 'test_manager.php'; +App::uses('TestManager', 'TestSuite'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); diff --git a/lib/Cake/tests/cases/libs/xml.test.php b/lib/Cake/tests/cases/libs/xml.test.php index 666a4f45d..ee00efd2b 100644 --- a/lib/Cake/tests/cases/libs/xml.test.php +++ b/lib/Cake/tests/cases/libs/xml.test.php @@ -17,7 +17,8 @@ * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Xml'); +App::uses('Xml', 'Utility'); +App::uses('CakeTestModel', 'TestSuite/Fixture'); /** * Article class From b8344ecd3389e355eaa41e36afbe52085fd9d2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 8 Dec 2010 23:15:18 -0430 Subject: [PATCH 057/668] Replacing some of the App::import by App::uses --- lib/Cake/Console/Command/AclShell.php | 4 +-- lib/Cake/Console/Command/ApiShell.php | 2 +- lib/Cake/Console/Command/BakeShell.php | 9 ++++-- lib/Cake/Console/Command/ConsoleShell.php | 2 +- .../Console/Command/Task/ControllerTask.php | 6 ++-- .../Console/Command/Task/DbConfigTask.php | 2 +- lib/Cake/Console/Command/Task/FixtureTask.php | 6 ++-- lib/Cake/Console/Command/Task/ModelTask.php | 2 +- lib/Cake/Console/Command/Task/PluginTask.php | 3 +- lib/Cake/Console/Command/Task/ViewTask.php | 14 +++++---- lib/Cake/Console/ConsoleErrorHandler.php | 2 +- .../Controller/Component/AclComponent.php | 2 +- .../Controller/Component/EmailComponent.php | 6 ++-- .../Component/RequestHandlerComponent.php | 3 +- lib/Cake/Controller/Controller.php | 4 +-- lib/Cake/Core/App.php | 6 ++-- lib/Cake/Error/ErrorHandler.php | 2 +- lib/Cake/Error/ExceptionRenderer.php | 5 ++-- lib/Cake/I18n/I18n.php | 2 +- lib/Cake/I18n/Multibyte.php | 2 +- lib/Cake/Model/BehaviorCollection.php | 7 +---- lib/Cake/Model/CakeSchema.php | 6 ++-- lib/Cake/Model/Datasource/DboSource.php | 3 +- lib/Cake/Utility/Set.php | 2 +- lib/Cake/View/pages/home.ctp | 2 +- lib/Cake/basics.php | 4 +-- lib/Cake/tests/cases/basics.test.php | 3 +- .../console/libs/task_collection.test.php | 4 +-- .../tests/cases/console/shells/acl.test.php | 6 ++-- .../tests/cases/console/shells/api.test.php | 7 ++--- .../tests/cases/console/shells/bake.test.php | 16 +++++----- .../console/shells/command_list.test.php | 2 +- .../cases/console/shells/schema.test.php | 9 ++---- .../tests/cases/console/shells/shell.test.php | 6 ++-- .../console/shells/tasks/controller.test.php | 30 ++++++++----------- .../console/shells/tasks/db_config.test.php | 7 ++--- .../console/shells/tasks/extract.test.php | 8 ++--- .../console/shells/tasks/fixture.test.php | 12 ++++---- .../cases/console/shells/tasks/model.test.php | 12 ++++---- .../console/shells/tasks/plugin.test.php | 13 ++++---- .../console/shells/tasks/project.test.php | 9 +++--- .../console/shells/tasks/template.test.php | 7 ++--- .../cases/console/shells/tasks/test.test.php | 15 ++++------ 43 files changed, 127 insertions(+), 147 deletions(-) diff --git a/lib/Cake/Console/Command/AclShell.php b/lib/Cake/Console/Command/AclShell.php index e29e4f4ef..04aaa4936 100644 --- a/lib/Cake/Console/Command/AclShell.php +++ b/lib/Cake/Console/Command/AclShell.php @@ -17,8 +17,8 @@ * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Component', 'Acl'); -App::import('Model', 'DbAcl'); +App::uses('AclComponent', 'Controller/Component'); +App::uses('DbAcl', 'Model'); /** * Shell for ACL management. This console is known to have issues with zend.ze1_compatibility_mode diff --git a/lib/Cake/Console/Command/ApiShell.php b/lib/Cake/Console/Command/ApiShell.php index 0c036d09d..a9a436a29 100644 --- a/lib/Cake/Console/Command/ApiShell.php +++ b/lib/Cake/Console/Command/ApiShell.php @@ -19,7 +19,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'); /** * API shell to show method signatures of CakePHP core classes. diff --git a/lib/Cake/Console/Command/BakeShell.php b/lib/Cake/Console/Command/BakeShell.php index 77dd36201..ed09609f0 100644 --- a/lib/Cake/Console/Command/BakeShell.php +++ b/lib/Cake/Console/Command/BakeShell.php @@ -22,6 +22,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. * @@ -151,11 +153,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)); } @@ -176,7 +178,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/lib/Cake/Console/Command/ConsoleShell.php b/lib/Cake/Console/Command/ConsoleShell.php index 404c348ed..5cedf5a97 100644 --- a/lib/Cake/Console/Command/ConsoleShell.php +++ b/lib/Cake/Console/Command/ConsoleShell.php @@ -56,11 +56,11 @@ class ConsoleShell extends Shell { 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:'); diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 46f512365..449a3aa84 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -108,7 +108,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); @@ -273,7 +274,8 @@ class ControllerTask extends BakeTask { if ($plugin) { $modelImport = $plugin . '.' . $modelImport; } - if (!App::import('Model', $modelImport)) { + App::uses($modelImport, 'Model'); + if (!class_exists($modelImport)) { $this->err(__('You must have a model for this class to build basic methods. Please try again.')); $this->_stop(); } diff --git a/lib/Cake/Console/Command/Task/DbConfigTask.php b/lib/Cake/Console/Command/Task/DbConfigTask.php index a98b6b053..9f866b1c1 100644 --- a/lib/Cake/Console/Command/Task/DbConfigTask.php +++ b/lib/Cake/Console/Command/Task/DbConfigTask.php @@ -353,7 +353,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/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index cc081c84c..2e0a4c31e 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -19,6 +19,7 @@ */ App::uses('BakeTask', 'Console/Command/Task'); +App::uses('Model', 'Model'); /** * Task class for creating and updating fixtures files. @@ -186,9 +187,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 = $recordImport = null; if (!$useTable) { $useTable = Inflector::tableize($model); @@ -394,7 +393,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/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index c893de33a..e0bc29378 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -20,6 +20,7 @@ App::uses('BakeTask', 'Console/Command/Task'); App::uses('ConnectionManager', 'Model'); +App::uses('Model', 'Model'); /** * Task class for creating and updating model files. @@ -74,7 +75,6 @@ class ModelTask extends BakeTask { * */ public function execute() { - App::import('Model', 'Model', false); parent::execute(); if (empty($this->args)) { diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index 6ae7bd5cb..84c296623 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -17,7 +17,8 @@ * @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'); /** * Task class for creating a plugin diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index fc3baa8ae..106ba864a 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -191,7 +191,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(); @@ -272,17 +273,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($controllerName, $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/lib/Cake/Console/ConsoleErrorHandler.php b/lib/Cake/Console/ConsoleErrorHandler.php index 9eaebb2e5..dbd84aa99 100644 --- a/lib/Cake/Console/ConsoleErrorHandler.php +++ b/lib/Cake/Console/ConsoleErrorHandler.php @@ -19,6 +19,7 @@ */ App::uses('ErrorHandler', 'Error'); App::uses('ConsoleOutput', 'Console'); +App::uses('CakeLog', 'Log'); /** * Error Handler for Cake console. Does simple printing of the @@ -79,7 +80,6 @@ class ConsoleErrorHandler extends ErrorHandler { $stderr->write(__("%s Error: %s\n", $name, $message)); if (Configure::read('debug') == 0) { - App::import('Core', 'CakeLog'); CakeLog::write($log, $message); } } diff --git a/lib/Cake/Controller/Component/AclComponent.php b/lib/Cake/Controller/Component/AclComponent.php index 3a09c590b..7fc8a0a10 100644 --- a/lib/Cake/Controller/Component/AclComponent.php +++ b/lib/Cake/Controller/Component/AclComponent.php @@ -662,7 +662,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/lib/Cake/Controller/Component/EmailComponent.php b/lib/Cake/Controller/Component/EmailComponent.php index 47ab6775b..9a3aa9f9b 100755 --- a/lib/Cake/Controller/Component/EmailComponent.php +++ b/lib/Cake/Controller/Component/EmailComponent.php @@ -433,9 +433,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, false); @@ -810,7 +810,7 @@ class EmailComponent extends Component { * @access private */ function _smtp() { - App::import('Core', 'CakeSocket'); + App::uses('CakeSocket', 'Network'); $defaults = array( 'host' => 'localhost', diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index 4928c945a..4f5cc3dfe 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -542,7 +542,8 @@ class RequestHandlerComponent extends Component { ); if (!$isAdded) { - if (App::import('Helper', $helper)) { + App::uses($helper . 'Helper', 'Helper'); + if (class_exists($helper . 'Helper')) { $controller->helpers[] = $helper; } } diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index c423a9227..68b255fc7 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -789,9 +789,9 @@ class Controller extends Object { $viewClass = $this->view; if ($this->view != 'View') { - list($plugin, $viewClass) = pluginSplit($viewClass); + list($plugin, $viewClass) = pluginSplit($viewClass, true); $viewClass = $viewClass . 'View'; - App::import('View', $this->view); + App::uses($viewClass, $plugin . 'View'); } $this->request->params['models'] = $this->modelNames; diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index f22d8925d..2e4383ac8 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -23,8 +23,8 @@ * ### Adding paths * * You can add paths to the search indexes App uses to find classes using `App::build()`. Adding - * additional controller paths for example would alter where CakePHP looks for controllers when you - * call App::import('Controller', 'Posts'); This allows you to split your application up across the filesystem. + * additional controller paths for example would alter where CakePHP looks for controllers. + * This allows you to split your application up across the filesystem. * * ### Inspecting loaded paths * @@ -261,7 +261,7 @@ class App { 'View' => array(VIEWS), 'View/Helper' => array(HELPERS), 'locales' => array(APP . 'locale' . DS), - 'shells' => array( + 'Console' => array( APP . 'console' . DS . 'shells' . DS, APP . 'vendors' . DS . 'shells' . DS, VENDORS . 'shells' . DS diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index 5124136c2..1af6cc156 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -113,7 +113,7 @@ class ErrorHandler { CakeLog::write(LOG_ERR, '[' . get_class($exception) . '] ' . $exception->getMessage()); } if ($config['renderer'] !== 'ExceptionRenderer') { - App::import('Lib', $config['renderer']); + App::uses($config['renderer'], 'Error'); } $error = new $config['renderer']($exception); $error->render(); diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 1ea26c502..5b5289d29 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -20,6 +20,9 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::import('Sanitize', 'Utility'); + /** * Exception Renderer. * @@ -88,8 +91,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')) { diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index b85d9b75b..b899a7cab 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -101,7 +101,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/lib/Cake/I18n/Multibyte.php b/lib/Cake/I18n/Multibyte.php index 69c23188f..b1045e7b7 100644 --- a/lib/Cake/I18n/Multibyte.php +++ b/lib/Cake/I18n/Multibyte.php @@ -1078,7 +1078,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/lib/Cake/Model/BehaviorCollection.php b/lib/Cake/Model/BehaviorCollection.php index 05fad7db9..064e9a37d 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -94,12 +94,7 @@ class BehaviorCollection extends ObjectCollection { list($plugin, $name) = pluginSplit($behavior); $class = $name . 'Behavior'; - if (!App::import('Behavior', $behavior)) { - throw new MissingBehaviorFileException(array( - 'file' => Inflector::underscore($behavior) . '.php', - 'class' => $class - )); - } + App::uses($class, 'Model/Behavior'); if (!class_exists($class)) { throw new MissingBehaviorClassException(array( 'file' => Inflector::underscore($behavior) . '.php', diff --git a/lib/Cake/Model/CakeSchema.php b/lib/Cake/Model/CakeSchema.php index 17bc19f84..df7601308 100644 --- a/lib/Cake/Model/CakeSchema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -207,9 +207,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(); @@ -234,7 +233,8 @@ class CakeSchema extends Object { if (isset($this->plugin)) { $importModel = $this->plugin . '.' . $model; } - if (!App::import('Model', $importModel)) { + App::uses($importModel, 'Model'); + if (!class_exists($importModel)) { continue; } $vars = get_class_vars($model); diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index a11f4fcd8..83c962a32 100755 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -17,7 +17,9 @@ * @since CakePHP(tm) v 0.10.0.1076 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + App::uses('String', 'Utility'); +App::uses('View', 'View'); /** * DboSource @@ -763,7 +765,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/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index ff2af8519..9fbdc8218 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -585,7 +585,7 @@ class Set { if (is_string($path) && strpos($path, '{') !== false) { $path = String::tokenize($path, '.', '{', '}'); - } else { + } elseif (is_string($path)) { $path = explode('.', $path); } $tmp = array(); diff --git a/lib/Cake/View/pages/home.ctp b/lib/Cake/View/pages/home.ctp index d861c5c12..9beb7b0d0 100644 --- a/lib/Cake/View/pages/home.ctp +++ b/lib/Cake/View/pages/home.ctp @@ -24,7 +24,7 @@ endif; 0): - Debugger::checkSecurityKeys(); + //Debugger::checkSecurityKeys(); endif; ?>

diff --git a/lib/Cake/basics.php b/lib/Cake/basics.php index 287f0fc20..2d23d220d 100644 --- a/lib/Cake/basics.php +++ b/lib/Cake/basics.php @@ -670,9 +670,7 @@ if (!function_exists('sortByKey')) { * @param string $message Message to write to log */ function LogError($message) { - if (!class_exists('CakeLog')) { - App::import('Core', 'CakeLog'); - } + App::uses('CakeLog', 'Log'); $bad = array("\n", "\r", "\t"); $good = ' '; CakeLog::write('error', str_replace($bad, $good, $message)); diff --git a/lib/Cake/tests/cases/basics.test.php b/lib/Cake/tests/cases/basics.test.php index f6051717b..b3b028cd4 100644 --- a/lib/Cake/tests/cases/basics.test.php +++ b/lib/Cake/tests/cases/basics.test.php @@ -17,8 +17,9 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + require_once CAKE . 'basics.php'; -App::import('Core', 'Folder'); +App::uses('Folder', 'Utility'); /** * BasicsTest class diff --git a/lib/Cake/tests/cases/console/libs/task_collection.test.php b/lib/Cake/tests/cases/console/libs/task_collection.test.php index da7d6eaef..b918469e6 100644 --- a/lib/Cake/tests/cases/console/libs/task_collection.test.php +++ b/lib/Cake/tests/cases/console/libs/task_collection.test.php @@ -18,8 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'TaskCollection', false); -App::import('Shell', 'Shell', false); +App::uses('TaskCollection', 'Console'); +App::uses('Shell', 'Console'); class TaskCollectionTest extends CakeTestCase { /** diff --git a/lib/Cake/tests/cases/console/shells/acl.test.php b/lib/Cake/tests/cases/console/shells/acl.test.php index 0bb6489b1..7a0270084 100644 --- a/lib/Cake/tests/cases/console/shells/acl.test.php +++ b/lib/Cake/tests/cases/console/shells/acl.test.php @@ -17,10 +17,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', 'Acl'); -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; +App::uses('ShellDispatcher', 'Console'); +App::uses('Shell', 'Console'); +App::uses('AclShell', 'Console/Command'); /** * AclShellTest class diff --git a/lib/Cake/tests/cases/console/shells/api.test.php b/lib/Cake/tests/cases/console/shells/api.test.php index 82f134552..4c76f4aa8 100644 --- a/lib/Cake/tests/cases/console/shells/api.test.php +++ b/lib/Cake/tests/cases/console/shells/api.test.php @@ -17,11 +17,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/lib/Cake/tests/cases/console/shells/bake.test.php b/lib/Cake/tests/cases/console/shells/bake.test.php index 6f68e8bb3..f627c069a 100644 --- a/lib/Cake/tests/cases/console/shells/bake.test.php +++ b/lib/Cake/tests/cases/console/shells/bake.test.php @@ -18,14 +18,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', false); -App::import('Shell', 'tasks/controller', false); -App::import('Shell', 'tasks/db_config', false); -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 { @@ -76,7 +76,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/lib/Cake/tests/cases/console/shells/command_list.test.php b/lib/Cake/tests/cases/console/shells/command_list.test.php index bdabc2230..48fecaaa8 100644 --- a/lib/Cake/tests/cases/console/shells/command_list.test.php +++ b/lib/Cake/tests/cases/console/shells/command_list.test.php @@ -17,7 +17,7 @@ * @since CakePHP v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'CommandList', false); +App::import('CommandListShell', 'Console/Command'); class TestStringOutput extends ConsoleOutput { diff --git a/lib/Cake/tests/cases/console/shells/schema.test.php b/lib/Cake/tests/cases/console/shells/schema.test.php index 6a7a619a1..d438335e2 100644 --- a/lib/Cake/tests/cases/console/shells/schema.test.php +++ b/lib/Cake/tests/cases/console/shells/schema.test.php @@ -17,13 +17,10 @@ * @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('Shell', 'Console'); +App::uses('CakeSchema', 'Model'); /** * Test for Schema database management diff --git a/lib/Cake/tests/cases/console/shells/shell.test.php b/lib/Cake/tests/cases/console/shells/shell.test.php index 91c623cda..fcd8d4dd6 100644 --- a/lib/Cake/tests/cases/console/shells/shell.test.php +++ b/lib/Cake/tests/cases/console/shells/shell.test.php @@ -19,10 +19,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 diff --git a/lib/Cake/tests/cases/console/shells/tasks/controller.test.php b/lib/Cake/tests/cases/console/shells/tasks/controller.test.php index f3601376e..ef2bd70e0 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/controller.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/controller.test.php @@ -17,33 +17,27 @@ * @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'); - -if (!$imported) { +if (class_exists('BakeArticle')) { define('ARTICLE_MODEL_CREATED', true); - App::import('Core', 'Model'); class BakeArticle extends Model { public $name = 'BakeArticle'; public $hasMany = array('BakeComment'); public $hasAndBelongsToMany = array('BakeTag'); } - } /** diff --git a/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php b/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php index aca87ac94..50aa43873 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php @@ -17,11 +17,10 @@ * @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('Shell', 'Console'); +App::uses('DbConfigTask', 'Console/Command/Task'); class TEST_DATABASE_CONFIG { public $default = array( diff --git a/lib/Cake/tests/cases/console/shells/tasks/extract.test.php b/lib/Cake/tests/cases/console/shells/tasks/extract.test.php index 21993e0d4..6d634e5b4 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/extract.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/extract.test.php @@ -19,11 +19,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 diff --git a/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php b/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php index 7121f7fd1..c00b4fb94 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php @@ -17,14 +17,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', 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('FixtureTask', 'Console/Command/Task'); +App::uses('TemplateTask', 'Console/Command/Task'); +App::uses('DbConfigTask', 'Console/Command/Task'); /** * FixtureTaskTest class diff --git a/lib/Cake/tests/cases/console/shells/tasks/model.test.php b/lib/Cake/tests/cases/console/shells/tasks/model.test.php index ac2a2c7fc..fa48d5921 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/model.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/model.test.php @@ -19,14 +19,12 @@ * @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('FixtureTask', 'Console/Command/Task'); +App::uses('TemplateTask', 'Console/Command/Task'); +App::uses('ModelTask', 'Console/Command/Task'); /** * ModelTaskTest class diff --git a/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php b/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php index 327b258c2..652159880 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php @@ -19,15 +19,12 @@ * @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('Shell', 'Console'); +App::uses('PluginTask', 'Console/Command/Task'); +App::uses('ModelTask', 'Console/Command/Task'); +App::import('File', 'Utility'); /** * PluginTaskPlugin class diff --git a/lib/Cake/tests/cases/console/shells/tasks/project.test.php b/lib/Cake/tests/cases/console/shells/tasks/project.test.php index 8e92b7949..63870f4bd 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/project.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/project.test.php @@ -19,12 +19,11 @@ * @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('Shell', 'Console'); +App::uses('ProjecTask', 'Console/Command/Task'); +App::import('File', 'Utility'); /** * ProjectTask Test class diff --git a/lib/Cake/tests/cases/console/shells/tasks/template.test.php b/lib/Cake/tests/cases/console/shells/tasks/template.test.php index bbd81404d..c2b162dd8 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/template.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/template.test.php @@ -20,11 +20,10 @@ * @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('Shell', 'Console'); +App::uses('TemplateTask', 'Console/Command/Task'); /** * TemplateTaskTest class * diff --git a/lib/Cake/tests/cases/console/shells/tasks/test.test.php b/lib/Cake/tests/cases/console/shells/tasks/test.test.php index 14b603e54..4a77aaeab 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/test.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/test.test.php @@ -19,16 +19,13 @@ * @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('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 From f84351dd07f7658598ea90519de46d9f6e80bbdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Thu, 9 Dec 2010 00:43:11 -0430 Subject: [PATCH 058/668] More replacements of App::import to App::uses --- lib/Cake/Error/ExceptionRenderer.php | 2 +- .../cases/console/shells/command_list.test.php | 3 ++- .../cases/console/shells/tasks/plugin.test.php | 2 +- .../cases/console/shells/tasks/project.test.php | 2 +- .../cases/console/shells/tasks/view.test.php | 16 +++++++--------- .../cases/console/shells/testsuite.test.php | 7 ++----- lib/Cake/tests/cases/libs/cake_log.test.php | 5 +++-- lib/Cake/tests/cases/libs/cake_request.test.php | 7 +++---- lib/Cake/tests/cases/libs/cake_response.test.php | 2 +- lib/Cake/tests/cases/libs/cake_session.test.php | 5 ++--- lib/Cake/tests/cases/libs/cake_socket.test.php | 3 ++- .../tests/cases/libs/cake_test_case.test.php | 9 +++++---- .../tests/cases/libs/cake_test_fixture.test.php | 2 +- .../tests/cases/libs/class_registry.test.php | 2 +- .../tests/cases/libs/config/ini_reader.test.php | 2 +- .../tests/cases/libs/config/php_reader.test.php | 2 +- lib/Cake/tests/cases/libs/configure.test.php | 2 +- .../cases/libs/controller/component.test.php | 7 ++++--- .../controller/component_collection.test.php | 5 +++-- .../libs/controller/components/acl.test.php | 5 +++-- .../cases/libs/route/redirect_route.test.php | 8 +++++--- lib/Cake/tests/cases/libs/router.test.php | 5 +++-- 22 files changed, 53 insertions(+), 50 deletions(-) diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 5b5289d29..c62e45d7d 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -21,7 +21,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Sanitize', 'Utility'); +App::uses('Sanitize', 'Utility'); /** * Exception Renderer. diff --git a/lib/Cake/tests/cases/console/shells/command_list.test.php b/lib/Cake/tests/cases/console/shells/command_list.test.php index 48fecaaa8..6f25ed68b 100644 --- a/lib/Cake/tests/cases/console/shells/command_list.test.php +++ b/lib/Cake/tests/cases/console/shells/command_list.test.php @@ -17,7 +17,8 @@ * @since CakePHP v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('CommandListShell', 'Console/Command'); + +App::uses('CommandListShell', 'Console/Command'); class TestStringOutput extends ConsoleOutput { diff --git a/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php b/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php index 652159880..ad86a6a50 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php @@ -24,7 +24,7 @@ App::uses('ShellDispatcher', 'Console'); App::uses('Shell', 'Console'); App::uses('PluginTask', 'Console/Command/Task'); App::uses('ModelTask', 'Console/Command/Task'); -App::import('File', 'Utility'); +App::uses('File', 'Utility'); /** * PluginTaskPlugin class diff --git a/lib/Cake/tests/cases/console/shells/tasks/project.test.php b/lib/Cake/tests/cases/console/shells/tasks/project.test.php index 63870f4bd..cdd27e451 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/project.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/project.test.php @@ -23,7 +23,7 @@ App::uses('ShellDispatcher', 'Console'); App::uses('Shell', 'Console'); App::uses('ProjecTask', 'Console/Command/Task'); -App::import('File', 'Utility'); +App::uses('File', 'Utility'); /** * ProjectTask Test class diff --git a/lib/Cake/tests/cases/console/shells/tasks/view.test.php b/lib/Cake/tests/cases/console/shells/tasks/view.test.php index 5a2dfcce5..e742bff64 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/view.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/view.test.php @@ -19,16 +19,14 @@ * @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('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'); /** * Test View Task Comment Model diff --git a/lib/Cake/tests/cases/console/shells/testsuite.test.php b/lib/Cake/tests/cases/console/shells/testsuite.test.php index bfe463dbf..80bd9873a 100644 --- a/lib/Cake/tests/cases/console/shells/testsuite.test.php +++ b/lib/Cake/tests/cases/console/shells/testsuite.test.php @@ -18,11 +18,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Shell', 'Shell', false); -App::import('Shell', 'Testsuite'); - -require_once CAKE . 'console' . DS . 'shell_dispatcher.php'; - +App::uses('ShellDispatcher', 'Console'); +App::uses('TestSuiteShell', 'Console/Command'); class TestSuiteShellTest extends CakeTestCase { diff --git a/lib/Cake/tests/cases/libs/cake_log.test.php b/lib/Cake/tests/cases/libs/cake_log.test.php index 52c5c5abc..2569eae58 100644 --- a/lib/Cake/tests/cases/libs/cake_log.test.php +++ b/lib/Cake/tests/cases/libs/cake_log.test.php @@ -17,8 +17,9 @@ * @since CakePHP(tm) v 1.2.0.5432 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Log'); -App::import('Core', 'log/FileLog'); + +App::uses('CakeLog', 'Log'); +App::uses('FileLog', 'Log/Engine'); /** * CakeLogTest class diff --git a/lib/Cake/tests/cases/libs/cake_request.test.php b/lib/Cake/tests/cases/libs/cake_request.test.php index af4ad93cb..28036de43 100644 --- a/lib/Cake/tests/cases/libs/cake_request.test.php +++ b/lib/Cake/tests/cases/libs/cake_request.test.php @@ -17,10 +17,9 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -if (!class_exists('dispatcher')) { - require CAKE . 'dispatcher.php'; -} -App::import('Core', 'CakeRequest'); + +App::uses('Dispatcher', 'Routing') +App::uses('CakeRequest', 'Network'); class CakeRequestTestCase extends CakeTestCase { /** diff --git a/lib/Cake/tests/cases/libs/cake_response.test.php b/lib/Cake/tests/cases/libs/cake_response.test.php index eee0cfc69..bf43304c8 100644 --- a/lib/Cake/tests/cases/libs/cake_response.test.php +++ b/lib/Cake/tests/cases/libs/cake_response.test.php @@ -1,6 +1,6 @@ Date: Thu, 9 Dec 2010 01:25:24 -0430 Subject: [PATCH 059/668] More App::imports converted --- .../tests/cases/libs/cake_test_fixture.test.php | 2 +- .../cases/libs/controller/components/auth.test.php | 11 ++++++----- .../libs/controller/components/cookie.test.php | 7 +++++-- .../cases/libs/controller/components/email.test.php | 6 +++--- .../controller/components/request_handler.test.php | 7 ++++--- .../libs/controller/components/security.test.php | 4 ++-- .../libs/controller/components/session.test.php | 4 ++-- .../tests/cases/libs/controller/controller.test.php | 13 +++++++------ .../libs/controller/controller_merge_vars.test.php | 2 +- .../cases/libs/controller/pages_controller.test.php | 6 +++--- .../tests/cases/libs/controller/scaffold.test.php | 4 ++-- lib/Cake/tests/cases/libs/debugger.test.php | 4 ++-- lib/Cake/tests/cases/libs/dispatcher.test.php | 8 ++++---- .../tests/cases/libs/error/error_handler.test.php | 4 +++- .../cases/libs/error/exception_renderer.test.php | 4 +++- lib/Cake/tests/cases/libs/file.test.php | 2 +- lib/Cake/tests/cases/libs/http_socket.test.php | 3 ++- lib/Cake/tests/cases/libs/i18n.test.php | 2 +- lib/Cake/tests/cases/libs/inflector.test.php | 2 +- lib/Cake/tests/cases/libs/l10n.test.php | 2 +- lib/Cake/tests/cases/libs/log/file_log.test.php | 2 +- .../cases/libs/model/behavior_collection.test.php | 3 ++- .../tests/cases/libs/model/behaviors/acl.test.php | 4 ++-- .../cases/libs/model/behaviors/containable.test.php | 4 +++- .../cases/libs/model/behaviors/translate.test.php | 3 ++- .../tests/cases/libs/model/behaviors/tree.test.php | 4 +++- .../tests/cases/libs/model/cake_schema.test.php | 3 ++- .../cases/libs/model/connection_manager.test.php | 2 +- .../libs/model/datasources/dbo/dbo_mysql.test.php | 9 +++++---- .../model/datasources/dbo/dbo_postgres.test.php | 7 +++++-- .../libs/model/datasources/dbo/dbo_sqlite.test.php | 4 +++- .../libs/model/datasources/dbo_source.test.php | 4 +++- lib/Cake/tests/cases/libs/model/db_acl.test.php | 5 +++-- lib/Cake/tests/cases/libs/model/model.test.php | 4 +++- .../cases/libs/model/model_integration.test.php | 3 ++- .../tests/cases/libs/model/model_write.test.php | 2 +- lib/Cake/tests/cases/libs/multibyte.test.php | 2 +- lib/Cake/tests/cases/libs/set.test.php | 2 +- lib/Cake/tests/cases/libs/view/theme.test.php | 2 +- 39 files changed, 98 insertions(+), 68 deletions(-) diff --git a/lib/Cake/tests/cases/libs/cake_test_fixture.test.php b/lib/Cake/tests/cases/libs/cake_test_fixture.test.php index e82420834..4541b2526 100644 --- a/lib/Cake/tests/cases/libs/cake_test_fixture.test.php +++ b/lib/Cake/tests/cases/libs/cake_test_fixture.test.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0.4667 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('DboSource', 'Model/Datasource'); +App::uses('DboSource', 'Model/Datasource'); /** * CakeTestFixtureTestFixture class diff --git a/lib/Cake/tests/cases/libs/controller/components/auth.test.php b/lib/Cake/tests/cases/libs/controller/components/auth.test.php index 98f389efd..bc7e01ab4 100644 --- a/lib/Cake/tests/cases/libs/controller/components/auth.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/auth.test.php @@ -17,10 +17,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('Model', 'DbAcl'); -App::import('Core', 'Xml'); +App::uses('Controller', 'Controller'); +App::uses('AuthComponent', 'Controller/Component'); +App::uses('AclComponent', 'Controller/Component'); +App::uses('DbAcl', 'Model'); +App::uses('Xml', 'Utility'); /** * TestAuthComponent class @@ -1456,7 +1457,7 @@ class AuthTest extends CakeTestCase { )); $_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest"; - App::import('Core', 'Dispatcher'); + App::uses('Dispatcher', 'Routing'); ob_start(); $Dispatcher = new Dispatcher(); diff --git a/lib/Cake/tests/cases/libs/controller/components/cookie.test.php b/lib/Cake/tests/cases/libs/controller/components/cookie.test.php index cd16ca19e..41d962c08 100644 --- a/lib/Cake/tests/cases/libs/controller/components/cookie.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/cookie.test.php @@ -17,8 +17,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/lib/Cake/tests/cases/libs/controller/components/email.test.php b/lib/Cake/tests/cases/libs/controller/components/email.test.php index f8fd2e4a5..65bfc3ce5 100755 --- a/lib/Cake/tests/cases/libs/controller/components/email.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/email.test.php @@ -19,9 +19,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 diff --git a/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php b/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php index a9fe81d81..ddafab1f6 100644 --- a/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php @@ -17,9 +17,10 @@ * @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'); /** * RequestHandlerTestController class diff --git a/lib/Cake/tests/cases/libs/controller/components/security.test.php b/lib/Cake/tests/cases/libs/controller/components/security.test.php index 22274277a..599fe27b6 100644 --- a/lib/Cake/tests/cases/libs/controller/components/security.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/security.test.php @@ -17,8 +17,8 @@ * @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('Controller', 'Controller'); +App::uses('SecurityComponent', 'Component'); /** * TestSecurityComponent diff --git a/lib/Cake/tests/cases/libs/controller/components/session.test.php b/lib/Cake/tests/cases/libs/controller/components/session.test.php index bf605f1df..30c1a1ec2 100644 --- a/lib/Cake/tests/cases/libs/controller/components/session.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/session.test.php @@ -17,8 +17,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/lib/Cake/tests/cases/libs/controller/controller.test.php b/lib/Cake/tests/cases/libs/controller/controller.test.php index e55ed54b6..411df3309 100644 --- a/lib/Cake/tests/cases/libs/controller/controller.test.php +++ b/lib/Cake/tests/cases/libs/controller/controller.test.php @@ -17,10 +17,11 @@ * @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('CakeRequest', 'Network'); +App::uses('CakeResponse', 'Network'); +App::uses('SecurityComponent', 'Controller/Component'); +App::uses('CookieComponent', 'Controller/Component'); /** * AppController class @@ -28,7 +29,7 @@ App::import('Component', 'Cookie'); * @package cake * @subpackage cake.tests.cases.libs.controller */ -if (!class_exists('AppController')) { +if (!class_exists('AppController', false)) { /** * AppController class * @@ -498,7 +499,7 @@ class ControllerTest extends CakeTestCase { '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) )); - App::import('Controller', 'TestPlugin.TestPlugin'); + App::uses('TestPluginController', 'TestPlugin.Controller'); $Controller = new TestPluginController(); $Controller->plugin = 'TestPlugin'; diff --git a/lib/Cake/tests/cases/libs/controller/controller_merge_vars.test.php b/lib/Cake/tests/cases/libs/controller/controller_merge_vars.test.php index a3199b3a2..eb3301a4f 100644 --- a/lib/Cake/tests/cases/libs/controller/controller_merge_vars.test.php +++ b/lib/Cake/tests/cases/libs/controller/controller_merge_vars.test.php @@ -19,7 +19,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'); if (!class_exists('AppController')) { diff --git a/lib/Cake/tests/cases/libs/controller/pages_controller.test.php b/lib/Cake/tests/cases/libs/controller/pages_controller.test.php index 8188d3976..0c0f8813b 100644 --- a/lib/Cake/tests/cases/libs/controller/pages_controller.test.php +++ b/lib/Cake/tests/cases/libs/controller/pages_controller.test.php @@ -17,12 +17,12 @@ * @since CakePHP(tm) v 1.2.0.5436 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -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); } -App::import('Controller', 'Pages'); +App::uses('PagesController', 'Controller'); /** * PagesControllerTest class diff --git a/lib/Cake/tests/cases/libs/controller/scaffold.test.php b/lib/Cake/tests/cases/libs/controller/scaffold.test.php index 2ebd3f5e3..7f90f4be1 100644 --- a/lib/Cake/tests/cases/libs/controller/scaffold.test.php +++ b/lib/Cake/tests/cases/libs/controller/scaffold.test.php @@ -17,8 +17,8 @@ * @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('Scaffold', 'Controller'); +App::uses('Controller', 'Controller'); /** * ScaffoldMockController class diff --git a/lib/Cake/tests/cases/libs/debugger.test.php b/lib/Cake/tests/cases/libs/debugger.test.php index d6ea5ac8e..c6638abb7 100644 --- a/lib/Cake/tests/cases/libs/debugger.test.php +++ b/lib/Cake/tests/cases/libs/debugger.test.php @@ -17,7 +17,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 @@ -217,7 +217,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/lib/Cake/tests/cases/libs/dispatcher.test.php b/lib/Cake/tests/cases/libs/dispatcher.test.php index 35f161e7a..a92f72fb9 100644 --- a/lib/Cake/tests/cases/libs/dispatcher.test.php +++ b/lib/Cake/tests/cases/libs/dispatcher.test.php @@ -17,11 +17,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); } diff --git a/lib/Cake/tests/cases/libs/error/error_handler.test.php b/lib/Cake/tests/cases/libs/error/error_handler.test.php index 736524251..21d7eadd4 100644 --- a/lib/Cake/tests/cases/libs/error/error_handler.test.php +++ b/lib/Cake/tests/cases/libs/error/error_handler.test.php @@ -18,7 +18,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 diff --git a/lib/Cake/tests/cases/libs/error/exception_renderer.test.php b/lib/Cake/tests/cases/libs/error/exception_renderer.test.php index c99c6b118..f7293db84 100644 --- a/lib/Cake/tests/cases/libs/error/exception_renderer.test.php +++ b/lib/Cake/tests/cases/libs/error/exception_renderer.test.php @@ -18,7 +18,9 @@ * @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('Component', 'Controller'); /** * Short description for class. diff --git a/lib/Cake/tests/cases/libs/file.test.php b/lib/Cake/tests/cases/libs/file.test.php index 2895deb88..ebaa2062b 100644 --- a/lib/Cake/tests/cases/libs/file.test.php +++ b/lib/Cake/tests/cases/libs/file.test.php @@ -17,7 +17,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/lib/Cake/tests/cases/libs/http_socket.test.php b/lib/Cake/tests/cases/libs/http_socket.test.php index 5b3f79e0c..51e9e45bd 100644 --- a/lib/Cake/tests/cases/libs/http_socket.test.php +++ b/lib/Cake/tests/cases/libs/http_socket.test.php @@ -17,7 +17,8 @@ * @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'); class TestHttpSocket extends HttpSocket { diff --git a/lib/Cake/tests/cases/libs/i18n.test.php b/lib/Cake/tests/cases/libs/i18n.test.php index 1ca37bcb1..a446df605 100644 --- a/lib/Cake/tests/cases/libs/i18n.test.php +++ b/lib/Cake/tests/cases/libs/i18n.test.php @@ -17,7 +17,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 diff --git a/lib/Cake/tests/cases/libs/inflector.test.php b/lib/Cake/tests/cases/libs/inflector.test.php index 4d383c887..1535f82fa 100644 --- a/lib/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/lib/Cake/tests/cases/libs/l10n.test.php b/lib/Cake/tests/cases/libs/l10n.test.php index a1b35aee1..d685f3ed1 100644 --- a/lib/Cake/tests/cases/libs/l10n.test.php +++ b/lib/Cake/tests/cases/libs/l10n.test.php @@ -17,7 +17,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/lib/Cake/tests/cases/libs/log/file_log.test.php b/lib/Cake/tests/cases/libs/log/file_log.test.php index f07ab9771..623b66d88 100644 --- a/lib/Cake/tests/cases/libs/log/file_log.test.php +++ b/lib/Cake/tests/cases/libs/log/file_log.test.php @@ -17,7 +17,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/lib/Cake/tests/cases/libs/model/behavior_collection.test.php b/lib/Cake/tests/cases/libs/model/behavior_collection.test.php index 12ce1dd4f..de10eeaa1 100644 --- a/lib/Cake/tests/cases/libs/model/behavior_collection.test.php +++ b/lib/Cake/tests/cases/libs/model/behavior_collection.test.php @@ -19,7 +19,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'; /** diff --git a/lib/Cake/tests/cases/libs/model/behaviors/acl.test.php b/lib/Cake/tests/cases/libs/model/behaviors/acl.test.php index a7705dcd9..d644b8381 100644 --- a/lib/Cake/tests/cases/libs/model/behaviors/acl.test.php +++ b/lib/Cake/tests/cases/libs/model/behaviors/acl.test.php @@ -19,8 +19,8 @@ * @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('DbAcl', 'Model'); /** * Test Person class - self joined model diff --git a/lib/Cake/tests/cases/libs/model/behaviors/containable.test.php b/lib/Cake/tests/cases/libs/model/behaviors/containable.test.php index 10ea65fb5..4b1050395 100644 --- a/lib/Cake/tests/cases/libs/model/behaviors/containable.test.php +++ b/lib/Cake/tests/cases/libs/model/behaviors/containable.test.php @@ -17,7 +17,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/lib/Cake/tests/cases/libs/model/behaviors/translate.test.php b/lib/Cake/tests/cases/libs/model/behaviors/translate.test.php index ee13fe3bb..50f2ff3ab 100644 --- a/lib/Cake/tests/cases/libs/model/behaviors/translate.test.php +++ b/lib/Cake/tests/cases/libs/model/behaviors/translate.test.php @@ -21,7 +21,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'); /** diff --git a/lib/Cake/tests/cases/libs/model/behaviors/tree.test.php b/lib/Cake/tests/cases/libs/model/behaviors/tree.test.php index 75375459f..fd56daa12 100644 --- a/lib/Cake/tests/cases/libs/model/behaviors/tree.test.php +++ b/lib/Cake/tests/cases/libs/model/behaviors/tree.test.php @@ -19,7 +19,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/lib/Cake/tests/cases/libs/model/cake_schema.test.php b/lib/Cake/tests/cases/libs/model/cake_schema.test.php index ff5c8ffdd..5132fb557 100644 --- a/lib/Cake/tests/cases/libs/model/cake_schema.test.php +++ b/lib/Cake/tests/cases/libs/model/cake_schema.test.php @@ -18,7 +18,8 @@ * @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'); /** * Test for Schema database management diff --git a/lib/Cake/tests/cases/libs/model/connection_manager.test.php b/lib/Cake/tests/cases/libs/model/connection_manager.test.php index 04212fa4a..1798fb6b9 100644 --- a/lib/Cake/tests/cases/libs/model/connection_manager.test.php +++ b/lib/Cake/tests/cases/libs/model/connection_manager.test.php @@ -17,7 +17,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 diff --git a/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index bd29b5d39..30cecc0a3 100644 --- a/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -17,8 +17,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'; /** @@ -457,7 +460,6 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testAlterSchemaIndexes() { - App::import('Model', 'CakeSchema'); $this->Dbo->cacheSources = $this->Dbo->testing = false; $schema1 = new CakeSchema(array( @@ -577,7 +579,6 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testAlteringTableParameters() { - App::import('Model', 'CakeSchema'); $this->Dbo->cacheSources = $this->Dbo->testing = false; $schema1 = new CakeSchema(array( diff --git a/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php index c71836f5d..ebb803c92 100644 --- a/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php +++ b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php @@ -17,8 +17,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'; /** diff --git a/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php index b42b6209a..a71fc7075 100644 --- a/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php +++ b/lib/Cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php @@ -17,7 +17,9 @@ * @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 diff --git a/lib/Cake/tests/cases/libs/model/datasources/dbo_source.test.php b/lib/Cake/tests/cases/libs/model/datasources/dbo_source.test.php index 9ac868c3b..ab95b50cc 100644 --- a/lib/Cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/lib/Cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -18,7 +18,9 @@ * @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('DboSource', 'Model/Datasource'); require_once dirname(dirname(__FILE__)) . DS . 'models.php'; /** diff --git a/lib/Cake/tests/cases/libs/model/db_acl.test.php b/lib/Cake/tests/cases/libs/model/db_acl.test.php index fb0a9f3f3..694fdaffe 100644 --- a/lib/Cake/tests/cases/libs/model/db_acl.test.php +++ b/lib/Cake/tests/cases/libs/model/db_acl.test.php @@ -17,8 +17,9 @@ * @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('DbAcl', 'Model'); /** * DB ACL wrapper test class diff --git a/lib/Cake/tests/cases/libs/model/model.test.php b/lib/Cake/tests/cases/libs/model/model.test.php index 9809b3a0d..4e1411ea2 100644 --- a/lib/Cake/tests/cases/libs/model/model.test.php +++ b/lib/Cake/tests/cases/libs/model/model.test.php @@ -17,7 +17,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/lib/Cake/tests/cases/libs/model/model_integration.test.php b/lib/Cake/tests/cases/libs/model/model_integration.test.php index a8b5a6796..cd6063df3 100644 --- a/lib/Cake/tests/cases/libs/model/model_integration.test.php +++ b/lib/Cake/tests/cases/libs/model/model_integration.test.php @@ -19,8 +19,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/Database'); /** * DboMock class diff --git a/lib/Cake/tests/cases/libs/model/model_write.test.php b/lib/Cake/tests/cases/libs/model/model_write.test.php index 4cac5959e..f80fc0263 100644 --- a/lib/Cake/tests/cases/libs/model/model_write.test.php +++ b/lib/Cake/tests/cases/libs/model/model_write.test.php @@ -1016,7 +1016,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('

')); diff --git a/lib/Cake/tests/cases/libs/multibyte.test.php b/lib/Cake/tests/cases/libs/multibyte.test.php index 9ec3538ea..7da643c34 100644 --- a/lib/Cake/tests/cases/libs/multibyte.test.php +++ b/lib/Cake/tests/cases/libs/multibyte.test.php @@ -17,7 +17,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::import('Multibyte', 'I18n'); /** * MultibyteTest class diff --git a/lib/Cake/tests/cases/libs/set.test.php b/lib/Cake/tests/cases/libs/set.test.php index 9fbc4086b..ebabe84a5 100644 --- a/lib/Cake/tests/cases/libs/set.test.php +++ b/lib/Cake/tests/cases/libs/set.test.php @@ -2708,7 +2708,7 @@ class SetTest extends CakeTestCase { * @return void */ function testXmlSetReverse() { - App::import('Core', 'Xml'); + App::uses('Xml', 'Utility'); $string = ' diff --git a/lib/Cake/tests/cases/libs/view/theme.test.php b/lib/Cake/tests/cases/libs/view/theme.test.php index 314d38ba7..ffc8ee045 100644 --- a/lib/Cake/tests/cases/libs/view/theme.test.php +++ b/lib/Cake/tests/cases/libs/view/theme.test.php @@ -19,7 +19,7 @@ */ App::import('View', 'View'); App::import('View', 'Theme'); -App::import('Core', 'Controller'); +App::uses('Controller', 'Controller'); /** From 29077654040ae4074558725a50342a9f85f18632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 10 Dec 2010 01:53:27 -0430 Subject: [PATCH 060/668] Replacing almost all remaining uses of App::import --- lib/Cake/TestSuite/Fixture/CakeTestFixture.php | 12 ++++++++---- lib/Cake/TestSuite/templates/footer.php | 2 +- lib/Cake/tests/cases/libs/folder.test.php | 2 +- lib/Cake/tests/cases/libs/multibyte.test.php | 2 +- lib/Cake/tests/cases/libs/object.test.php | 5 ++++- lib/Cake/tests/cases/libs/object_collection.test.php | 2 +- lib/Cake/tests/cases/libs/route/cake_route.test.php | 4 ++-- .../cases/libs/route/plugin_short_route.test.php | 4 ++-- lib/Cake/tests/cases/libs/sanitize.test.php | 2 +- lib/Cake/tests/cases/libs/security.test.php | 2 +- .../tests/cases/libs/session/cache_session.test.php | 4 ++-- .../cases/libs/session/database_session.test.php | 6 +++--- lib/Cake/tests/cases/libs/set.test.php | 2 +- lib/Cake/tests/cases/libs/string.test.php | 2 +- lib/Cake/tests/cases/libs/validation.test.php | 2 +- lib/Cake/tests/cases/libs/view/helper.test.php | 5 ++++- .../tests/cases/libs/view/helper_collection.test.php | 4 ++-- .../tests/cases/libs/view/helpers/cache.test.php | 7 +++++-- lib/Cake/tests/cases/libs/view/helpers/form.test.php | 11 ++++++++--- lib/Cake/tests/cases/libs/view/helpers/html.test.php | 12 +++++++++--- .../cases/libs/view/helpers/jquery_engine.test.php | 7 +++++-- lib/Cake/tests/cases/libs/view/helpers/js.test.php | 7 +++++-- .../cases/libs/view/helpers/mootools_engine.test.php | 5 ++++- .../tests/cases/libs/view/helpers/number.test.php | 2 +- .../tests/cases/libs/view/helpers/paginator.test.php | 7 +++++-- .../libs/view/helpers/prototype_engine.test.php | 5 ++++- lib/Cake/tests/cases/libs/view/helpers/rss.test.php | 5 +++-- .../tests/cases/libs/view/helpers/session.test.php | 6 ++++-- lib/Cake/tests/cases/libs/view/helpers/text.test.php | 4 ++-- lib/Cake/tests/cases/libs/view/helpers/time.test.php | 4 ++-- lib/Cake/tests/cases/libs/view/media.test.php | 5 ++++- lib/Cake/tests/cases/libs/view/theme.test.php | 4 ++-- lib/Cake/tests/cases/libs/view/view.test.php | 8 +++++--- 33 files changed, 104 insertions(+), 57 deletions(-) diff --git a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php index b7676cf5c..db66430c9 100644 --- a/lib/Cake/TestSuite/Fixture/CakeTestFixture.php +++ b/lib/Cake/TestSuite/Fixture/CakeTestFixture.php @@ -20,6 +20,8 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); +App::uses('CakeSchema', 'Model'); + /** * Short description for class. * @@ -52,7 +54,6 @@ class CakeTestFixture { * */ public function __construct() { - App::import('Model', 'CakeSchema'); $this->Schema = new CakeSchema(array('name' => 'TestSuite', 'connection' => 'test')); $this->init(); } @@ -68,9 +69,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/lib/Cake/TestSuite/templates/footer.php b/lib/Cake/TestSuite/templates/footer.php index e9b6c6746..172195f02 100644 --- a/lib/Cake/TestSuite/templates/footer.php +++ b/lib/Cake/TestSuite/templates/footer.php @@ -27,7 +27,7 @@

element('sql_dump'); diff --git a/lib/Cake/tests/cases/libs/folder.test.php b/lib/Cake/tests/cases/libs/folder.test.php index 428520610..739047e57 100644 --- a/lib/Cake/tests/cases/libs/folder.test.php +++ b/lib/Cake/tests/cases/libs/folder.test.php @@ -17,7 +17,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'); /** * FolderTest class diff --git a/lib/Cake/tests/cases/libs/multibyte.test.php b/lib/Cake/tests/cases/libs/multibyte.test.php index 7da643c34..6eb0068b5 100644 --- a/lib/Cake/tests/cases/libs/multibyte.test.php +++ b/lib/Cake/tests/cases/libs/multibyte.test.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0.6833 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Multibyte', 'I18n'); +App::uses('Multibyte', 'I18n'); /** * MultibyteTest class diff --git a/lib/Cake/tests/cases/libs/object.test.php b/lib/Cake/tests/cases/libs/object.test.php index a371cf9f2..f5ad44cad 100644 --- a/lib/Cake/tests/cases/libs/object.test.php +++ b/lib/Cake/tests/cases/libs/object.test.php @@ -17,7 +17,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 diff --git a/lib/Cake/tests/cases/libs/object_collection.test.php b/lib/Cake/tests/cases/libs/object_collection.test.php index 9d0861861..ffc061cd2 100644 --- a/lib/Cake/tests/cases/libs/object_collection.test.php +++ b/lib/Cake/tests/cases/libs/object_collection.test.php @@ -18,7 +18,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/lib/Cake/tests/cases/libs/route/cake_route.test.php b/lib/Cake/tests/cases/libs/route/cake_route.test.php index dae305b23..76f76f336 100644 --- a/lib/Cake/tests/cases/libs/route/cake_route.test.php +++ b/lib/Cake/tests/cases/libs/route/cake_route.test.php @@ -1,7 +1,7 @@ skipIf(!is_writable(WWW_ROOT . 'theme'), 'Cannot write to webroot/theme')) { return; } - App::import('Core', 'File'); + App::uses('File', 'Utility'); $testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'img' . DS . '__cake_test_image.gif'; $file = new File($testfile, true); @@ -596,7 +602,7 @@ class HtmlHelperTest extends CakeTestCase { if ($this->skipIf(!is_writable(WWW_ROOT . 'theme'), 'Cannot write to webroot/theme')) { return; } - App::import('Core', 'File'); + App::uses('File', 'Utility'); $testfile = WWW_ROOT . 'theme' . DS . 'test_theme' . DS . 'js' . DS . '__test_js.js'; $file = new File($testfile, true); diff --git a/lib/Cake/tests/cases/libs/view/helpers/jquery_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/jquery_engine.test.php index 87c2b8b2b..ecbff4bb8 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/jquery_engine.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/jquery_engine.test.php @@ -18,8 +18,11 @@ * @subpackage cake.tests.cases.views.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', array('Html', 'Js', 'JqueryEngine')); -App::import('Core', 'View'); + +App::uses('HtmlHelper', 'View/Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('JqueryEngineHelper', 'View/Helper'); +App::uses('View', 'View'); class JqueryEngineHelperTest extends CakeTestCase { /** diff --git a/lib/Cake/tests/cases/libs/view/helpers/js.test.php b/lib/Cake/tests/cases/libs/view/helpers/js.test.php index 1fd1602a7..1b03d5648 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/js.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/js.test.php @@ -19,8 +19,11 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', array('Js', 'Html', 'Form')); -App::import('Core', array('View', 'ClassRegistry')); +App::uses('HtmlHelper', 'View/Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('FormHelper', 'View/Helper'); +App::uses('View', 'View'); +App::uses('ClassRegistry', 'Utility'); class OptionEngineHelper extends JsBaseEngineHelper { protected $_optionMap = array( diff --git a/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php index 53af75a80..fa4253842 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php @@ -20,7 +20,10 @@ * @subpackage cake.tests.cases.views.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', array('Html', 'Js', 'MootoolsEngine')); + +App::uses('HtmlHelper', 'View/Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('MooToolsEngineHelper', 'View/Helper'); class MooEngineHelperTest extends CakeTestCase { /** diff --git a/lib/Cake/tests/cases/libs/view/helpers/number.test.php b/lib/Cake/tests/cases/libs/view/helpers/number.test.php index 1d1d04c4c..9919416fb 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/number.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/number.test.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Number'); +App::uses('NumberHelper', 'View/Helper'); /** * NumberHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/helpers/paginator.test.php b/lib/Cake/tests/cases/libs/view/helpers/paginator.test.php index 2d0bda4a9..ef720ccc8 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/paginator.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/paginator.test.php @@ -17,8 +17,11 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'View'); -App::import('Helper', array('Html', 'Paginator', 'Form', 'Js')); +App::uses('View', 'View'); +App::uses('HtmlHelper', 'View/Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('PaginatorHelper', 'View/Helper'); +App::uses('FormHelper', 'View/Helper'); if (!defined('FULL_BASE_URL')) { define('FULL_BASE_URL', 'http://cakephp.org'); diff --git a/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php index 395b25cd7..77c2b1b87 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php @@ -18,7 +18,10 @@ * @subpackage cake.tests.cases.views.helpers * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', array('Html', 'Js', 'PrototypeEngine')); + +App::uses('HtmlHelper', 'View/Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('PrototypeEngineHelper', 'View/Helper'); class PrototypeEngineHelperTest extends CakeTestCase { /** diff --git a/lib/Cake/tests/cases/libs/view/helpers/rss.test.php b/lib/Cake/tests/cases/libs/view/helpers/rss.test.php index afc3e54e9..0e6e18474 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/rss.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/rss.test.php @@ -17,8 +17,9 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('View', 'View'); -App::import('Helper', array('Rss', 'Time')); +App::uses('View', 'View'); +App::uses('RssHelper', 'View/Helper'); +App::uses('TimeHelper', 'View/Helper'); /** * RssHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/helpers/session.test.php b/lib/Cake/tests/cases/libs/view/helpers/session.test.php index c61421bd1..2fa1dad0a 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/session.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/session.test.php @@ -17,8 +17,10 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', array('Controller', 'View')); -App::import('Helper', array('Session')); + +App::uses('Controller', 'Controller'); +App::uses('View', 'View'); +App::uses('SessionHelper', 'View/Helper'); /** * SessionHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/helpers/text.test.php b/lib/Cake/tests/cases/libs/view/helpers/text.test.php index cdb5dcecb..2ac412374 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/text.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/text.test.php @@ -17,8 +17,8 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'View'); -App::import('Helper', 'Text'); +App::uses('View', 'View'); +App::uses('TextHelper', 'Helper'); /** * TextHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/helpers/time.test.php b/lib/Cake/tests/cases/libs/view/helpers/time.test.php index 668467296..d5ba62b61 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/time.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/time.test.php @@ -17,8 +17,8 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Helper', 'Time'); -App::import('Core', 'View'); +App::uses('TimeHelper', 'View/Helper'); +App::uses('View', 'View'); /** * TimeHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/media.test.php b/lib/Cake/tests/cases/libs/view/media.test.php index 39b9d190d..a9352f5d9 100644 --- a/lib/Cake/tests/cases/libs/view/media.test.php +++ b/lib/Cake/tests/cases/libs/view/media.test.php @@ -17,7 +17,10 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', array('Media', 'Controller', 'CakeResponse')); + +App::uses('Controller', 'Controller'); +App::uses('MediaView', 'View'); +App::uses('CakeResponse', 'Network'); /** * MediaViewTest class diff --git a/lib/Cake/tests/cases/libs/view/theme.test.php b/lib/Cake/tests/cases/libs/view/theme.test.php index ffc8ee045..69a986ad7 100644 --- a/lib/Cake/tests/cases/libs/view/theme.test.php +++ b/lib/Cake/tests/cases/libs/view/theme.test.php @@ -17,8 +17,8 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('View', 'View'); -App::import('View', 'Theme'); +App::uses('View', 'View'); +App::uses('ThemeView', 'View'); App::uses('Controller', 'Controller'); diff --git a/lib/Cake/tests/cases/libs/view/view.test.php b/lib/Cake/tests/cases/libs/view/view.test.php index 8038ff010..9824b125a 100644 --- a/lib/Cake/tests/cases/libs/view/view.test.php +++ b/lib/Cake/tests/cases/libs/view/view.test.php @@ -17,9 +17,11 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', array('View', 'Controller')); -App::import('Helper', 'Cache'); -App::import('Core', array('ErrorHandler')); + +App::uses('View', 'View'); +App::uses('Controller', 'Controller'); +App::uses('CacheHelper', 'View/Helper'); +App::uses('ErrorHandler', 'Error'); /** From 4e722ddb74dae3ee0ba6638a1b5ec4e51bb9ac06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 11 Dec 2010 01:13:01 -0430 Subject: [PATCH 061/668] Fixing some constants to load the web testsuite --- app/webroot/index.php | 2 +- app/webroot/test.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/webroot/index.php b/app/webroot/index.php index 70991f787..d011f3939 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -68,7 +68,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); } if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { diff --git a/app/webroot/test.php b/app/webroot/test.php index 7a27e8e29..2f6a55e7a 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -50,7 +50,7 @@ ini_set('display_errors', 1); * */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT); + define('CAKE_CORE_INCLUDE_PATH', ROOT . DS .'lib'); } /** @@ -68,7 +68,7 @@ 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); } @@ -83,6 +83,6 @@ if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.', true)); } -require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php'; +require_once CAKE_TESTS_LIB . 'CakeTestSuiteDispatcher.php'; CakeTestSuiteDispatcher::run(); From 4389764050cb3aa2762f2f518a5903a0952c3670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 11 Dec 2010 01:13:42 -0430 Subject: [PATCH 062/668] Fixing core path --- lib/Cake/Core/App.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 2e4383ac8..cf751135c 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -339,8 +339,7 @@ class App { static $paths = false; if (!$paths) { $paths = array(); - $libs = LIBS; - $cake = dirname($libs) . DS; + $cake = $libs = LIBS; $path = dirname($cake) . DS; $paths['cake'][] = $cake; From 8e5bd76752a52873a913c5d985c73b07625b9e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 11 Dec 2010 01:17:55 -0430 Subject: [PATCH 063/668] Fixing several errors when running the testsuite --- lib/Cake/Core/App.php | 3 +-- lib/Cake/Model/BehaviorCollection.php | 2 +- lib/Cake/Model/Datasource/DboSource.php | 1 + lib/Cake/Network/HttpSocket.php | 2 +- lib/Cake/Routing/Router.php | 2 +- lib/Cake/TestSuite/CakeTestCase.php | 3 +-- lib/Cake/TestSuite/CakeTestSuiteDispatcher.php | 12 ++++++------ lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php | 3 ++- lib/Cake/TestSuite/Fixture/CakeFixtureManager.php | 4 ++++ lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php | 2 +- lib/Cake/TestSuite/TestManager.php | 2 ++ lib/Cake/View/Helper.php | 2 +- lib/Cake/View/Helper/JqueryEngineHelper.php | 3 ++- lib/Cake/View/HelperCollection.php | 2 +- lib/Cake/View/View.php | 1 + lib/Cake/bootstrap.php | 2 +- lib/Cake/tests/cases/libs/cake_test_case.test.php | 6 +++--- lib/Cake/tests/cases/libs/cake_test_fixture.test.php | 1 + .../tests/cases/libs/html_coverage_report.test.php | 2 +- lib/Cake/tests/cases/libs/set.test.php | 1 + lib/Cake/tests/cases/libs/view/helper.test.php | 1 + lib/Cake/tests/cases/libs/view/helpers/text.test.php | 3 ++- lib/Cake/tests/cases/libs/view/view.test.php | 1 + 23 files changed, 37 insertions(+), 24 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index cf751135c..a5f7019a0 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -285,8 +285,7 @@ class App { if (!empty($paths[$type])) { $path = array_flip(array_flip(array_merge( - (array)$paths[$type], self::$__packages[$type], $merge - ))); + (array)$paths[$type], self::$__packages[$type]))); self::$__packages[$type] = array_values($path); } else { $path = array_flip(array_flip(self::$__packages[$type])); diff --git a/lib/Cake/Model/BehaviorCollection.php b/lib/Cake/Model/BehaviorCollection.php index 064e9a37d..4cd769509 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -19,7 +19,7 @@ * @since CakePHP(tm) v 1.2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('ObjectCollection', 'Core'); +App::uses('ObjectCollection', 'Utility'); /** * Model behavior collection class. diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 83c962a32..c756d6aaa 100755 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -18,6 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('DataSource', 'Model/Datasource'); App::uses('String', 'Utility'); App::uses('View', 'View'); diff --git a/lib/Cake/Network/HttpSocket.php b/lib/Cake/Network/HttpSocket.php index 307448cf2..b80bebc12 100644 --- a/lib/Cake/Network/HttpSocket.php +++ b/lib/Cake/Network/HttpSocket.php @@ -18,7 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::uses('CakeSocket', 'Core'); -App::uses('Router', 'Core'); +App::uses('Router', 'Routing'); /** * Cake network socket connection class. diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 3824fdd0c..9f4d298c8 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -286,7 +286,7 @@ class Router { * @return array Array of routes */ public static function redirect($route, $url, $options) { - App::uses('RedirectRoute', 'Core'); + App::uses('RedirectRoute', 'Routing/Route'); $options['routeClass'] = 'RedirectRoute'; return self::connect($route, $url, $options); } diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 95819c5e1..d8fd93038 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -21,7 +21,6 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); App::uses('CakeFixtureManager', 'TestSuite/Fixture'); -App::uses('CakeTestModel', 'TestSuite/Fixture'); App::uses('CakeTestFixture', 'TestSuite/Fixture'); /** @@ -30,7 +29,7 @@ App::uses('CakeTestFixture', 'TestSuite/Fixture'); * @package cake * @subpackage cake.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 diff --git a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index 4642dc2b4..d67be7f1a 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php +++ b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php @@ -18,6 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('TestManager', 'TestSuite'); /** * CakeTestSuiteDispatcher handles web requests to the test suite and runs the correct action. * @@ -201,7 +202,6 @@ class CakeTestSuiteDispatcher { */ function &getManager() { if (empty($this->Manager)) { - require_once CAKE_TESTS_LIB . 'test_manager.php'; $this->Manager = new $this->_managerClass($this->params); } return $this->Manager; @@ -217,13 +217,13 @@ class CakeTestSuiteDispatcher { if (!self::$_Reporter) { $type = strtolower($this->params['output']); $coreClass = 'Cake' . ucwords($this->params['output']) . 'Reporter'; - $coreFile = CAKE_TESTS_LIB . 'reporter/cake_' . $type . '_reporter.php'; - $appClass = $this->params['output'] . 'Reporter'; - $appFile = APPLIBS . 'test_suite/reporter/' . $type . '_reporter.php'; - if (include_once $coreFile) { + App::uses($coreClass, 'TestSuite/Reporter'); + App::uses($appClass, 'TestSuite/Reporter'); + + if (class_exists($coreClass)) { self::$_Reporter = new $coreClass(null, $this->params); - } elseif (include_once $appFile) { + } elseif (class_exists($appClass)) { self::$_Reporter = new $appClass(null, $this->params); } } diff --git a/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php b/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php index ae4fa081c..802f462ca 100644 --- a/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php +++ b/lib/Cake/TestSuite/Coverage/HtmlCoverageReport.php @@ -17,10 +17,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/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php index ea09473e7..66bf11352 100644 --- a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php +++ b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php @@ -19,6 +19,9 @@ */ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); +App::uses('ConnectionManager', 'Model'); +App::uses('ClassRegistry', 'Utility'); + class CakeFixtureManager { /** @@ -100,6 +103,7 @@ 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) { diff --git a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php index 186c3fe73..1f4d6331c 100755 --- a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php @@ -17,7 +17,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'); diff --git a/lib/Cake/TestSuite/TestManager.php b/lib/Cake/TestSuite/TestManager.php index cf56a20b7..2498f106d 100644 --- a/lib/Cake/TestSuite/TestManager.php +++ b/lib/Cake/TestSuite/TestManager.php @@ -23,9 +23,11 @@ define('APP_TEST_CASES', TESTS . 'cases'); define('APP_TEST_GROUPS', TESTS . 'groups'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); + App::uses('CakeTestSuite', 'TestSuite'); App::uses('CakeTestCase', 'TestSuite'); App::uses('CakeFixtureManager', 'TestSuite/Fixture'); +App::uses('CakeTestModel', 'TestSuite/Fixture'); /** * TestManager is the base class that handles loading and initiating the running diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index f9d26e447..f0a43a33c 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -20,7 +20,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Router', 'Core'); +App::uses('Router', 'Routing'); /** * Abstract base class for all other Helpers in CakePHP. diff --git a/lib/Cake/View/Helper/JqueryEngineHelper.php b/lib/Cake/View/Helper/JqueryEngineHelper.php index ce9c017db..bc3d90423 100644 --- a/lib/Cake/View/Helper/JqueryEngineHelper.php +++ b/lib/Cake/View/Helper/JqueryEngineHelper.php @@ -23,7 +23,8 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('JsHelper', 'Helper'); +App::uses('JsHelper', 'View/Helper'); +App::uses('JsBaseEngineHelper', 'View/Helper'); class JqueryEngineHelper extends JsBaseEngineHelper { /** diff --git a/lib/Cake/View/HelperCollection.php b/lib/Cake/View/HelperCollection.php index 99e709c03..fe5f74ad5 100644 --- a/lib/Cake/View/HelperCollection.php +++ b/lib/Cake/View/HelperCollection.php @@ -16,7 +16,7 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('ObjectCollection', 'Core'); +App::uses('ObjectCollection', 'Utility'); class HelperCollection extends ObjectCollection { diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index ef241d334..f25469f07 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -22,6 +22,7 @@ * Included libraries. */ App::uses('HelperCollection', 'View'); +App::uses('Router', 'Routing'); /** * View, the V in the MVC triad. diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index a6b0099f6..97f38c04a 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -145,7 +145,7 @@ if (!defined('CAKE_TESTS')) { /** * Path to the test suite. */ - define('CAKE_TESTS_LIB', CAKE_TESTS.'lib'.DS); + define('CAKE_TESTS_LIB', LIBS . 'TestSuite' . DS); /** * Path to the controller test directory. diff --git a/lib/Cake/tests/cases/libs/cake_test_case.test.php b/lib/Cake/tests/cases/libs/cake_test_case.test.php index c0623529d..34d8a4a9b 100644 --- a/lib/Cake/tests/cases/libs/cake_test_case.test.php +++ b/lib/Cake/tests/cases/libs/cake_test_case.test.php @@ -24,7 +24,7 @@ App::uses('Controller', 'Controller'); App::uses('CakeHtmlReporter', 'TestSuite/Reporter'); if (!class_exists('AppController', false)) { - require_once LIBS . 'Controller' . DS . 'app_controller.php'; + require_once LIBS . 'Controller' . DS . 'AppController.php'; } elseif (!defined('APP_CONTROLLER_EXISTS')) { define('APP_CONTROLLER_EXISTS', true); } @@ -38,8 +38,8 @@ if (!class_exists('AppController', false)) { 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/lib/Cake/tests/cases/libs/cake_test_fixture.test.php b/lib/Cake/tests/cases/libs/cake_test_fixture.test.php index 4541b2526..fa851e52e 100644 --- a/lib/Cake/tests/cases/libs/cake_test_fixture.test.php +++ b/lib/Cake/tests/cases/libs/cake_test_fixture.test.php @@ -18,6 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::uses('DboSource', 'Model/Datasource'); +App::uses('Model', 'Model'); /** * CakeTestFixtureTestFixture class diff --git a/lib/Cake/tests/cases/libs/html_coverage_report.test.php b/lib/Cake/tests/cases/libs/html_coverage_report.test.php index 39f41fb60..325271131 100644 --- a/lib/Cake/tests/cases/libs/html_coverage_report.test.php +++ b/lib/Cake/tests/cases/libs/html_coverage_report.test.php @@ -18,7 +18,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 { /** diff --git a/lib/Cake/tests/cases/libs/set.test.php b/lib/Cake/tests/cases/libs/set.test.php index e17a6af06..e0c5c3348 100644 --- a/lib/Cake/tests/cases/libs/set.test.php +++ b/lib/Cake/tests/cases/libs/set.test.php @@ -18,6 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::uses('Set', 'Utility'); +App::uses('Model', 'Model'); /** * SetTest class diff --git a/lib/Cake/tests/cases/libs/view/helper.test.php b/lib/Cake/tests/cases/libs/view/helper.test.php index f14704e1c..c00ee271c 100644 --- a/lib/Cake/tests/cases/libs/view/helper.test.php +++ b/lib/Cake/tests/cases/libs/view/helper.test.php @@ -20,6 +20,7 @@ App::uses('View', 'View'); App::uses('Helper', 'View'); +App::uses('Model', 'Model'); App::uses('Router', 'Routing'); /** diff --git a/lib/Cake/tests/cases/libs/view/helpers/text.test.php b/lib/Cake/tests/cases/libs/view/helpers/text.test.php index 2ac412374..b867c988a 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/text.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/text.test.php @@ -17,8 +17,9 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + App::uses('View', 'View'); -App::uses('TextHelper', 'Helper'); +App::uses('TextHelper', 'View/Helper'); /** * TextHelperTest class diff --git a/lib/Cake/tests/cases/libs/view/view.test.php b/lib/Cake/tests/cases/libs/view/view.test.php index 9824b125a..34ca6ae0f 100644 --- a/lib/Cake/tests/cases/libs/view/view.test.php +++ b/lib/Cake/tests/cases/libs/view/view.test.php @@ -19,6 +19,7 @@ */ App::uses('View', 'View'); +App::uses('Helper', 'View'); App::uses('Controller', 'Controller'); App::uses('CacheHelper', 'View/Helper'); App::uses('ErrorHandler', 'Error'); From 5ffc84d28a82de9b12eb85c71de1fed760472143 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 12 Dec 2010 21:14:30 -0500 Subject: [PATCH 064/668] Calling parent constructors in helpers that have it omitted. Fixes #1359 --- cake/libs/view/helpers/js.php | 1 + cake/libs/view/helpers/paginator.php | 1 + 2 files changed, 2 insertions(+) diff --git a/cake/libs/view/helpers/js.php b/cake/libs/view/helpers/js.php index 546792c68..5c3571bef 100644 --- a/cake/libs/view/helpers/js.php +++ b/cake/libs/view/helpers/js.php @@ -501,6 +501,7 @@ class JsBaseEngineHelper extends AppHelper { * @return void */ function __construct() { + parent::__construct(); $this->useNative = function_exists('json_encode'); } diff --git a/cake/libs/view/helpers/paginator.php b/cake/libs/view/helpers/paginator.php index f3bb2cdb0..ca5f45541 100644 --- a/cake/libs/view/helpers/paginator.php +++ b/cake/libs/view/helpers/paginator.php @@ -88,6 +88,7 @@ class PaginatorHelper extends AppHelper { * @return void */ function __construct($config = array()) { + parent::__construct($config); $ajaxProvider = isset($config['ajax']) ? $config['ajax'] : 'Js'; $this->helpers[] = $ajaxProvider; $this->_ajaxHelperClass = $ajaxProvider; From e410509684a9aaeaa1fd7107459d80c4b290d220 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 13 Dec 2010 22:00:37 -0500 Subject: [PATCH 065/668] Fixing TestTask not being able to find plugin objects when baking test skeletons interactively. Test case added. Fixes #1361 --- cake/console/libs/tasks/test.php | 15 +++++++++++- .../cases/console/libs/tasks/test.test.php | 23 ++++++++++++++++++- cake/tests/cases/libs/model/db_acl.test.php | 3 ++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/cake/console/libs/tasks/test.php b/cake/console/libs/tasks/test.php index d90a1eb4a..ed9c7e433 100644 --- a/cake/console/libs/tasks/test.php +++ b/cake/console/libs/tasks/test.php @@ -181,7 +181,20 @@ class TestTask extends BakeTask { * @access public */ function getClassName($objectType) { - $options = App::objects(strtolower($objectType)); + $type = strtolower($objectType); + if ($this->plugin) { + $path = Inflector::pluralize($type); + if ($type === 'helper') { + $path = 'views' . DS . $path; + } elseif ($type === 'component') { + $path = 'controllers' . DS . $path; + } elseif ($type === 'behavior') { + $path = 'models' . DS . $path; + } + $options = App::objects($type, App::pluginPath($this->plugin) . $path, false); + } else { + $options = App::objects($type); + } $this->out(sprintf(__('Choose a %s class', true), $objectType)); $keys = array(); foreach ($options as $key => $option) { diff --git a/cake/tests/cases/console/libs/tasks/test.test.php b/cake/tests/cases/console/libs/tasks/test.test.php index e660cdea8..b6f1e8c2a 100644 --- a/cake/tests/cases/console/libs/tasks/test.test.php +++ b/cake/tests/cases/console/libs/tasks/test.test.php @@ -44,7 +44,7 @@ Mock::generatePartial( ); Mock::generatePartial( 'TestTask', 'MockTestTask', - array('in', '_stop', 'err', 'out', 'createFile', 'isLoadableClass') + array('in', '_stop', 'err', 'out', 'hr', 'createFile', 'isLoadableClass') ); /** @@ -278,6 +278,7 @@ class TestTaskTest extends CakeTestCase { */ function endTest() { ClassRegistry::flush(); + App::build(); } /** @@ -560,6 +561,26 @@ class TestTaskTest extends CakeTestCase { $this->Task->bake('Helper', 'Form'); } +/** + * test interactive with plugins lists from the plugin + * + * @return void + */ + function testInteractiveWithPlugin() { + $testApp = TEST_CAKE_CORE_INCLUDE_PATH . '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'; + $this->Task->setReturnValueAt(0, 'in', 5); //helper + $this->Task->setReturnValueAt(1, 'in', 1); //OtherHelper + $this->Task->expectAt(0, 'createFile', array($path, '*')); + $this->Task->expectAt(9, 'out', array('1. OtherHelper')); + $this->Task->execute(); + } + /** * Test filename generation for each type + plugins * diff --git a/cake/tests/cases/libs/model/db_acl.test.php b/cake/tests/cases/libs/model/db_acl.test.php index 73e9cf6a6..b970d2332 100644 --- a/cake/tests/cases/libs/model/db_acl.test.php +++ b/cake/tests/cases/libs/model/db_acl.test.php @@ -211,7 +211,8 @@ class DbAroUserTest extends CakeTestModel { * @access public */ var $useTable = 'auth_users'; - /** + +/** * bindNode method * * @param mixed $ref From 53a687049ce78e2d2211f51ca89e72d06edd5e40 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 13 Dec 2010 23:23:02 -0500 Subject: [PATCH 066/668] Fixing encoding of address aliases. They are now mime-encoded like other headers. Tests added. Fixes #1360 --- cake/libs/controller/components/email.php | 5 +++-- .../libs/controller/components/email.test.php | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 2aa96c3e0..83ee15df2 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -774,14 +774,15 @@ class EmailComponent extends Object{ * @access private */ function _formatAddress($string, $smtp = false) { - $hasAlias = preg_match('/((.*)\s)?<(.+)>/', $string, $matches); + $hasAlias = preg_match('/((.*))?\s?<(.+)>/', $string, $matches); if ($smtp && $hasAlias) { return $this->_strip('<' . $matches[3] . '>'); } elseif ($smtp) { return $this->_strip('<' . $string . '>'); } + if ($hasAlias && !empty($matches[2])) { - return $this->_strip($matches[2] . ' <' . $matches[3] . '>'); + return $this->_encode($matches[2]) . $this->_strip(' <' . $matches[3] . '>'); } return $this->_strip($string); } diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index ed80c1b2b..0dbb72d0e 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -1216,6 +1216,9 @@ HTMLBLOC; $result = $this->Controller->EmailTest->formatAddress('alias '); $this->assertEqual($result, 'alias '); + + $result = $this->Controller->EmailTest->formatAddress('alias'); + $this->assertEqual($result, 'alias '); $result = $this->Controller->EmailTest->formatAddress('email@example.com'); $this->assertEqual($result, 'email@example.com'); @@ -1232,4 +1235,21 @@ HTMLBLOC; $result = $this->Controller->EmailTest->formatAddress('alias name ', true); $this->assertEqual($result, ''); } + +/** + * test formatting addresses with multibyte chars + * + * @return void + */ + function testFormatAddressMultibyte() { + $this->Controller->EmailTest->charset = 'UTF-8'; + $result = $this->Controller->EmailTest->formatAddress('ÄÖÜTest '); + $this->assertEqual($result, '=?UTF-8?B?w4TDlsOcVGVzdCA=?= '); + + $result = $this->Controller->EmailTest->formatAddress('ÄÖÜTest'); + $this->assertEqual($result, '=?UTF-8?B?w4TDlsOcVGVzdA==?= '); + + $result = $this->Controller->EmailTest->formatAddress('ÄÖÜTest ', true); + $this->assertEqual($result, ''); + } } From 7416e58759856f5c4944eb9d4442aa9f3f7d0525 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 14 Dec 2010 20:55:34 -0800 Subject: [PATCH 067/668] Allowed comma-delimited list in smtp $to var to be consistent with standard mail delivery. Fixes #1353 --- cake/libs/controller/components/email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 83ee15df2..3bb1357ac 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -893,7 +893,7 @@ class EmailComponent extends Object{ } if (!is_array($this->to)) { - $tos = array($this->to); + $tos = array_map('trim', explode(',', $this->to)); } else { $tos = $this->to; } From 8436fd53d0adc9cbcd96e3d6f09550ca3c03295a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 15 Dec 2010 01:20:02 -0430 Subject: [PATCH 068/668] Changing initial uses of App::uses() to the new packages system --- lib/Cake/Controller/Component/AuthComponent.php | 2 +- lib/Cake/Controller/Component/CookieComponent.php | 2 +- lib/Cake/Controller/Component/RequestHandlerComponent.php | 2 +- lib/Cake/Controller/Component/SecurityComponent.php | 4 ++-- lib/Cake/Network/CakeSocket.php | 2 +- lib/Cake/Network/HttpSocket.php | 2 +- lib/Cake/Routing/Route/PluginShortRoute.php | 2 +- lib/Cake/Routing/Route/RedirectRoute.php | 4 ++-- lib/Cake/Routing/Router.php | 2 +- lib/Cake/Utility/Security.php | 2 +- lib/Cake/View/MediaView.php | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 7122804af..f96e6dbe9 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -21,7 +21,7 @@ */ App::uses('Router', 'Routing'); -App::uses('Security', 'Core'); +App::uses('Security', 'Utility'); App::uses('Debugger', 'Utility'); /** diff --git a/lib/Cake/Controller/Component/CookieComponent.php b/lib/Cake/Controller/Component/CookieComponent.php index 781d5012c..df0be063d 100644 --- a/lib/Cake/Controller/Component/CookieComponent.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -21,7 +21,7 @@ /** * Load Security class */ -App::uses('Security', 'Core'); +App::uses('Security', 'Utility'); /** * Cookie Component. diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index 4f5cc3dfe..06f4db96b 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -20,7 +20,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Xml', 'Core'); +App::uses('Xml', 'Utility'); /** * Request object for handling HTTP requests diff --git a/lib/Cake/Controller/Component/SecurityComponent.php b/lib/Cake/Controller/Component/SecurityComponent.php index 96d275792..e9d0de4a5 100644 --- a/lib/Cake/Controller/Component/SecurityComponent.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -17,8 +17,8 @@ * @since CakePHP(tm) v 0.10.8.2156 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('String', 'Core'); -App::uses('Security', 'Core'); +App::uses('String', 'Utility'); +App::uses('Security', 'Utility'); /** * SecurityComponent diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index d6dd6f8be..8c0a031e1 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Validation', 'Core'); +App::uses('Validation', 'Utility'); /** * Cake network socket connection class. diff --git a/lib/Cake/Network/HttpSocket.php b/lib/Cake/Network/HttpSocket.php index e2dec93c4..c636cfd63 100644 --- a/lib/Cake/Network/HttpSocket.php +++ b/lib/Cake/Network/HttpSocket.php @@ -17,7 +17,7 @@ * @since CakePHP(tm) v 1.2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('CakeSocket', 'Core'); +App::uses('CakeSocket', 'Network'); App::uses('Router', 'Routing'); /** diff --git a/lib/Cake/Routing/Route/PluginShortRoute.php b/lib/Cake/Routing/Route/PluginShortRoute.php index 062cfcbfb..3077226b4 100644 --- a/lib/Cake/Routing/Route/PluginShortRoute.php +++ b/lib/Cake/Routing/Route/PluginShortRoute.php @@ -1,5 +1,5 @@ $value) { $plugins[$key] = Inflector::underscore($value); } diff --git a/lib/Cake/Utility/Security.php b/lib/Cake/Utility/Security.php index 2cbe838b0..ecc59d310 100644 --- a/lib/Cake/Utility/Security.php +++ b/lib/Cake/Utility/Security.php @@ -18,7 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('String', 'Core'); +App::uses('String', 'Utility'); /** * Security Library contains utility methods related to security diff --git a/lib/Cake/View/MediaView.php b/lib/Cake/View/MediaView.php index 856e8d920..f6cacd078 100644 --- a/lib/Cake/View/MediaView.php +++ b/lib/Cake/View/MediaView.php @@ -18,7 +18,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::uses('View', 'View'); -App::uses('CakeRequest', 'Core'); +App::uses('CakeRequest', 'Network'); class MediaView extends View { /** From 387281e506501f5747d8df0ccd169a017b4b8ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 15 Dec 2010 01:32:37 -0430 Subject: [PATCH 069/668] Moving newly created classes to the new folders --- .../Cake/Controller/Component/PaginatorComponent.php | 0 .../Cake/Network/Http/BasicAuthentication.php | 0 .../Cake/Network/Http/DigestAuthentication.php | 0 .../http_response.php => lib/Cake/Network/Http/HttpResponse.php | 0 lib/Cake/Network/{ => Http}/HttpSocket.php | 0 {cake/libs/view => lib/Cake/View}/scaffolds/form.ctp | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename cake/libs/controller/components/paginator.php => lib/Cake/Controller/Component/PaginatorComponent.php (100%) rename cake/libs/http/basic_authentication.php => lib/Cake/Network/Http/BasicAuthentication.php (100%) rename cake/libs/http/digest_authentication.php => lib/Cake/Network/Http/DigestAuthentication.php (100%) rename cake/libs/http_response.php => lib/Cake/Network/Http/HttpResponse.php (100%) rename lib/Cake/Network/{ => Http}/HttpSocket.php (100%) rename {cake/libs/view => lib/Cake/View}/scaffolds/form.ctp (100%) 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/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/lib/Cake/Network/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php similarity index 100% rename from lib/Cake/Network/HttpSocket.php rename to lib/Cake/Network/Http/HttpSocket.php diff --git a/cake/libs/view/scaffolds/form.ctp b/lib/Cake/View/scaffolds/form.ctp similarity index 100% rename from cake/libs/view/scaffolds/form.ctp rename to lib/Cake/View/scaffolds/form.ctp From a7c7436d8ec758795e0cf38b6062befd12933134 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 18 Dec 2010 19:31:10 -0200 Subject: [PATCH 070/668] Passing viewVars to cache views, avoiding cake:nocache problems. --- cake/libs/view/helpers/cache.php | 2 ++ cake/libs/view/view.php | 1 + .../cases/libs/view/helpers/cache.test.php | 36 +++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index adea15cc5..52ebd75b9 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -233,6 +233,7 @@ class CacheHelper extends AppHelper { $controller->params = $this->params = unserialize(stripslashes(\'' . addslashes(serialize($this->params)) . '\')); $controller->action = $this->action = unserialize(\'' . serialize($this->action) . '\'); $controller->data = $this->data = unserialize(stripslashes(\'' . addslashes(serialize($this->data)) . '\')); + $controller->viewVars = $this->viewVars = unserialize(stripslashes(\'' . addslashes(serialize($this->viewVars)) . '\')); $controller->theme = $this->theme = \'' . $this->theme . '\'; Router::setRequestInfo(array($this->params, array(\'base\' => $this->base, \'webroot\' => $this->webroot)));'; @@ -253,6 +254,7 @@ class CacheHelper extends AppHelper { $this->loaded[$camelBackedHelper] =& ${$camelBackedHelper}; $this->{$helper} =& $loadedHelpers[$helper]; } + extract($this->viewVars, EXTR_SKIP); ?>'; $content = preg_replace("/(<\\?xml)/", "",$content); $file .= $content; diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index fd1999e9a..dbf7b5f9b 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -751,6 +751,7 @@ class View extends Object { $cache->controllerName = $this->name; $cache->layout = $this->layout; $cache->cacheAction = $this->cacheAction; + $cache->viewVars = $this->viewVars; $cache->cache($___viewFn, $out, $cached); } } diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index 3a42ec0fa..d2d6b43ee 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -308,6 +308,42 @@ class CacheHelperTest extends CakeTestCase { $this->assertPattern('/7\. layout after content and after element with no cache tags/', $contents); } +/** + * test cache of view vars + * + * @access public + * @return void + */ + function testCacheViewVars() { + $this->Controller->cache_parsing(); + $this->Controller->params = array( + 'controller' => 'cache_test', + 'action' => 'cache_parsing', + 'url' => array(), + 'pass' => array(), + 'named' => array() + ); + $this->Controller->cacheAction = 21600; + $this->Controller->here = '/cacheTest/cache_parsing'; + $this->Controller->action = 'cache_parsing'; + + $View = new View($this->Controller); + $result = $View->render('index'); + $this->assertNoPattern('/cake:nocache/', $result); + $this->assertNoPattern('/php echo/', $result); + + $filename = CACHE . 'views' . DS . 'cachetest_cache_parsing.php'; + $this->assertTrue(file_exists($filename)); + + $contents = file_get_contents($filename); + $this->assertPattern('/\$this\-\>viewVars.*variable/', $contents); + $this->assertPattern('/extract\(\$this\-\>viewVars, EXTR_SKIP\);/', $contents); + $this->assertPattern('/php echo \$variable/', $contents); + $this->assertPattern('/variableValue/', $contents); + + @unlink($filename); + } + /** * test cacheAction set to a boolean * From 5d2b4c758dd2de4ac470e25416f35bcb9a3c16cb Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 18 Dec 2010 19:41:57 -0200 Subject: [PATCH 071/668] Minor optimization in cache views. --- cake/libs/view/helpers/cache.php | 10 +++++----- cake/tests/cases/libs/view/helpers/cache.test.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 52ebd75b9..e2e911b8c 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -225,15 +225,15 @@ class CacheHelper extends AppHelper { $file .= '$controller =& new ' . $this->controllerName . 'Controller(); $controller->plugin = $this->plugin = \''.$this->plugin.'\'; - $controller->helpers = $this->helpers = unserialize(\'' . serialize($this->helpers) . '\'); + $controller->helpers = $this->helpers = ' . var_export($this->helpers, true) . '; $controller->base = $this->base = \'' . $this->base . '\'; $controller->layout = $this->layout = \'' . $this->layout. '\'; $controller->webroot = $this->webroot = \'' . $this->webroot . '\'; $controller->here = $this->here = \'' . $this->here . '\'; - $controller->params = $this->params = unserialize(stripslashes(\'' . addslashes(serialize($this->params)) . '\')); - $controller->action = $this->action = unserialize(\'' . serialize($this->action) . '\'); - $controller->data = $this->data = unserialize(stripslashes(\'' . addslashes(serialize($this->data)) . '\')); - $controller->viewVars = $this->viewVars = unserialize(stripslashes(\'' . addslashes(serialize($this->viewVars)) . '\')); + $controller->params = $this->params = ' . var_export($this->params, true) . '; + $controller->action = $this->action = ' . var_export($this->action, true) . '; + $controller->data = $this->data = ' . var_export($this->data, true) . '; + $controller->viewVars = $this->viewVars = ' . var_export($this->viewVars, true) . '; $controller->theme = $this->theme = \'' . $this->theme . '\'; Router::setRequestInfo(array($this->params, array(\'base\' => $this->base, \'webroot\' => $this->webroot)));'; diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index d2d6b43ee..45edea332 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -336,7 +336,7 @@ class CacheHelperTest extends CakeTestCase { $this->assertTrue(file_exists($filename)); $contents = file_get_contents($filename); - $this->assertPattern('/\$this\-\>viewVars.*variable/', $contents); + $this->assertPattern('/\$this\-\>viewVars/', $contents); $this->assertPattern('/extract\(\$this\-\>viewVars, EXTR_SKIP\);/', $contents); $this->assertPattern('/php echo \$variable/', $contents); $this->assertPattern('/variableValue/', $contents); From 5efa201b9bddb2563e09521f18facd0e1ee7de6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 18 Dec 2010 21:52:03 -0430 Subject: [PATCH 072/668] Moving recently created files into the new folders --- {cake => lib/Cake}/tests/test_app/config/routes.php | 0 .../test_app/plugins/test_plugin/views/tests/scaffold.form.ctp | 0 .../tests/test_app/views/elements/email/html/nested_element.ctp | 0 {cake => lib/Cake}/tests/test_app/views/elements/html_call.ctp | 0 {cake => lib/Cake}/tests/test_app/views/elements/type_check.ctp | 0 {cake => lib/Cake}/tests/test_app/views/layouts/json/default.ctp | 0 {cake => lib/Cake}/tests/test_app/views/posts/scaffold.form.ctp | 0 {cake => lib/Cake}/tests/test_app/views/tests_apps/json/index.ctp | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename {cake => lib/Cake}/tests/test_app/config/routes.php (100%) rename {cake => lib/Cake}/tests/test_app/plugins/test_plugin/views/tests/scaffold.form.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/email/html/nested_element.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/html_call.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/elements/type_check.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/layouts/json/default.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/posts/scaffold.form.ctp (100%) rename {cake => lib/Cake}/tests/test_app/views/tests_apps/json/index.ctp (100%) diff --git a/cake/tests/test_app/config/routes.php b/lib/Cake/tests/test_app/config/routes.php similarity index 100% rename from cake/tests/test_app/config/routes.php rename to lib/Cake/tests/test_app/config/routes.php diff --git a/cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.form.ctp b/lib/Cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.form.ctp similarity index 100% rename from cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.form.ctp rename to lib/Cake/tests/test_app/plugins/test_plugin/views/tests/scaffold.form.ctp diff --git a/cake/tests/test_app/views/elements/email/html/nested_element.ctp b/lib/Cake/tests/test_app/views/elements/email/html/nested_element.ctp similarity index 100% rename from cake/tests/test_app/views/elements/email/html/nested_element.ctp rename to lib/Cake/tests/test_app/views/elements/email/html/nested_element.ctp diff --git a/cake/tests/test_app/views/elements/html_call.ctp b/lib/Cake/tests/test_app/views/elements/html_call.ctp similarity index 100% rename from cake/tests/test_app/views/elements/html_call.ctp rename to lib/Cake/tests/test_app/views/elements/html_call.ctp diff --git a/cake/tests/test_app/views/elements/type_check.ctp b/lib/Cake/tests/test_app/views/elements/type_check.ctp similarity index 100% rename from cake/tests/test_app/views/elements/type_check.ctp rename to lib/Cake/tests/test_app/views/elements/type_check.ctp diff --git a/cake/tests/test_app/views/layouts/json/default.ctp b/lib/Cake/tests/test_app/views/layouts/json/default.ctp similarity index 100% rename from cake/tests/test_app/views/layouts/json/default.ctp rename to lib/Cake/tests/test_app/views/layouts/json/default.ctp diff --git a/cake/tests/test_app/views/posts/scaffold.form.ctp b/lib/Cake/tests/test_app/views/posts/scaffold.form.ctp similarity index 100% rename from cake/tests/test_app/views/posts/scaffold.form.ctp rename to lib/Cake/tests/test_app/views/posts/scaffold.form.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 From 8bcabdea6a30d8b72991bd5ad195a9206be603ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 18 Dec 2010 22:02:25 -0430 Subject: [PATCH 073/668] Fixing constants for test suite --- app/webroot/test.php | 7 +------ lib/Cake/Console/Command/TestSuiteShell.php | 8 +------- lib/Cake/tests/cases/libs/folder.test.php | 1 + 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/app/webroot/test.php b/app/webroot/test.php index 2f6a55e7a..fdf97f457 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -72,12 +72,7 @@ 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); -} +define('TEST_CAKE_CORE_INCLUDE_PATH', LIBS); if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.', true)); diff --git a/lib/Cake/Console/Command/TestSuiteShell.php b/lib/Cake/Console/Command/TestSuiteShell.php index 3b3b1f901..9705d05de 100644 --- a/lib/Cake/Console/Command/TestSuiteShell.php +++ b/lib/Cake/Console/Command/TestSuiteShell.php @@ -160,13 +160,7 @@ class TestSuiteShell extends Shell { * @return void */ public function initialize() { - $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); - } - + define('TEST_CAKE_CORE_INCLUDE_PATH', LIBS); $this->_dispatcher = new CakeTestSuiteDispatcher(); $this->_dispatcher->loadTestFramework(); } diff --git a/lib/Cake/tests/cases/libs/folder.test.php b/lib/Cake/tests/cases/libs/folder.test.php index f70b60e84..65ca682ab 100644 --- a/lib/Cake/tests/cases/libs/folder.test.php +++ b/lib/Cake/tests/cases/libs/folder.test.php @@ -17,6 +17,7 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Folder', 'Utility'); App::uses('File', 'Utility'); /** From ad78f1dc746a9a8e9f637fb0c20a28b5bc7c73b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 18 Dec 2010 22:07:30 -0430 Subject: [PATCH 074/668] Adding support for plugin classes back, Allowing the user to override core classes in app/libs Adding some backward compatibility for App::path() and App::build() --- lib/Cake/Core/App.php | 177 +++++++++++++++++++++++++++++------------- 1 file changed, 122 insertions(+), 55 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index a5f7019a0..8b7ad40bc 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -213,6 +213,27 @@ class App { */ private static $__packages = array(); +/** + * + * + */ + 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' => 'Model/Datasource', + 'views' => 'View', + 'helpers' => 'View/Helper', + 'shells' => 'Console' + ); + /** * Inicates whether the class cache should be stored again because of an addition to it * @@ -235,7 +256,24 @@ class App { * @param string $type type of path * @return string array */ - public static function path($type) { + 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); + } + return $path; + } + + return $pluginPath . 'libs' . DS . $type; + } + if (!isset(self::$__packages[$type])) { return array(); } @@ -251,32 +289,50 @@ class App { * @return void */ public static function build($paths = array(), $reset = false) { - $defaults = array( - 'Model' => array(MODELS), - 'Model/Behavior' => array(BEHAVIORS), - 'Datasource' => array(MODELS . 'datasources'), - 'Controller' => array(CONTROLLERS), - 'Controller/Component' => array(COMPONENTS), - 'libs' => array(APPLIBS), - 'View' => array(VIEWS), - 'View/Helper' => array(HELPERS), - 'locales' => array(APP . 'locale' . DS), - 'Console' => 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 (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), + '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 . 'shells' . DS, + '%s' . 'vendors' . DS . 'shells' . DS, + VENDORS . 'shells' . DS + ), + 'libs' => array('%s' . 'libs' . DS), + 'locales' => array('%s' . 'locale' . DS), + 'vendors' => array('%s' . 'vendors' . DS, VENDORS), + 'plugins' => array(APP . 'plugins' . DS) + ); + + self::$__packageFormat['Console/Command'] = self::$__packageFormat['Console']; + } if ($reset == true) { foreach ($paths as $type => $new) { + if (!empty(self::$legacy[$type])) { + $type = self::$legacy[$type]; + } self::$__packages[$type] = (array)$new; } return $paths; } + $defaults = array(); + foreach (self::$__packageFormat as $package => $format) { + foreach ($format as $f) { + $defaults[$package][] = sprintf($f, APP); + } + } + + $mergeExclude = array('libs', 'locales', 'vendors', 'plugins'); + $appLibs = empty($paths['libs']) ? $defaults['libs'] : $paths['libs']; + foreach ($defaults as $type => $default) { if (empty(self::$__packages[$type]) || empty($paths)) { @@ -284,13 +340,12 @@ class App { } if (!empty($paths[$type])) { - $path = array_flip(array_flip(array_merge( - (array)$paths[$type], self::$__packages[$type]))); - self::$__packages[$type] = array_values($path); + $path = array_merge((array)$paths[$type], self::$__packages[$type]); } else { - $path = array_flip(array_flip(self::$__packages[$type])); - self::$__packages[$type] = array_values($path); + $path = self::$__packages[$type]; } + + self::$__packages[$type] = array_values(array_unique($path)); } } @@ -302,12 +357,12 @@ class App { */ 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 ; + foreach (self::$__packages['plugins'] as $pluginPath) { + if (is_dir($pluginPath . $pluginDir)) { + return $pluginPath . $pluginDir . DS ; } } - return self::$plugins[0] . $pluginDir . DS; + return self::$__packages['plugins'][0] . $pluginDir . DS; } /** @@ -318,46 +373,35 @@ class App { */ 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 ; + foreach (self::$__packages['View'] as $path) { + if (is_dir($path . $themeDir)) { + return $path . $themeDir . DS ; } } - return self::$views[0] . $themeDir . DS; + return self::$__packages['View'][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' + * @param string $type valid values are: 'cake' ,'plugins', 'vendors' and 'shells' * @return array numeric keyed array of core lib paths */ public static function core($type = null) { static $paths = false; if (!$paths) { $paths = array(); - $cake = $libs = LIBS; - $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'][] = $libs . 'Console' . DS . 'Command' . DS; + $root = dirname(dirname(LIBS)) . DS; + $paths['cake'][] = $root; + $paths['plugins'][] = $root . 'plugins' . DS; + $paths['vendors'][] = $root . 'vendors' . DS; + $paths['shells'][] = LIBS . 'Console' . DS . 'Command' . DS; // Provide BC path to vendors/shells - $paths['shells'][] = $path . 'vendors' . DS . 'shells' . DS; + $paths['shells'][] = $root . 'vendors' . DS . 'shells' . DS; } - if ($type && isset($paths[$type])) { - return $paths[$type]; + if ($type) { + return isset($paths[$type]) ? $paths[$type] : array(LIBS . $type . DS); } return $paths; } @@ -453,9 +497,14 @@ class App { return include $file; } - $package = self::$__classMap[$className]; - $paths = self::path($package); - $paths[] = LIBS . self::$__classMap[$className] . DS; + list($plugin, $package) = pluginSplit(self::$__classMap[$className]); + $paths = self::path($package, $plugin); + + if (empty($plugin)) { + $appLibs = empty(self::$__packages['libs']) ? APPLIBS : self::$__packages['libs']; + $paths[] = $appLibs . self::$__classMap[$className] . DS; + $paths[] = LIBS . self::$__classMap[$className] . DS; + } foreach ($paths as $path) { $file = $path . $className . '.php'; @@ -464,7 +513,25 @@ class App { 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; } From 151a4bdb33fa73fe44b196e5499e71925379e7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 18 Dec 2010 22:09:08 -0430 Subject: [PATCH 075/668] Fixing view files finding and making tests pass --- lib/Cake/View/HelperCollection.php | 4 ++-- lib/Cake/View/View.php | 6 +++--- lib/Cake/tests/cases/libs/view/view.test.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Cake/View/HelperCollection.php b/lib/Cake/View/HelperCollection.php index fe5f74ad5..fa7503456 100644 --- a/lib/Cake/View/HelperCollection.php +++ b/lib/Cake/View/HelperCollection.php @@ -54,11 +54,11 @@ class HelperCollection extends ObjectCollection { return $this->_loaded[$name]; } $helperClass = $name . 'Helper'; - App::uses($helperClass, 'View/Helper'); + App::uses($helperClass, $plugin . 'View/Helper'); if (!class_exists($helperClass)) { throw new MissingHelperClassException(array( 'class' => $helperClass, - 'file' => Inflector::underscore($name) . '.php' + 'file' => $helperClass . '.php' )); } $this->_loaded[$name] = new $helperClass($this->_View, $settings); diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index f524328ed..e24fed5c4 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -803,7 +803,7 @@ class View extends Object { } $paths = array(); $viewPaths = App::path('View'); - $corePaths = array_flip(App::core('views')); + $corePaths = array_flip(App::core('View')); if (!empty($plugin)) { $count = count($viewPaths); @@ -812,10 +812,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, array_flip($corePaths)); + $this->__paths = array_unique(array_merge($paths, $viewPaths, array_keys($corePaths))); return $this->__paths; } } diff --git a/lib/Cake/tests/cases/libs/view/view.test.php b/lib/Cake/tests/cases/libs/view/view.test.php index 17c5c6274..61762f475 100644 --- a/lib/Cake/tests/cases/libs/view/view.test.php +++ b/lib/Cake/tests/cases/libs/view/view.test.php @@ -204,7 +204,7 @@ class ViewTest extends CakeTestCase { '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, - TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS + TEST_CAKE_CORE_INCLUDE_PATH . 'View' . DS ) ), true); @@ -268,7 +268,7 @@ class ViewTest extends CakeTestCase { TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'plugins' . DS . 'test_plugin' . DS, TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'views' . DS, TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS, - TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS + TEST_CAKE_CORE_INCLUDE_PATH . 'View' . DS ); $this->assertEqual($paths, $expected); } From 5e1b49918bf8d3d99f628226d851e48511cc6e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 18 Dec 2010 22:26:23 -0430 Subject: [PATCH 076/668] Fixing App::core('cake') --- lib/Cake/Core/App.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 8b7ad40bc..e541c5f51 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -393,7 +393,7 @@ class App { if (!$paths) { $paths = array(); $root = dirname(dirname(LIBS)) . DS; - $paths['cake'][] = $root; + $paths['cake'][] = LIBS; $paths['plugins'][] = $root . 'plugins' . DS; $paths['vendors'][] = $root . 'vendors' . DS; $paths['shells'][] = LIBS . 'Console' . DS . 'Command' . DS; From 633f1dc1e5f72a1ed25e60bdb1b54e54506bd4ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 18 Dec 2010 22:27:02 -0430 Subject: [PATCH 077/668] Fixing warning in ConnectionManager --- lib/Cake/Model/ConnectionManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index 324dcf554..5500e7547 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -180,7 +180,7 @@ class ConnectionManager { App::uses($conn['classname'], $plugin . 'Model/Datasource' . $package); if (!class_exists($conn['classname'])) { - trigger_error(__('ConnectionManager::loadDataSource - Unable to import DataSource class %s', $class), E_USER_ERROR); + trigger_error(__('ConnectionManager::loadDataSource - Unable to import DataSource class %s', $conn['classname']), E_USER_ERROR); return null; } return true; From e8c73170ba2d2211637e5e88c4582609ef6b1c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 18 Dec 2010 22:27:28 -0430 Subject: [PATCH 078/668] Ficing a couple of notices when using a mocked CakeRequest --- lib/Cake/Network/CakeRequest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index bd0ad3bb4..403624505 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -273,7 +273,7 @@ class CakeRequest implements ArrayAccess { $config = Configure::read('App'); extract($config); - if (!$base) { + if (empty($base)) { $base = $this->base; } @@ -281,7 +281,7 @@ class CakeRequest implements ArrayAccess { $this->webroot = $base . '/'; return $base; } - if (!$baseUrl) { + if (empty($baseUrl)) { $replace = array('<', '>', '*', '\'', '"'); $base = str_replace($replace, '', dirname(env('PHP_SELF'))); From 5f7ca8d2b660ff4b8a802c4506c6542e98a22fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 18 Dec 2010 22:27:55 -0430 Subject: [PATCH 079/668] Removing some internal chenck for the "driver" key in database configs --- .../tests/cases/libs/model/model_write.test.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Cake/tests/cases/libs/model/model_write.test.php b/lib/Cake/tests/cases/libs/model/model_write.test.php index 43f8846ef..bf72dbf2a 100644 --- a/lib/Cake/tests/cases/libs/model/model_write.test.php +++ b/lib/Cake/tests/cases/libs/model/model_write.test.php @@ -148,7 +148,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(); @@ -170,7 +170,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(); @@ -192,7 +192,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'); @@ -409,7 +409,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) { @@ -2988,7 +2988,7 @@ class ModelWriteTest extends BaseModelTest { $this->getMock('DboSource', array(), array(), 'MockTransactionDboSource'); $db = ConnectionManager::create('mock_transaction', array( - 'datasource' => 'MockTransactionDbo', + 'datasource' => 'MockTransactionDboSource', )); $db->expects($this->at(2)) ->method('isInterfaceSupported') @@ -3023,7 +3023,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; @@ -3841,7 +3841,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'); @@ -3892,7 +3892,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'); From 5605bf2d9ee9d746cf11b2a3ad21d8ea00e14c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sat, 18 Dec 2010 22:32:20 -0430 Subject: [PATCH 080/668] Fixing failing test for HelperCollection --- lib/Cake/tests/cases/libs/view/helper_collection.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/libs/view/helper_collection.test.php b/lib/Cake/tests/cases/libs/view/helper_collection.test.php index 43048973b..54aa16cde 100644 --- a/lib/Cake/tests/cases/libs/view/helper_collection.test.php +++ b/lib/Cake/tests/cases/libs/view/helper_collection.test.php @@ -73,7 +73,7 @@ class HelperCollectionTest extends CakeTestCase { /** * test missinghelper exception * - * @expectedException MissingHelperFileException + * @expectedException MissingHelperClassException * @return void */ function testLoadMissingHelperFile() { From 5fa028839e9004c1bd3347f4a35fef45d8de628d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 19 Dec 2010 23:17:53 -0430 Subject: [PATCH 081/668] Fixing paths location in cake.php files --- app/console/cake.php | 2 +- lib/Cake/Console/templates/skel/console/cake.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/console/cake.php b/app/console/cake.php index af02ae4ff..6a91ffc98 100755 --- a/app/console/cake.php +++ b/app/console/cake.php @@ -20,6 +20,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/lib/Cake/Console/templates/skel/console/cake.php b/lib/Cake/Console/templates/skel/console/cake.php index 8ccac0bfb..fc0c0b484 100644 --- a/lib/Cake/Console/templates/skel/console/cake.php +++ b/lib/Cake/Console/templates/skel/console/cake.php @@ -20,6 +20,7 @@ * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once(__CAKE_PATH__ . 'shell_dispatcher.php'); +require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'ShellDispatcher.php'); return ShellDispatcher::run($argv); + From b2ad8fe113aaa4025c75d2f89cea0b2c047f6ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 19 Dec 2010 23:33:37 -0430 Subject: [PATCH 082/668] Removing constant TEST_CAKE_CORE_INCLUDE_PATH --- app/webroot/test.php | 2 - .../cases/libs/controller_test_case.test.php | 20 +++--- lib/Cake/Console/Command/TestSuiteShell.php | 1 - .../Console/templates/skel/webroot/test.php | 13 +--- .../TestSuite/Coverage/BaseCoverageReport.php | 2 +- .../TestSuite/Fixture/CakeFixtureManager.php | 2 +- lib/Cake/tests/cases/basics.test.php | 2 +- .../console/libs/task_collection.test.php | 2 +- .../cases/console/shell_dispatcher.test.php | 4 +- .../console/shells/command_list.test.php | 4 +- .../cases/console/shells/schema.test.php | 12 ++-- .../tests/cases/console/shells/shell.test.php | 4 +- .../console/shells/tasks/extract.test.php | 8 +-- .../console/shells/tasks/template.test.php | 4 +- lib/Cake/tests/cases/libs/app.test.php | 46 ++++++------- lib/Cake/tests/cases/libs/cache.test.php | 12 ++-- lib/Cake/tests/cases/libs/cake_log.test.php | 4 +- .../tests/cases/libs/cake_session.test.php | 8 +-- .../cases/libs/config/ini_reader.test.php | 2 +- .../cases/libs/config/php_reader.test.php | 4 +- lib/Cake/tests/cases/libs/configure.test.php | 4 +- .../cases/libs/controller/component.test.php | 12 ++-- .../controller/component_collection.test.php | 2 +- .../libs/controller/components/acl.test.php | 4 +- .../libs/controller/components/auth.test.php | 11 ++- .../libs/controller/components/email.test.php | 13 ++-- .../components/request_handler.test.php | 4 +- .../cases/libs/controller/controller.test.php | 32 ++++----- .../libs/controller/pages_controller.test.php | 12 +++- .../cases/libs/controller/scaffold.test.php | 34 +++++----- lib/Cake/tests/cases/libs/dispatcher.test.php | 28 ++++---- .../cases/libs/error/error_handler.test.php | 4 +- .../libs/error/exception_renderer.test.php | 6 +- lib/Cake/tests/cases/libs/folder.test.php | 68 +++++++++---------- .../cases/libs/html_coverage_report.test.php | 8 +-- lib/Cake/tests/cases/libs/i18n.test.php | 6 +- .../cases/libs/model/cake_schema.test.php | 4 +- .../libs/model/connection_manager.test.php | 14 ++-- lib/Cake/tests/cases/libs/object.test.php | 24 +++---- lib/Cake/tests/cases/libs/router.test.php | 4 +- .../tests/cases/libs/view/helper.test.php | 10 +-- .../libs/view/helper_collection.test.php | 2 +- .../cases/libs/view/helpers/cache.test.php | 2 +- .../cases/libs/view/helpers/html.test.php | 8 +-- .../cases/libs/view/helpers/session.test.php | 2 +- .../cases/libs/view/helpers/time.test.php | 4 +- lib/Cake/tests/cases/libs/view/media.test.php | 6 +- lib/Cake/tests/cases/libs/view/theme.test.php | 21 +++--- lib/Cake/tests/cases/libs/view/view.test.php | 40 +++++------ lib/Cake/tests/cases/libs/xml.test.php | 10 +-- 50 files changed, 277 insertions(+), 278 deletions(-) diff --git a/app/webroot/test.php b/app/webroot/test.php index fdf97f457..94c7f8784 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -72,8 +72,6 @@ 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); } -define('TEST_CAKE_CORE_INCLUDE_PATH', LIBS); - if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.', true)); } diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/cake/tests/cases/libs/controller_test_case.test.php index c457da428..0ec621ccb 100644 --- a/cake/tests/cases/libs/controller_test_case.test.php +++ b/cake/tests/cases/libs/controller_test_case.test.php @@ -21,7 +21,7 @@ */ App::import('Controller', 'Controller', false); App::import('Core', array('AppModel', 'Model')); -require_once TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'lib' . DS . 'reporter' . DS . 'cake_html_reporter.php'; +require_once LIBS . 'tests' . DS . 'lib' . DS . 'reporter' . DS . 'cake_html_reporter.php'; require_once dirname(__FILE__) . DS . 'model' . DS . 'models.php'; /** @@ -108,10 +108,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), + 'controllers' => array(LIBS . '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) )); $this->Case = new ControllerTestCase(); Router::reload(); @@ -222,7 +222,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')); @@ -230,16 +230,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)); @@ -251,7 +251,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; diff --git a/lib/Cake/Console/Command/TestSuiteShell.php b/lib/Cake/Console/Command/TestSuiteShell.php index 9705d05de..c62205162 100644 --- a/lib/Cake/Console/Command/TestSuiteShell.php +++ b/lib/Cake/Console/Command/TestSuiteShell.php @@ -160,7 +160,6 @@ class TestSuiteShell extends Shell { * @return void */ public function initialize() { - define('TEST_CAKE_CORE_INCLUDE_PATH', LIBS); $this->_dispatcher = new CakeTestSuiteDispatcher(); $this->_dispatcher->loadTestFramework(); } diff --git a/lib/Cake/Console/templates/skel/webroot/test.php b/lib/Cake/Console/templates/skel/webroot/test.php index 7a27e8e29..94c7f8784 100644 --- a/lib/Cake/Console/templates/skel/webroot/test.php +++ b/lib/Cake/Console/templates/skel/webroot/test.php @@ -50,7 +50,7 @@ ini_set('display_errors', 1); * */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT); + define('CAKE_CORE_INCLUDE_PATH', ROOT . DS .'lib'); } /** @@ -68,21 +68,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.', true)); } -require_once CAKE_TESTS_LIB . 'cake_test_suite_dispatcher.php'; +require_once CAKE_TESTS_LIB . 'CakeTestSuiteDispatcher.php'; CakeTestSuiteDispatcher::run(); diff --git a/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php b/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php index d532f06d6..c259c338d 100644 --- a/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php +++ b/lib/Cake/TestSuite/Coverage/BaseCoverageReport.php @@ -102,7 +102,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/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php index 66bf11352..b46c48c26 100644 --- a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php +++ b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php @@ -128,7 +128,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/lib/Cake/tests/cases/basics.test.php b/lib/Cake/tests/cases/basics.test.php index fca3079df..255158a88 100644 --- a/lib/Cake/tests/cases/basics.test.php +++ b/lib/Cake/tests/cases/basics.test.php @@ -36,7 +36,7 @@ class BasicsTest extends CakeTestCase { */ public function setUp() { App::build(array( - 'locales' => 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/lib/Cake/tests/cases/console/libs/task_collection.test.php b/lib/Cake/tests/cases/console/libs/task_collection.test.php index e2efdfb0e..ac22f2ac2 100644 --- a/lib/Cake/tests/cases/console/libs/task_collection.test.php +++ b/lib/Cake/tests/cases/console/libs/task_collection.test.php @@ -89,7 +89,7 @@ class TaskCollectionTest extends CakeTestCase { $dispatcher = $this->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/lib/Cake/tests/cases/console/shell_dispatcher.test.php b/lib/Cake/tests/cases/console/shell_dispatcher.test.php index 2da5bbe81..f0e342f51 100644 --- a/lib/Cake/tests/cases/console/shell_dispatcher.test.php +++ b/lib/Cake/tests/cases/console/shell_dispatcher.test.php @@ -119,11 +119,11 @@ 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 + LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS . 'shells' . DS ) ), true); } diff --git a/lib/Cake/tests/cases/console/shells/command_list.test.php b/lib/Cake/tests/cases/console/shells/command_list.test.php index 6f25ed68b..602037cf3 100644 --- a/lib/Cake/tests/cases/console/shells/command_list.test.php +++ b/lib/Cake/tests/cases/console/shells/command_list.test.php @@ -39,13 +39,13 @@ 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 + LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS . 'shells' . DS ) ), true); App::objects('plugin', null, false); diff --git a/lib/Cake/tests/cases/console/shells/schema.test.php b/lib/Cake/tests/cases/console/shells/schema.test.php index d438335e2..ae95a52df 100644 --- a/lib/Cake/tests/cases/console/shells/schema.test.php +++ b/lib/Cake/tests/cases/console/shells/schema.test.php @@ -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/lib/Cake/tests/cases/console/shells/shell.test.php b/lib/Cake/tests/cases/console/shells/shell.test.php index fcd8d4dd6..457af05d5 100644 --- a/lib/Cake/tests/cases/console/shells/shell.test.php +++ b/lib/Cake/tests/cases/console/shells/shell.test.php @@ -174,8 +174,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/lib/Cake/tests/cases/console/shells/tasks/extract.test.php b/lib/Cake/tests/cases/console/shells/tasks/extract.test.php index 6d634e5b4..e4c81e182 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/extract.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/extract.test.php @@ -72,7 +72,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') @@ -154,7 +154,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'; @@ -181,8 +181,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/lib/Cake/tests/cases/console/shells/tasks/template.test.php b/lib/Cake/tests/cases/console/shells/tasks/template.test.php index c2b162dd8..273beb968 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/template.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/template.test.php @@ -126,7 +126,7 @@ class TemplateTaskTest extends CakeTestCase { public function testGenerate() { App::build(array( 'shells' => array( - TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'console' . DS + LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS ) )); $this->Task->initialize(); @@ -146,7 +146,7 @@ class TemplateTaskTest extends CakeTestCase { public function testGenerateWithTemplateFallbacks() { App::build(array( 'shells' => array( - TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'console' . DS, + LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS, CAKE_CORE_INCLUDE_PATH . DS . 'console' . DS ) )); diff --git a/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php index cbebd4bf3..4a70fdf8a 100644 --- a/lib/Cake/tests/cases/libs/app.test.php +++ b/lib/Cake/tests/cases/libs/app.test.php @@ -94,7 +94,7 @@ class AppImportTest extends CakeTestCase { * @return void */ function testListObjects() { - $result = App::objects('class', TEST_CAKE_CORE_INCLUDE_PATH . 'libs', false); + $result = App::objects('class', LIBS . 'libs', false); $this->assertTrue(in_array('Xml', $result)); $this->assertTrue(in_array('Cache', $result)); $this->assertTrue(in_array('HttpSocket', $result)); @@ -132,7 +132,7 @@ class AppImportTest extends CakeTestCase { App::build(array( 'plugins' => array( - TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS + LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS ) )); $result = App::objects('plugin', null, false); @@ -149,18 +149,18 @@ class AppImportTest extends CakeTestCase { */ function testPluginPath() { 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) )); $path = App::pluginPath('test_plugin'); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS; + $expected = LIBS . '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; + $expected = LIBS . '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; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS; $this->assertEqual($path, $expected); App::build(); } @@ -172,14 +172,14 @@ class AppImportTest extends CakeTestCase { */ function testThemePath() { 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) )); $path = App::themePath('test_theme'); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS; + $expected = LIBS . '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; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS; $this->assertEqual($path, $expected); App::build(); @@ -284,8 +284,8 @@ class AppImportTest extends CakeTestCase { */ 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) + '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'); @@ -330,10 +330,10 @@ class AppImportTest extends CakeTestCase { App::build(array( 'helpers' => array( - TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS + LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS ) )); - App::build(array('vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH))); + App::build(array('vendors' => array(LIBS))); $this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.'); App::import('Helper', 'Banana'); $this->assertTrue(class_exists('BananaHelper'), 'BananaHelper was not loaded.'); @@ -348,10 +348,10 @@ class AppImportTest extends CakeTestCase { * @return void */ function testFileLoading () { - $file = App::import('File', 'RealFile', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php'); + $file = App::import('File', 'RealFile', false, array(), LIBS . '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'); + $file = App::import('File', 'NoFile', false, array(), LIBS . 'config' . DS . 'cake' . DS . 'config.php'); $this->assertFalse($file); } @@ -363,12 +363,12 @@ class AppImportTest extends CakeTestCase { */ function testFileLoadingWithArray() { $type = array('type' => 'File', 'name' => 'SomeName', 'parent' => false, - 'file' => TEST_CAKE_CORE_INCLUDE_PATH . DS . 'config' . DS . 'config.php'); + 'file' => LIBS . 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' => LIBS . 'config' . DS . 'cake' . DS . 'config.php'); $file = App::import($type); $this->assertFalse($file); } @@ -380,13 +380,13 @@ class AppImportTest extends CakeTestCase { * @return void */ function testFileLoadingReturnValue () { - $file = App::import('File', 'Name', false, array(), TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', true); + $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' => TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php', 'return' => true); + 'file' => LIBS . 'config' . DS . 'config.php', 'return' => true); $file = App::import($type); $this->assertTrue(!empty($file)); @@ -400,7 +400,7 @@ class AppImportTest extends CakeTestCase { * @return void */ function testLoadingWithSearch () { - $file = App::import('File', 'NewName', false, array(TEST_CAKE_CORE_INCLUDE_PATH ), 'config.php'); + $file = App::import('File', 'NewName', false, array(LIBS ), 'config.php'); $this->assertTrue($file); $file = App::import('File', 'AnotherNewName', false, array(LIBS), 'config.php'); @@ -414,7 +414,7 @@ class AppImportTest extends CakeTestCase { * @return void */ function testLoadingWithSearchArray () { - $type = array('type' => 'File', 'name' => 'RandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(TEST_CAKE_CORE_INCLUDE_PATH )); + $type = array('type' => 'File', 'name' => 'RandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(LIBS )); $file = App::import($type); $this->assertTrue($file); @@ -476,8 +476,8 @@ class AppImportTest extends CakeTestCase { */ 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), + 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), + 'vendors' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'vendors'. DS), ), true); ob_start(); diff --git a/lib/Cake/tests/cases/libs/cache.test.php b/lib/Cake/tests/cases/libs/cache.test.php index ad24b70d3..5edbe94fc 100644 --- a/lib/Cake/tests/cases/libs/cache.test.php +++ b/lib/Cake/tests/cases/libs/cache.test.php @@ -92,8 +92,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) + 'libs' => 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_'); @@ -260,8 +260,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'); @@ -313,8 +313,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')); diff --git a/lib/Cake/tests/cases/libs/cake_log.test.php b/lib/Cake/tests/cases/libs/cake_log.test.php index 96b64c96b..a6a3115cf 100644 --- a/lib/Cake/tests/cases/libs/cake_log.test.php +++ b/lib/Cake/tests/cases/libs/cake_log.test.php @@ -49,8 +49,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/lib/Cake/tests/cases/libs/cake_session.test.php b/lib/Cake/tests/cases/libs/cake_session.test.php index bbed31d39..d0e96aba5 100644 --- a/lib/Cake/tests/cases/libs/cake_session.test.php +++ b/lib/Cake/tests/cases/libs/cake_session.test.php @@ -529,8 +529,8 @@ class CakeSessionTest extends CakeTestCase { */ function testUsingAppLibsHandler() { 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); Configure::write('Session', array( 'defaults' => 'cake', @@ -551,8 +551,8 @@ 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) + 'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS), + 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) ), true); Configure::write('Session', array( diff --git a/lib/Cake/tests/cases/libs/config/ini_reader.test.php b/lib/Cake/tests/cases/libs/config/ini_reader.test.php index 6f47c3f69..8022ca69e 100644 --- a/lib/Cake/tests/cases/libs/config/ini_reader.test.php +++ b/lib/Cake/tests/cases/libs/config/ini_reader.test.php @@ -35,7 +35,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/lib/Cake/tests/cases/libs/config/php_reader.test.php b/lib/Cake/tests/cases/libs/config/php_reader.test.php index bb89378ba..29d47ff89 100644 --- a/lib/Cake/tests/cases/libs/config/php_reader.test.php +++ b/lib/Cake/tests/cases/libs/config/php_reader.test.php @@ -27,7 +27,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 @@ -81,7 +81,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/lib/Cake/tests/cases/libs/configure.test.php b/lib/Cake/tests/cases/libs/configure.test.php index 6fb85efed..16717b39a 100644 --- a/lib/Cake/tests/cases/libs/configure.test.php +++ b/lib/Cake/tests/cases/libs/configure.test.php @@ -200,7 +200,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); @@ -215,7 +215,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/lib/Cake/tests/cases/libs/controller/component.test.php b/lib/Cake/tests/cases/libs/controller/component.test.php index 43dff8cd6..1d1464d6d 100644 --- a/lib/Cake/tests/cases/libs/controller/component.test.php +++ b/lib/Cake/tests/cases/libs/controller/component.test.php @@ -53,7 +53,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; @@ -121,7 +121,7 @@ class AppleComponent extends Component { * @access public * @return void */ - function startup($controller) { + function startup(&$controller) { $this->testName = $controller->name; } } @@ -149,7 +149,7 @@ class OrangeComponent extends Component { * @access public * @return void */ - function initialize($controller) { + function initialize(&$controller) { $this->Controller = $controller; $this->Banana->testField = 'OrangeField'; } @@ -160,7 +160,7 @@ class OrangeComponent extends Component { * @param Controller $controller * @return string */ - public function startup($controller) { + public function startup(&$controller) { $controller->foo = 'pass'; } } @@ -187,7 +187,7 @@ class BananaComponent extends Component { * @param Controller $controller * @return string */ - public function startup($controller) { + public function startup(&$controller) { $controller->bar = 'fail'; } } @@ -261,7 +261,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/lib/Cake/tests/cases/libs/controller/component_collection.test.php b/lib/Cake/tests/cases/libs/controller/component_collection.test.php index acc98ed28..ab0ea91de 100644 --- a/lib/Cake/tests/cases/libs/controller/component_collection.test.php +++ b/lib/Cake/tests/cases/libs/controller/component_collection.test.php @@ -89,7 +89,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->assertType('OtherComponentComponent', $result, 'Component class is wrong.'); diff --git a/lib/Cake/tests/cases/libs/controller/components/acl.test.php b/lib/Cake/tests/cases/libs/controller/components/acl.test.php index 06a219b4a..e2415797c 100644 --- a/lib/Cake/tests/cases/libs/controller/components/acl.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/acl.test.php @@ -268,7 +268,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); @@ -291,7 +291,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/lib/Cake/tests/cases/libs/controller/components/auth.test.php b/lib/Cake/tests/cases/libs/controller/components/auth.test.php index 35f0356bc..dda510668 100644 --- a/lib/Cake/tests/cases/libs/controller/components/auth.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/auth.test.php @@ -53,7 +53,7 @@ class TestAuthComponent extends AuthComponent { * @access public * @return void */ - function _stop($status = 0) { + function _stop() { $this->testStop = true; } } @@ -499,8 +499,7 @@ class AuthTest extends CakeTestCase { ); $this->Controller->beforeFilter(); - $view = new View($this->Controller); - ClassRegistry::addObject('view', $view); + ClassRegistry::addObject('view', new View($this->Controller)); $this->Controller->Session->delete('Auth'); $this->Controller->Session->delete('Message.auth'); @@ -1396,8 +1395,8 @@ class AuthTest extends CakeTestCase { // Adding plugins Cache::delete('object_map', '_cake_core_'); 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); App::objects('plugin', null, false); @@ -1454,7 +1453,7 @@ class AuthTest extends CakeTestCase { */ function testAjaxLogin() { 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) )); $_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest"; diff --git a/lib/Cake/tests/cases/libs/controller/components/email.test.php b/lib/Cake/tests/cases/libs/controller/components/email.test.php index 2863308b0..36db895a7 100755 --- a/lib/Cake/tests/cases/libs/controller/components/email.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/email.test.php @@ -230,11 +230,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) + 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); } @@ -754,7 +753,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'; @@ -792,7 +791,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); @@ -1124,8 +1123,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/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php b/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php index ddafab1f6..112ffa472 100644 --- a/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php @@ -673,7 +673,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)); @@ -702,7 +702,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/lib/Cake/tests/cases/libs/controller/controller.test.php b/lib/Cake/tests/cases/libs/controller/controller.test.php index fd36df0fa..97003eb8d 100644 --- a/lib/Cake/tests/cases/libs/controller/controller.test.php +++ b/lib/Cake/tests/cases/libs/controller/controller.test.php @@ -107,13 +107,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); } } @@ -320,7 +320,7 @@ class TestComponent extends Object { * @access public * @return void */ - function initialize($controller) { + function initialize(&$controller) { } /** @@ -329,7 +329,7 @@ class TestComponent extends Object { * @access public * @return void */ - function startup($controller) { + function startup(&$controller) { } /** * shutdown method @@ -337,14 +337,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->view = $this->viewclass; } @@ -442,9 +442,9 @@ 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), + 'controllers' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS), + 'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS) )); App::uses('TestPluginController', 'TestPlugin.Controller'); @@ -491,7 +491,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'); @@ -581,7 +581,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) + 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $Controller = new Controller($request); $Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); @@ -643,7 +643,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'); @@ -685,7 +685,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/lib/Cake/tests/cases/libs/controller/pages_controller.test.php b/lib/Cake/tests/cases/libs/controller/pages_controller.test.php index ce3d7a0ec..be422e227 100644 --- a/lib/Cake/tests/cases/libs/controller/pages_controller.test.php +++ b/lib/Cake/tests/cases/libs/controller/pages_controller.test.php @@ -28,6 +28,16 @@ App::uses('PagesController', 'Controller'); */ class PagesControllerTest extends CakeTestCase { +/** + * endTest method + * + * @access public + * @return void + */ + function endTest() { + App::build(); + } + /** * testDisplay method * @@ -36,7 +46,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) + 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS, LIBS . 'libs' . DS . 'view' . DS) )); $Pages = new PagesController(new CakeRequest(null, false)); diff --git a/lib/Cake/tests/cases/libs/controller/scaffold.test.php b/lib/Cake/tests/cases/libs/controller/scaffold.test.php index 147380c7f..67ec7e9f2 100644 --- a/lib/Cake/tests/cases/libs/controller/scaffold.test.php +++ b/lib/Cake/tests/cases/libs/controller/scaffold.test.php @@ -93,8 +93,8 @@ class TestScaffoldMock extends Scaffold { * * @param unknown_type $params */ - function _scaffold(CakeRequest $request) { - $this->_params = $request; + function _scaffold($params) { + $this->_params = $params; } /** @@ -287,8 +287,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) + 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS), + 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); } @@ -315,35 +315,35 @@ 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 . 'libs' . DS . '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 . 'libs' . DS . '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 . 'libs' . DS . '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 . 'libs' . DS . '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 . 'libs' . DS . '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 . 'libs' . DS . '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 . 'libs' . DS . '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 . 'libs' . DS . 'view' . DS . 'scaffolds' . DS . 'form.ctp'; $this->assertEqual($result, $expected); $result = $ScaffoldView->testGetFilename('error'); @@ -357,11 +357,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); @@ -376,12 +376,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); @@ -400,7 +400,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/lib/Cake/tests/cases/libs/dispatcher.test.php b/lib/Cake/tests/cases/libs/dispatcher.test.php index d950510d8..008a286cf 100644 --- a/lib/Cake/tests/cases/libs/dispatcher.test.php +++ b/lib/Cake/tests/cases/libs/dispatcher.test.php @@ -787,7 +787,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'); @@ -1078,7 +1078,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); @@ -1178,7 +1178,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(); @@ -1236,9 +1236,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), + 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $Dispatcher = new TestDispatcher(); @@ -1262,21 +1262,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(); @@ -1297,20 +1297,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); @@ -1332,7 +1332,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(); @@ -1435,7 +1435,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/lib/Cake/tests/cases/libs/error/error_handler.test.php b/lib/Cake/tests/cases/libs/error/error_handler.test.php index dbdc0c8fc..ece3a77ec 100644 --- a/lib/Cake/tests/cases/libs/error/error_handler.test.php +++ b/lib/Cake/tests/cases/libs/error/error_handler.test.php @@ -39,8 +39,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/lib/Cake/tests/cases/libs/error/exception_renderer.test.php b/lib/Cake/tests/cases/libs/error/exception_renderer.test.php index aaf04e4e7..4d130f62d 100644 --- a/lib/Cake/tests/cases/libs/error/exception_renderer.test.php +++ b/lib/Cake/tests/cases/libs/error/exception_renderer.test.php @@ -69,7 +69,7 @@ class BlueberryComponent extends Component { * @access public * @return void */ - function initialize($controller) { + function initialize(&$controller) { $this->testName = 'BlueberryComponent'; } } @@ -162,8 +162,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/lib/Cake/tests/cases/libs/folder.test.php b/lib/Cake/tests/cases/libs/folder.test.php index 65ca682ab..d8b220700 100644 --- a/lib/Cake/tests/cases/libs/folder.test.php +++ b/lib/Cake/tests/cases/libs/folder.test.php @@ -149,7 +149,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()); @@ -222,7 +222,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'; @@ -318,42 +318,42 @@ 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 . 'paths.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()); } @@ -490,7 +490,7 @@ 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'); $this->assertIdentical(array_diff($expected, $result), array()); @@ -543,19 +543,19 @@ 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', + LIBS . 'config' . DS . 'paths.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', + LIBS . 'config' . DS . 'paths.php' ); $this->assertIdentical($result, $expected); @@ -589,7 +589,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/lib/Cake/tests/cases/libs/html_coverage_report.test.php b/lib/Cake/tests/cases/libs/html_coverage_report.test.php index 325271131..d07aeb29a 100644 --- a/lib/Cake/tests/cases/libs/html_coverage_report.test.php +++ b/lib/Cake/tests/cases/libs/html_coverage_report.test.php @@ -41,7 +41,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(); @@ -60,7 +60,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 ), @@ -70,8 +70,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/lib/Cake/tests/cases/libs/i18n.test.php b/lib/Cake/tests/cases/libs/i18n.test.php index a446df605..f481835e3 100644 --- a/lib/Cake/tests/cases/libs/i18n.test.php +++ b/lib/Cake/tests/cases/libs/i18n.test.php @@ -36,8 +36,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); } @@ -2434,7 +2434,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/lib/Cake/tests/cases/libs/model/cake_schema.test.php b/lib/Cake/tests/cases/libs/model/cake_schema.test.php index 5132fb557..b62e96ecb 100644 --- a/lib/Cake/tests/cases/libs/model/cake_schema.test.php +++ b/lib/Cake/tests/cases/libs/model/cake_schema.test.php @@ -659,7 +659,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(); @@ -977,7 +977,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/lib/Cake/tests/cases/libs/model/connection_manager.test.php b/lib/Cake/tests/cases/libs/model/connection_manager.test.php index 1798fb6b9..c121cee07 100644 --- a/lib/Cake/tests/cases/libs/model/connection_manager.test.php +++ b/lib/Cake/tests/cases/libs/model/connection_manager.test.php @@ -99,7 +99,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'; @@ -121,7 +121,7 @@ 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'; @@ -145,7 +145,7 @@ 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'; @@ -168,8 +168,8 @@ 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), + 'datasources' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS . 'datasources' . DS) )); $name = 'test_plugin_source_and_local_driver'; @@ -284,8 +284,8 @@ 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), + 'datasources' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS . 'datasources' . DS) )); $expected = array( diff --git a/lib/Cake/tests/cases/libs/object.test.php b/lib/Cake/tests/cases/libs/object.test.php index f5ad44cad..cc10aa86b 100644 --- a/lib/Cake/tests/cases/libs/object.test.php +++ b/lib/Cake/tests/cases/libs/object.test.php @@ -485,9 +485,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')); @@ -546,8 +546,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')); @@ -690,9 +690,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); @@ -730,7 +730,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(); @@ -770,9 +770,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/lib/Cake/tests/cases/libs/router.test.php b/lib/Cake/tests/cases/libs/router.test.php index fc01a246c..8b58b521b 100644 --- a/lib/Cake/tests/cases/libs/router.test.php +++ b/lib/Cake/tests/cases/libs/router.test.php @@ -1177,7 +1177,7 @@ class RouterTest extends CakeTestCase { $paths = App::path('plugins'); 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); @@ -2191,7 +2191,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/lib/Cake/tests/cases/libs/view/helper.test.php b/lib/Cake/tests/cases/libs/view/helper.test.php index ce8f655cb..063ae9fc9 100644 --- a/lib/Cake/tests/cases/libs/view/helper.test.php +++ b/lib/Cake/tests/cases/libs/view/helper.test.php @@ -553,8 +553,8 @@ class HelperTest extends CakeTestCase { $_timestamp = Configure::read('Asset.timestamp'); Configure::write('Asset.timestamp', 'force'); 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), )); $result = $this->Helper->assetTimestamp('/test_plugin/css/test_plugin_asset.css'); @@ -793,7 +793,7 @@ class HelperTest extends CakeTestCase { $this->Helper->theme = 'test_theme'; 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) )); $result = $this->Helper->webroot('/img/cake.power.gif'); @@ -805,7 +805,7 @@ class HelperTest extends CakeTestCase { $this->assertEqual($result, $expected); $webRoot = Configure::read('App.www_root'); - Configure::write('App.www_root', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'webroot' . DS); + Configure::write('App.www_root', LIBS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS); $result = $this->Helper->webroot('/img/cake.power.gif'); $expected = '/theme/test_theme/img/cake.power.gif'; @@ -859,7 +859,7 @@ class HelperTest extends CakeTestCase { */ function testLazyLoadingHelpers() { 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), )); $Helper = new TestHelper($this->View); $this->assertType('OtherHelperHelper', $Helper->OtherHelper); diff --git a/lib/Cake/tests/cases/libs/view/helper_collection.test.php b/lib/Cake/tests/cases/libs/view/helper_collection.test.php index 54aa16cde..6ca842e7f 100644 --- a/lib/Cake/tests/cases/libs/view/helper_collection.test.php +++ b/lib/Cake/tests/cases/libs/view/helper_collection.test.php @@ -87,7 +87,7 @@ class HelperCollectionTest extends CakeTestCase { */ function testLoadPluginHelper() { 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->Helpers->load('TestPlugin.OtherHelper'); $this->assertType('OtherHelperHelper', $result, 'Helper class is wrong.'); diff --git a/lib/Cake/tests/cases/libs/view/helpers/cache.test.php b/lib/Cake/tests/cases/libs/view/helpers/cache.test.php index c56463a85..db4b03f02 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/cache.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/cache.test.php @@ -86,7 +86,7 @@ class CacheHelperTest extends CakeTestCase { Configure::write('Cache.check', true); Configure::write('Cache.disable', false); 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); } diff --git a/lib/Cake/tests/cases/libs/view/helpers/html.test.php b/lib/Cake/tests/cases/libs/view/helpers/html.test.php index 4d3a7dac1..a8fb606b6 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/html.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/html.test.php @@ -327,7 +327,7 @@ class HtmlHelperTest extends CakeTestCase { $file = new File($testfile, true); 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) )); Configure::write('Asset.timestamp', true); Configure::write('debug', 1); @@ -362,10 +362,10 @@ class HtmlHelperTest extends CakeTestCase { */ function testThemeAssetsInMainWebrootPath() { 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) )); $webRoot = Configure::read('App.www_root'); - Configure::write('App.www_root', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'webroot' . DS); + Configure::write('App.www_root', LIBS . 'tests' . DS . 'test_app' . DS . 'webroot' . DS); $this->Html->theme = 'test_theme'; $result = $this->Html->css('webroot_test'); @@ -608,7 +608,7 @@ class HtmlHelperTest extends CakeTestCase { $file = new File($testfile, true); 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->Html->webroot = '/'; diff --git a/lib/Cake/tests/cases/libs/view/helpers/session.test.php b/lib/Cake/tests/cases/libs/view/helpers/session.test.php index 2fa1dad0a..eb278b9de 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/session.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/session.test.php @@ -129,7 +129,7 @@ class SessionHelperTest extends CakeTestCase { $this->assertEqual($result, $expected); 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) )); $result = $this->Session->flash('notification', true); $result = str_replace("\r\n", "\n", $result); diff --git a/lib/Cake/tests/cases/libs/view/helpers/time.test.php b/lib/Cake/tests/cases/libs/view/helpers/time.test.php index d5ba62b61..885e17674 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/time.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/time.test.php @@ -658,7 +658,7 @@ class TimeHelperTest extends CakeTestCase { */ function testConvertSpecifiers() { App::build(array( - 'locales' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale' . DS) + 'locales' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'locale' . DS) ), true); Configure::write('Config.language', 'time_test'); $time = strtotime('Thu Jan 14 11:43:39 2010'); @@ -748,7 +748,7 @@ class TimeHelperTest extends CakeTestCase { */ function testI18nFormat() { App::build(array( - 'locales' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale' . DS) + 'locales' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'locale' . DS) ), true); Configure::write('Config.language', 'time_test'); $time = strtotime('Thu Jan 14 13:59:28 2010'); diff --git a/lib/Cake/tests/cases/libs/view/media.test.php b/lib/Cake/tests/cases/libs/view/media.test.php index a9352f5d9..22d633d02 100644 --- a/lib/Cake/tests/cases/libs/view/media.test.php +++ b/lib/Cake/tests/cases/libs/view/media.test.php @@ -74,7 +74,7 @@ class MediaViewTest extends CakeTestCase { */ function testRender() { $this->MediaView->viewVars = array( - 'path' => TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'css' . DS, + 'path' => LIBS . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'css' . DS, 'id' => 'test_asset.css', 'extension' => 'css', ); @@ -120,7 +120,7 @@ class MediaViewTest extends CakeTestCase { */ function testConnectionAborted() { $this->MediaView->viewVars = array( - 'path' => TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'css' . DS, + 'path' => LIBS . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'css' . DS, 'id' => 'test_asset.css', 'extension' => 'css', ); @@ -146,7 +146,7 @@ class MediaViewTest extends CakeTestCase { */ function testConnectionAbortedOnBuffering() { $this->MediaView->viewVars = array( - 'path' => TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'css' . DS, + 'path' => LIBS . 'tests' . DS . 'test_app' . DS . 'vendors' . DS .'css' . DS, 'id' => 'test_asset.css', 'extension' => 'css', ); diff --git a/lib/Cake/tests/cases/libs/view/theme.test.php b/lib/Cake/tests/cases/libs/view/theme.test.php index 69a986ad7..8c7344328 100644 --- a/lib/Cake/tests/cases/libs/view/theme.test.php +++ b/lib/Cake/tests/cases/libs/view/theme.test.php @@ -121,8 +121,8 @@ class ThemeViewTest extends CakeTestCase { $this->PostsController->index(); $this->ThemeView = new ThemeView($this->PostsController); 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) )); } @@ -154,15 +154,16 @@ class ThemeViewTest extends CakeTestCase { $this->Controller->theme = 'test_theme'; $ThemeView = new TestThemeView($this->Controller); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp'; $result = $ThemeView->getViewFileName('index'); + debug($expected); $this->assertEqual($result, $expected); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'layouts' . DS .'plugin_default.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'layouts' . DS .'plugin_default.ctp'; $result = $ThemeView->getLayoutFileName('plugin_default'); $this->assertEqual($result, $expected); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp'; $result = $ThemeView->getLayoutFileName('default'); $this->assertEqual($result, $expected); } @@ -182,25 +183,25 @@ class ThemeViewTest extends CakeTestCase { $ThemeView = new TestThemeView($this->Controller); $ThemeView->theme = 'test_theme'; - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp'; $result = $ThemeView->getViewFileName('home'); $this->assertEqual($result, $expected); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'posts' . DS .'index.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'posts' . DS .'index.ctp'; $result = $ThemeView->getViewFileName('/posts/index'); $this->assertEqual($result, $expected); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEqual($result, $expected); $ThemeView->layoutPath = 'rss'; - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'rss' . DS . 'default.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'rss' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEqual($result, $expected); $ThemeView->layoutPath = 'email' . DS . 'html'; - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp'; $result = $ThemeView->getLayoutFileName(); $this->assertEqual($result, $expected); } diff --git a/lib/Cake/tests/cases/libs/view/view.test.php b/lib/Cake/tests/cases/libs/view/view.test.php index 61762f475..8b90213cc 100644 --- a/lib/Cake/tests/cases/libs/view/view.test.php +++ b/lib/Cake/tests/cases/libs/view/view.test.php @@ -201,10 +201,10 @@ class ViewTest extends CakeTestCase { $this->PostsController->index(); $this->View = new View($this->PostsController); 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), 'views' => array( - TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, - TEST_CAKE_CORE_INCLUDE_PATH . 'View' . DS + LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS, + LIBS . 'View' . DS ) ), true); @@ -238,11 +238,11 @@ class ViewTest extends CakeTestCase { $View = new TestView($this->Controller); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS .'tests' . DS .'index.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS .'tests' . DS .'index.ctp'; $result = $View->getViewFileName('index'); $this->assertEqual($result, $expected); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEqual($result, $expected); } @@ -265,10 +265,10 @@ class ViewTest extends CakeTestCase { $paths = $View->paths('test_plugin'); $expected = array( - TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'plugins' . DS . 'test_plugin' . DS, - TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'views' . DS, - TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS, - TEST_CAKE_CORE_INCLUDE_PATH . 'View' . DS + LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'plugins' . DS . 'test_plugin' . DS, + LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'views' . DS, + LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS, + LIBS . 'View' . DS ); $this->assertEqual($paths, $expected); } @@ -286,15 +286,15 @@ class ViewTest extends CakeTestCase { $View = new TestView($this->Controller); 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) )); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS .'tests' . DS .'index.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS .'tests' . DS .'index.ctp'; $result = $View->getViewFileName('index'); $this->assertEqual($result, $expected); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEqual($result, $expected); } @@ -314,29 +314,29 @@ class ViewTest extends CakeTestCase { $View = new TestView($this->Controller); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp'; $result = $View->getViewFileName('home'); $this->assertEqual($result, $expected); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'posts' . DS .'index.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS .'posts' . DS .'index.ctp'; $result = $View->getViewFileName('/posts/index'); $this->assertEqual($result, $expected); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'posts' . DS .'index.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS .'posts' . DS .'index.ctp'; $result = $View->getViewFileName('../posts/index'); $this->assertEqual($result, $expected); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS .'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEqual($result, $expected); $View->layoutPath = 'rss'; - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'rss' . DS . 'default.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'rss' . DS . 'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEqual($result, $expected); $View->layoutPath = 'email' . DS . 'html'; - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp'; $result = $View->getLayoutFileName(); $this->assertEqual($result, $expected); @@ -733,7 +733,7 @@ class ViewTest extends CakeTestCase { $result = $View->getViewFileName('../themed/test_theme/posts/index'); $this->assertPattern('/themed(\/|\\\)test_theme(\/|\\\)posts(\/|\\\)index.ctp/', $result); - $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS .'posts' . DS .'index.ctp'; + $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS .'posts' . DS .'index.ctp'; $result = $View->getViewFileName('../posts/index'); $this->assertEqual($result, $expected); diff --git a/lib/Cake/tests/cases/libs/xml.test.php b/lib/Cake/tests/cases/libs/xml.test.php index ee00efd2b..6a61d6cab 100644 --- a/lib/Cake/tests/cases/libs/xml.test.php +++ b/lib/Cake/tests/cases/libs/xml.test.php @@ -137,7 +137,7 @@ class XmlTest extends CakeTestCase { $this->assertEqual($obj->firstChild->nodeName, 'tag'); $this->assertEqual($obj->firstChild->nodeValue, 'value'); - $xml = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'fixtures' . DS . 'sample.xml'; + $xml = LIBS . 'tests' . DS . 'fixtures' . DS . 'sample.xml'; $obj = Xml::build($xml); $this->assertEqual($obj->getName(), 'tags'); $this->assertEqual(count($obj), 2); @@ -378,7 +378,7 @@ class XmlTest extends CakeTestCase { $obj = Xml::build($xml); $this->assertEqual(Xml::toArray($obj), array('tag' => 'name')); - $xml = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'fixtures' . DS . 'sample.xml'; + $xml = LIBS . 'tests' . DS . 'fixtures' . DS . 'sample.xml'; $obj = Xml::build($xml); $expected = array( 'tags' => array( @@ -520,7 +520,7 @@ class XmlTest extends CakeTestCase { * @return void */ public function testRss() { - $rss = file_get_contents(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'fixtures' . DS . 'rss.xml'); + $rss = file_get_contents(LIBS . 'tests' . DS . 'fixtures' . DS . 'rss.xml'); $rssAsArray = Xml::toArray(Xml::build($rss)); $this->assertEqual($rssAsArray['rss']['@version'], '2.0'); $this->assertEqual(count($rssAsArray['rss']['channel']['item']), 2); @@ -651,7 +651,7 @@ class XmlTest extends CakeTestCase { * @return void */ public function testSoap() { - $xmlRequest = Xml::build(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'fixtures' . DS . 'soap_request.xml'); + $xmlRequest = Xml::build(LIBS . 'tests' . DS . 'fixtures' . DS . 'soap_request.xml'); $expected = array( 'Envelope' => array( '@soap:encodingStyle' => 'http://www.w3.org/2001/12/soap-encoding', @@ -664,7 +664,7 @@ class XmlTest extends CakeTestCase { ); $this->assertEqual(Xml::toArray($xmlRequest), $expected); - $xmlResponse = Xml::build(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'fixtures' . DS . 'soap_response.xml'); + $xmlResponse = Xml::build(LIBS . 'tests' . DS . 'fixtures' . DS . 'soap_response.xml'); $expected = array( 'Envelope' => array( '@soap:encodingStyle' => 'http://www.w3.org/2001/12/soap-encoding', From 2cb2609a4342da449d70d4322ac47d02b9e3fccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 19 Dec 2010 23:49:20 -0430 Subject: [PATCH 083/668] Making ThemeView test pass --- lib/Cake/View/ThemeView.php | 2 +- lib/Cake/tests/cases/libs/view/theme.test.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Cake/View/ThemeView.php b/lib/Cake/View/ThemeView.php index 02cba797f..bbb6ab623 100644 --- a/lib/Cake/View/ThemeView.php +++ b/lib/Cake/View/ThemeView.php @@ -60,7 +60,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/lib/Cake/tests/cases/libs/view/theme.test.php b/lib/Cake/tests/cases/libs/view/theme.test.php index 8c7344328..19004383f 100644 --- a/lib/Cake/tests/cases/libs/view/theme.test.php +++ b/lib/Cake/tests/cases/libs/view/theme.test.php @@ -122,7 +122,7 @@ class ThemeViewTest extends CakeTestCase { $this->ThemeView = new ThemeView($this->PostsController); App::build(array( 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), - 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) + 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); } @@ -156,7 +156,6 @@ class ThemeViewTest extends CakeTestCase { $ThemeView = new TestThemeView($this->Controller); $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp'; $result = $ThemeView->getViewFileName('index'); - debug($expected); $this->assertEqual($result, $expected); $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'layouts' . DS .'plugin_default.ctp'; From 3fff5d144a7591400c7436a30af197112dc2dd25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 19 Dec 2010 23:58:47 -0430 Subject: [PATCH 084/668] Making SessionHelper tests pass again --- lib/Cake/tests/cases/libs/view/helpers/session.test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/libs/view/helpers/session.test.php b/lib/Cake/tests/cases/libs/view/helpers/session.test.php index eb278b9de..63be0cba0 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/session.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/session.test.php @@ -41,6 +41,7 @@ class SessionHelperTest extends CakeTestCase { $controller = null; $this->View = new View($controller); $this->Session = new SessionHelper($this->View); + CakeSession::start(); $_SESSION = array( 'test' => 'info', @@ -129,7 +130,7 @@ class SessionHelperTest extends CakeTestCase { $this->assertEqual($result, $expected); App::build(array( - 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) + 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $result = $this->Session->flash('notification', true); $result = str_replace("\r\n", "\n", $result); From 04929ae1df80420bb53d6257c6125e3fe51ca70d Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 21 Dec 2010 20:40:19 -0500 Subject: [PATCH 085/668] Applying patch from 'Thorsten Buss'. Fixes issues in DboSource, where mismatching types on join columns could result in incorrect query generation. Fixes #708 --- cake/libs/model/datasources/datasource.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 94b5d5cef..5de46be8a 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -503,6 +503,7 @@ class DataSource extends Object { foreach ($keys as $key) { $val = null; + $type = null; if (strpos($query, $key) !== false) { switch ($key) { @@ -526,6 +527,7 @@ class DataSource extends Object { $val = ''; } } + $type = $model->getColumnType($model->primaryKey); break; case '{$__cakeForeignKey__$}': foreach ($model->__associations as $id => $name) { @@ -533,6 +535,8 @@ class DataSource extends Object { if ($assocName === $association) { if (isset($assoc['foreignKey'])) { $foreignKey = $assoc['foreignKey']; + $assocModel = $model->$assocName; + $type = $assocModel->getColumnType($assocModel->primaryKey); if (isset($data[$model->alias][$foreignKey])) { $val = $data[$model->alias][$foreignKey]; @@ -561,7 +565,7 @@ class DataSource extends Object { if (empty($val) && $val !== '0') { return false; } - $query = str_replace($key, $this->value($val, $model->getColumnType($model->primaryKey)), $query); + $query = str_replace($key, $this->value($val, $type), $query); } } return $query; From 43401c271a34f32b710ce18d1d0b15f2310b026a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 21 Dec 2010 21:46:12 -0430 Subject: [PATCH 086/668] Fixing App::uses usage un CakeRouteTest --- lib/Cake/tests/cases/libs/route/cake_route.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/libs/route/cake_route.test.php b/lib/Cake/tests/cases/libs/route/cake_route.test.php index 76f76f336..904a1ca88 100644 --- a/lib/Cake/tests/cases/libs/route/cake_route.test.php +++ b/lib/Cake/tests/cases/libs/route/cake_route.test.php @@ -1,6 +1,6 @@ Date: Tue, 21 Dec 2010 22:01:38 -0430 Subject: [PATCH 087/668] Extracting JsBaseEngineHelper to its own file, fixing some JsHelper related test cases --- lib/Cake/View/Helper/JqueryEngineHelper.php | 2 +- lib/Cake/View/Helper/JsBaseEngineHelper.php | 652 ++++++++++++++++++ lib/Cake/View/Helper/JsHelper.php | 635 +---------------- lib/Cake/View/Helper/MootoolsEngineHelper.php | 2 +- .../View/Helper/PrototypeEngineHelper.php | 2 +- .../tests/cases/libs/view/helpers/js.test.php | 1 + .../view/helpers/mootools_engine.test.php | 2 +- 7 files changed, 659 insertions(+), 637 deletions(-) create mode 100644 lib/Cake/View/Helper/JsBaseEngineHelper.php diff --git a/lib/Cake/View/Helper/JqueryEngineHelper.php b/lib/Cake/View/Helper/JqueryEngineHelper.php index bc3d90423..17e226d6f 100644 --- a/lib/Cake/View/Helper/JqueryEngineHelper.php +++ b/lib/Cake/View/Helper/JqueryEngineHelper.php @@ -23,7 +23,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('JsHelper', 'View/Helper'); +App::uses('AppHelper', 'View/Helper'); App::uses('JsBaseEngineHelper', 'View/Helper'); class JqueryEngineHelper extends JsBaseEngineHelper { diff --git a/lib/Cake/View/Helper/JsBaseEngineHelper.php b/lib/Cake/View/Helper/JsBaseEngineHelper.php new file mode 100644 index 000000000..8d52f6939 --- /dev/null +++ b/lib/Cake/View/Helper/JsBaseEngineHelper.php @@ -0,0 +1,652 @@ + default arguments. + * + * @var array + * @access protected + */ + protected $_callbackArguments = array(); + +/** + * Constructor. + * + * @return void + */ + function __construct() { + $this->useNative = function_exists('json_encode'); + } + +/** + * Create an `alert()` message in Javascript + * + * @param string $message Message you want to alter. + * @return string completed alert() + */ + public function alert($message) { + return 'alert("' . $this->escape($message) . '");'; + } + +/** + * Redirects to a URL. Creates a window.location modification snippet + * that can be used to trigger 'redirects' from Javascript. + * + * @param mixed $url + * @param array $options + * @return string completed redirect in javascript + */ + public function redirect($url = null) { + return 'window.location = "' . Router::url($url) . '";'; + } + +/** + * Create a `confirm()` message + * + * @param string $message Message you want confirmed. + * @return string completed confirm() + */ + public function confirm($message) { + return 'confirm("' . $this->escape($message) . '");'; + } + +/** + * Generate a confirm snippet that returns false from the current + * function scope. + * + * @param string $message Message to use in the confirm dialog. + * @return string completed confirm with return script + */ + public function confirmReturn($message) { + $out = 'var _confirm = ' . $this->confirm($message); + $out .= "if (!_confirm) {\n\treturn false;\n}"; + return $out; + } + +/** + * Create a `prompt()` Javascript function + * + * @param string $message Message you want to prompt. + * @param string $default Default message + * @return string completed prompt() + */ + public function prompt($message, $default = '') { + return 'prompt("' . $this->escape($message) . '", "' . $this->escape($default) . '");'; + } + +/** + * Generates a JavaScript object in JavaScript Object Notation (JSON) + * from an array. Will use native JSON encode method if available, and $useNative == true + * + * ### Options: + * + * - `prefix` - String prepended to the returned data. + * - `postfix` - String appended to the returned data. + * + * @param array $data Data to be converted. + * @param array $options Set of options, see above. + * @return string A JSON code block + */ + public function object($data = array(), $options = array()) { + $defaultOptions = array( + 'prefix' => '', 'postfix' => '', + ); + $options = array_merge($defaultOptions, $options); + + if (is_object($data)) { + $data = get_object_vars($data); + } + + $out = $keys = array(); + $numeric = true; + + if ($this->useNative && function_exists('json_encode')) { + $rt = json_encode($data); + } else { + if (is_null($data)) { + return 'null'; + } + if (is_bool($data)) { + return $data ? 'true' : 'false'; + } + if (is_array($data)) { + $keys = array_keys($data); + } + + if (!empty($keys)) { + $numeric = (array_values($keys) === array_keys(array_values($keys))); + } + + foreach ($data as $key => $val) { + if (is_array($val) || is_object($val)) { + $val = $this->object($val); + } else { + $val = $this->value($val); + } + if (!$numeric) { + $val = '"' . $this->value($key, false) . '":' . $val; + } + $out[] = $val; + } + + if (!$numeric) { + $rt = '{' . join(',', $out) . '}'; + } else { + $rt = '[' . join(',', $out) . ']'; + } + } + $rt = $options['prefix'] . $rt . $options['postfix']; + return $rt; + } + +/** + * Converts a PHP-native variable of any type to a JSON-equivalent representation + * + * @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 + */ + public function value($val, $quoteString = true) { + switch (true) { + case (is_array($val) || is_object($val)): + $val = $this->object($val); + break; + case ($val === null): + $val = 'null'; + break; + case (is_bool($val)): + $val = ($val === true) ? 'true' : 'false'; + break; + case (is_int($val)): + $val = $val; + break; + case (is_float($val)): + $val = sprintf("%.11f", $val); + break; + default: + $val = $this->escape($val); + if ($quoteString) { + $val = '"' . $val . '"'; + } + break; + } + return $val; + } + +/** + * Escape a string to be JSON friendly. + * + * List of escaped elements: + * + * - "\r" => '\n' + * - "\n" => '\n' + * - '"' => '\"' + * + * @param string $script String that needs to get escaped. + * @return string Escaped string. + */ + public function escape($string) { + return $this->_utf8ToHex($string); + } + +/** + * Encode a string into JSON. Converts and escapes necessary characters. + * + * @param string $string The string that needs to be utf8->hex encoded + * @return void + */ + protected function _utf8ToHex($string) { + $length = strlen($string); + $return = ''; + for ($i = 0; $i < $length; ++$i) { + $ord = ord($string{$i}); + switch (true) { + case $ord == 0x08: + $return .= '\b'; + break; + case $ord == 0x09: + $return .= '\t'; + break; + case $ord == 0x0A: + $return .= '\n'; + break; + case $ord == 0x0C: + $return .= '\f'; + break; + case $ord == 0x0D: + $return .= '\r'; + break; + case $ord == 0x22: + case $ord == 0x2F: + case $ord == 0x5C: + $return .= '\\' . $string{$i}; + break; + case (($ord >= 0x20) && ($ord <= 0x7F)): + $return .= $string{$i}; + break; + case (($ord & 0xE0) == 0xC0): + if ($i + 1 >= $length) { + $i += 1; + $return .= '?'; + break; + } + $charbits = $string{$i} . $string{$i + 1}; + $char = Multibyte::utf8($charbits); + $return .= sprintf('\u%04s', dechex($char[0])); + $i += 1; + break; + case (($ord & 0xF0) == 0xE0): + if ($i + 2 >= $length) { + $i += 2; + $return .= '?'; + break; + } + $charbits = $string{$i} . $string{$i + 1} . $string{$i + 2}; + $char = Multibyte::utf8($charbits); + $return .= sprintf('\u%04s', dechex($char[0])); + $i += 2; + break; + case (($ord & 0xF8) == 0xF0): + if ($i + 3 >= $length) { + $i += 3; + $return .= '?'; + break; + } + $charbits = $string{$i} . $string{$i + 1} . $string{$i + 2} . $string{$i + 3}; + $char = Multibyte::utf8($charbits); + $return .= sprintf('\u%04s', dechex($char[0])); + $i += 3; + break; + case (($ord & 0xFC) == 0xF8): + if ($i + 4 >= $length) { + $i += 4; + $return .= '?'; + break; + } + $charbits = $string{$i} . $string{$i + 1} . $string{$i + 2} . $string{$i + 3} . $string{$i + 4}; + $char = Multibyte::utf8($charbits); + $return .= sprintf('\u%04s', dechex($char[0])); + $i += 4; + break; + case (($ord & 0xFE) == 0xFC): + if ($i + 5 >= $length) { + $i += 5; + $return .= '?'; + break; + } + $charbits = $string{$i} . $string{$i + 1} . $string{$i + 2} . $string{$i + 3} . $string{$i + 4} . $string{$i + 5}; + $char = Multibyte::utf8($charbits); + $return .= sprintf('\u%04s', dechex($char[0])); + $i += 5; + break; + } + } + return $return; + } + +/** + * Create javascript selector for a CSS rule + * + * @param string $selector The selector that is targeted + * @return object instance of $this. Allows chained methods. + */ + abstract public function get($selector); + +/** + * Add an event to the script cache. Operates on the currently selected elements. + * + * ### Options + * + * - `wrap` - Whether you want the callback wrapped in an anonymous function. (defaults to true) + * - `stop` - Whether you want the event to stopped. (defaults to true) + * + * @param string $type Type of event to bind to the current dom id + * @param string $callback The Javascript function you wish to trigger or the function literal + * @param array $options Options for the event. + * @return string completed event handler + */ + abstract public function event($type, $callback, $options = array()); + +/** + * Create a domReady event. This is a special event in many libraries + * + * @param string $functionBody The code to run on domReady + * @return string completed domReady method + */ + abstract public function domReady($functionBody); + +/** + * Create an iteration over the current selection result. + * + * @param string $callback The function body you wish to apply during the iteration. + * @return string completed iteration + */ + abstract public function each($callback); + +/** + * Trigger an Effect. + * + * ### Supported Effects + * + * The following effects are supported by all core JsEngines + * + * - `show` - reveal an element. + * - `hide` - hide an element. + * - `fadeIn` - Fade in an element. + * - `fadeOut` - Fade out an element. + * - `slideIn` - Slide an element in. + * - `slideOut` - Slide an element out. + * + * ### Options + * + * - `speed` - Speed at which the animation should occur. Accepted values are 'slow', 'fast'. Not all effects use + * the speed option. + * + * @param string $name The name of the effect to trigger. + * @param array $options Array of options for the effect. + * @return string completed string with effect. + */ + abstract public function effect($name, $options = array()); + +/** + * Make an XHR request + * + * ### Event Options + * + * - `complete` - Callback to fire on complete. + * - `success` - Callback to fire on success. + * - `before` - Callback to fire on request initialization. + * - `error` - Callback to fire on request failure. + * + * ### Options + * + * - `method` - The method to make the request with defaults to GET in more libraries + * - `async` - Whether or not you want an asynchronous request. + * - `data` - Additional data to send. + * - `update` - Dom id to update with the content of the request. + * - `type` - Data type for response. 'json' and 'html' are supported. Default is html for most libraries. + * - `evalScripts` - Whether or not ' ); +/** + * Minimized attributes + * + * @var array + */ + protected $_minimizedAttributes = array( + 'compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', + 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize' + ); + +/** + * Format to attribute + * + * @var string + */ + protected $_attributeFormat = '%s="%s"'; + +/** + * Format to attribute + * + * @var string + */ + protected $_minimizedAttributeFormat = '%s="%s"'; + /** * Breadcrumbs. * @@ -881,4 +905,93 @@ class HtmlHelper extends AppHelper { } return $out; } + +/** + * 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_array($options)) { + $options = array_merge(array('escape' => true), $options); + + if (!is_array($exclude)) { + $exclude = array(); + } + $filtered = array_diff_key($options, array_merge(array_flip($exclude), array('escape' => true))); + $escape = $options['escape']; + $attributes = array(); + + foreach ($filtered as $key => $value) { + if ($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; + } + } diff --git a/cake/tests/cases/libs/view/helper.test.php b/cake/tests/cases/libs/view/helper.test.php index 44b38f903..125e00ac1 100644 --- a/cake/tests/cases/libs/view/helper.test.php +++ b/cake/tests/cases/libs/view/helper.test.php @@ -179,35 +179,6 @@ class TestHelper extends Helper { } } -/** - * Html5TestHelper class - * - * @package cake.tests.cases.libs.view - */ -class Html5TestHelper extends TestHelper { - -/** - * Minimized - * - * @var array - */ - protected $_minimizedAttributes = array('require', 'checked'); - -/** - * Allow compact use in HTML - * - * @var string - */ - protected $_minimizedAttributeFormat = '%s'; - -/** - * Test to attribute format - * - * @var string - */ - protected $_attributeFormat = 'data-%s="%s"'; -} - /** * HelperTest class * @@ -815,32 +786,6 @@ class HelperTest extends CakeTestCase { Configure::write('App.www_root', $webRoot); } -/** - * test parsing attributes. - * - * @return void - */ - function testParseAttributeCompact() { - $helper = new TestHelper($this->View); - $compact = array('compact', 'checked', 'declare', 'readonly', 'disabled', - 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize'); - - foreach ($compact as $attribute) { - foreach (array('true', true, 1, '1', $attribute) as $value) { - $attrs = array($attribute => $value); - $expected = ' ' . $attribute . '="' . $attribute . '"'; - $this->assertEqual($helper->parseAttributes($attrs), $expected, '%s Failed on ' . $value); - } - } - $this->assertEqual($helper->parseAttributes(array('compact')), ' compact="compact"'); - - $helper = new Html5TestHelper($this->View); - $expected = ' require'; - $this->assertEqual($helper->parseAttributes(array('require')), $expected); - $this->assertEqual($helper->parseAttributes(array('require' => true)), $expected); - $this->assertEqual($helper->parseAttributes(array('require' => false)), ''); - } - /** * test lazy loading helpers is seamless * diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index 41d0aed9b..c3e73790e 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -47,6 +47,50 @@ class TheHtmlTestController extends Controller { public $uses = null; } +class TestHtmlHelper extends HtmlHelper { +/** + * expose a method as public + * + * @param string $options + * @param string $exclude + * @param string $insertBefore + * @param string $insertAfter + * @return void + */ + function parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { + return $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter); + } +} + +/** + * Html5TestHelper class + * + * @package cake.tests.cases.libs.view.helpers + */ +class Html5TestHelper extends TestHtmlHelper { + +/** + * Minimized + * + * @var array + */ + protected $_minimizedAttributes = array('require', 'checked'); + +/** + * Allow compact use in HTML + * + * @var string + */ + protected $_minimizedAttributeFormat = '%s'; + +/** + * Test to attribute format + * + * @var string + */ + protected $_attributeFormat = 'data-%s="%s"'; +} + /** * HtmlHelperTest class * @@ -1312,4 +1356,31 @@ class HtmlHelperTest extends CakeTestCase { ) ); } + +/** + * test parsing attributes. + * + * @return void + */ + function testParseAttributeCompact() { + $helper = new TestHtmlHelper($this->View); + $compact = array('compact', 'checked', 'declare', 'readonly', 'disabled', + 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize'); + + foreach ($compact as $attribute) { + foreach (array('true', true, 1, '1', $attribute) as $value) { + $attrs = array($attribute => $value); + $expected = ' ' . $attribute . '="' . $attribute . '"'; + $this->assertEqual($helper->parseAttributes($attrs), $expected, '%s Failed on ' . $value); + } + } + $this->assertEqual($helper->parseAttributes(array('compact')), ' compact="compact"'); + + $helper = new Html5TestHelper($this->View); + $expected = ' require'; + $this->assertEqual($helper->parseAttributes(array('require')), $expected); + $this->assertEqual($helper->parseAttributes(array('require' => true)), $expected); + $this->assertEqual($helper->parseAttributes(array('require' => false)), ''); + } + } From b1f4c6a0c9bd932e25bf1090cf0287594653f321 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 23 Jan 2011 12:38:36 -0200 Subject: [PATCH 186/668] Changed tags attributes to protected. --- cake/libs/view/helpers/html.php | 47 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index d4af24612..21746f60a 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -29,9 +29,8 @@ class HtmlHelper extends AppHelper { * html tags used by this helper. * * @var array - * @access public */ - public $tags = array( + protected $_tags = array( 'meta' => '', 'metalink' => '', 'link' => '%s', @@ -246,14 +245,14 @@ class HtmlHelper extends AppHelper { if (isset($options['link'])) { if (isset($options['rel']) && $options['rel'] === 'icon') { - $out = sprintf($this->tags['metalink'], $options['link'], $this->_parseAttributes($options, array('link'), ' ', ' ')); + $out = sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('link'), ' ', ' ')); $options['rel'] = 'shortcut icon'; } else { $options['link'] = $this->url($options['link'], true); } - $out .= sprintf($this->tags['metalink'], $options['link'], $this->_parseAttributes($options, array('link'), ' ', ' ')); + $out .= sprintf($this->_tags['metalink'], $options['link'], $this->_parseAttributes($options, array('link'), ' ', ' ')); } else { - $out = sprintf($this->tags['meta'], $this->_parseAttributes($options, array('type'), ' ', ' ')); + $out = sprintf($this->_tags['meta'], $this->_parseAttributes($options, array('type'), ' ', ' ')); } if ($inline) { @@ -276,7 +275,7 @@ class HtmlHelper extends AppHelper { if (empty($charset)) { $charset = strtolower(Configure::read('App.encoding')); } - return sprintf($this->tags['charset'], (!empty($charset) ? $charset : 'utf-8')); + return sprintf($this->_tags['charset'], (!empty($charset) ? $charset : 'utf-8')); } /** @@ -336,7 +335,7 @@ class HtmlHelper extends AppHelper { } unset($options['default']); } - return sprintf($this->tags['link'], $url, $this->_parseAttributes($options), $title); + return sprintf($this->_tags['link'], $url, $this->_parseAttributes($options), $title); } /** @@ -391,12 +390,12 @@ class HtmlHelper extends AppHelper { } if ($rel == 'import') { - $out = sprintf($this->tags['style'], $this->_parseAttributes($options, array('inline'), '', ' '), '@import url(' . $url . ');'); + $out = sprintf($this->_tags['style'], $this->_parseAttributes($options, array('inline'), '', ' '), '@import url(' . $url . ');'); } else { if ($rel == null) { $rel = 'stylesheet'; } - $out = sprintf($this->tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline'), '', ' ')); + $out = sprintf($this->_tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline'), '', ' ')); } if ($options['inline']) { @@ -462,7 +461,7 @@ class HtmlHelper extends AppHelper { } } $attributes = $this->_parseAttributes($options, array('inline', 'once'), ' '); - $out = sprintf($this->tags['javascriptlink'], $url, $attributes); + $out = sprintf($this->_tags['javascriptlink'], $url, $attributes); if ($options['inline']) { return $out; @@ -494,9 +493,9 @@ class HtmlHelper extends AppHelper { unset($options['inline'], $options['safe']); $attributes = $this->_parseAttributes($options, ' ', ' '); if ($inline) { - return sprintf($this->tags['javascriptblock'], $attributes, $script); + return sprintf($this->_tags['javascriptblock'], $attributes, $script); } else { - $this->_View->addScript(sprintf($this->tags['javascriptblock'], $attributes, $script)); + $this->_View->addScript(sprintf($this->_tags['javascriptblock'], $attributes, $script)); return null; } } @@ -675,10 +674,10 @@ class HtmlHelper extends AppHelper { unset($options['url']); } - $image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' ')); + $image = sprintf($this->_tags['image'], $path, $this->_parseAttributes($options, null, '', ' ')); if ($url) { - return sprintf($this->tags['link'], $this->url($url), null, $image); + return sprintf($this->_tags['link'], $this->url($url), null, $image); } return $image; } @@ -696,9 +695,9 @@ class HtmlHelper extends AppHelper { public function tableHeaders($names, $trOptions = null, $thOptions = null) { $out = array(); foreach ($names as $arg) { - $out[] = sprintf($this->tags['tableheader'], $this->_parseAttributes($thOptions), $arg); + $out[] = sprintf($this->_tags['tableheader'], $this->_parseAttributes($thOptions), $arg); } - return sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out)); + return sprintf($this->_tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out)); } /** @@ -748,10 +747,10 @@ class HtmlHelper extends AppHelper { } elseif ($useCount) { $cellOptions['class'] = 'column-' . ++$i; } - $cellsOut[] = sprintf($this->tags['tablecell'], $this->_parseAttributes($cellOptions), $cell); + $cellsOut[] = sprintf($this->_tags['tablecell'], $this->_parseAttributes($cellOptions), $cell); } $options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions); - $out[] = sprintf($this->tags['tablerow'], $options, implode(' ', $cellsOut)); + $out[] = sprintf($this->_tags['tablerow'], $options, implode(' ', $cellsOut)); } return implode("\n", $out); } @@ -784,7 +783,7 @@ class HtmlHelper extends AppHelper { } else { $tag = 'tag'; } - return sprintf($this->tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name); + return sprintf($this->_tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name); } /** @@ -794,7 +793,7 @@ class HtmlHelper extends AppHelper { * @return string Formatted block */ public function useTag($tag) { - if (!isset($this->tags[$tag])) { + if (!isset($this->_tags[$tag])) { return ''; } $args = func_get_args(); @@ -804,7 +803,7 @@ class HtmlHelper extends AppHelper { $arg = $this->_parseAttributes($arg, null, ' ', ''); } } - return vsprintf($this->tags[$tag], $args); + return vsprintf($this->_tags[$tag], $args); } /** @@ -855,7 +854,7 @@ class HtmlHelper extends AppHelper { } else { $tag = 'para'; } - return sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text); + return sprintf($this->_tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text); } /** @@ -873,7 +872,7 @@ class HtmlHelper extends AppHelper { $options = array(); } $items = $this->__nestedListItem($list, $options, $itemOptions, $tag); - return sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $items); + return sprintf($this->_tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $items); } /** @@ -900,7 +899,7 @@ class HtmlHelper extends AppHelper { } else if (isset($itemOptions['odd']) && $index % 2 != 0) { $itemOptions['class'] = $itemOptions['odd']; } - $out .= sprintf($this->tags['li'], $this->_parseAttributes($itemOptions, array('even', 'odd'), ' ', ''), $item); + $out .= sprintf($this->_tags['li'], $this->_parseAttributes($itemOptions, array('even', 'odd'), ' ', ''), $item); $index++; } return $out; From 7df97820207fd600bffa2fd484b8be667fe46a4d Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 23 Jan 2011 16:21:17 -0200 Subject: [PATCH 187/668] Moving loadConfig to Html helper. --- cake/libs/view/helper.php | 16 ---------------- cake/libs/view/helpers/html.php | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index 88588f808..0337b5088 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -174,22 +174,6 @@ class Helper extends Object { return $this->{$name} = $value; } -/** - * Parses tag templates into $this->tags. - * - * @param $name file name inside app/config to load. - * @return array merged tags from config/$name.php - */ - public function loadConfig($name = 'tags') { - if (file_exists(CONFIGS . $name .'.php')) { - require(CONFIGS . $name .'.php'); - if (isset($tags)) { - $this->tags = array_merge($this->tags, $tags); - } - } - return $this->tags; - } - /** * Finds URL for specified action. * diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 21746f60a..d784c6f66 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -905,6 +905,22 @@ class HtmlHelper extends AppHelper { return $out; } +/** + * Parses tag templates into $this->tags. + * + * @param $name file name inside app/config to load. + * @return array merged tags from config/$name.php + */ + public function loadConfig($name = 'tags') { + if (file_exists(CONFIGS . $name .'.php')) { + require(CONFIGS . $name .'.php'); + if (isset($tags)) { + $this->_tags = array_merge($this->_tags, $tags); + } + } + return $this->_tags; + } + /** * Returns a space-delimited string with items of the $options array. If a * key of $options array happens to be one of: From 1a90bf7292930af87859c2b7d4e7a7322c07bdd6 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 23 Jan 2011 19:26:13 -0200 Subject: [PATCH 188/668] Support to read ini files without section in IniReader. --- cake/libs/config/ini_reader.php | 7 ++++++- cake/tests/cases/libs/config/ini_reader.test.php | 16 ++++++++++++++++ cake/tests/test_app/config/no_section.ini | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 cake/tests/test_app/config/no_section.ini diff --git a/cake/libs/config/ini_reader.php b/cake/libs/config/ini_reader.php index 915bf9498..e20f8dcfb 100644 --- a/cake/libs/config/ini_reader.php +++ b/cake/libs/config/ini_reader.php @@ -77,7 +77,12 @@ class IniReader implements ConfigReaderInterface { } else { $values = array(); foreach ($contents as $section => $attribs) { - $values[$section] = $this->_parseNestedValues($attribs); + if (is_array($attribs)) { + $values[$section] = $this->_parseNestedValues($attribs); + } else { + $parse = $this->_parseNestedValues(array($attribs)); + $values[$section] = array_shift($parse); + } } } return $values; diff --git a/cake/tests/cases/libs/config/ini_reader.test.php b/cake/tests/cases/libs/config/ini_reader.test.php index 2fb8eb2dd..3db8bb942 100644 --- a/cake/tests/cases/libs/config/ini_reader.test.php +++ b/cake/tests/cases/libs/config/ini_reader.test.php @@ -64,6 +64,22 @@ class IniReaderTest extends CakeTestCase { $this->assertEquals('administrators', $config['groups']); } +/** + * test without section + * + * @return void + */ + public function testReadingWithoutSection() { + $reader = new IniReader($this->path); + $config = $reader->read('no_section.ini'); + + $expected = array( + 'some_key' => 'some_value', + 'bool_key' => true + ); + $this->assertEquals($config, $expected); + } + /** * test that names with .'s get exploded into arrays. * diff --git a/cake/tests/test_app/config/no_section.ini b/cake/tests/test_app/config/no_section.ini new file mode 100644 index 000000000..6e6fbb7a0 --- /dev/null +++ b/cake/tests/test_app/config/no_section.ini @@ -0,0 +1,2 @@ +some_key = some_value +bool_key = 1 From 175e00830830328e104a7669dffba36c5b6d89d8 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 23 Jan 2011 19:27:50 -0200 Subject: [PATCH 189/668] Reading configuration using reader classes. You can pass the key configFile in Html settings to load in constructor. --- cake/libs/view/helpers/html.php | 66 ++++++++++++++++--- .../cases/libs/view/helpers/html.test.php | 54 ++++++++++++++- .../test_app/config/htmlhelper_minimized.ini | 2 + .../tests/test_app/config/htmlhelper_tags.php | 8 +++ 4 files changed, 120 insertions(+), 10 deletions(-) create mode 100644 cake/tests/test_app/config/htmlhelper_minimized.ini create mode 100644 cake/tests/test_app/config/htmlhelper_tags.php diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index d784c6f66..21543f311 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -152,6 +152,19 @@ class HtmlHelper extends AppHelper { 'xhtml11' => '' ); +/** + * Default Constructor + * + * @param View $View The View this helper is being attached to. + * @param array $settings Configuration settings for the helper. + */ + public function __construct(View $View, $settings = array()) { + parent::__construct($View, $settings); + if (!empty($settings['configFile'])) { + $this->loadConfig($settings['configFile']); + } + } + /** * Adds a link to the breadcrumbs array. * @@ -906,19 +919,54 @@ class HtmlHelper extends AppHelper { } /** - * Parses tag templates into $this->tags. + * Load Html configs * - * @param $name file name inside app/config to load. - * @return array merged tags from config/$name.php + * @param mixed $configFile String with the config file (load using PhpReader) or an array with file and reader name + * @param string $path Path with config file + * @return mixed False to error or loaded configs */ - public function loadConfig($name = 'tags') { - if (file_exists(CONFIGS . $name .'.php')) { - require(CONFIGS . $name .'.php'); - if (isset($tags)) { - $this->_tags = array_merge($this->_tags, $tags); + public function loadConfig($configFile, $path = CONFIGS) { + $file = null; + $reader = 'php'; + + if (!is_array($configFile)) { + $file = $configFile; + } elseif (isset($configFile[0])) { + $file = $configFile[0]; + if (isset($configFile[1])) { + $reader = $configFile[1]; } + } else { + return trigger_error(__('Cannot load the configuration file. Wrong "configFile" configuration.'), E_USER_NOTICE); } - return $this->_tags; + + $readerClass = Inflector::camelize($reader) . 'Reader'; + if (!App::import('Lib', 'config/' . $readerClass)) { + return trigger_error(__('Cannot load the configuration file. Unknown reader.'), E_USER_NOTICE); + } + + try { + $readerObj = new $readerClass($path); + $configs = $readerObj->read($file); + if (isset($configs['tags']) && is_array($configs['tags'])) { + $this->_tags = array_merge($this->_tags, $configs['tags']); + } + if (isset($configs['minimizedAttributes']) && is_array($configs['minimizedAttributes'])) { + $this->_minimizedAttributes = array_merge($this->_minimizedAttributes, $configs['minimizedAttributes']); + } + if (isset($configs['docTypes']) && is_array($configs['docTypes'])) { + $this->__docTypes = array_merge($this->__docTypes, $configs['docTypes']); + } + if (isset($configs['attributeFormat'])) { + $this->_attributeFormat = $configs['attributeFormat']; + } + if (isset($configs['minimizedAttributeFormat'])) { + $this->_minimizedAttributeFormat = $configs['minimizedAttributeFormat']; + } + } catch (Exception $e) { + return trigger_error(__('Cannot load the configuration file. Failed to load the file.'), E_USER_NOTICE); + } + return $configs; } /** diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index c3e73790e..a7a4cfbec 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -60,6 +60,20 @@ class TestHtmlHelper extends HtmlHelper { function parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { return $this->_parseAttributes($options, $exclude, $insertBefore, $insertAfter); } + +/** + * Get a protected attribute value + * + * @param string $attribute + * @return mixed + */ + public function getAttribute($attribute) { + if (!isset($this->{$attribute})) { + return null; + } + return $this->{$attribute}; + } + } /** @@ -128,7 +142,7 @@ class HtmlHelperTest extends CakeTestCase { function setUp() { parent::setUp(); $this->View = $this->getMock('View', array('addScript'), array(new TheHtmlTestController())); - $this->Html = new HtmlHelper($this->View); + $this->Html = new TestHtmlHelper($this->View); $this->Html->request = new CakeRequest(null, false); $this->Html->request->webroot = ''; @@ -1357,6 +1371,44 @@ class HtmlHelperTest extends CakeTestCase { ); } +/** + * testLoadConfig method + * + * @return void + */ + + public function testLoadConfig() { + $path = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS; + + $result = $this->Html->loadConfig('htmlhelper_tags', $path); + $expected = array( + 'tags' => array( + 'form' => 'start form', + 'formend' => 'finish form' + ) + ); + $this->assertEqual($result, $expected); + $tags = $this->Html->getAttribute('_tags'); + $this->assertEqual($tags['form'], 'start form'); + $this->assertEqual($tags['formend'], 'finish form'); + $this->assertEqual($tags['selectend'], ''); + + $result = $this->Html->loadConfig(array('htmlhelper_minimized.ini', 'ini'), $path); + $expected = array( + 'minimizedAttributeFormat' => 'format' + ); + $this->assertEqual($result, $expected); + $this->assertEqual($this->Html->getAttribute('_minimizedAttributeFormat'), 'format'); + + $this->expectError(); + $result = $this->Html->loadConfig('wrong_file'); + $this->assertFalse($result); + + $this->expectError(); + $result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path); + $this->assertFalse($result); + } + /** * test parsing attributes. * diff --git a/cake/tests/test_app/config/htmlhelper_minimized.ini b/cake/tests/test_app/config/htmlhelper_minimized.ini new file mode 100644 index 000000000..e6a722d67 --- /dev/null +++ b/cake/tests/test_app/config/htmlhelper_minimized.ini @@ -0,0 +1,2 @@ +minimizedAttributeFormat = "format" + diff --git a/cake/tests/test_app/config/htmlhelper_tags.php b/cake/tests/test_app/config/htmlhelper_tags.php new file mode 100644 index 000000000..abff9cdf5 --- /dev/null +++ b/cake/tests/test_app/config/htmlhelper_tags.php @@ -0,0 +1,8 @@ + array( + 'form' => 'start form', + 'formend' => 'finish form' + ) +); \ No newline at end of file From 55c557d5a154e1880a0191c1a8305697fe51713e Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 23 Jan 2011 19:26:13 -0200 Subject: [PATCH 190/668] Support to read ini files without section in IniReader. --- cake/libs/config/ini_reader.php | 7 ++++++- cake/tests/cases/libs/config/ini_reader.test.php | 16 ++++++++++++++++ cake/tests/test_app/config/no_section.ini | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 cake/tests/test_app/config/no_section.ini diff --git a/cake/libs/config/ini_reader.php b/cake/libs/config/ini_reader.php index 915bf9498..e20f8dcfb 100644 --- a/cake/libs/config/ini_reader.php +++ b/cake/libs/config/ini_reader.php @@ -77,7 +77,12 @@ class IniReader implements ConfigReaderInterface { } else { $values = array(); foreach ($contents as $section => $attribs) { - $values[$section] = $this->_parseNestedValues($attribs); + if (is_array($attribs)) { + $values[$section] = $this->_parseNestedValues($attribs); + } else { + $parse = $this->_parseNestedValues(array($attribs)); + $values[$section] = array_shift($parse); + } } } return $values; diff --git a/cake/tests/cases/libs/config/ini_reader.test.php b/cake/tests/cases/libs/config/ini_reader.test.php index 2fb8eb2dd..3db8bb942 100644 --- a/cake/tests/cases/libs/config/ini_reader.test.php +++ b/cake/tests/cases/libs/config/ini_reader.test.php @@ -64,6 +64,22 @@ class IniReaderTest extends CakeTestCase { $this->assertEquals('administrators', $config['groups']); } +/** + * test without section + * + * @return void + */ + public function testReadingWithoutSection() { + $reader = new IniReader($this->path); + $config = $reader->read('no_section.ini'); + + $expected = array( + 'some_key' => 'some_value', + 'bool_key' => true + ); + $this->assertEquals($config, $expected); + } + /** * test that names with .'s get exploded into arrays. * diff --git a/cake/tests/test_app/config/no_section.ini b/cake/tests/test_app/config/no_section.ini new file mode 100644 index 000000000..6e6fbb7a0 --- /dev/null +++ b/cake/tests/test_app/config/no_section.ini @@ -0,0 +1,2 @@ +some_key = some_value +bool_key = 1 From 5b8f680d43874e98ac3be2ba40045c61777b05b2 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 23 Jan 2011 20:00:06 -0200 Subject: [PATCH 191/668] Throwing exception instead notice in loadConfig. --- cake/libs/view/helpers/html.php | 40 +++++++++---------- .../cases/libs/view/helpers/html.test.php | 4 +- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 21543f311..436941a81 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -937,34 +937,30 @@ class HtmlHelper extends AppHelper { $reader = $configFile[1]; } } else { - return trigger_error(__('Cannot load the configuration file. Wrong "configFile" configuration.'), E_USER_NOTICE); + throw new ConfigureException(__('Cannot load the configuration file. Wrong "configFile" configuration.')); } $readerClass = Inflector::camelize($reader) . 'Reader'; if (!App::import('Lib', 'config/' . $readerClass)) { - return trigger_error(__('Cannot load the configuration file. Unknown reader.'), E_USER_NOTICE); + throw new ConfigureException(__('Cannot load the configuration file. Unknown reader.')); } - try { - $readerObj = new $readerClass($path); - $configs = $readerObj->read($file); - if (isset($configs['tags']) && is_array($configs['tags'])) { - $this->_tags = array_merge($this->_tags, $configs['tags']); - } - if (isset($configs['minimizedAttributes']) && is_array($configs['minimizedAttributes'])) { - $this->_minimizedAttributes = array_merge($this->_minimizedAttributes, $configs['minimizedAttributes']); - } - if (isset($configs['docTypes']) && is_array($configs['docTypes'])) { - $this->__docTypes = array_merge($this->__docTypes, $configs['docTypes']); - } - if (isset($configs['attributeFormat'])) { - $this->_attributeFormat = $configs['attributeFormat']; - } - if (isset($configs['minimizedAttributeFormat'])) { - $this->_minimizedAttributeFormat = $configs['minimizedAttributeFormat']; - } - } catch (Exception $e) { - return trigger_error(__('Cannot load the configuration file. Failed to load the file.'), E_USER_NOTICE); + $readerObj = new $readerClass($path); + $configs = $readerObj->read($file); + if (isset($configs['tags']) && is_array($configs['tags'])) { + $this->_tags = array_merge($this->_tags, $configs['tags']); + } + if (isset($configs['minimizedAttributes']) && is_array($configs['minimizedAttributes'])) { + $this->_minimizedAttributes = array_merge($this->_minimizedAttributes, $configs['minimizedAttributes']); + } + if (isset($configs['docTypes']) && is_array($configs['docTypes'])) { + $this->__docTypes = array_merge($this->__docTypes, $configs['docTypes']); + } + if (isset($configs['attributeFormat'])) { + $this->_attributeFormat = $configs['attributeFormat']; + } + if (isset($configs['minimizedAttributeFormat'])) { + $this->_minimizedAttributeFormat = $configs['minimizedAttributeFormat']; } return $configs; } diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index a7a4cfbec..c2226acac 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -1400,11 +1400,11 @@ class HtmlHelperTest extends CakeTestCase { $this->assertEqual($result, $expected); $this->assertEqual($this->Html->getAttribute('_minimizedAttributeFormat'), 'format'); - $this->expectError(); + $this->expectException('ConfigureException'); $result = $this->Html->loadConfig('wrong_file'); $this->assertFalse($result); - $this->expectError(); + $this->expectException('ConfigureException'); $result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path); $this->assertFalse($result); } From 703272965106532764817b661ef08791d29464ac Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 23 Jan 2011 17:08:09 -0500 Subject: [PATCH 192/668] Fixing how webroot is calculated for installs not using url rewriting. Also fixes using the top level index.php file. Test cases added for using both index.php files. Cleaned up existing tests for environment detection. Fixes #1261, Fixes #1432 --- cake/dispatcher.php | 8 ++- cake/tests/cases/dispatcher.test.php | 94 ++++++++++++++++++++++++++-- 2 files changed, 95 insertions(+), 7 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index cddd302cd..729bb7a44 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -357,9 +357,13 @@ class Dispatcher extends Object { if ($base === DS || $base === '.') { $base = ''; } - $this->webroot = $base .'/'; + $this->webroot = $base . '/'; - if (!empty($base)) { + $docRoot = env('DOCUMENT_ROOT'); + $script = realpath(env('SCRIPT_FILENAME')); + $docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot); + + if (!empty($base) || !$docRootContainsWebroot) { if (strpos($this->webroot, $dir) === false) { $this->webroot .= $dir . '/' ; } diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 58f25da5c..0255829b5 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1207,6 +1207,42 @@ class DispatcherTest extends CakeTestCase { $this->assertEqual($expectedWebroot, $Dispatcher->webroot); } +/** + * test baseUrl with no rewrite and using the top level index.php. + * + * @return void + */ + function testBaseUrlNoRewriteTopLevelIndex() { + $Dispatcher =& new Dispatcher(); + + Configure::write('App.baseUrl', '/index.php'); + $_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/cake_dev'; + $_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/cake_dev/index.php'; + + $result = $Dispatcher->baseUrl(); + $this->assertEqual('/index.php', $result); + $this->assertEqual('/app/webroot/', $Dispatcher->webroot); + $this->assertEqual('', $Dispatcher->base); + } + +/** + * test baseUrl with no rewrite, and using the app/webroot/index.php file as is normal with virtual hosts. + * + * @return void + */ + function testBaseUrlNoRewriteWebrootIndex() { + $Dispatcher =& new Dispatcher(); + + Configure::write('App.baseUrl', '/index.php'); + $_SERVER['DOCUMENT_ROOT'] = '/Users/markstory/Sites/cake_dev/app/webroot'; + $_SERVER['SCRIPT_FILENAME'] = '/Users/markstory/Sites/cake_dev/app/webroot/index.php'; + + $result = $Dispatcher->baseUrl(); + $this->assertEqual('/index.php', $result); + $this->assertEqual('/', $Dispatcher->webroot); + $this->assertEqual('', $Dispatcher->base); + } + /** * testBaseUrlAndWebrootWithBase method * @@ -2304,7 +2340,7 @@ class DispatcherTest extends CakeTestCase { 'IIS' => array( 'No rewrite base path' => array( 'App' => array('base' => false, 'baseUrl' => '/index.php?', 'server' => 'IIS'), - 'SERVER' => array('HTTPS' => 'off', 'SCRIPT_NAME' => '/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', 'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_HOST' => '127.0.0.1', 'REQUEST_METHOD' => 'GET', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_SOFTWARE' => 'Microsoft-IIS/5.1', 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'ORIG_PATH_INFO' => '/index.php', 'PATH_INFO' => '', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', 'HTTP_ACCEPT' => '*/*', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_CONNECTION' => 'Keep-Alive', 'HTTP_HOST' => 'localhost', 'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'argv' => array(), 'argc' => 0), + 'SERVER' => array('HTTPS' => 'off', 'SCRIPT_NAME' => '/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', 'REMOTE_ADDR' => '127.0.0.1', 'REMOTE_HOST' => '127.0.0.1', 'REQUEST_METHOD' => 'GET', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', 'ORIG_PATH_INFO' => '/index.php', 'PATH_INFO' => '', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', 'HTTP_HOST' => 'localhost', 'argv' => array(), 'argc' => 0), 'reload' => true, 'path' => '' ), @@ -2343,18 +2379,54 @@ class DispatcherTest extends CakeTestCase { 'Apache' => array( 'No rewrite base path' => array( 'App' => array('base' => false, 'baseUrl' => '/index.php', 'dir' => 'app', 'webroot' => 'webroot'), - 'SERVER' => array('SERVER_NAME' => 'localhost', 'SERVER_ADDR' => '::1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '::1', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => '', 'REQUEST_URI' => '/', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php', 'argv' => array(), 'argc' => 0), + 'SERVER' => array( + 'SERVER_NAME' => 'localhost', + 'SERVER_ADDR' => '::1', + 'SERVER_PORT' => '80', + 'REMOTE_ADDR' => '::1', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', + 'QUERY_STRING' => '', + 'REQUEST_URI' => '/', + 'SCRIPT_NAME' => '/index.php', + 'PHP_SELF' => '/index.php', + 'argv' => array(), + 'argc' => 0 + ), 'reload' => true, 'path' => '' ), 'No rewrite with path' => array( - 'SERVER' => array('UNIQUE_ID' => 'VardGqn@17IAAAu7LY8AAAAK', 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/523.10.5 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6', 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/officespace/app/webroot/index.php', 'QUERY_STRING' => '', 'REQUEST_URI' => '/index.php/posts/add', 'SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/posts/add', 'PHP_SELF' => '/index.php/posts/add', 'argv' => array(), 'argc' => 0), + 'SERVER' => array( + 'HTTP_HOST' => 'localhost', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/officespace/app/webroot/index.php', + 'QUERY_STRING' => '', + 'REQUEST_URI' => '/index.php/posts/add', + 'SCRIPT_NAME' => '/index.php', + 'PATH_INFO' => '/posts/add', + 'PHP_SELF' => '/index.php/posts/add', + 'argv' => array(), + 'argc' => 0), 'reload' => false, 'path' => '/posts/add' ), 'GET Request at base domain' => array( 'App' => array('base' => false, 'baseUrl' => null, 'dir' => 'app', 'webroot' => 'webroot'), - 'SERVER' => array('UNIQUE_ID' => '2A-v8sCoAQ8AAAc-2xUAAAAB', 'HTTP_ACCEPT_LANGUAGE' => 'en-us', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_COOKIE' => 'CAKEPHP=jcbv51apn84kd9ucv5aj2ln3t3', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'cake.1.2', 'SERVER_NAME' => 'cake.1.2', 'SERVER_ADDR' => '127.0.0.1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '127.0.0.1', 'DOCUMENT_ROOT' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot', 'SERVER_ADMIN' => 'you@example.com', 'SCRIPT_FILENAME' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot/index.php', 'REMOTE_PORT' => '53550', 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => 'a=b', 'REQUEST_URI' => '/?a=b', 'SCRIPT_NAME' => '/index.php', 'PHP_SELF' => '/index.php'), + 'SERVER' => array( + 'HTTP_HOST' => 'cake.1.2', + 'SERVER_NAME' => 'cake.1.2', + 'SERVER_ADDR' => '127.0.0.1', + 'SERVER_PORT' => '80', + 'REMOTE_ADDR' => '127.0.0.1', + 'DOCUMENT_ROOT' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot', + 'SCRIPT_FILENAME' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot/index.php', + 'REMOTE_PORT' => '53550', + 'QUERY_STRING' => 'a=b', + 'REQUEST_URI' => '/?a=b', + 'SCRIPT_NAME' => '/index.php', + 'PHP_SELF' => '/index.php' + ), 'GET' => array('a' => 'b'), 'POST' => array(), 'reload' => true, @@ -2364,7 +2436,19 @@ class DispatcherTest extends CakeTestCase { ), 'New CGI no mod_rewrite' => array( 'App' => array('base' => false, 'baseUrl' => '/limesurvey20/index.php', 'dir' => 'app', 'webroot' => 'webroot'), - 'SERVER' => array('DOCUMENT_ROOT' => '/home/.sites/110/site313/web', 'PATH_INFO' => '/installations', 'PATH_TRANSLATED' => '/home/.sites/110/site313/web/limesurvey20/index.php', 'PHPRC' => '/home/.sites/110/site313', 'QUERY_STRING' => '', 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/limesurvey20/index.php/installations', 'SCRIPT_FILENAME' => '/home/.sites/110/site313/web/limesurvey20/index.php', 'SCRIPT_NAME' => '/limesurvey20/index.php', 'SCRIPT_URI' => 'http://www.gisdat-umfragen.at/limesurvey20/index.php/installations', 'PHP_SELF' => '/limesurvey20/index.php/installations', 'CGI_MODE' => true), + 'SERVER' => array( + 'DOCUMENT_ROOT' => '/home/.sites/110/site313/web', + 'PATH_INFO' => '/installations', + 'PATH_TRANSLATED' => '/home/.sites/110/site313/web/limesurvey20/index.php', + 'PHPRC' => '/home/.sites/110/site313', + 'QUERY_STRING' => '', + 'REQUEST_URI' => '/limesurvey20/index.php/installations', + 'SCRIPT_FILENAME' => '/home/.sites/110/site313/web/limesurvey20/index.php', + 'SCRIPT_NAME' => '/limesurvey20/index.php', + 'SCRIPT_URI' => 'http://www.gisdat-umfragen.at/limesurvey20/index.php/installations', + 'PHP_SELF' => '/limesurvey20/index.php/installations', + 'CGI_MODE' => true + ), 'GET' => array(), 'POST' => array(), 'reload' => true, From be98491413a217518b9741cb70d644b328276081 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 23 Jan 2011 20:27:46 -0200 Subject: [PATCH 193/668] Ini/Php readers now read files with/without extension. --- cake/libs/config/ini_reader.php | 6 ++++++ cake/libs/config/php_reader.php | 12 +++++++++--- cake/tests/cases/libs/config/ini_reader.test.php | 11 +++++++++++ cake/tests/cases/libs/config/php_reader.test.php | 5 +++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/cake/libs/config/ini_reader.php b/cake/libs/config/ini_reader.php index e20f8dcfb..7ab9694ce 100644 --- a/cake/libs/config/ini_reader.php +++ b/cake/libs/config/ini_reader.php @@ -71,6 +71,12 @@ class IniReader implements ConfigReaderInterface { */ public function read($file) { $filename = $this->_path . $file; + if (!file_exists($filename)) { + $filename .= '.ini'; + if (!file_exists($filename)) { + throw new ConfigureException(__('Could not load configuration files: %s or %s', substr($filename, 0, -4), $filename)); + } + } $contents = parse_ini_file($filename, true); if (!empty($this->_section) && isset($contents[$this->_section])) { $values = $this->_parseNestedValues($contents[$this->_section]); diff --git a/cake/libs/config/php_reader.php b/cake/libs/config/php_reader.php index c122f0808..acd0f94df 100644 --- a/cake/libs/config/php_reader.php +++ b/cake/libs/config/php_reader.php @@ -57,15 +57,21 @@ class PhpReader implements ConfigReaderInterface { if (strpos($key, '..') !== false) { throw new ConfigureException(__('Cannot load configuration files with ../ in them.')); } + if (substr($key, -4) === '.php') { + $key = substr($key, 0, -4); + } list($plugin, $key) = pluginSplit($key); if ($plugin) { - $file = App::pluginPath($plugin) . 'config' . DS . $key . '.php'; + $file = App::pluginPath($plugin) . 'config' . DS . $key; } else { - $file = $this->_path . $key . '.php'; + $file = $this->_path . $key; } if (!file_exists($file)) { - throw new ConfigureException(__('Could not load configuration file: ') . $file); + $file .= '.php'; + if (!file_exists($file)) { + throw new ConfigureException(__('Could not load configuration files: %s or %s', substr($file, 0, -4), $file)); + } } include $file; if (!isset($config)) { diff --git a/cake/tests/cases/libs/config/ini_reader.test.php b/cake/tests/cases/libs/config/ini_reader.test.php index 3db8bb942..4f077873a 100644 --- a/cake/tests/cases/libs/config/ini_reader.test.php +++ b/cake/tests/cases/libs/config/ini_reader.test.php @@ -114,4 +114,15 @@ class IniReaderTest extends CakeTestCase { $this->assertFalse($config['bools']['test_null']); } + +/** + * test read file without extension + * + * @return void + */ + public function testReadingWithoutExtension() { + $reader = new IniReader($this->path); + $config = $reader->read('nested'); + $this->assertTrue($config['bools']['test_on']); + } } \ No newline at end of file diff --git a/cake/tests/cases/libs/config/php_reader.test.php b/cake/tests/cases/libs/config/php_reader.test.php index 63957ea62..a1d3034fc 100644 --- a/cake/tests/cases/libs/config/php_reader.test.php +++ b/cake/tests/cases/libs/config/php_reader.test.php @@ -38,6 +38,9 @@ class PhpReaderTest extends CakeTestCase { $values = $reader->read('var_test'); $this->assertEquals('value', $values['Read']); $this->assertEquals('buried', $values['Deep']['Deeper']['Deepest']); + + $values = $reader->read('var_test.php'); + $this->assertEquals('value', $values['Read']); } /** @@ -84,7 +87,9 @@ class PhpReaderTest extends CakeTestCase { ), true); $reader = new PhpReader($this->path); $result = $reader->read('TestPlugin.load'); + $this->assertTrue(isset($result['plugin_load'])); + $result = $reader->read('TestPlugin.load.php'); $this->assertTrue(isset($result['plugin_load'])); } } From d933d6bd73bf650c8cccf8bbc4ac2f3e532b537b Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 23 Jan 2011 20:51:56 -0200 Subject: [PATCH 194/668] Assigning the helper object in view class, avoiding to use __get magic for each call. --- cake/libs/view/view.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 7ff7ed9fa..35a886fbc 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -624,7 +624,8 @@ class View extends Object { public function loadHelpers() { $helpers = HelperCollection::normalizeObjectArray($this->helpers); foreach ($helpers as $name => $properties) { - $this->Helpers->load($properties['class'], $properties['settings']); + list($plugin, $class) = pluginSplit($properties['class']); + $this->{$class} = $this->Helpers->load($properties['class'], $properties['settings']); } $this->_helpersLoaded = true; } From 32f0b20a336074b8d09d912e8e1a2b07aa8d7f0e Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 24 Jan 2011 22:05:16 -0500 Subject: [PATCH 195/668] Removing wonky and most likely incorrect manipulation of socket and port setting mangling in DboMysqli. Fixes #1478 --- cake/libs/model/datasources/dbo/dbo_mysqli.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php index daf47f557..8b0543d6d 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ b/cake/libs/model/datasources/dbo/dbo_mysqli.php @@ -59,13 +59,6 @@ class DboMysqli extends DboMysqlBase { $config = $this->config; $this->connected = false; - if (is_numeric($config['port'])) { - $config['socket'] = null; - } else { - $config['socket'] = $config['port']; - $config['port'] = null; - } - $this->connection = mysqli_connect($config['host'], $config['login'], $config['password'], $config['database'], $config['port'], $config['socket']); if ($this->connection !== false) { From 95713fbf3b082d094bd7a87c371b3d0029d14eb7 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 25 Jan 2011 01:18:39 -0200 Subject: [PATCH 196/668] Separated the tests for HtmlHelper::loadConfig() with exception in different methods. --- .../cases/libs/view/helpers/html.test.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index c2226acac..4da61890d 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -1399,14 +1399,27 @@ class HtmlHelperTest extends CakeTestCase { ); $this->assertEqual($result, $expected); $this->assertEqual($this->Html->getAttribute('_minimizedAttributeFormat'), 'format'); + } - $this->expectException('ConfigureException'); +/** + * testLoadConfigWrongFile method + * + * @return void + * @expectedException ConfigureException + */ + public function testLoadConfigWrongFile() { $result = $this->Html->loadConfig('wrong_file'); - $this->assertFalse($result); + } - $this->expectException('ConfigureException'); +/** + * testLoadConfigWrongReader method + * + * @return void + * @expectedException ConfigureException + */ + public function testLoadConfigWrongReader() { + $path = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS; $result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path); - $this->assertFalse($result); } /** From 161d3ea5fb64a24d50cdf9d0843a364be35c0450 Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 26 Jan 2011 19:33:06 +0530 Subject: [PATCH 197/668] Removed from comments references to DBOs which are no longer available. Closes #1479 --- app/config/database.php.default | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/config/database.php.default b/app/config/database.php.default index 2078240ea..9fb8e9e98 100644 --- a/app/config/database.php.default +++ b/app/config/database.php.default @@ -29,7 +29,6 @@ * * driver => The name of a supported driver; valid options are as follows: * mysql - MySQL 4 & 5, - * mysqli - MySQL 4 & 5 Improved Interface (PHP5 only), * sqlite - SQLite (PHP5 only), * postgres - PostgreSQL 7 and higher, * mssql - Microsoft SQL Server 2000 and higher, @@ -43,19 +42,18 @@ * 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, MySQLi, Postgres 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 { From d192ed32f05b0b17fbc46580b1e30fb3819c6fda Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 26 Jan 2011 20:54:14 -0500 Subject: [PATCH 198/668] Adding a socket key to DboMysqli::$baseConfig. Fixes notice errors when socket is undefined. Fixes #1482 --- cake/libs/model/datasources/dbo/dbo_mysqli.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php index 8b0543d6d..844554cdd 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ b/cake/libs/model/datasources/dbo/dbo_mysqli.php @@ -47,7 +47,8 @@ class DboMysqli extends DboMysqlBase { 'login' => 'root', 'password' => '', 'database' => 'cake', - 'port' => '3306' + 'port' => '3306', + 'socket' => null ); /** From 71d8e744f160c918e4a1b86dc32f9d3447145e12 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 26 Jan 2011 20:58:16 -0500 Subject: [PATCH 199/668] Fixing case-sensitivity of AS in fields. Tests added. Fixes #1474 --- cake/libs/model/datasources/dbo_source.php | 2 +- cake/tests/cases/libs/model/datasources/dbo_source.test.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 42d7db354..b610ee121 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -562,7 +562,7 @@ class DboSource extends DataSource { ); } if ( - preg_match('/^([\w-]+(\.[\w-]+|\(.*\))*)\s+' . preg_quote($this->alias) . '\s*([\w-]+)$/', $data, $matches + preg_match('/^([\w-]+(\.[\w-]+|\(.*\))*)\s+' . preg_quote($this->alias) . '\s*([\w-]+)$/i', $data, $matches )) { return $this->cacheMethod( __FUNCTION__, $cacheKey, diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index d60898dab..924e7256d 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -4077,10 +4077,14 @@ class DboSourceTest extends CakeTestCase { $result = $this->testDb->name(array('my-name', 'Foo-Model.*')); $expected = array('`my-name`', '`Foo-Model`.*'); $this->assertEqual($result, $expected); - + $result = $this->testDb->name(array('Team.P%', 'Team.G/G')); $expected = array('`Team`.`P%`', '`Team`.`G/G`'); $this->assertEqual($result, $expected); + + $result = $this->testDb->name('Model.name as y'); + $expected = '`Model`.`name` AS `y`'; + $this->assertEqual($result, $expected); } /** From 38e286e978b13a9480a9a862705468025d49460f Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 27 Jan 2011 19:30:21 -0500 Subject: [PATCH 200/668] Fixing order of paths so core paths are last in the search array. Fixes #1488 --- cake/console/libs/tasks/template.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/console/libs/tasks/template.php b/cake/console/libs/tasks/template.php index 15b1721fd..aac544abc 100644 --- a/cake/console/libs/tasks/template.php +++ b/cake/console/libs/tasks/template.php @@ -56,7 +56,7 @@ class TemplateTask extends Shell { $core = array_pop($paths); $separator = DS === '/' ? '/' : '\\\\'; $core = preg_replace('#libs' . $separator . '$#', '', $core); - $paths[] = $core; + $Folder =& new Folder($core . 'templates' . DS . 'default'); $contents = $Folder->read(); $themeFolders = $contents[0]; @@ -65,6 +65,7 @@ class TemplateTask extends Shell { foreach ($plugins as $plugin) { $paths[] = $this->_pluginPath($plugin) . 'vendors' . DS . 'shells' . DS; } + $paths[] = $core; // TEMPORARY TODO remove when all paths are DS terminated foreach ($paths as $i => $path) { From 5464ed845594047b47285abd1afdc6506c3e0bc2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 27 Jan 2011 21:05:30 -0500 Subject: [PATCH 201/668] Fixing blackholes caused by using custom name attributes with inputs. Fixes #1489 --- cake/libs/view/helpers/form.php | 11 ++++++++++- cake/tests/cases/libs/view/helpers/form.test.php | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 5c4435f97..7026d5afb 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -2190,10 +2190,19 @@ class FormHelper extends AppHelper { } else { $secure = (isset($this->params['_Token']) && !empty($this->params['_Token'])); } + + $fieldName = null; + if ($secure && !empty($options['name'])) { + preg_match_all('/\[(.*?)\]/', $options['name'], $matches); + if (isset($matches[1])) { + $fieldName = $matches[1]; + } + } + $result = parent::_initInputField($field, $options); if ($secure) { - $this->__secure(); + $this->__secure($fieldName); } return $result; } diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 103a33d02..27815a8b0 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -1083,6 +1083,21 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * test securing inputs with custom name attributes. + * + * @return void + */ + function testFormSecureWithCustomNameAttribute() { + $this->Form->params['_Token']['key'] = 'testKey'; + + $this->Form->text('UserForm.published', array('name' => 'data[User][custom]')); + $this->assertEqual('User.custom', $this->Form->fields[0]); + + $this->Form->text('UserForm.published', array('name' => 'data[User][custom][another][value]')); + $this->assertEqual('User.custom.another.value', $this->Form->fields[1]); + } + /** * testFormSecuredInput method * From bbf6aedd9cb520ada416b9eeedc090e461ce32bc Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 28 Jan 2011 00:18:44 -0200 Subject: [PATCH 202/668] Fixed wrong viewVars store when have objects in view caching. Fixes #1486. --- cake/libs/view/helpers/cache.php | 10 +++++----- cake/tests/cases/libs/view/helpers/cache.test.php | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index e2e911b8c..65ed53ca2 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -225,15 +225,15 @@ class CacheHelper extends AppHelper { $file .= '$controller =& new ' . $this->controllerName . 'Controller(); $controller->plugin = $this->plugin = \''.$this->plugin.'\'; - $controller->helpers = $this->helpers = ' . var_export($this->helpers, true) . '; + $controller->helpers = $this->helpers = unserialize(\'' . serialize($this->helpers) . '\'); $controller->base = $this->base = \'' . $this->base . '\'; $controller->layout = $this->layout = \'' . $this->layout. '\'; $controller->webroot = $this->webroot = \'' . $this->webroot . '\'; $controller->here = $this->here = \'' . $this->here . '\'; - $controller->params = $this->params = ' . var_export($this->params, true) . '; - $controller->action = $this->action = ' . var_export($this->action, true) . '; - $controller->data = $this->data = ' . var_export($this->data, true) . '; - $controller->viewVars = $this->viewVars = ' . var_export($this->viewVars, true) . '; + $controller->params = $this->params = unserialize(stripslashes(\'' . addslashes(serialize($this->params)) . '\')); + $controller->action = $this->action = unserialize(\'' . serialize($this->action) . '\'); + $controller->data = $this->data = unserialize(stripslashes(\'' . addslashes(serialize($this->data)) . '\')); + $controller->viewVars = $this->viewVars = unserialize(base64_decode(\'' . base64_encode(serialize($this->viewVars)) . '\')); $controller->theme = $this->theme = \'' . $this->theme . '\'; Router::setRequestInfo(array($this->params, array(\'base\' => $this->base, \'webroot\' => $this->webroot)));'; diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index 45edea332..01a8c0bcc 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -339,7 +339,6 @@ class CacheHelperTest extends CakeTestCase { $this->assertPattern('/\$this\-\>viewVars/', $contents); $this->assertPattern('/extract\(\$this\-\>viewVars, EXTR_SKIP\);/', $contents); $this->assertPattern('/php echo \$variable/', $contents); - $this->assertPattern('/variableValue/', $contents); @unlink($filename); } From e99f090ee0fb7ec531c40848bcfe43a6a1b1a1f5 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Thu, 27 Jan 2011 18:32:51 -0800 Subject: [PATCH 203/668] Fixed issue where ClassRegistry alias was incorrectly set --- .../cases/libs/controller_test_case.test.php | 32 ++++++++++++++++++- cake/tests/lib/controller_test_case.php | 4 +-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/cake/tests/cases/libs/controller_test_case.test.php index 6d4812937..1ffb518c6 100644 --- a/cake/tests/cases/libs/controller_test_case.test.php +++ b/cake/tests/cases/libs/controller_test_case.test.php @@ -76,6 +76,20 @@ if (!class_exists('PostsController')) { } } +/** + * ControllerTestCaseTest controller + */ +class ControllerTestCaseTestController extends AppController { + +/** + * Uses array + * + * @param array + */ + public $uses = array('TestPlugin.TestPluginComment'); + +} + /** * ControllerTestCaseTest @@ -90,7 +104,7 @@ class ControllerTestCaseTest extends CakeTestCase { * @var array * @access public */ - public $fixtures = array('core.post', 'core.author'); + public $fixtures = array('core.post', 'core.author', 'core.test_plugin_comment'); /** * reset environment. @@ -201,6 +215,22 @@ class ControllerTestCaseTest extends CakeTestCase { $result = ClassRegistry::init('TestPlugin.TestPluginComment'); $this->assertInstanceOf('TestPluginComment', $result); + + $Tests = $this->Case->generate('ControllerTestCaseTest', array( + 'models' => array( + 'TestPlugin.TestPluginComment' => array('save') + ) + )); + $this->assertInstanceOf('TestPluginComment', $Tests->TestPluginComment); + $Tests->TestPluginComment->expects($this->at(0)) + ->method('save') + ->will($this->returnValue(true)); + $Tests->TestPluginComment->expects($this->at(1)) + ->method('save') + ->will($this->returnValue(false)); + $this->assertTrue($Tests->TestPluginComment->save(array())); + $this->assertFalse($Tests->TestPluginComment->save(array())); + } /** diff --git a/cake/tests/lib/controller_test_case.php b/cake/tests/lib/controller_test_case.php index 217463ecf..150bf12a5 100644 --- a/cake/tests/lib/controller_test_case.php +++ b/cake/tests/lib/controller_test_case.php @@ -280,8 +280,8 @@ class ControllerTestCase extends CakeTestCase { list($plugin, $name) = pluginSplit($model); $config = array_merge((array)$config, array('name' => $model)); $_model = $this->getMock($name, $methods, array($config)); - ClassRegistry::removeObject($model); - ClassRegistry::addObject($model, $_model); + ClassRegistry::removeObject($name); + ClassRegistry::addObject($name, $_model); } foreach ($mocks['components'] as $component => $methods) { From 61e7cafe32589182e9f52b8f2486073fe4055685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 28 Jan 2011 01:33:08 -0430 Subject: [PATCH 204/668] Fixing HelperCollection tests after merging 2.0 branch in --- lib/Cake/Core/App.php | 3 ++- lib/Cake/View/HelperCollection.php | 2 +- lib/Cake/tests/cases/libs/view/helper_collection.test.php | 4 ++-- .../views/helpers/{other_helper.php => OtherHelperHelper.php} | 0 4 files changed, 5 insertions(+), 4 deletions(-) rename lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/{other_helper.php => OtherHelperHelper.php} (100%) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index fdccbeef4..ff27bc6aa 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -515,7 +515,8 @@ class App { return include $file; } - list($plugin, $package) = pluginSplit(self::$__classMap[$className]); + $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)) { diff --git a/lib/Cake/View/HelperCollection.php b/lib/Cake/View/HelperCollection.php index 534e6bbd8..8b10180a4 100644 --- a/lib/Cake/View/HelperCollection.php +++ b/lib/Cake/View/HelperCollection.php @@ -61,7 +61,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; } diff --git a/lib/Cake/tests/cases/libs/view/helper_collection.test.php b/lib/Cake/tests/cases/libs/view/helper_collection.test.php index e23390136..ede4c5cab 100644 --- a/lib/Cake/tests/cases/libs/view/helper_collection.test.php +++ b/lib/Cake/tests/cases/libs/view/helper_collection.test.php @@ -18,12 +18,12 @@ */ App::uses('HelperCollection', 'View/Helper'); +App::uses('HtmlHelper', 'View/Helper'); App::uses('View', 'View'); /** * Extended HtmlHelper */ -App::import('Helper', 'Html'); class HtmlAliasHelper extends HtmlHelper { } @@ -81,7 +81,7 @@ class HelperCollectionTest extends CakeTestCase { $result = $this->Helpers->load('Html'); $this->assertInstanceOf('HtmlAliasHelper', $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->Helpers->load('SomeOther', array('className' => 'TestPlugin.OtherHelper')); $this->assertInstanceOf('OtherHelperHelper', $result); $this->assertInstanceOf('OtherHelperHelper', $this->Helpers->SomeOther); diff --git a/lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php b/lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/OtherHelperHelper.php similarity index 100% rename from lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php rename to lib/Cake/tests/test_app/plugins/test_plugin/views/helpers/OtherHelperHelper.php From 0bde6d35f500d0c75ebbd1a07148dbfc72905aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 28 Jan 2011 01:44:04 -0430 Subject: [PATCH 205/668] Fixing Acl classes loading for the AclBehavior tests --- lib/Cake/Model/AclNode.php | 132 ------------------ .../cases/libs/model/behaviors/acl.test.php | 5 + 2 files changed, 5 insertions(+), 132 deletions(-) diff --git a/lib/Cake/Model/AclNode.php b/lib/Cake/Model/AclNode.php index 2e725ef41..e8107fbf3 100644 --- a/lib/Cake/Model/AclNode.php +++ b/lib/Cake/Model/AclNode.php @@ -184,135 +184,3 @@ class AclNode extends AppModel { return $result; } } - -/** - * Access Control Object - * - * @package cake.libs.model - */ -class Aco extends AclNode { - -/** - * Model name - * - * @var string - * @access public - */ - public $name = 'Aco'; - -/** - * Binds to ARO nodes through permissions settings - * - * @var array - * @access public - */ - public $hasAndBelongsToMany = array('Aro' => 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/tests/cases/libs/model/behaviors/acl.test.php b/lib/Cake/tests/cases/libs/model/behaviors/acl.test.php index fc97b74c1..8d1ea6ce3 100644 --- a/lib/Cake/tests/cases/libs/model/behaviors/acl.test.php +++ b/lib/Cake/tests/cases/libs/model/behaviors/acl.test.php @@ -18,9 +18,14 @@ * @since CakePHP v 1.2.0.4487 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + 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 * From e81ff384c7b21e13f2df4150909c13202b734cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 28 Jan 2011 01:48:15 -0430 Subject: [PATCH 206/668] Fixing BehaviorCollection test regarding how classes are loaded. with the introduction of App::uses() it is not possible to determine if a file is missing or just the class in the file, so removing the throwing of MissingBehaviorFileException seems the only choice --- lib/Cake/Model/BehaviorCollection.php | 6 +++--- .../tests/cases/libs/model/behavior_collection.test.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Model/BehaviorCollection.php b/lib/Cake/Model/BehaviorCollection.php index 7cb353224..a75b6deec 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -96,21 +96,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'; - App::uses($class, 'Model/Behavior'); + App::uses($class, $plugin . 'Model/Behavior'); if (!class_exists($class)) { throw new MissingBehaviorClassException(array( 'file' => Inflector::underscore($behavior) . '.php', diff --git a/lib/Cake/tests/cases/libs/model/behavior_collection.test.php b/lib/Cake/tests/cases/libs/model/behavior_collection.test.php index 1f38ae97c..6724c2784 100644 --- a/lib/Cake/tests/cases/libs/model/behavior_collection.test.php +++ b/lib/Cake/tests/cases/libs/model/behavior_collection.test.php @@ -453,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); @@ -553,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() { From 1ada281e14a303e7ccfef98bab524a723037a7f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 28 Jan 2011 01:52:54 -0430 Subject: [PATCH 207/668] Extracting CakeLogInterface to its own file, this fixes the FileLog test case --- lib/Cake/Log/CakeLog.php | 16 ---------------- lib/Cake/Log/CakeLogInterface.php | 18 ++++++++++++++++++ lib/Cake/Log/Engine/FileLog.php | 3 +++ 3 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 lib/Cake/Log/CakeLogInterface.php diff --git a/lib/Cake/Log/CakeLog.php b/lib/Cake/Log/CakeLog.php index 041779a96..0a1875a23 100644 --- a/lib/Cake/Log/CakeLog.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 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 @@ + Date: Fri, 28 Jan 2011 01:55:07 -0430 Subject: [PATCH 208/668] Fixing ExceptionRenderer tests --- lib/Cake/tests/cases/libs/error/exception_renderer.test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Cake/tests/cases/libs/error/exception_renderer.test.php b/lib/Cake/tests/cases/libs/error/exception_renderer.test.php index 7e949c801..7851d89fe 100644 --- a/lib/Cake/tests/cases/libs/error/exception_renderer.test.php +++ b/lib/Cake/tests/cases/libs/error/exception_renderer.test.php @@ -19,7 +19,9 @@ App::uses('ExceptionRenderer', 'Error'); App::uses('Controller', 'Controller'); +App::uses('AppController', 'Controller'); App::uses('Component', 'Controller'); +App::uses('Router', 'Routing'); /** * Short description for class. From 024bff21269c9a8f4b820e8fda1fa7a91e77185a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 28 Jan 2011 01:56:00 -0430 Subject: [PATCH 209/668] Adding missing class usage declaration in ExceptionHandler test case --- lib/Cake/Error/ErrorHandler.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index f996b4bee..6787e23f7 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -22,6 +22,7 @@ App::uses('Debugger', 'Utility'); App::uses('CakeLog', 'Log'); App::uses('ExceptionRenderer', 'Error'); +App::uses('AppController', 'Controller'); /** * From 4a55ef47cfb96819d43c0da077091218bd9e4381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 28 Jan 2011 02:00:20 -0430 Subject: [PATCH 210/668] Fixing SessionComponent tests --- lib/Cake/Controller/AppController.php | 2 ++ lib/Cake/Controller/Component/SessionComponent.php | 1 + lib/Cake/Core/Object.php | 4 +--- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Controller/AppController.php b/lib/Cake/Controller/AppController.php index 07c117dff..383cca2be 100644 --- a/lib/Cake/Controller/AppController.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/lib/Cake/Controller/Component/SessionComponent.php b/lib/Cake/Controller/Component/SessionComponent.php index 6ebb59884..71ba5c477 100644 --- a/lib/Cake/Controller/Component/SessionComponent.php +++ b/lib/Cake/Controller/Component/SessionComponent.php @@ -17,6 +17,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Component', 'Controller'); App::uses('CakeSession', 'Model/Datasource'); /** diff --git a/lib/Cake/Core/Object.php b/lib/Cake/Core/Object.php index cf1e369b6..28a3d0d29 100644 --- a/lib/Cake/Core/Object.php +++ b/lib/Cake/Core/Object.php @@ -66,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)); } From 32e0d8697628f148ef515f0319dbdaeb6080764a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 28 Jan 2011 02:02:33 -0430 Subject: [PATCH 211/668] Fixing sSecurity component tests --- lib/Cake/Controller/Component/SecurityComponent.php | 2 ++ .../tests/cases/libs/controller/components/security.test.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/SecurityComponent.php b/lib/Cake/Controller/Component/SecurityComponent.php index 7286e8419..721d9f57f 100644 --- a/lib/Cake/Controller/Component/SecurityComponent.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -16,6 +16,8 @@ * @since CakePHP(tm) v 0.10.8.2156 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('Component', 'Controller'); App::uses('String', 'Utility'); App::uses('Security', 'Utility'); diff --git a/lib/Cake/tests/cases/libs/controller/components/security.test.php b/lib/Cake/tests/cases/libs/controller/components/security.test.php index d40372c3d..bda666f66 100644 --- a/lib/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::uses('SecurityComponent', 'Controller/Component'); App::uses('Controller', 'Controller'); -App::uses('SecurityComponent', 'Component'); /** * TestSecurityComponent From 06fb51f19d1c47d397fd86213d54e8f6ef0c8f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 28 Jan 2011 02:06:30 -0430 Subject: [PATCH 212/668] Added some missing App::uses() calls --- lib/Cake/Controller/Component/AclComponent.php | 4 +--- lib/Cake/Controller/Component/AuthComponent.php | 1 + lib/Cake/Controller/Component/CookieComponent.php | 4 +--- lib/Cake/Controller/Component/EmailComponent.php | 2 ++ .../cases/libs/controller/components/request_handler.test.php | 1 + 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Controller/Component/AclComponent.php b/lib/Cake/Controller/Component/AclComponent.php index 66c274a30..e8809f864 100644 --- a/lib/Cake/Controller/Component/AclComponent.php +++ b/lib/Cake/Controller/Component/AclComponent.php @@ -264,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')); } diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 251a0e1fe..7f1cf6a94 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -19,6 +19,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Component', 'Controller'); App::uses('Router', 'Routing'); App::uses('Security', 'Utility'); App::uses('Debugger', 'Utility'); diff --git a/lib/Cake/Controller/Component/CookieComponent.php b/lib/Cake/Controller/Component/CookieComponent.php index dfe360f2c..9fefdb540 100644 --- a/lib/Cake/Controller/Component/CookieComponent.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -17,9 +17,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -/** - * Load Security class - */ +App::uses('Component', 'Controller'); App::uses('Security', 'Utility'); /** diff --git a/lib/Cake/Controller/Component/EmailComponent.php b/lib/Cake/Controller/Component/EmailComponent.php index d52a82e77..0c5d95358 100755 --- a/lib/Cake/Controller/Component/EmailComponent.php +++ b/lib/Cake/Controller/Component/EmailComponent.php @@ -16,6 +16,8 @@ * @since CakePHP(tm) v 1.2.0.3467 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('Component', 'Controller'); App::uses('Multibyte', 'I18n'); /** diff --git a/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php b/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php index 91a39da37..3d0ea9c9b 100644 --- a/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/request_handler.test.php @@ -20,6 +20,7 @@ App::uses('Controller', 'Controller'); App::uses('RequestHandlerComponent', 'Controller/Component'); App::uses('CakeRequest', 'Network'); App::uses('CakeResponse', 'Network'); +App::uses('Router', 'Routing'); /** * RequestHandlerTestController class From 4f01fc79c15346a2310ecda7ec5d7ac24e2bff67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Fri, 28 Jan 2011 10:49:53 -0430 Subject: [PATCH 213/668] Fixing ComponentCollecction components loading, as with Behaviors and Helpers, thee MissingFileException can not be thrown --- lib/Cake/Controller/ComponentCollection.php | 4 ++-- .../tests/cases/libs/controller/component_collection.test.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Controller/ComponentCollection.php b/lib/Cake/Controller/ComponentCollection.php index 7c7c0c63a..52540af64 100644 --- a/lib/Cake/Controller/ComponentCollection.php +++ b/lib/Cake/Controller/ComponentCollection.php @@ -79,7 +79,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; } @@ -87,7 +87,7 @@ class ComponentCollection extends ObjectCollection { return $this->_loaded[$alias]; } $componentClass = $name . 'Component'; - App::uses($componentClass, 'Controller/Component'); + App::uses($componentClass, $plugin . 'Controller/Component'); if (!class_exists($componentClass)) { throw new MissingComponentClassException(array( 'file' => Inflector::underscore($componentClass) . '.php', diff --git a/lib/Cake/tests/cases/libs/controller/component_collection.test.php b/lib/Cake/tests/cases/libs/controller/component_collection.test.php index 8bba76fde..a6b779073 100644 --- a/lib/Cake/tests/cases/libs/controller/component_collection.test.php +++ b/lib/Cake/tests/cases/libs/controller/component_collection.test.php @@ -84,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); @@ -109,7 +109,7 @@ class ComponentCollectionTest extends CakeTestCase { /** * test missingcomponent exception * - * @expectedException MissingComponentFileException + * @expectedException MissingComponentClassException * @return void */ function testLoadMissingComponentFile() { From b30f40582e3338ebe931ff47c308126bf81ca06c Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 29 Jan 2011 09:24:28 -0500 Subject: [PATCH 214/668] Making SchemaShell disable the cache when reading table information for schema generation. Fixes #1490 --- cake/console/libs/schema.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cake/console/libs/schema.php b/cake/console/libs/schema.php index 889f85453..840e3c61a 100644 --- a/cake/console/libs/schema.php +++ b/cake/console/libs/schema.php @@ -153,8 +153,13 @@ class SchemaShell extends Shell { } } + $cacheDisable = Configure::read('Cache.disable'); + Configure::write('Cache.disable', true); + $content = $this->Schema->read($options); $content['file'] = $this->params['file']; + + Configure::write('Cache.disable', $cacheDisable); if ($snapshot === true) { $Folder =& new Folder($this->Schema->path); From 01801a7777a75392eae358c2e32f046effad0fe9 Mon Sep 17 00:00:00 2001 From: Maggion Emmanuel Date: Tue, 25 Jan 2011 18:16:47 +0100 Subject: [PATCH 215/668] Reducing code related to CakeSchema. Fixes #1477 --- app/config/schema/db_acl.php | 9 --------- app/config/schema/i18n.php | 9 --------- app/config/schema/sessions.php | 9 --------- cake/libs/model/cake_schema.php | 10 ---------- 4 files changed, 37 deletions(-) diff --git a/app/config/schema/db_acl.php b/app/config/schema/db_acl.php index 25b6ee6df..25ed49204 100644 --- a/app/config/schema/db_acl.php +++ b/app/config/schema/db_acl.php @@ -27,15 +27,6 @@ */ class DbAclSchema extends CakeSchema { - public $name = 'DbAcl'; - - function before($event = array()) { - return true; - } - - function after($event = array()) { - } - public $acos = array( 'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'), 'parent_id' => array('type'=>'integer', 'null' => true, 'default' => NULL, 'length' => 10), diff --git a/app/config/schema/i18n.php b/app/config/schema/i18n.php index f57bbce7f..7776dbcd0 100644 --- a/app/config/schema/i18n.php +++ b/app/config/schema/i18n.php @@ -27,15 +27,6 @@ */ class i18nSchema extends CakeSchema { - public $name = 'i18n'; - - function before($event = array()) { - return true; - } - - function after($event = array()) { - } - public $i18n = array( 'id' => array('type'=>'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'), 'locale' => array('type'=>'string', 'null' => false, 'length' => 6, 'key' => 'index'), diff --git a/app/config/schema/sessions.php b/app/config/schema/sessions.php index e5ae37dc1..6304317f9 100644 --- a/app/config/schema/sessions.php +++ b/app/config/schema/sessions.php @@ -27,15 +27,6 @@ */ class SessionsSchema extends CakeSchema { - public $name = 'Sessions'; - - function before($event = array()) { - return true; - } - - function after($event = array()) { - } - public $cake_sessions = array( 'id' => array('type'=>'string', 'null' => false, 'key' => 'primary'), 'data' => array('type'=>'text', 'null' => true, 'default' => NULL), diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index fb3a77c13..eb577c7d8 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -26,14 +26,6 @@ App::import('Core', 'ConnectionManager'); */ class CakeSchema extends Object { -/** - * Name of the App Schema - * - * @var string - * @access public - */ - public $name = null; - /** * Path to write location * @@ -337,8 +329,6 @@ class CakeSchema extends Object { $out = "class {$name}Schema extends CakeSchema {\n"; - $out .= "\tvar \$name = '{$name}';\n\n"; - if ($path !== $this->path) { $out .= "\tvar \$path = '{$path}';\n\n"; } From 88d5db76fddf16a5467818d8c9ab37e23273e4ad Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 30 Jan 2011 04:13:01 +0530 Subject: [PATCH 216/668] Removed overriding of recursive to 0 in Model::_findNeighbors() if 'recusive' option is not specified in find options. Closes #860 --- cake/libs/model/model.php | 9 ++++----- cake/tests/cases/libs/model/model_read.test.php | 15 ++++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 396da7d4e..a375dc2eb 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -331,9 +331,9 @@ class Model extends Object { public $__backAssociation = array(); public $__backInnerAssociation = array(); - + public $__backOriginalAssociation = array(); - + public $__backContainableAssociation = array(); /** @@ -1067,7 +1067,7 @@ class Model extends Object { } /** - * Check that a method is callable on a model. This will check both the model's own methods, its + * Check that a method is callable on a model. This will check both the model's own methods, its * inherited methods and methods that could be callable through behaviors. * * @param string $method The method to be called. @@ -2156,7 +2156,7 @@ class Model extends Object { if ($query['callbacks'] === true || $query['callbacks'] === 'before') { $return = $this->Behaviors->trigger( - 'beforeFind', + 'beforeFind', array(&$this, $query), array('break' => true, 'breakOn' => array(false, null), 'modParams' => 1) ); @@ -2321,7 +2321,6 @@ class Model extends Object { */ protected function _findNeighbors($state, $query, $results = array()) { if ($state == 'before') { - $query = array_merge(array('recursive' => 0), $query); extract($query); $conditions = (array)$conditions; if (isset($field) && isset($value)) { diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php index 29ef9e929..8788b04af 100755 --- a/cake/tests/cases/libs/model/model_read.test.php +++ b/cake/tests/cases/libs/model/model_read.test.php @@ -3504,11 +3504,14 @@ class ModelReadTest extends BaseModelTest { $expected = array( 'prev' => null, 'next' => array( - 'Article' => array('id' => 2) + 'Article' => array('id' => 2), + 'Comment' => array(), + 'Tag' => array() )); $this->assertEqual($result, $expected); $TestModel->id = 2; + $TestModel->recursive = 0; $result = $TestModel->find('neighbors', array( 'fields' => array('id') )); @@ -3525,12 +3528,14 @@ class ModelReadTest extends BaseModelTest { $this->assertEqual($result, $expected); $TestModel->id = 3; + $TestModel->recursive = 1; $result = $TestModel->find('neighbors', array('fields' => array('id'))); $expected = array( 'prev' => array( - 'Article' => array( - 'id' => 2 - )), + 'Article' => array('id' => 2), + 'Comment' => array(), + 'Tag' => array() + ), 'next' => null ); $this->assertEqual($result, $expected); @@ -4793,7 +4798,7 @@ class ModelReadTest extends BaseModelTest { } /** - * test that calling unbindModel() with reset == true multiple times + * test that calling unbindModel() with reset == true multiple times * leaves associations in the correct state. * * @return void From 5b8499c8c74e58e5b77915ff086ba13112affa10 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 29 Jan 2011 20:53:50 -0500 Subject: [PATCH 217/668] Adding $name back in as it causes numerous notice errors in fixtures when it is missing. --- cake/libs/model/cake_schema.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index eb577c7d8..c083c7356 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -26,6 +26,14 @@ App::import('Core', 'ConnectionManager'); */ class CakeSchema extends Object { +/** + * Name of the schema + * + * @var string + * @access public + */ + public $name = null; + /** * Path to write location * From 6db8515e60ae0031af4ea0e9d50099c6f1bb2f1e Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 30 Jan 2011 12:25:40 -0500 Subject: [PATCH 218/668] Fixing incorrectly nested sprintf + __ call. Refs #1305 --- cake/libs/controller/scaffold.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index ea5e9031f..27b7632c8 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -223,7 +223,7 @@ class Scaffold extends Object { function __scaffoldView($params) { if ($this->controller->_beforeScaffold('view')) { - $message = __(sprintf("No id set for %s::view()", Inflector::humanize($this->modelKey)), true); + $message = sprintf(__("No id set for %s::view()", true), Inflector::humanize($this->modelKey)); if (isset($params['pass'][0])) { $this->ScaffoldModel->id = $params['pass'][0]; } elseif ($this->_validSession) { From 9402f0ab79307946c0eabee63d0c19a46d6dbf60 Mon Sep 17 00:00:00 2001 From: Phally Date: Mon, 31 Jan 2011 00:06:11 +0100 Subject: [PATCH 219/668] Added missing skipIf when no SMTP server is running. --- cake/tests/cases/libs/controller/components/email.test.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index de1be084e..541ed4f2a 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -437,6 +437,9 @@ TEMPDOC; * @return void */ function testSmtpSendMultipleTo() { + if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { + return; + } $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = array('postmaster@localhost', 'root@localhost'); $this->Controller->EmailTest->from = 'noreply@example.com'; From f3812342c226ec1d3355b84f60edfc54146095b7 Mon Sep 17 00:00:00 2001 From: Phally Date: Mon, 31 Jan 2011 00:15:12 +0100 Subject: [PATCH 220/668] Minor optimization for email linefeeds. --- cake/libs/controller/components/email.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 78698b056..fd4ed3479 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -159,7 +159,7 @@ class EmailComponent extends Object{ /** * Line feed character(s) to be used when sending using mail() function - * If null PHP_EOL is used. + * By default PHP_EOL is used. * RFC2822 requires it to be CRLF but some Unix * mail transfer agents replace LF by CRLF automatically * (which leads to doubling CR if CRLF is used). @@ -167,7 +167,7 @@ class EmailComponent extends Object{ * @var string * @access public */ - var $lineFeed = null; + var $lineFeed = PHP_EOL; /** * @deprecated see lineLength @@ -819,13 +819,8 @@ class EmailComponent extends Object{ * @access private */ function _mail() { - if ($this->lineFeed === null) { - $lineFeed = PHP_EOL; - } else { - $lineFeed = $this->lineFeed; - } - $header = implode($lineFeed, $this->__header); - $message = implode($lineFeed, $this->__message); + $header = implode($this->lineFeed, $this->__header); + $message = implode($this->lineFeed, $this->__message); if (is_array($this->to)) { $to = implode(', ', array_map(array($this, '_formatAddress'), $this->to)); } else { From 33cbdefd8c3c48dd7a764fe64b5870636de88f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 30 Jan 2011 23:39:07 -0430 Subject: [PATCH 221/668] Moving config tests assets and adding missing view path in View tests case --- {cake => lib/Cake}/tests/test_app/config/htmlhelper_minimized.ini | 0 {cake => lib/Cake}/tests/test_app/config/htmlhelper_tags.php | 0 {cake => lib/Cake}/tests/test_app/config/no_section.ini | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {cake => lib/Cake}/tests/test_app/config/htmlhelper_minimized.ini (100%) rename {cake => lib/Cake}/tests/test_app/config/htmlhelper_tags.php (100%) rename {cake => lib/Cake}/tests/test_app/config/no_section.ini (100%) diff --git a/cake/tests/test_app/config/htmlhelper_minimized.ini b/lib/Cake/tests/test_app/config/htmlhelper_minimized.ini similarity index 100% rename from cake/tests/test_app/config/htmlhelper_minimized.ini rename to lib/Cake/tests/test_app/config/htmlhelper_minimized.ini diff --git a/cake/tests/test_app/config/htmlhelper_tags.php b/lib/Cake/tests/test_app/config/htmlhelper_tags.php similarity index 100% rename from cake/tests/test_app/config/htmlhelper_tags.php rename to lib/Cake/tests/test_app/config/htmlhelper_tags.php diff --git a/cake/tests/test_app/config/no_section.ini b/lib/Cake/tests/test_app/config/no_section.ini similarity index 100% rename from cake/tests/test_app/config/no_section.ini rename to lib/Cake/tests/test_app/config/no_section.ini From a1fd27741d1e80d604d53fe2817953cc7ac19278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 30 Jan 2011 23:41:59 -0430 Subject: [PATCH 222/668] Fixing CakeTestFixture test case --- lib/Cake/tests/cases/libs/cake_test_fixture.test.php | 1 + lib/Cake/tests/cases/libs/view/view.test.php | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/Cake/tests/cases/libs/cake_test_fixture.test.php b/lib/Cake/tests/cases/libs/cake_test_fixture.test.php index fc0dad82c..ee7edbd2d 100644 --- a/lib/Cake/tests/cases/libs/cake_test_fixture.test.php +++ b/lib/Cake/tests/cases/libs/cake_test_fixture.test.php @@ -18,6 +18,7 @@ */ App::uses('DboSource', 'Model/Datasource'); App::uses('Model', 'Model'); +App::uses('CakeTestFixture', 'TestSuite/Fixture'); /** * CakeTestFixtureTestFixture class diff --git a/lib/Cake/tests/cases/libs/view/view.test.php b/lib/Cake/tests/cases/libs/view/view.test.php index 7b32888f3..d14a8a24d 100644 --- a/lib/Cake/tests/cases/libs/view/view.test.php +++ b/lib/Cake/tests/cases/libs/view/view.test.php @@ -261,6 +261,7 @@ class ViewTest extends CakeTestCase { $expected = array( LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'plugins' . DS . 'test_plugin' . DS, LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'views' . DS, + LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'libs' . DS . 'View' . DS, LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS, LIBS . 'View' . DS ); From bff634397984b601cd961fc356c68c3fa59002f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 31 Jan 2011 00:02:17 -0430 Subject: [PATCH 223/668] Adding the session datasources apth to App::build(), in the future look into registering only the top level packages Fixing CakeSession tests --- lib/Cake/Core/App.php | 3 ++- lib/Cake/tests/cases/libs/cake_session.test.php | 3 +-- .../datasources/Session/TestAppLibSession.php} | 0 .../datasources/Session/TestPluginSession.php} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename lib/Cake/tests/test_app/{libs/session/test_app_lib_session.php => models/datasources/Session/TestAppLibSession.php} (100%) rename lib/Cake/tests/test_app/plugins/test_plugin/{libs/session/test_plugin_session.php => models/datasources/Session/TestPluginSession.php} (100%) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index ff27bc6aa..ac324e265 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -291,7 +291,8 @@ class App { '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/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), diff --git a/lib/Cake/tests/cases/libs/cake_session.test.php b/lib/Cake/tests/cases/libs/cake_session.test.php index 2da0f25a0..510cdc068 100644 --- a/lib/Cake/tests/cases/libs/cake_session.test.php +++ b/lib/Cake/tests/cases/libs/cake_session.test.php @@ -527,7 +527,7 @@ class CakeSessionTest extends CakeTestCase { */ function testUsingAppLibsHandler() { App::build(array( - 'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . 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( @@ -549,7 +549,6 @@ class CakeSessionTest extends CakeTestCase { */ function testUsingPluginHandler() { App::build(array( - 'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS), 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) ), true); diff --git a/lib/Cake/tests/test_app/libs/session/test_app_lib_session.php b/lib/Cake/tests/test_app/models/datasources/Session/TestAppLibSession.php similarity index 100% rename from lib/Cake/tests/test_app/libs/session/test_app_lib_session.php rename to lib/Cake/tests/test_app/models/datasources/Session/TestAppLibSession.php diff --git a/lib/Cake/tests/test_app/plugins/test_plugin/libs/session/test_plugin_session.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/Session/TestPluginSession.php similarity index 100% rename from lib/Cake/tests/test_app/plugins/test_plugin/libs/session/test_plugin_session.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/Session/TestPluginSession.php From ff5a809b2989fa21f8e42c94ec7102d8c7dc1a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 31 Jan 2011 00:14:20 -0430 Subject: [PATCH 224/668] Fixing log engines loading --- .../libs/{log/test_app_log.php => Log/Engine/TestAppLog.php} | 3 +++ .../{log/test_plugin_log.php => Log/Engine/TestPluginLog.php} | 0 2 files changed, 3 insertions(+) rename lib/Cake/tests/test_app/libs/{log/test_app_log.php => Log/Engine/TestAppLog.php} (94%) rename lib/Cake/tests/test_app/plugins/test_plugin/libs/{log/test_plugin_log.php => Log/Engine/TestPluginLog.php} (100%) diff --git a/lib/Cake/tests/test_app/libs/log/test_app_log.php b/lib/Cake/tests/test_app/libs/Log/Engine/TestAppLog.php similarity index 94% rename from lib/Cake/tests/test_app/libs/log/test_app_log.php rename to lib/Cake/tests/test_app/libs/Log/Engine/TestAppLog.php index 129e1b65d..736be6cb6 100644 --- a/lib/Cake/tests/test_app/libs/log/test_app_log.php +++ b/lib/Cake/tests/test_app/libs/Log/Engine/TestAppLog.php @@ -16,6 +16,9 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('CakeLogInterface', 'Log'); + class TestAppLog implements CakeLogInterface { function write($type, $message) { diff --git a/lib/Cake/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php b/lib/Cake/tests/test_app/plugins/test_plugin/libs/Log/Engine/TestPluginLog.php similarity index 100% rename from lib/Cake/tests/test_app/plugins/test_plugin/libs/log/test_plugin_log.php rename to lib/Cake/tests/test_app/plugins/test_plugin/libs/Log/Engine/TestPluginLog.php From 72c6e0cd58dcb5ba2d1f04c47633bbc8bd3037d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 31 Jan 2011 00:47:30 -0430 Subject: [PATCH 225/668] Fixing Cache tests --- lib/Cake/Cache/Cache.php | 4 ++-- lib/Cake/tests/cases/libs/cache.test.php | 20 ++++++------------- .../Engine/TestAppCacheEngine.php} | 0 .../Engine/TestPluginCacheEngine.php} | 0 4 files changed, 8 insertions(+), 16 deletions(-) rename lib/Cake/tests/test_app/libs/{cache/test_app_cache.php => Cache/Engine/TestAppCacheEngine.php} (100%) rename lib/Cake/tests/test_app/plugins/test_plugin/libs/{cache/test_plugin_cache.php => Cache/Engine/TestPluginCacheEngine.php} (100%) diff --git a/lib/Cake/Cache/Cache.php b/lib/Cake/Cache/Cache.php index 9f84ac997..59b62fd7a 100644 --- a/lib/Cake/Cache/Cache.php +++ b/lib/Cake/Cache/Cache.php @@ -125,9 +125,9 @@ class Cache { protected static function _buildEngine($name) { $config = self::$_config[$name]; - list($plugin, $class) = pluginSplit($config['engine']); + list($plugin, $class) = pluginSplit($config['engine'], true); $cacheClass = $class . 'Engine'; - App::uses($cacheClass, 'Cache/Engine'); + App::uses($cacheClass, $plugin . 'Cache/Engine'); if (!class_exists($cacheClass)) { return false; } diff --git a/lib/Cake/tests/cases/libs/cache.test.php b/lib/Cake/tests/cases/libs/cache.test.php index 82c8a7c10..b0bf9e33d 100644 --- a/lib/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 @@ -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); } diff --git a/lib/Cake/tests/test_app/libs/cache/test_app_cache.php b/lib/Cake/tests/test_app/libs/Cache/Engine/TestAppCacheEngine.php similarity index 100% rename from lib/Cake/tests/test_app/libs/cache/test_app_cache.php rename to lib/Cake/tests/test_app/libs/Cache/Engine/TestAppCacheEngine.php diff --git a/lib/Cake/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php b/lib/Cake/tests/test_app/plugins/test_plugin/libs/Cache/Engine/TestPluginCacheEngine.php similarity index 100% rename from lib/Cake/tests/test_app/plugins/test_plugin/libs/cache/test_plugin_cache.php rename to lib/Cake/tests/test_app/plugins/test_plugin/libs/Cache/Engine/TestPluginCacheEngine.php From 63308fdbd8308440c6c0f5aefbf41ae36f9351c6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Feb 2011 21:52:41 -0500 Subject: [PATCH 226/668] Fixing issue where a false id would be appended to the route url. Test added. Fixes #1501 --- cake/libs/view/helpers/form.php | 2 +- .../cases/libs/view/helpers/form.test.php | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 1eb2b315f..92e87fb3e 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -260,7 +260,7 @@ class FormHelper extends AppHelper { $options['id'] = $this->domId($options['action'] . 'Form'); } $options['action'] = array_merge($actionDefaults, (array)$options['url']); - if (empty($options['action'][0])) { + if (empty($options['action'][0]) && !empty($id)) { $options['action'][0] = $id; } } elseif (is_string($options['url'])) { diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index bb389396a..ed3af90d1 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -661,8 +661,6 @@ class FormHelperTest extends CakeTestCase { */ function setUp() { parent::setUp(); - Router::reload(); - $this->Controller = new ContactTestController(); $this->View = new View($this->Controller); @@ -703,7 +701,7 @@ class FormHelperTest extends CakeTestCase { * @return void */ function tearDown() { - ClassRegistry::flush(); + parent::tearDown(); unset($this->Form->Html, $this->Form, $this->Controller, $this->View); Configure::write('Security.salt', $this->oldSalt); } @@ -5640,6 +5638,28 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * test create() with a custom route + * + * @return void + */ + function testCreateCustomRoute() { + Router::connect('/login', array('controller' => 'users', 'action' => 'login')); + $encoding = strtolower(Configure::read('App.encoding')); + + $result = $this->Form->create('User', array('action' => 'login')); + $expected = array( + 'form' => array( + 'id' => 'UserLoginForm', 'method' => 'post', 'action' => '/login', + 'accept-charset' => $encoding + ), + 'div' => array('style' => 'display:none;'), + 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), + '/div' + ); + $this->assertTags($result, $expected); + } + /** * test that inputDefaults are stored and used. * From 68da3fab8f8aba726db74156e35f20bb966c752f Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 2 Jan 2011 00:57:23 -0500 Subject: [PATCH 227/668] Starting to extract authentication objects out of AuthComponent. Started off with extracting FormAuthenticate as its what currently exists in AuthComponent. Test case added. --- .../components/auth/form_authenticate.php | 70 +++++++++ .../auth/form_authenticate.test.php | 133 ++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 cake/libs/controller/components/auth/form_authenticate.php create mode 100644 cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/cake/libs/controller/components/auth/form_authenticate.php new file mode 100644 index 000000000..324bff557 --- /dev/null +++ b/cake/libs/controller/components/auth/form_authenticate.php @@ -0,0 +1,70 @@ + 1).` + * + * @var array + */ + public $settings = array( + 'fields' => array( + 'username' => 'username', + 'password' => 'password' + ), + 'userModel' => 'User', + 'scope' => array() + ); + +/** + * Constructor + * + * @param array $settings Array of settings to use. + */ + public function __construct($settings) { + $this->settings = Set::merge($this->settings, $settings); + } + +/** + * Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields` + * to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if + * there is no post data, either username or password is missing, of if the scope conditions have not been met. + * + * @param CakeRequest $request The request that contains login information. + * @return mixed. False on login failure. An array of User data on success. + */ + public function authenticate(CakeRequest $request) { + $userModel = $this->settings['userModel']; + $fields = $this->settings['fields']; + if (empty($request->data[$userModel])) { + return false; + } + if ( + empty($request->data[$userModel][$fields['username']]) || + empty($request->data[$userModel][$fields['password']]) + ) { + return false; + } + $conditions = array( + $userModel . '.' . $fields['username'] => $request->data[$userModel][$fields['username']], + $userModel . '.' . $fields['password'] => $request->data[$userModel][$fields['password']], + ); + if (!empty($this->settings['scope'])) { + $conditions = array_merge($conditions, $this->settings['scope']); + } + $result = ClassRegistry::init($userModel)->find('first', array( + 'conditions' => $conditions, + 'recursive' => 0 + )); + if (empty($result) || empty($result[$userModel])) { + return false; + } + unset($result[$userModel][$fields['password']]); + return $result[$userModel]; + } +} \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php new file mode 100644 index 000000000..940c973e0 --- /dev/null +++ b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php @@ -0,0 +1,133 @@ +auth = new FormAuthenticate(array( + 'fields' => array('username' => 'user', 'password' => 'password'), + 'userModel' => 'User' + )); + $this->password = Security::hash('password', null, true); + ClassRegistry::init('User')->updateAll(array('password' => '"' . $this->password . '"')); + } + +/** + * test applying settings in the constructor + * + * @return void + */ + function testConstructor() { + $object = new FormAuthenticate(array( + 'userModel' => 'AuthUser', + 'fields' => array('username' => 'user', 'password' => 'password') + )); + $this->assertEquals('AuthUser', $object->settings['userModel']); + $this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->settings['fields']); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateNoData() { + $request = new CakeRequest('posts/index', false); + $request->data = array(); + $this->assertFalse($this->auth->authenticate($request)); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateNoUsername() { + $request = new CakeRequest('posts/index', false); + $request->data = array('User' => array('password' => 'foobar')); + $this->assertFalse($this->auth->authenticate($request)); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateNoPassword() { + $request = new CakeRequest('posts/index', false); + $request->data = array('User' => array('user' => 'mariano')); + $this->assertFalse($this->auth->authenticate($request)); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateInjection() { + $request = new CakeRequest('posts/index', false); + $request->data = array( + 'User' => array( + 'user' => '> 1', + 'password' => "' OR 1 = 1" + )); + $this->assertFalse($this->auth->authenticate($request)); + } + +/** + * test authenticate sucesss + * + * @return void + */ + function testAuthenticateSuccess() { + $request = new CakeRequest('posts/index', false); + $request->data = array('User' => array( + 'user' => 'mariano', + 'password' => $this->password + )); + $result = $this->auth->authenticate($request); + $expected = array( + 'id' => 1, + 'user' => 'mariano', + 'created' => '2007-03-17 01:16:23', + 'updated' => '2007-03-17 01:18:31' + ); + $this->assertEquals($expected, $result); + } + +/** + * test scope failure. + * + * @return void + */ + function testAuthenticateScopeFail() { + $this->auth->settings['scope'] = array('user' => 'nate'); + $request = new CakeRequest('posts/index', false); + $request->data = array('User' => array( + 'user' => 'mariano', + 'password' => $this->password + )); + + $this->assertFalse($this->auth->authenticate($request)); + } + +} \ No newline at end of file From 1c827573ceb9f376c3b2acdeaf2e5605328c2ea1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 2 Jan 2011 12:31:48 -0500 Subject: [PATCH 228/668] Adding doc blocks for FormAuthenticate. --- .../components/auth/form_authenticate.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/cake/libs/controller/components/auth/form_authenticate.php index 324bff557..e337b9715 100644 --- a/cake/libs/controller/components/auth/form_authenticate.php +++ b/cake/libs/controller/components/auth/form_authenticate.php @@ -1,5 +1,36 @@ Auth->authenticate = array( + * 'Form' => array( + * 'scope' => array('User.active' => 1) + * ) + * ) + * }}} + * + * When configuring FormAuthenticate you can pass in settings to which fields, model and additional conditions + * are used. See FormAuthenticate::$settings for more information. + * + * @package cake.libs.controller.components.auth + * @since 2.0 + */ class FormAuthenticate { /** From 693360bc9e27ff08eb5341c82b9f13aae0b88911 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 2 Jan 2011 13:21:21 -0500 Subject: [PATCH 229/668] Removing isAuthorized() as there is no need for it once AuthComponent is updated. --- .../components/auth/form_authenticate.php | 1 + cake/libs/controller/controller.php | 14 -------------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/cake/libs/controller/components/auth/form_authenticate.php index e337b9715..e4ffb2dc6 100644 --- a/cake/libs/controller/components/auth/form_authenticate.php +++ b/cake/libs/controller/components/auth/form_authenticate.php @@ -30,6 +30,7 @@ * * @package cake.libs.controller.components.auth * @since 2.0 + * @see AuthComponent::$authenticate */ class FormAuthenticate { diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 3929d7ed9..521b47503 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -756,20 +756,6 @@ class Controller extends Object { return call_user_func_array(array(&$this, $action), $args); } -/** - * Controller callback to tie into Auth component. - * Only called when AuthComponent::$authorize is set to 'controller'. - * - * @return bool true if authorized, false otherwise - * @link http://book.cakephp.org/view/1275/authorize - */ - public function isAuthorized() { - trigger_error(sprintf( - __('%sController::isAuthorized() is not defined.'), $this->name - ), E_USER_WARNING); - return false; - } - /** * Returns number of errors in a submitted FORM. * From 16b3beec5ef4e0fcf47b5a87857d2bea01a9e301 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 2 Jan 2011 13:35:43 -0500 Subject: [PATCH 230/668] Starting ControllerAuthorize adding it and the test cases. --- .../components/auth/controller_authorize.php | 52 ++++++++++++++++ .../auth/controller_authorize.test.php | 62 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 cake/libs/controller/components/auth/controller_authorize.php create mode 100644 cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php diff --git a/cake/libs/controller/components/auth/controller_authorize.php b/cake/libs/controller/components/auth/controller_authorize.php new file mode 100644 index 000000000..ed78ac5bd --- /dev/null +++ b/cake/libs/controller/components/auth/controller_authorize.php @@ -0,0 +1,52 @@ +controller($controller); + } + +/** + * Checks user authorization using a controller callback. + * + * @param array $user Active user data + * @param CakeRequest $request + * @return boolean + */ + public function authorize($user, CakeRequest $request) { + return (bool) $this->_controller->isAuthorized($user); + } + +/** + * Accessor to the controller object. + * + * @param mixed $controller null to get, a controller to set. + * @return mixed. + */ + public function controller($controller = null) { + if ($controller) { + if (!$controller instanceof Controller) { + throw new CakeException(__('$controller needs to be an instance of Controller')); + } + if (!method_exists($controller, 'isAuthorized')) { + throw new CakeException(__('$controller does not implement an isAuthorized() method.')); + } + $this->_controller = $controller; + return true; + } + return $this->_controller; + } +} \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php new file mode 100644 index 000000000..9863d23de --- /dev/null +++ b/cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php @@ -0,0 +1,62 @@ +controller = $this->getMock('Controller', array('isAuthorized'), array(), '', false); + $this->auth = new ControllerAuthorize($this->controller); + } + +/** + * + * @expectedException CakeException + */ + function testControllerTypeError() { + $this->auth->controller(new StdClass()); + } + +/** + * @expectedException CakeException + */ + function testControllerErrorOnMissingMethod() { + $this->auth->controller(new Controller()); + } + +/** + * test failure + * + * @return void + */ + function testAuthorizeFailure() { + $user = array(); + $request = new CakeRequest('/posts/index', false); + $this->assertFalse($this->auth->authorize($user, $request)); + } + +/** + * test isAuthorized working. + * + * @return void + */ + function testAuthorizeSuccess() { + $user = array('User' => array('username' => 'mark')); + $request = new CakeRequest('/posts/index', false); + + $this->controller->expects($this->once()) + ->method('isAuthorized') + ->with($user) + ->will($this->returnValue(true)); + + $this->assertTrue($this->auth->authorize($user, $request)); + } +} From 67c9acbc94c5399f27cdf801d2492a7fe71af6b0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 2 Jan 2011 13:39:48 -0500 Subject: [PATCH 231/668] Adding a doc block. --- .../components/auth/controller_authorize.php | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth/controller_authorize.php b/cake/libs/controller/components/auth/controller_authorize.php index ed78ac5bd..eea082111 100644 --- a/cake/libs/controller/components/auth/controller_authorize.php +++ b/cake/libs/controller/components/auth/controller_authorize.php @@ -1,6 +1,38 @@ request->params['admin'])) { + * return $user['role'] == 'admin'; + * } + * return !empty($user); + * } + * }}} + * + * the above is simple implementation that would only authorize users of the 'admin' role to access + * admin routing. + * + * @package cake.libs.controller.components.auth + * @since 2.0 + * @see AuthComponent::$authenticate + */ class ControllerAuthorize { /** * Controller for the request. From 4058e7f48c54c8d4040cae097c483b76e5f6ee29 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 2 Jan 2011 14:23:43 -0500 Subject: [PATCH 232/668] Extracting a base class, as it will be needed. Moving AuthComponent::action() into the authorize object base as that's where its used. --- .../components/auth/base_authorize.php | 90 +++++++++++++++++++ .../components/auth/controller_authorize.php | 43 +++------ 2 files changed, 102 insertions(+), 31 deletions(-) create mode 100644 cake/libs/controller/components/auth/base_authorize.php diff --git a/cake/libs/controller/components/auth/base_authorize.php b/cake/libs/controller/components/auth/base_authorize.php new file mode 100644 index 000000000..a7828eae5 --- /dev/null +++ b/cake/libs/controller/components/auth/base_authorize.php @@ -0,0 +1,90 @@ +action(); + * + * @var string + */ + public $actionPath = null; + +/** + * Constructor + * + * @param Controller $controller The controller for this request. + * @param string $settings An array of settings. This class does not use any settings. + */ + public function __construct(Controller $controller, $settings = array()) { + $this->controller($controller); + } + +/** + * Checks user authorization. + * + * @param array $user Active user data + * @param CakeRequest $request + * @return boolean + */ + abstract public function authorize($user, CakeRequest $request); + +/** + * Accessor to the controller object. + * + * @param mixed $controller null to get, a controller to set. + * @return mixed. + */ + public function controller($controller = null) { + if ($controller) { + if (!$controller instanceof Controller) { + throw new CakeException(__('$controller needs to be an instance of Controller')); + } + $this->_controller = $controller; + return true; + } + return $this->_controller; + } + +/** + * Get the action path for a given request. Primarily used by authorize objects + * that need to get information about the plugin, controller, and action being invoked. + * + * @param CakeRequest $request The request a path is needed for. + * @return string the action path for the given request. + */ + public function action($request, $path = '/:plugin/:controller/:action') { + $plugin = empty($request['plugin']) ? null : Inflector::camelize($request['plugin']) . '/'; + return str_replace( + array(':controller', ':action', ':plugin/'), + array(Inflector::camelize($request['controller']), $request['action'], $plugin), + $this->actionPath . $path + ); + } +} \ No newline at end of file diff --git a/cake/libs/controller/components/auth/controller_authorize.php b/cake/libs/controller/components/auth/controller_authorize.php index eea082111..720242e0b 100644 --- a/cake/libs/controller/components/auth/controller_authorize.php +++ b/cake/libs/controller/components/auth/controller_authorize.php @@ -12,6 +12,7 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::import('Component', 'auth/base_authorize'); /** * An authorization adapter for AuthComponent. Provides the ability to authorize using a controller callback. @@ -33,22 +34,21 @@ * @since 2.0 * @see AuthComponent::$authenticate */ -class ControllerAuthorize { -/** - * Controller for the request. - * - * @var Controller - */ - protected $_controller = null; +class ControllerAuthorize extends BaseAuthorize { /** - * Constructor + * Get/set the controller this authorize object will be working with. Also checks that isAuthorized is implemented. * - * @param Controller $controller The controller for this request. - * @param string $settings An array of settings. This class does not use any settings. + * @param mixed $controller null to get, a controller to set. + * @return mixed. */ - public function __construct(Controller $controller, $settings = array()) { - $this->controller($controller); + public function controller($controller = null) { + if ($controller) { + if (!method_exists($controller, 'isAuthorized')) { + throw new CakeException(__('$controller does not implement an isAuthorized() method.')); + } + } + return parent::controller($controller); } /** @@ -62,23 +62,4 @@ class ControllerAuthorize { return (bool) $this->_controller->isAuthorized($user); } -/** - * Accessor to the controller object. - * - * @param mixed $controller null to get, a controller to set. - * @return mixed. - */ - public function controller($controller = null) { - if ($controller) { - if (!$controller instanceof Controller) { - throw new CakeException(__('$controller needs to be an instance of Controller')); - } - if (!method_exists($controller, 'isAuthorized')) { - throw new CakeException(__('$controller does not implement an isAuthorized() method.')); - } - $this->_controller = $controller; - return true; - } - return $this->_controller; - } } \ No newline at end of file From 7207dccc7cebd641913796ff0270ff451818cfa5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 2 Jan 2011 14:24:25 -0500 Subject: [PATCH 233/668] Adding ActionsAuthorize. It implements using Acl as the authorization object. --- .../components/auth/actions_authorize.php | 39 ++++++ .../auth/actions_authorize.test.php | 130 ++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 cake/libs/controller/components/auth/actions_authorize.php create mode 100644 cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php diff --git a/cake/libs/controller/components/auth/actions_authorize.php b/cake/libs/controller/components/auth/actions_authorize.php new file mode 100644 index 000000000..7f4f722d7 --- /dev/null +++ b/cake/libs/controller/components/auth/actions_authorize.php @@ -0,0 +1,39 @@ +_controller->Components->load('Acl'); + return $Acl->check($user, $this->action($request)); + } +} \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php new file mode 100644 index 000000000..5aedbda04 --- /dev/null +++ b/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php @@ -0,0 +1,130 @@ +controller = $this->getMock('Controller', array(), array(), '', false); + $this->Acl = $this->getMock('AclComponent', array(), array(), '', false); + $this->controller->Components = $this->getMock('ComponentCollection'); + + $this->auth = new ActionsAuthorize($this->controller); + $this->auth->actionPath = '/controllers'; + } + +/** + * setup the mock acl. + * + * @return void + */ + protected function _mockAcl() { + $this->controller->Components->expects($this->any()) + ->method('load') + ->with('Acl') + ->will($this->returnValue($this->Acl)); + } + +/** + * test failure + * + * @return void + */ + function testAuthorizeFailure() { + $user = array( + 'User' => array( + 'id' => 1, + 'user' => 'mariano' + ) + ); + $request = new CakeRequest('/posts/index', false); + $request->addParams(array( + 'plugin' => null, + 'controller' => 'posts', + 'action' => 'index' + )); + + $this->_mockAcl(); + + $this->Acl->expects($this->once()) + ->method('check') + ->with($user, '/controllers/Posts/index') + ->will($this->returnValue(false)); + + $this->assertFalse($this->auth->authorize($user, $request)); + } + +/** + * test isAuthorized working. + * + * @return void + */ + function testAuthorizeSuccess() { + $user = array( + 'User' => array( + 'id' => 1, + 'user' => 'mariano' + ) + ); + $request = new CakeRequest('/posts/index', false); + $request->addParams(array( + 'plugin' => null, + 'controller' => 'posts', + 'action' => 'index' + )); + + $this->_mockAcl(); + + $this->Acl->expects($this->once()) + ->method('check') + ->with($user, '/controllers/Posts/index') + ->will($this->returnValue(true)); + + $this->assertTrue($this->auth->authorize($user, $request)); + } + +/** + * test action() + * + * @return void + */ + function testActionMethod() { + $request = new CakeRequest('/posts/index', false); + $request->addParams(array( + 'plugin' => null, + 'controller' => 'posts', + 'action' => 'index' + )); + + $result = $this->auth->action($request); + + $this->assertEquals('/controllers/Posts/index', $result); + } + +/** + * test action() and plugins + * + * @return void + */ + function testActionWithPlugin() { + $request = new CakeRequest('/debug_kit/posts/index', false); + $request->addParams(array( + 'plugin' => 'debug_kit', + 'controller' => 'posts', + 'action' => 'index' + )); + + $result = $this->auth->action($request); + $this->assertEquals('/controllers/DebugKit/Posts/index', $result); + } +} From 2e9d9479a6b4361745919b1f1c7692c95bc90f1d Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 3 Jan 2011 01:49:06 -0500 Subject: [PATCH 234/668] Moving another part of AuthComponent's authorize strategies into BaseAuthorize. Implementing CrudAuthorize and adding tests for it. --- .../components/auth/base_authorize.php | 37 +++++ .../components/auth/crud_authorize.php | 59 +++++++ .../components/auth/crud_authorize.test.php | 149 ++++++++++++++++++ 3 files changed, 245 insertions(+) create mode 100644 cake/libs/controller/components/auth/crud_authorize.php create mode 100644 cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php diff --git a/cake/libs/controller/components/auth/base_authorize.php b/cake/libs/controller/components/auth/base_authorize.php index a7828eae5..cc19acb26 100644 --- a/cake/libs/controller/components/auth/base_authorize.php +++ b/cake/libs/controller/components/auth/base_authorize.php @@ -36,6 +36,21 @@ abstract class BaseAuthorize { */ public $actionPath = null; +/** + * Action -> crud mappings. Used by authorization objects that want to map actions to CRUD roles. + * + * @var array + * @see CrudAuthorize + */ + protected $_actionMap = array( + 'index' => 'read', + 'add' => 'create', + 'edit' => 'update', + 'view' => 'read', + 'delete' => 'delete', + 'remove' => 'delete' + ); + /** * Constructor * @@ -87,4 +102,26 @@ abstract class BaseAuthorize { $this->actionPath . $path ); } + +/** + * Maps crud actions to actual controller names. Used to modify or get the current mapped actions. + * + * @param mixed $map Either an array of mappings, or undefined to get current values. + * @return mixed Either the current mappings or null when setting. + */ + public function mapActions($map = array()) { + if (empty($map)) { + return $this->_actionMap; + } + $crud = array('create', 'read', 'update', 'delete'); + foreach ($map as $action => $type) { + if (in_array($action, $crud) && is_array($type)) { + foreach ($type as $typedAction) { + $this->_actionMap[$typedAction] = $action; + } + } else { + $this->_actionMap[$action] = $type; + } + } + } } \ No newline at end of file diff --git a/cake/libs/controller/components/auth/crud_authorize.php b/cake/libs/controller/components/auth/crud_authorize.php new file mode 100644 index 000000000..5e6c9c85c --- /dev/null +++ b/cake/libs/controller/components/auth/crud_authorize.php @@ -0,0 +1,59 @@ +_actionMap[$request->params['action']])) { + trigger_error(__( + 'CrudAuthorize::authorize() - Attempted access of un-mapped action "%1$s" in controller "%2$s"', + $request->action, + $request->controller + ), + E_USER_WARNING + ); + return false; + } + $Acl = $this->_controller->Components->load('Acl'); + return $Acl->check( + $user, + $this->action($request, ':controller'), + $this->_actionMap[$request->params['action']] + ); + } +} \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php new file mode 100644 index 000000000..684fc4b97 --- /dev/null +++ b/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php @@ -0,0 +1,149 @@ +controller = $this->getMock('Controller', array(), array(), '', false); + $this->Acl = $this->getMock('AclComponent', array(), array(), '', false); + $this->controller->Components = $this->getMock('ComponentCollection'); + + $this->auth = new CrudAuthorize($this->controller); + } + +/** + * setup the mock acl. + * + * @return void + */ + protected function _mockAcl() { + $this->controller->Components->expects($this->any()) + ->method('load') + ->with('Acl') + ->will($this->returnValue($this->Acl)); + } + +/** + * test authorize() without a mapped action, ensure an error is generated. + * + * @expectedException Exception + * @return void + */ + function testAuthorizeNoMappedAction() { + $request = new CakeRequest('/posts/foobar', false); + $request->addParams(array( + 'controller' => 'posts', + 'action' => 'foobar' + )); + $user = array('User' => array('user' => 'mark')); + + $this->auth->authorize($user, $request); + } + +/** + * test check() passing + * + * @return void + */ + function testAuthorizeCheckSuccess() { + $request = new CakeRequest('posts/index', false); + $request->addParams(array( + 'controller' => 'posts', + 'action' => 'index' + )); + $user = array('User' => array('user' => 'mark')); + + $this->_mockAcl(); + $this->Acl->expects($this->once()) + ->method('check') + ->with($user, 'Posts', 'read') + ->will($this->returnValue(true)); + + $this->assertTrue($this->auth->authorize($user, $request)); + } + +/** + * test check() failing + * + * @return void + */ + function testAuthorizeCheckFailure() { + $request = new CakeRequest('posts/index', false); + $request->addParams(array( + 'controller' => 'posts', + 'action' => 'index' + )); + $user = array('User' => array('user' => 'mark')); + + $this->_mockAcl(); + $this->Acl->expects($this->once()) + ->method('check') + ->with($user, 'Posts', 'read') + ->will($this->returnValue(false)); + + $this->assertFalse($this->auth->authorize($user, $request)); + } + + +/** + * test getting actionMap + * + * @return void + */ + function testMapActionsGet() { + $result = $this->auth->mapActions(); + $expected = array( + 'index' => 'read', + 'add' => 'create', + 'edit' => 'update', + 'view' => 'read', + 'delete' => 'delete', + 'remove' => 'delete' + ); + $this->assertEquals($expected, $result); + } + +/** + * test adding into mapActions + * + * @return void + */ + function testMapActionsSet() { + $map = array( + 'create' => array('generate'), + 'read' => array('listing', 'show'), + 'update' => array('update'), + 'random' => 'custom' + ); + $result = $this->auth->mapActions($map); + $this->assertNull($result); + + $result = $this->auth->mapActions(); + $expected = array( + 'index' => 'read', + 'add' => 'create', + 'edit' => 'update', + 'view' => 'read', + 'delete' => 'delete', + 'remove' => 'delete', + 'generate' => 'create', + 'listing' => 'read', + 'show' => 'read', + 'update' => 'update', + 'random' => 'custom' + ); + $this->assertEquals($expected, $result); + } + +} From 5ae194ec905d28d52a21a6b96a9ed00254caa7bb Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 3 Jan 2011 12:58:49 -0500 Subject: [PATCH 235/668] Updating group test case, and fixing test case classname. --- cake/tests/cases/libs/all_components.test.php | 1 + .../libs/controller/components/auth/crud_authorize.test.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/all_components.test.php b/cake/tests/cases/libs/all_components.test.php index 28e59aadf..480c93219 100644 --- a/cake/tests/cases/libs/all_components.test.php +++ b/cake/tests/cases/libs/all_components.test.php @@ -37,6 +37,7 @@ class AllComponentsTest extends PHPUnit_Framework_TestSuite { $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'component.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'component_collection.test.php'); $suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'components'); + $suite->addTestDirectory(CORE_TEST_CASES . DS . 'libs' . DS . 'controller' . DS . 'components' . DS . 'auth'); return $suite; } } diff --git a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php index 684fc4b97..6382bed4f 100644 --- a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php +++ b/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php @@ -6,7 +6,7 @@ App::import('Component', 'Acl'); App::import('Core', 'CakeRequest'); App::import('Core', 'Controller'); -class ActionsAuthorizeTest extends CakeTestCase { +class CrudAuthorizeTest extends CakeTestCase { /** * setup From ca9aabdfec3da8c0cd2b10ffa31f3e7f1d5a0636 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 3 Jan 2011 13:00:06 -0500 Subject: [PATCH 236/668] Adding file headers. --- .../components/auth/actions_authorize.test.php | 15 ++++++++++++++- .../components/auth/controller_authorize.test.php | 15 ++++++++++++++- .../components/auth/crud_authorize.test.php | 15 ++++++++++++++- .../components/auth/form_authenticate.test.php | 14 ++++++++++++++ 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php index 5aedbda04..7af508c9c 100644 --- a/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php +++ b/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php @@ -1,5 +1,18 @@ Date: Mon, 3 Jan 2011 16:48:16 -0500 Subject: [PATCH 237/668] Starting to integrate Authorization objects into AuthComponent. Tests updated and duplicate tests skipped, they will eventually be removed when duplication is confirmed. --- cake/libs/controller/components/auth.php | 153 +++++------------- .../libs/controller/components/auth.test.php | 58 ++++++- 2 files changed, 99 insertions(+), 112 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 063960f91..c6429a419 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -21,6 +21,7 @@ App::import('Core', 'Router', false); App::import('Core', 'Security', false); +App::import('Component', 'auth/base_authorize'); /** * Authentication control component class @@ -67,6 +68,13 @@ class AuthComponent extends Component { */ public $authorize = false; +/** + * Objects that will be used for authorization checks. + * + * @var array + */ + protected $_authorizeObjects = array(); + /** * The name of an optional view element to render when an Ajax request is made * with an invalid or expired session @@ -400,42 +408,8 @@ class AuthComponent extends Component { if (!$this->authorize) { return true; } - - extract($this->__authType()); - switch ($type) { - case 'controller': - $this->object = $controller; - break; - case 'crud': - case 'actions': - if (isset($controller->Acl)) { - $this->Acl = $controller->Acl; - } else { - trigger_error(__('Could not find AclComponent. Please include Acl in Controller::$components.'), E_USER_WARNING); - } - break; - case 'model': - if (!isset($object)) { - $hasModel = ( - isset($controller->{$controller->modelClass}) && - is_object($controller->{$controller->modelClass}) - ); - $isUses = ( - !empty($controller->uses) && isset($controller->{$controller->uses[0]}) && - is_object($controller->{$controller->uses[0]}) - ); - - if ($hasModel) { - $object = $controller->modelClass; - } elseif ($isUses) { - $object = $controller->uses[0]; - } - } - $type = array('model' => $object); - break; - } - - if ($this->isAuthorized($type)) { + + if ($this->isAuthorized()) { return true; } @@ -478,91 +452,48 @@ class AuthComponent extends Component { } /** - * Determines whether the given user is authorized to perform an action. The type of - * authorization used is based on the value of AuthComponent::$authorize or the - * passed $type param. + * Uses the configured Authorization adapters to check whether or not a user is authorized. + * Each adapter will be checked in sequence, if any of them return true, then the user will + * be authorized for the request. * - * Types: - * 'controller' will validate against Controller::isAuthorized() if controller instance is - * passed in $object - * 'actions' will validate Controller::action against an AclComponent::check() - * 'crud' will validate mapActions against an AclComponent::check() - * array('model'=> 'name'); will validate mapActions against model - * $name::isAuthorized(user, controller, mapAction) - * 'object' will validate Controller::action against - * object::isAuthorized(user, controller, action) - * - * @param string $type Type of authorization - * @param mixed $object object, model object, or model name - * @param mixed $user The user to check the authorization of + * @param mixed $user The user to check the authorization of, if empty the user in the session will be used. * @return boolean True if $user is authorized, otherwise false */ - public function isAuthorized($type = null, $object = null, $user = null) { + public function isAuthorized($user = null) { if (empty($user) && !$this->user()) { return false; } elseif (empty($user)) { $user = $this->user(); } - - extract($this->__authType($type)); - - if (!$object) { - $object = $this->object; - } - - $valid = false; - switch ($type) { - case 'controller': - $valid = $object->isAuthorized(); - break; - case 'actions': - $valid = $this->Acl->check($user, $this->action()); - break; - case 'crud': - if (!isset($this->actionMap[$this->request['action']])) { - trigger_error( - __('Auth::startup() - Attempted access of un-mapped action "%1$s" in controller "%2$s"', $this->request['action'], $this->request['controller']), - E_USER_WARNING - ); - } else { - $valid = $this->Acl->check( - $user, - $this->action(':controller'), - $this->actionMap[$this->request['action']] - ); - } - break; - case 'model': - $action = $this->request['action']; - if (isset($this->actionMap[$action])) { - $action = $this->actionMap[$action]; - } - if (is_string($object)) { - $object = $this->getModel($object); - } - case 'object': - if (!isset($action)) { - $action = $this->action(':action'); - } - if (empty($object)) { - trigger_error(__('Could not find %s. Set AuthComponent::$object in beforeFilter() or pass a valid object', get_class($object)), E_USER_WARNING); - return; - } - if (method_exists($object, 'isAuthorized')) { - $valid = $object->isAuthorized($user, $this->action(':controller'), $action); - } elseif ($object) { - trigger_error(__('%s::isAuthorized() is not defined.', get_class($object)), E_USER_WARNING); - } - break; - case null: - case false: + $this->loadAuthorizeObjects(); + foreach ($this->_authorizeObjects as $authorizer) { + if ($authorizer->authorize($user, $this->request) === true) { return true; - break; - default: - trigger_error(__('Auth::isAuthorized() - $authorize is set to an incorrect value. Allowed settings are: "actions", "crud", "model" or null.'), E_USER_WARNING); - break; + } } - return $valid; + return false; + } + +/** + * Loads the authorization objects configured. + * + * @return mixed Either null when authorize is empty, or the loaded authorization objects. + */ + public function loadAuthorizeObjects() { + if (empty($this->authorize)) { + return; + } + foreach (Set::normalize($this->authorize) as $class => $settings) { + $className = $class . 'Authorize'; + if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authorize')) { + throw new CakeException(__('Authorization adapter "%s" was not found.', $class)); + } + if (!method_exists($className, 'authorize')) { + throw new CakeException(__('Authorization objects must implement an authorize method.')); + } + $this->_authorizeObjects[] = new $className($this->_Collection->getController(), $settings); + } + return $this->_authorizeObjects; } /** diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 371edd2ed..54689c841 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -54,6 +54,7 @@ class TestAuthComponent extends AuthComponent { function _stop($status = 0) { $this->testStop = true; } + } /** @@ -684,6 +685,8 @@ class AuthTest extends CakeTestCase { * @return void */ function testAuthorizeController() { + $this->markTestSkipped('This is already tested in ControllerAuthorizeTest'); + $this->AuthUser = new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); @@ -708,6 +711,8 @@ class AuthTest extends CakeTestCase { * @return void */ function testAuthorizeModel() { + $this->markTestSkipped('This is not implemented'); + $this->AuthUser = new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); @@ -734,6 +739,8 @@ class AuthTest extends CakeTestCase { * @return void */ function testAuthorizeCrud() { + $this->markTestSkipped('This is already tested in CrudAuthorizeTest'); + $this->AuthUser = new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); @@ -795,6 +802,8 @@ class AuthTest extends CakeTestCase { * @return void */ function testAuthorizeActions() { + $this->markTestSkipped('This is already tested in ActionsAuthorizeTest'); + $this->AuthUser = new AuthUser(); $user = $this->AuthUser->find(); $this->Controller->Session->write('Auth', $user); @@ -816,6 +825,49 @@ class AuthTest extends CakeTestCase { $this->assertTrue($this->Controller->Auth->isAuthorized()); } +/** + * @expectedException CakeException + * @return void + */ + function testIsAuthorizedMissingFile() { + $this->Controller->Auth->authorize = 'Missing'; + $this->Controller->Auth->isAuthorized(array('User' => array('id' => 1))); + } + +/** + * test that isAuthroized calls methods correctly + * + * @return void + */ + function testIsAuthorizedDelegation() { + $this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockOneAuthorize', false); + $this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockTwoAuthorize', false); + $this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockThreeAuthorize', false); + + $this->Controller->Auth->authorize = array( + 'AuthMockOne', + 'AuthMockTwo', + 'AuthMockThree' + ); + $mocks = $this->Controller->Auth->loadAuthorizeObjects(); + + $this->assertEquals(3, count($mocks)); + $mocks[0]->expects($this->once()) + ->method('authorize') + ->with(array('User')) + ->will($this->returnValue(false)); + + $mocks[1]->expects($this->once()) + ->method('authorize') + ->with(array('User')) + ->will($this->returnValue(true)); + + $mocks[2]->expects($this->never()) + ->method('authorize'); + + $this->assertTrue($this->Controller->Auth->isAuthorized(array('User'))); + } + /** * Tests that deny always takes precedence over allow * @@ -1136,6 +1188,8 @@ class AuthTest extends CakeTestCase { * @return void */ function testEmptyUsernameOrPassword() { + $this->markTestSkipped('This is already tested in FormAuthenticateTest'); + $this->AuthUser = new AuthUser(); $user['id'] = 1; $user['username'] = 'mariano'; @@ -1168,6 +1222,8 @@ class AuthTest extends CakeTestCase { * @return void */ function testInjection() { + $this->markTestSkipped('This is already tested in FormAuthenticateTest'); + $this->AuthUser = new AuthUser(); $this->AuthUser->id = 2; $this->AuthUser->saveField('password', Security::hash(Configure::read('Security.salt') . 'cake')); @@ -1326,6 +1382,7 @@ class AuthTest extends CakeTestCase { * @return void */ function testCustomField() { + $this->markTestSkipped('This is already tested in FormAuthenticateTest'); Router::reload(); $this->AuthUserCustomField = new AuthUserCustomField(); @@ -1544,7 +1601,6 @@ class AuthTest extends CakeTestCase { * @return void */ function testComponentSettings() { - $request = new CakeRequest(null, false); $this->Controller = new AuthTestController($request); From ced832ba62012e1fe40bde834bbf4a8872234d1f Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 3 Jan 2011 18:17:27 -0500 Subject: [PATCH 238/668] Fixing issues with FormAuthenticate and plugin models. --- .../components/auth/form_authenticate.php | 18 +++++---- .../auth/form_authenticate.test.php | 39 ++++++++++++++++++- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/cake/libs/controller/components/auth/form_authenticate.php index e4ffb2dc6..d536499b5 100644 --- a/cake/libs/controller/components/auth/form_authenticate.php +++ b/cake/libs/controller/components/auth/form_authenticate.php @@ -72,19 +72,21 @@ class FormAuthenticate { */ public function authenticate(CakeRequest $request) { $userModel = $this->settings['userModel']; + list($plugin, $model) = pluginSplit($userModel); + $fields = $this->settings['fields']; - if (empty($request->data[$userModel])) { + if (empty($request->data[$model])) { return false; } if ( - empty($request->data[$userModel][$fields['username']]) || - empty($request->data[$userModel][$fields['password']]) + empty($request->data[$model][$fields['username']]) || + empty($request->data[$model][$fields['password']]) ) { return false; } $conditions = array( - $userModel . '.' . $fields['username'] => $request->data[$userModel][$fields['username']], - $userModel . '.' . $fields['password'] => $request->data[$userModel][$fields['password']], + $model . '.' . $fields['username'] => $request->data[$model][$fields['username']], + $model . '.' . $fields['password'] => $request->data[$model][$fields['password']], ); if (!empty($this->settings['scope'])) { $conditions = array_merge($conditions, $this->settings['scope']); @@ -93,10 +95,10 @@ class FormAuthenticate { 'conditions' => $conditions, 'recursive' => 0 )); - if (empty($result) || empty($result[$userModel])) { + if (empty($result) || empty($result[$model])) { return false; } - unset($result[$userModel][$fields['password']]); - return $result[$userModel]; + unset($result[$model][$fields['password']]); + return $result[$model]; } } \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php index fe6547251..0c5e36a18 100644 --- a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php @@ -28,7 +28,7 @@ require_once CAKE_TESTS . 'cases' . DS . 'libs' . DS . 'model' . DS . 'models.p */ class FormAuthenticateTest extends CakeTestCase { - public $fixtures = array('core.user'); + public $fixtures = array('core.user', 'core.auth_user'); /** * setup @@ -144,4 +144,41 @@ class FormAuthenticateTest extends CakeTestCase { $this->assertFalse($this->auth->authenticate($request)); } +/** + * test a model in a plugin. + * + * @return void + */ + 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), + ), true); + App::objects('plugin', null, false); + + $PluginModel = ClassRegistry::init('TestPlugin.TestPluginAuthUser'); + $user['id'] = 1; + $user['username'] = 'gwoo'; + $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); + $PluginModel->save($user, false); + + $this->auth->settings['userModel'] = 'TestPlugin.TestPluginAuthUser'; + $this->auth->settings['fields']['username'] = 'username'; + + $request = new CakeRequest('posts/index', false); + $request->data = array('TestPluginAuthUser' => array( + 'username' => 'gwoo', + 'password' => Security::hash('cake', null, true) + )); + + $result = $this->auth->authenticate($request); + $expected = array( + 'id' => 1, + 'username' => 'gwoo', + 'created' => '2007-03-17 01:16:23', + 'updated' => date('Y-m-d H:i:s') + ); + $this->assertEquals($expected, $result); + } + } \ No newline at end of file From 3f9c83c43d2d2b8b9086cec83d7f3ce19d9e4b36 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 3 Jan 2011 18:18:42 -0500 Subject: [PATCH 239/668] Authentication and Authorization objects are integrated with AuthComponent. Minimal App changes are needed as legacy settings are forwarded. --- cake/libs/controller/components/auth.php | 167 ++++++++---------- .../libs/controller/components/auth.test.php | 103 ++++++++--- 2 files changed, 158 insertions(+), 112 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index c6429a419..a7993c249 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -48,20 +48,36 @@ class AuthComponent extends Component { public $components = array('Session', 'RequestHandler'); /** - * A reference to the object used for authentication + * An array of authentication objects to use for authenticating users. You can configure + * multiple adapters and they will be checked sequentially when users are identified. * * @var object * @link http://book.cakephp.org/view/1278/authenticate */ - public $authenticate = null; + public $authenticate = array('Form'); /** - * The name of the component to use for Authorization or set this to - * 'controller' will validate against Controller::isAuthorized() - * 'actions' will validate Controller::action against an AclComponent::check() - * 'crud' will validate mapActions against an AclComponent::check() - * array('model'=> 'name'); will validate mapActions against model $name::isAuthorized(user, controller, mapAction) - * 'object' will validate Controller::action against object::isAuthorized(user, controller, action) + * Objects that will be used for authentication checks. + * + * @var array + */ + protected $_authenticateObjects = array(); + +/** + * A hash mapping legacy properties => to settings passed into Authenticate objects. + * + * @var string + * @deprecated Will be removed in 2.1+ + */ + protected $_authenticateLegacyMap = array( + 'userModel' => 'userModel', + 'userScope' => 'scope', + 'fields' => 'fields' + ); + +/** + * An array of authorization objects to use for authorizing users. You can configure + * multiple adapters and they will be checked sequentially when authorization checks are done. * * @var mixed * @link http://book.cakephp.org/view/1275/authorize @@ -363,15 +379,7 @@ class AuthComponent extends Component { !empty($request->data[$model->alias][$this->fields['password']]); if ($isValid) { - $username = $request->data[$model->alias][$this->fields['username']]; - $password = $request->data[$model->alias][$this->fields['password']]; - - $data = array( - $model->alias . '.' . $this->fields['username'] => $username, - $model->alias . '.' . $this->fields['password'] => $password - ); - - if ($this->login($data)) { + if ($this->login()) { if ($this->autoRedirect) { $controller->redirect($this->redirect(), null, true); } @@ -456,18 +464,24 @@ class AuthComponent extends Component { * Each adapter will be checked in sequence, if any of them return true, then the user will * be authorized for the request. * - * @param mixed $user The user to check the authorization of, if empty the user in the session will be used. + * @param mixed $user The user to check the authorization of. If empty the user in the session will be used. + * @param CakeRequest $request The request to authenticate for. If empty, the current request will be used. * @return boolean True if $user is authorized, otherwise false */ - public function isAuthorized($user = null) { + public function isAuthorized($user = null, $request = null) { if (empty($user) && !$this->user()) { return false; } elseif (empty($user)) { $user = $this->user(); } - $this->loadAuthorizeObjects(); + if (empty($request)) { + $request = $this->request; + } + if (empty($this->_authorizeObjects)) { + $this->loadAuthorizeObjects(); + } foreach ($this->_authorizeObjects as $authorizer) { - if ($authorizer->authorize($user, $this->request) === true) { + if ($authorizer->authorize($user, $request) === true) { return true; } } @@ -483,6 +497,7 @@ class AuthComponent extends Component { if (empty($this->authorize)) { return; } + $this->_authorizeObjects = array(); foreach (Set::normalize($this->authorize) as $class => $settings) { $className = $class . 'Authorize'; if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authorize')) { @@ -596,15 +611,14 @@ class AuthComponent extends Component { * @return boolean True on login success, false on failure * @link http://book.cakephp.org/view/1261/login */ - public function login($data = null) { + public function login($request = null) { $this->__setDefaults(); $this->_loggedIn = false; - if (empty($data)) { - $data = $this->data; + if (empty($request)) { + $request = $this->request; } - - if ($user = $this->identify($data)) { + if ($user = $this->identify($request)) { $this->Session->write($this->sessionKey, $user); $this->_loggedIn = true; } @@ -739,80 +753,51 @@ class AuthComponent extends Component { } /** - * Identifies a user based on specific criteria. + * Use the configured authentication adapters, and attempt to identify the user + * by credentials contained in $request. * - * @param mixed $user Optional. The identity of the user to be validated. - * Uses the current user session if none specified. - * @param array $conditions Optional. Additional conditions to a find. - * @return array User record data, or null, if the user could not be identified. + * @param CakeRequest $request The request that contains authentication data. + * @return array User record data, or false, if the user could not be identified. */ - public function identify($user = null, $conditions = null) { - if ($conditions === false) { - $conditions = null; - } elseif (is_array($conditions)) { - $conditions = array_merge((array)$this->userScope, $conditions); - } else { - $conditions = $this->userScope; + public function identify(CakeRequest $request) { + if (empty($this->_authenticateObjects)) { + $this->loadAuthenticateObjects(); } - $model = $this->getModel(); - if (empty($user)) { - $user = $this->user(); - if (empty($user)) { - return null; + foreach ($this->_authenticateObjects as $auth) { + $result = $auth->authenticate($request); + if (!empty($result) && is_array($result)) { + return $result; } - } elseif (is_object($user) && is_a($user, 'Model')) { - if (!$user->exists()) { - return null; - } - $user = $user->read(); - $user = $user[$model->alias]; - } elseif (is_array($user) && isset($user[$model->alias])) { - $user = $user[$model->alias]; } + return false; + } - if (is_array($user) && (isset($user[$this->fields['username']]) || isset($user[$model->alias . '.' . $this->fields['username']]))) { - if (isset($user[$this->fields['username']]) && !empty($user[$this->fields['username']]) && !empty($user[$this->fields['password']])) { - if (trim($user[$this->fields['username']]) == '=' || trim($user[$this->fields['password']]) == '=') { - return false; - } - $find = array( - $model->alias.'.'.$this->fields['username'] => $user[$this->fields['username']], - $model->alias.'.'.$this->fields['password'] => $user[$this->fields['password']] - ); - } elseif (isset($user[$model->alias . '.' . $this->fields['username']]) && !empty($user[$model->alias . '.' . $this->fields['username']])) { - if (trim($user[$model->alias . '.' . $this->fields['username']]) == '=' || trim($user[$model->alias . '.' . $this->fields['password']]) == '=') { - return false; - } - $find = array( - $model->alias.'.'.$this->fields['username'] => $user[$model->alias . '.' . $this->fields['username']], - $model->alias.'.'.$this->fields['password'] => $user[$model->alias . '.' . $this->fields['password']] - ); - } else { - return false; - } - $data = $model->find('first', array( - 'conditions' => array_merge($find, $conditions), - 'recursive' => 0 - )); - if (empty($data) || empty($data[$model->alias])) { - return null; - } - } elseif (!empty($user) && is_string($user)) { - $data = $model->find('first', array( - 'conditions' => array_merge(array($model->escapeField() => $user), $conditions), - )); - if (empty($data) || empty($data[$model->alias])) { - return null; - } +/** + * loads the configured authentication objects. + * + * @return mixed either null on empty authenticate value, or an array of loaded objects. + */ + public function loadAuthenticateObjects() { + if (empty($this->authenticate)) { + return; } - - if (!empty($data)) { - if (!empty($data[$model->alias][$this->fields['password']])) { - unset($data[$model->alias][$this->fields['password']]); + $this->_authenticateObjects = array(); + foreach (Set::normalize($this->authenticate) as $class => $settings) { + $className = $class . 'Authenticate'; + if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authenticate')) { + throw new CakeException(__('Authentication adapter "%s" was not found.', $class)); } - return $data[$model->alias]; + if (!method_exists($className, 'authenticate')) { + throw new CakeException(__('Authentication objects must implement an authenticate method.')); + } + foreach ($this->_authenticateLegacyMap as $old => $new) { + if (empty($settings[$new]) && !empty($this->{$old})) { + $settings[$new] = $this->{$old}; + } + } + $this->_authenticateObjects[] = new $className($settings); } - return null; + return $this->_authenticateObjects; } /** diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 54689c841..27f9b6c10 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -582,13 +582,17 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $expected = array('AuthUser' => array( - 'id' => 1, 'username' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s') + 'id' => 1, + 'username' => 'mariano', + 'created' => '2007-03-17 01:16:23', + 'updated' => date('Y-m-d H:i:s') )); $this->assertEqual($user, $expected); $this->Controller->Session->delete('Auth'); $this->Controller->request->data['AuthUser'] = array( - 'username' => 'blah', 'password' => '' + 'username' => 'blah', + 'password' => '' ); $this->Controller->Auth->startup($this->Controller); @@ -598,7 +602,8 @@ class AuthTest extends CakeTestCase { $this->Controller->Session->delete('Auth'); $this->Controller->request->data['AuthUser'] = array( - 'username' => 'now() or 1=1 --', 'password' => '' + 'username' => 'now() or 1=1 --', + 'password' => '' ); $this->Controller->Auth->startup($this->Controller); @@ -608,7 +613,8 @@ class AuthTest extends CakeTestCase { $this->Controller->Session->delete('Auth'); $this->Controller->request->data['AuthUser'] = array( - 'username' => 'now() or 1=1 #something', 'password' => '' + 'username' => 'now() or 1=1 #something', + 'password' => '' ); $this->Controller->Auth->startup($this->Controller); @@ -617,14 +623,6 @@ class AuthTest extends CakeTestCase { $this->assertNull($user); $this->Controller->Session->delete('Auth'); - $this->Controller->Auth->userModel = 'UuidUser'; - $this->Controller->Auth->login('47c36f9c-bc00-4d17-9626-4e183ca6822b'); - - $user = $this->Controller->Auth->user(); - $expected = array('UuidUser' => array( - 'id' => '47c36f9c-bc00-4d17-9626-4e183ca6822b', 'title' => 'Unique record 1', 'count' => 2, 'created' => '2008-03-13 01:16:23', 'updated' => '2008-03-13 01:18:31' - )); - $this->assertEqual($user, $expected); $this->Controller->Session->delete('Auth'); } @@ -850,22 +848,80 @@ class AuthTest extends CakeTestCase { 'AuthMockThree' ); $mocks = $this->Controller->Auth->loadAuthorizeObjects(); + $request = $this->Controller->request; $this->assertEquals(3, count($mocks)); $mocks[0]->expects($this->once()) ->method('authorize') - ->with(array('User')) + ->with(array('User'), $request) ->will($this->returnValue(false)); - + $mocks[1]->expects($this->once()) ->method('authorize') - ->with(array('User')) + ->with(array('User'), $request) ->will($this->returnValue(true)); - + $mocks[2]->expects($this->never()) ->method('authorize'); - - $this->assertTrue($this->Controller->Auth->isAuthorized(array('User'))); + + $this->assertTrue($this->Controller->Auth->isAuthorized(array('User'), $request)); + } + +/** + * test that loadAuthorize resets the loaded objects each time. + * + * @return void + */ + function testLoadAuthorizeResets() { + $this->Controller->Auth->authorize = array( + 'Controller' + ); + $result = $this->Controller->Auth->loadAuthorizeObjects(); + $this->assertEquals(1, count($result)); + + $result = $this->Controller->Auth->loadAuthorizeObjects(); + $this->assertEquals(1, count($result)); + } + +/** + * @expectedException CakeException + * @return void + */ + function testLoadAuthenticateNoFile() { + $this->Controller->Auth->authenticate = 'Missing'; + $this->Controller->Auth->identify($this->Controller->request); + } + +/** + * test that loadAuthorize resets the loaded objects each time. + * + * @return void + */ + function testLoadAuthenticateResets() { + $this->Controller->Auth->authenticate = array( + 'Form' + ); + $result = $this->Controller->Auth->loadAuthenticateObjects(); + $this->assertEquals(1, count($result)); + + $result = $this->Controller->Auth->loadAuthenticateObjects(); + $this->assertEquals(1, count($result)); + } + +/** + * test that loadAuthenticate merges in legacy authentication settings. + * + * @return void + */ + function testLoadAuthenticateSettingsPass() { + $this->Controller->Auth->userModel = 'AuthUser'; + $this->Controller->Auth->userScope = array('AuthUser.active' => 1); + $this->Controller->Auth->fields = array('username' => 'user', 'password' => 'passwd'); + + $this->Controller->Auth->authenticate = array('Form'); + $objects = $this->Controller->Auth->loadAuthenticateObjects(); + $result = $objects[0]; + $this->assertEquals($result->settings['userModel'], 'AuthUser'); } /** @@ -1463,7 +1519,8 @@ class AuthTest extends CakeTestCase { $authUser = $PluginModel->find(); $this->Controller->request->data['TestPluginAuthUser'] = array( - 'username' => $authUser['TestPluginAuthUser']['username'], 'password' => 'cake' + 'username' => $authUser['TestPluginAuthUser']['username'], + 'password' => 'cake' ); $this->Controller->request->addParams(Router::parse('auth_test/login')); @@ -1476,8 +1533,12 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); - $expected = array('TestPluginAuthUser' => array( - 'id' => 1, 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s') + $expected = array( + 'TestPluginAuthUser' => array( + 'id' => 1, + 'username' => 'gwoo', + 'created' => '2007-03-17 01:16:23', + 'updated' => date('Y-m-d H:i:s') )); $this->assertEqual($user, $expected); $sessionKey = $this->Controller->Auth->sessionKey; From e96b20b93ea8004f0ec15d448d2d0156d29bcc43 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 4 Jan 2011 22:44:38 -0500 Subject: [PATCH 240/668] Removing skipped tests that cover features in other classes and tests. --- .../libs/controller/components/auth.test.php | 257 ------------------ 1 file changed, 257 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 27f9b6c10..13a92c91f 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -676,31 +676,6 @@ class AuthTest extends CakeTestCase { $this->assertFalse($result); } -/** - * testAuthorizeController method - * - * @access public - * @return void - */ - function testAuthorizeController() { - $this->markTestSkipped('This is already tested in ControllerAuthorizeTest'); - - $this->AuthUser = new AuthUser(); - $user = $this->AuthUser->find(); - $this->Controller->Session->write('Auth', $user); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->authorize = 'controller'; - $this->Controller->request->addParams(Router::parse('auth_test/add')); - $result = $this->Controller->Auth->startup($this->Controller); - $this->assertTrue($result); - - $this->Controller->request['testControllerAuth'] = 1; - $result = $this->Controller->Auth->startup($this->Controller); - $this->assertTrue($this->Controller->Session->check('Message.auth')); - $this->assertFalse($result); - - $this->Controller->Session->delete('Auth'); - } /** * testAuthorizeModel method @@ -730,99 +705,6 @@ class AuthTest extends CakeTestCase { $this->assertFalse($result); } -/** - * testAuthorizeCrud method - * - * @access public - * @return void - */ - function testAuthorizeCrud() { - $this->markTestSkipped('This is already tested in CrudAuthorizeTest'); - - $this->AuthUser = new AuthUser(); - $user = $this->AuthUser->find(); - $this->Controller->Session->write('Auth', $user); - - $this->Controller->request['controller'] = 'auth_test'; - $this->Controller->request['action'] = 'add'; - - $this->Controller->Acl->name = 'DbAclTest'; - - $this->Controller->Acl->Aro->id = null; - $this->Controller->Acl->Aro->create(array('alias' => 'Roles')); - $result = $this->Controller->Acl->Aro->save(); - $this->assertFalse(empty($result)); - - $parent = $this->Controller->Acl->Aro->id; - - $this->Controller->Acl->Aro->create(array('parent_id' => $parent, 'alias' => 'Admin')); - $result = $this->Controller->Acl->Aro->save(); - $this->assertFalse(empty($result)); - - $parent = $this->Controller->Acl->Aro->id; - - $this->Controller->Acl->Aro->create(array( - 'model' => 'AuthUser', 'parent_id' => $parent, 'foreign_key' => 1, 'alias'=> 'mariano' - )); - $result = $this->Controller->Acl->Aro->save(); - $this->assertFalse(empty($result)); - - $this->Controller->Acl->Aco->create(array('alias' => 'Root')); - $result = $this->Controller->Acl->Aco->save(); - $this->assertFalse(empty($result)); - - $parent = $this->Controller->Acl->Aco->id; - - $this->Controller->Acl->Aco->create(array('parent_id' => $parent, 'alias' => 'AuthTest')); - $result = $this->Controller->Acl->Aco->save(); - $this->assertFalse(empty($result)); - - $this->Controller->Acl->allow('Roles/Admin', 'Root'); - $this->Controller->Acl->allow('Roles/Admin', 'Root/AuthTest'); - - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->authorize = 'crud'; - $this->Controller->Auth->actionPath = 'Root/'; - - $this->Controller->Auth->startup($this->Controller); - $this->assertTrue($this->Controller->Auth->isAuthorized()); - - $this->Controller->Session->delete('Auth'); - $this->Controller->Auth->startup($this->Controller); - $this->assertTrue($this->Controller->Session->check('Message.auth')); - } - -/** - * test authorize = 'actions' setting. - * - * @return void - */ - function testAuthorizeActions() { - $this->markTestSkipped('This is already tested in ActionsAuthorizeTest'); - - $this->AuthUser = new AuthUser(); - $user = $this->AuthUser->find(); - $this->Controller->Session->write('Auth', $user); - $this->Controller->request['controller'] = 'auth_test'; - $this->Controller->request['action'] = 'add'; - - $this->Controller->Acl = $this->getMock('AclComponent', array(), array(), '', false); - $this->Controller->Acl->expects($this->atLeastOnce())->method('check')->will($this->returnValue(true)); - - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->authorize = 'actions'; - $this->Controller->Auth->actionPath = 'Root/'; - - $this->Controller->Acl->expects($this->at(0))->method('check')->with($user, 'Root/AuthTest/add'); - - $this->Controller->Auth->startup($this->Controller); - $this->assertTrue($this->Controller->Auth->isAuthorized()); - } - /** * @expectedException CakeException * @return void @@ -1237,110 +1119,6 @@ class AuthTest extends CakeTestCase { $this->assertTrue($result, 'Auth redirected a missing action %s'); } -/** - * testEmptyUsernameOrPassword method - * - * @access public - * @return void - */ - function testEmptyUsernameOrPassword() { - $this->markTestSkipped('This is already tested in FormAuthenticateTest'); - - $this->AuthUser = new AuthUser(); - $user['id'] = 1; - $user['username'] = 'mariano'; - $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); - $this->AuthUser->save($user, false); - - $authUser = $this->AuthUser->find(); - - $this->Controller->request->data['AuthUser'] = array( - 'username' => '', 'password' => '' - ); - - $this->Controller->request->addParams(Router::parse('auth_test/login')); - $this->Controller->request->query['url'] = 'auth_test/login'; - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = 'auth_test/login'; - $this->Controller->Auth->userModel = 'AuthUser'; - - $this->Controller->Auth->startup($this->Controller); - $user = $this->Controller->Auth->user(); - $this->assertTrue($this->Controller->Session->check('Message.auth')); - $this->assertEqual($user, false); - $this->Controller->Session->delete('Auth'); - } - -/** - * testInjection method - * - * @access public - * @return void - */ - function testInjection() { - $this->markTestSkipped('This is already tested in FormAuthenticateTest'); - - $this->AuthUser = new AuthUser(); - $this->AuthUser->id = 2; - $this->AuthUser->saveField('password', Security::hash(Configure::read('Security.salt') . 'cake')); - - $this->Controller->request->data['AuthUser'] = array( - 'username' => 'nate', 'password' => 'cake' - ); - - $this->Controller->request->addParams(Router::parse('auth_test/login')); - $this->Controller->request->query['url'] = 'auth_test/login'; - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->loginAction = 'auth_test/login'; - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); - $this->assertTrue(is_array($this->Controller->Auth->user())); - - $this->Controller->Session->delete($this->Controller->Auth->sessionKey); - - $this->Controller->request->data = array( - 'AuthUser' => array( - 'username' => 'nate', - 'password' => 'cake1' - ) - ); - $this->Controller->request->query['url'] = 'auth_test/login'; - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->loginAction = 'auth_test/login'; - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); - $this->assertTrue(is_null($this->Controller->Auth->user())); - - $this->Controller->Session->delete($this->Controller->Auth->sessionKey); - - $this->Controller->request->data = array( - 'AuthUser' => array( - 'username' => '> n', - 'password' => 'cake' - ) - ); - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->startup($this->Controller); - $this->assertTrue(is_null($this->Controller->Auth->user())); - - unset($this->Controller->request->data['AuthUser']['password']); - $this->Controller->request->data['AuthUser']['username'] = "1'1"; - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->startup($this->Controller); - $this->assertTrue(is_null($this->Controller->Auth->user())); - - unset($this->Controller->request->data['AuthUser']['username']); - $this->Controller->request->data['AuthUser']['password'] = "1'1"; - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->startup($this->Controller); - $this->assertTrue(is_null($this->Controller->Auth->user())); - } - /** * test Hashing of passwords * @@ -1431,41 +1209,6 @@ class AuthTest extends CakeTestCase { $this->assertTrue(!!$user); } -/** - * testCustomField method - * - * @access public - * @return void - */ - function testCustomField() { - $this->markTestSkipped('This is already tested in FormAuthenticateTest'); - Router::reload(); - - $this->AuthUserCustomField = new AuthUserCustomField(); - $user = array( - 'id' => 1, 'email' => 'harking@example.com', - 'password' => Security::hash(Configure::read('Security.salt') . 'cake' - )); - $user = $this->AuthUserCustomField->save($user, false); - - Router::connect('/', array('controller' => 'people', 'action' => 'login')); - $url = '/'; - $this->Controller->request->addParams(Router::parse($url)); - Router::setRequestInfo($this->Controller->request); - $this->Controller->request->data['AuthUserCustomField'] = array( - 'email' => 'harking@example.com', 'password' => 'cake' - ); - $this->Controller->request->query['url'] = substr($url, 1); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->fields = array('username' => 'email', 'password' => 'password'); - $this->Controller->Auth->loginAction = array('controller' => 'people', 'action' => 'login'); - $this->Controller->Auth->userModel = 'AuthUserCustomField'; - - $this->Controller->Auth->startup($this->Controller); - $user = $this->Controller->Auth->user(); - $this->assertTrue(!!$user); - } - /** * testAdminRoute method * From f21970c533ee64d7448be7f9cc05c1b636c80a6a Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 4 Jan 2011 23:12:37 -0500 Subject: [PATCH 241/668] Making AuthComponent::mapActions() delegate to the authorize objects. Adding tests. --- cake/libs/controller/components/auth.php | 40 ++++--------------- .../libs/controller/components/auth.test.php | 16 ++++++++ 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index a7993c249..244035d48 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -511,28 +511,6 @@ class AuthComponent extends Component { return $this->_authorizeObjects; } -/** - * Get authorization type - * - * @param string $auth Type of authorization - * @return array Associative array with: type, object - * @access private - */ - function __authType($auth = null) { - if ($auth == null) { - $auth = $this->authorize; - } - $object = null; - if (is_array($auth)) { - $type = key($auth); - $object = $auth[$type]; - } else { - $type = $auth; - return compact('type'); - } - return compact('type', 'object'); - } - /** * Takes a list of actions in the current controller for which authentication is not required, or * no parameters to allow all actions. @@ -580,22 +558,20 @@ class AuthComponent extends Component { } /** - * Maps action names to CRUD operations. Used for controller-based authentication. + * Maps action names to CRUD operations. Used for controller-based authentication. Make sure + * to configure the authorize property before calling this method. As it delegates $map to all the + * attached authorize objects. * * @param array $map Actions to map * @return void * @link http://book.cakephp.org/view/1260/mapActions */ public function mapActions($map = array()) { - $crud = array('create', 'read', 'update', 'delete'); - foreach ($map as $action => $type) { - if (in_array($action, $crud) && is_array($type)) { - foreach ($type as $typedAction) { - $this->actionMap[$typedAction] = $action; - } - } else { - $this->actionMap[$action] = $type; - } + if (empty($this->_authorizeObjects)) { + $this->loadAuthorizeObjects(); + } + foreach ($this->_authorizeObjects as $auth) { + $auth->mapActions($map); } } diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 13a92c91f..4381c3a2d 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -1470,4 +1470,20 @@ class AuthTest extends CakeTestCase { $this->assertNull($this->Controller->Session->read('Auth.AuthUser')); $this->assertNull($this->Controller->Session->read('Auth.redirect')); } + +/** + * test mapActions loading and delegating to authorize objects. + * + * @return void + */ + function testMapActionsDelegation() { + $this->getMock('BaseAuthorize', array('authorize'), array(), 'MapActionMockAuthorize', false); + $this->Controller->Auth->authorize = array('MapActionMock'); + $mock = $this->Controller->Auth->loadAuthorizeObjects(); + $mock[0]->expects($this->once()) + ->method('mapActions') + ->with(array('create' => array('my_action'))); + + $this->Controller->Auth->mapActions(array('create' => array('my_action'))); + } } From 7ea914938fc0715a0cef6c5f878336d4998bd57f Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 4 Jan 2011 23:27:16 -0500 Subject: [PATCH 242/668] Changing AuthComponent::login() so you can provide an array of user data to manually login a user. Leaving $user blank will attempt to identify the user using the request. --- cake/libs/controller/components/auth.php | 26 ++++++------------- .../libs/controller/components/auth.test.php | 19 ++++++++++++++ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 244035d48..2ce617878 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -264,13 +264,6 @@ class AuthComponent extends Component { */ public $params = array(); -/** - * AclComponent instance if using Acl + Auth - * - * @var AclComponent - */ - public $Acl; - /** * Method list for bound controller * @@ -576,25 +569,22 @@ class AuthComponent extends Component { } /** - * Manually log-in a user with the given parameter data. The $data provided can be any data - * structure used to identify a user in AuthComponent::identify(). If $data is empty or not - * specified, POST data from Controller::$data will be used automatically. + * Log a user in. If a $user is provided that data will be stored as the logged in user. If `$user` is empty or not + * specified, POST data from the current request will be used to identify a user. If the login was successful, + * the user record is written to the session key specified in AuthComponent::$sessionKey. * - * After (if) login is successful, the user record is written to the session key specified in - * AuthComponent::$sessionKey. - * - * @param mixed $data User object + * @param mixed $user Either an array of user data, or null to identify a user using the current request. * @return boolean True on login success, false on failure * @link http://book.cakephp.org/view/1261/login */ - public function login($request = null) { + public function login($user = null) { $this->__setDefaults(); $this->_loggedIn = false; - if (empty($request)) { - $request = $this->request; + if (empty($user)) { + $user = $this->identify($this->request); } - if ($user = $this->identify($request)) { + if ($user) { $this->Session->write($this->sessionKey, $user); $this->_loggedIn = true; } diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 4381c3a2d..97115e5b6 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -1486,4 +1486,23 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->mapActions(array('create' => array('my_action'))); } + +/** + * test login() with user data + * + * @return void + */ + function testLoginWithUserData() { + $this->assertFalse($this->Controller->Auth->loggedIn()); + + $user = array( + 'username' => 'mariano', + 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', + 'created' => '2007-03-17 01:16:23', + 'updated' => '2007-03-17 01:18:31' + ); + $this->assertTrue($this->Controller->Auth->login($user)); + $this->assertTrue($this->Controller->Auth->loggedIn()); + $this->assertEquals($user['username'], $this->Controller->Auth->user('username')); + } } From e34fdde91858ed9ed0fc0c02c71fa83f060bb875 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 4 Jan 2011 23:33:09 -0500 Subject: [PATCH 243/668] Adding a test for logging users in using request data. --- .../libs/controller/components/auth.test.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 97115e5b6..d22b1ea92 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -18,6 +18,7 @@ */ App::import('Core', 'Controller'); App::import('Component', array('Auth', 'Acl')); +App::import('Component', 'auth/form_authenticate'); App::import('Model', 'DbAcl'); App::import('Core', 'Xml'); @@ -1487,6 +1488,28 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->mapActions(array('create' => array('my_action'))); } +/** + * test logging in with a request. + * + * @return void + */ + function testLoginWithRequestData() { + $this->getMock('FormAuthenticate', array(), array(), 'RequestLoginMockAuthenticate', false); + $request = new CakeRequest('users/login', false); + $user = array('username' => 'mark', 'role' => 'admin'); + + $this->Controller->Auth->request = $request; + $this->Controller->Auth->authenticate = array('RequestLoginMock'); + $mock = $this->Controller->Auth->loadAuthenticateObjects(); + $mock[0]->expects($this->once()) + ->method('authenticate') + ->with($request) + ->will($this->returnValue($user)); + + $this->assertTrue($this->Controller->Auth->login()); + $this->assertEquals($user['username'], $this->Controller->Auth->user('username')); + } + /** * test login() with user data * From 0c7f9149ca1674cee50c95bc6ff533ad46fbc446 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 5 Jan 2011 00:01:40 -0500 Subject: [PATCH 244/668] Refactoring authorization objects to also use settings, it makes them consistent with authenticate objects. Making actionPath automatically pass into authentication objects. Adding tests. --- cake/libs/controller/components/auth.php | 15 +++++++ .../components/auth/base_authorize.php | 39 +++++++++---------- .../libs/controller/components/auth.test.php | 14 +++++++ 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 2ce617878..40695b2aa 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -91,6 +91,16 @@ class AuthComponent extends Component { */ protected $_authorizeObjects = array(); +/** + * A hash mapping legacy properties => to settings passed into Authorize objects. + * + * @var string + * @deprecated Will be removed in 2.1+ + */ + protected $_authorizeLegacyMap = array( + 'actionPath' => 'actionPath', + ); + /** * The name of an optional view element to render when an Ajax request is made * with an invalid or expired session @@ -499,6 +509,11 @@ class AuthComponent extends Component { if (!method_exists($className, 'authorize')) { throw new CakeException(__('Authorization objects must implement an authorize method.')); } + foreach ($this->_authorizeLegacyMap as $old => $new) { + if (empty($settings[$new]) && !empty($this->{$old})) { + $settings[$new] = $this->{$old}; + } + } $this->_authorizeObjects[] = new $className($this->_Collection->getController(), $settings); } return $this->_authorizeObjects; diff --git a/cake/libs/controller/components/auth/base_authorize.php b/cake/libs/controller/components/auth/base_authorize.php index cc19acb26..cf9a2892f 100644 --- a/cake/libs/controller/components/auth/base_authorize.php +++ b/cake/libs/controller/components/auth/base_authorize.php @@ -29,26 +29,24 @@ abstract class BaseAuthorize { protected $_controller = null; /** - * The path to ACO nodes that contains the nodes for controllers. Used as a prefix - * when calling $this->action(); + * Settings for authorize objects. * - * @var string - */ - public $actionPath = null; - -/** - * Action -> crud mappings. Used by authorization objects that want to map actions to CRUD roles. + * - `actionPath` - The path to ACO nodes that contains the nodes for controllers. Used as a prefix + * when calling $this->action(); + * - `actionMap` - Action -> crud mappings. Used by authorization objects that want to map actions to CRUD roles. * * @var array - * @see CrudAuthorize */ - protected $_actionMap = array( - 'index' => 'read', - 'add' => 'create', - 'edit' => 'update', - 'view' => 'read', - 'delete' => 'delete', - 'remove' => 'delete' + public $settings = array( + 'actionPath' => null, + 'actionMap' => array( + 'index' => 'read', + 'add' => 'create', + 'edit' => 'update', + 'view' => 'read', + 'delete' => 'delete', + 'remove' => 'delete' + ) ); /** @@ -59,6 +57,7 @@ abstract class BaseAuthorize { */ public function __construct(Controller $controller, $settings = array()) { $this->controller($controller); + $this->settings = Set::merge($this->settings, $settings); } /** @@ -99,7 +98,7 @@ abstract class BaseAuthorize { return str_replace( array(':controller', ':action', ':plugin/'), array(Inflector::camelize($request['controller']), $request['action'], $plugin), - $this->actionPath . $path + $this->settings['actionPath'] . $path ); } @@ -111,16 +110,16 @@ abstract class BaseAuthorize { */ public function mapActions($map = array()) { if (empty($map)) { - return $this->_actionMap; + return $this->settings['actionMap']; } $crud = array('create', 'read', 'update', 'delete'); foreach ($map as $action => $type) { if (in_array($action, $crud) && is_array($type)) { foreach ($type as $typedAction) { - $this->_actionMap[$typedAction] = $action; + $this->settings['actionMap'][$typedAction] = $action; } } else { - $this->_actionMap[$action] = $type; + $this->settings['actionMap'][$action] = $type; } } } diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index d22b1ea92..c4dc81e0c 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -775,6 +775,20 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->identify($this->Controller->request); } +/** + * test that loadAuthorize merges in legacy authorize settings. + * + * @return void + */ + function testLoadAuthorizeSettingsPass() { + $this->Controller->Auth->actionPath = 'controllers/'; + + $this->Controller->Auth->authorize = array('Actions'); + $objects = $this->Controller->Auth->loadAuthorizeObjects(); + $result = $objects[0]; + $this->assertEquals($result->settings['actionPath'], 'controllers/'); + } + /** * test that loadAuthorize resets the loaded objects each time. * From e11917ae9401aa1b7c2f05e6caf112ca3aaaf63a Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 5 Jan 2011 00:03:07 -0500 Subject: [PATCH 245/668] Removing public properties that aren't used anymore. --- cake/libs/controller/components/auth.php | 16 ---------------- .../components/auth/base_authorize.php | 2 +- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 40695b2aa..c18bea649 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -258,22 +258,6 @@ class AuthComponent extends Component { */ public $request; -/** - * Form data from Controller::$data - * - * @deprecated Use $this->request->data instead - * @var array - */ - public $data = array(); - -/** - * Parameter data from Controller::$params - * - * @deprecated Use $this->request instead - * @var array - */ - public $params = array(); - /** * Method list for bound controller * diff --git a/cake/libs/controller/components/auth/base_authorize.php b/cake/libs/controller/components/auth/base_authorize.php index cf9a2892f..e04f4e2de 100644 --- a/cake/libs/controller/components/auth/base_authorize.php +++ b/cake/libs/controller/components/auth/base_authorize.php @@ -32,7 +32,7 @@ abstract class BaseAuthorize { * Settings for authorize objects. * * - `actionPath` - The path to ACO nodes that contains the nodes for controllers. Used as a prefix - * when calling $this->action(); + * when calling $this->action(); * - `actionMap` - Action -> crud mappings. Used by authorization objects that want to map actions to CRUD roles. * * @var array From 1696df720135338910c0343a18da9d5dc8aa8638 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 5 Jan 2011 23:18:07 -0500 Subject: [PATCH 246/668] Removing the last of actionMap from AuthComponent. Its been moved into the authorization objects. Updating and adding tests for crud_authorize. --- cake/libs/controller/components/auth.php | 32 -------------- .../components/auth/crud_authorize.php | 43 ++++++++++++++++++- .../libs/controller/components/auth.test.php | 20 --------- .../components/auth/crud_authorize.test.php | 23 +++++++++- 4 files changed, 62 insertions(+), 56 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index c18bea649..6feac21ec 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -237,20 +237,6 @@ class AuthComponent extends Component { */ public $allowedActions = array(); -/** - * Maps actions to CRUD operations. Used for controller-based validation ($validate = 'controller'). - * - * @var array - * @see AuthComponent::mapActions() - */ - public $actionMap = array( - 'index' => 'read', - 'add' => 'create', - 'edit' => 'update', - 'view' => 'read', - 'remove' => 'delete' - ); - /** * Request object * @@ -275,26 +261,8 @@ class AuthComponent extends Component { $this->request = $controller->request; $this->params = $this->request; - $crud = array('create', 'read', 'update', 'delete'); - $this->actionMap = array_merge($this->actionMap, array_combine($crud, $crud)); $this->_methods = $controller->methods; - $prefixes = Router::prefixes(); - if (!empty($prefixes)) { - foreach ($prefixes as $prefix) { - $this->actionMap = array_merge($this->actionMap, array( - $prefix . '_index' => 'read', - $prefix . '_add' => 'create', - $prefix . '_edit' => 'update', - $prefix . '_view' => 'read', - $prefix . '_remove' => 'delete', - $prefix . '_create' => 'create', - $prefix . '_read' => 'read', - $prefix . '_update' => 'update', - $prefix . '_delete' => 'delete' - )); - } - } if (Configure::read('debug') > 0) { App::import('Debugger'); Debugger::checkSecurityKeys(); diff --git a/cake/libs/controller/components/auth/crud_authorize.php b/cake/libs/controller/components/auth/crud_authorize.php index 5e6c9c85c..40844f4b1 100644 --- a/cake/libs/controller/components/auth/crud_authorize.php +++ b/cake/libs/controller/components/auth/crud_authorize.php @@ -31,6 +31,45 @@ App::import('Component', 'auth/base_authorize'); */ class CrudAuthorize extends BaseAuthorize { +/** + * Sets up additional actionMap values that match the configured `Routing.prefixes`. + * + * @param Controller $controller The controller for this request. + * @param string $settings An array of settings. This class does not use any settings. + */ + public function __construct(Controller $controller, $settings = array()) { + parent::__construct($controller, $settings); + $this->_setPrefixMappings(); + } + +/** + * sets the crud mappings for prefix routes. + * + * @return void + */ + protected function _setPrefixMappings() { + $crud = array('create', 'read', 'update', 'delete'); + $map = array_combine($crud, $crud); + + $prefixes = Router::prefixes(); + if (!empty($prefixes)) { + foreach ($prefixes as $prefix) { + $map = array_merge($map, array( + $prefix . '_index' => 'read', + $prefix . '_add' => 'create', + $prefix . '_edit' => 'update', + $prefix . '_view' => 'read', + $prefix . '_remove' => 'delete', + $prefix . '_create' => 'create', + $prefix . '_read' => 'read', + $prefix . '_update' => 'update', + $prefix . '_delete' => 'delete' + )); + } + } + $this->mapActions($map); + } + /** * Authorize a user using the mapped actions and the AclComponent. * @@ -39,7 +78,7 @@ class CrudAuthorize extends BaseAuthorize { * @return boolean */ public function authorize($user, CakeRequest $request) { - if (!isset($this->_actionMap[$request->params['action']])) { + if (!isset($this->settings['actionMap'][$request->params['action']])) { trigger_error(__( 'CrudAuthorize::authorize() - Attempted access of un-mapped action "%1$s" in controller "%2$s"', $request->action, @@ -53,7 +92,7 @@ class CrudAuthorize extends BaseAuthorize { return $Acl->check( $user, $this->action($request, ':controller'), - $this->_actionMap[$request->params['action']] + $this->settings['actionMap'][$request->params['action']] ); } } \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index c4dc81e0c..9db1ac1ca 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -1393,26 +1393,6 @@ class AuthTest extends CakeTestCase { $this->assertNull($this->Controller->Session->read('Auth.redirect')); } -/** - * test the initialize callback and its interactions with Router::prefixes() - * - * @return void - */ - function testInitializeAndRoutingPrefixes() { - $restore = Configure::read('Routing'); - Configure::write('Routing.prefixes', array('admin', 'super_user')); - Router::reload(); - $this->Controller->Auth->initialize($this->Controller); - - $this->assertTrue(isset($this->Controller->Auth->actionMap['delete'])); - $this->assertTrue(isset($this->Controller->Auth->actionMap['view'])); - $this->assertTrue(isset($this->Controller->Auth->actionMap['add'])); - $this->assertTrue(isset($this->Controller->Auth->actionMap['admin_view'])); - $this->assertTrue(isset($this->Controller->Auth->actionMap['super_user_delete'])); - - Configure::write('Routing', $restore); - } - /** * test $settings in Controller::$components * diff --git a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php index fbad73a77..beee53fb9 100644 --- a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php +++ b/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php @@ -117,11 +117,14 @@ class CrudAuthorizeTest extends CakeTestCase { function testMapActionsGet() { $result = $this->auth->mapActions(); $expected = array( + 'create' => 'create', + 'read' => 'read', + 'update' => 'update', + 'delete' => 'delete', 'index' => 'read', 'add' => 'create', 'edit' => 'update', 'view' => 'read', - 'delete' => 'delete', 'remove' => 'delete' ); $this->assertEquals($expected, $result); @@ -144,6 +147,9 @@ class CrudAuthorizeTest extends CakeTestCase { $result = $this->auth->mapActions(); $expected = array( + 'add' => 'create', + 'create' => 'create', + 'read' => 'read', 'index' => 'read', 'add' => 'create', 'edit' => 'update', @@ -154,9 +160,22 @@ class CrudAuthorizeTest extends CakeTestCase { 'listing' => 'read', 'show' => 'read', 'update' => 'update', - 'random' => 'custom' + 'random' => 'custom', ); $this->assertEquals($expected, $result); } +/** + * test prefix routes getting auto mapped. + * + * @return void + */ + function testAutoPrefixMapActions() { + Configure::write('Routing.prefixes', array('admin', 'manager')); + Router::reload(); + + $auth = new CrudAuthorize($this->controller); + $this->assertTrue(isset($auth->settings['actionMap']['admin_index'])); + } + } From ff889c2c8ec1a22ee40efa6f22810fdc04c7dc05 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 9 Jan 2011 00:33:06 -0500 Subject: [PATCH 247/668] Renaming method names, no need to include Objects, its implied. --- cake/libs/controller/components/auth.php | 10 +++++----- .../libs/controller/components/auth.test.php | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 6feac21ec..4aed7f015 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -433,7 +433,7 @@ class AuthComponent extends Component { $request = $this->request; } if (empty($this->_authorizeObjects)) { - $this->loadAuthorizeObjects(); + $this->constructAuthorize(); } foreach ($this->_authorizeObjects as $authorizer) { if ($authorizer->authorize($user, $request) === true) { @@ -448,7 +448,7 @@ class AuthComponent extends Component { * * @return mixed Either null when authorize is empty, or the loaded authorization objects. */ - public function loadAuthorizeObjects() { + public function constructAuthorize() { if (empty($this->authorize)) { return; } @@ -528,7 +528,7 @@ class AuthComponent extends Component { */ public function mapActions($map = array()) { if (empty($this->_authorizeObjects)) { - $this->loadAuthorizeObjects(); + $this->constructAuthorize(); } foreach ($this->_authorizeObjects as $auth) { $auth->mapActions($map); @@ -694,7 +694,7 @@ class AuthComponent extends Component { */ public function identify(CakeRequest $request) { if (empty($this->_authenticateObjects)) { - $this->loadAuthenticateObjects(); + $this->constructAuthenticate(); } foreach ($this->_authenticateObjects as $auth) { $result = $auth->authenticate($request); @@ -710,7 +710,7 @@ class AuthComponent extends Component { * * @return mixed either null on empty authenticate value, or an array of loaded objects. */ - public function loadAuthenticateObjects() { + public function constructAuthenticate() { if (empty($this->authenticate)) { return; } diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 9db1ac1ca..600b08e20 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -730,7 +730,7 @@ class AuthTest extends CakeTestCase { 'AuthMockTwo', 'AuthMockThree' ); - $mocks = $this->Controller->Auth->loadAuthorizeObjects(); + $mocks = $this->Controller->Auth->constructAuthorize(); $request = $this->Controller->request; $this->assertEquals(3, count($mocks)); @@ -759,10 +759,10 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->authorize = array( 'Controller' ); - $result = $this->Controller->Auth->loadAuthorizeObjects(); + $result = $this->Controller->Auth->constructAuthorize(); $this->assertEquals(1, count($result)); - $result = $this->Controller->Auth->loadAuthorizeObjects(); + $result = $this->Controller->Auth->constructAuthorize(); $this->assertEquals(1, count($result)); } @@ -784,7 +784,7 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->actionPath = 'controllers/'; $this->Controller->Auth->authorize = array('Actions'); - $objects = $this->Controller->Auth->loadAuthorizeObjects(); + $objects = $this->Controller->Auth->constructAuthorize(); $result = $objects[0]; $this->assertEquals($result->settings['actionPath'], 'controllers/'); } @@ -798,10 +798,10 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->authenticate = array( 'Form' ); - $result = $this->Controller->Auth->loadAuthenticateObjects(); + $result = $this->Controller->Auth->constructAuthenticate(); $this->assertEquals(1, count($result)); - $result = $this->Controller->Auth->loadAuthenticateObjects(); + $result = $this->Controller->Auth->constructAuthenticate(); $this->assertEquals(1, count($result)); } @@ -816,7 +816,7 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->fields = array('username' => 'user', 'password' => 'passwd'); $this->Controller->Auth->authenticate = array('Form'); - $objects = $this->Controller->Auth->loadAuthenticateObjects(); + $objects = $this->Controller->Auth->constructAuthenticate(); $result = $objects[0]; $this->assertEquals($result->settings['userModel'], 'AuthUser'); } @@ -1474,7 +1474,7 @@ class AuthTest extends CakeTestCase { function testMapActionsDelegation() { $this->getMock('BaseAuthorize', array('authorize'), array(), 'MapActionMockAuthorize', false); $this->Controller->Auth->authorize = array('MapActionMock'); - $mock = $this->Controller->Auth->loadAuthorizeObjects(); + $mock = $this->Controller->Auth->constructAuthorize(); $mock[0]->expects($this->once()) ->method('mapActions') ->with(array('create' => array('my_action'))); @@ -1494,7 +1494,7 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->request = $request; $this->Controller->Auth->authenticate = array('RequestLoginMock'); - $mock = $this->Controller->Auth->loadAuthenticateObjects(); + $mock = $this->Controller->Auth->constructAuthenticate(); $mock[0]->expects($this->once()) ->method('authenticate') ->with($request) From b59d0e8bb15e6f9cd6b6b48a320cef73e2857005 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 19 Jan 2011 16:17:17 -0500 Subject: [PATCH 248/668] Replacing Authcomponent::$flashElement with Authcomponent::$flash, which gives access to all the flash parameters. Also adding a wrapper method for more terse code and ability to extend functionality. --- cake/libs/controller/components/auth.php | 31 +++++++++++++++---- .../libs/controller/components/auth.test.php | 19 ++++++++++++ 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 4aed7f015..afe98c888 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -111,11 +111,20 @@ class AuthComponent extends Component { public $ajaxLogin = null; /** - * The name of the element used for SessionComponent::setFlash + * Settings to use when Auth needs to do a flash message with SessionComponent::setFlash(). + * Available keys are: * - * @var string + * - `element` - The element to use, defaults to 'default'. + * - `key` - The key to use, defaults to 'auth' + * - `params` - The array of additional params to use, defaults to array() + * + * @var array */ - public $flashElement = 'default'; + public $flash = array( + 'element' => 'default', + 'key' => 'auth', + 'params' => array() + ); /** * The name of the model that represents users which will be authenticated. Defaults to 'User'. @@ -342,13 +351,13 @@ class AuthComponent extends Component { } } - $this->Session->setFlash($this->loginError, $this->flashElement, array(), 'auth'); + $this->flash($this->loginError); $request->data[$model->alias][$this->fields['password']] = null; return false; } else { if (!$this->user()) { if (!$request->is('ajax')) { - $this->Session->setFlash($this->authError, $this->flashElement, array(), 'auth'); + $this->flash($this->authError); if (!empty($request->query) && count($request->query) >= 2) { $query = $request->query; unset($query['url'], $query['ext']); @@ -376,7 +385,7 @@ class AuthComponent extends Component { return true; } - $this->Session->setFlash($this->authError, $this->flashElement, array(), 'auth'); + $this->flash($this->authError); $controller->redirect($controller->referer(), null, true); return false; } @@ -792,4 +801,14 @@ class AuthComponent extends Component { } return $this->_loggedIn; } + +/** + * Set a flash message. Uses the Session component, and values from AuthComponent::$flash. + * + * @param string $message The message to set. + * @return void + */ + public function flash($message) { + $this->Session->setFlash($message, $this->flash['element'], $this->flash['params'], $this->flash['key']); + } } diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 600b08e20..baac8287d 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -1522,4 +1522,23 @@ class AuthTest extends CakeTestCase { $this->assertTrue($this->Controller->Auth->loggedIn()); $this->assertEquals($user['username'], $this->Controller->Auth->user('username')); } + +/** + * test flash settings. + * + * @return void + */ + function testFlashSettings() { + $this->Controller->Auth->Session = $this->getMock('SessionComponent', array(), array(), '', zfalse); + $this->Controller->Auth->Session->expects($this->once()) + ->method('setFlash') + ->with('Auth failure', 'custom', array(1), 'auth-key'); + + $this->Controller->Auth->flash = array( + 'element' => 'custom', + 'params' => array(1), + 'key' => 'auth-key' + ); + $this->Controller->Auth->flash('Auth failure'); + } } From d8f2cf9395ddfd46009d2942dc635e706915874f Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 19 Jan 2011 16:53:58 -0500 Subject: [PATCH 249/668] Starting to remove magic around userModel, and deprecating/removing userModel from AuthComponent. --- cake/libs/controller/components/auth.php | 28 +++++----------- .../libs/controller/components/auth.test.php | 33 +++++++------------ 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index afe98c888..fafce8af8 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -154,12 +154,12 @@ class AuthComponent extends Component { /** * The session key name where the record of the current user is stored. If - * unspecified, it will be "Auth.{$userModel name}". + * unspecified, it will be "Auth.User". * * @var string * @link http://book.cakephp.org/view/1276/sessionKey */ - public $sessionKey = null; + public $sessionKey = 'Auth.User'; /** * If using action-based access control, this defines how the paths to action @@ -174,12 +174,16 @@ class AuthComponent extends Component { /** * A URL (defined as a string or array) to the controller action that handles - * logins. + * logins. Defaults to `/users/login` * * @var mixed * @link http://book.cakephp.org/view/1269/loginAction */ - public $loginAction = null; + public $loginAction = array( + 'controller' => 'users', + 'action' => 'login', + 'plugin' => null + ); /** * Normally, if a user is redirected to the $loginAction page, the location they @@ -268,8 +272,6 @@ class AuthComponent extends Component { */ public function initialize($controller) { $this->request = $controller->request; - $this->params = $this->request; - $this->_methods = $controller->methods; if (Configure::read('debug') > 0) { @@ -399,18 +401,7 @@ class AuthComponent extends Component { * @access private */ function __setDefaults() { - if (empty($this->userModel)) { - trigger_error(__("Could not find \$userModel. Please set AuthComponent::\$userModel in beforeFilter()."), E_USER_WARNING); - return false; - } - list($plugin, $model) = pluginSplit($this->userModel); $defaults = array( - 'loginAction' => array( - 'controller' => Inflector::underscore(Inflector::pluralize($model)), - 'action' => 'login', - 'plugin' => Inflector::underscore($plugin), - ), - 'sessionKey' => 'Auth.' . $model, 'logoutRedirect' => $this->loginAction, 'loginError' => __('Login failed. Invalid username or password.'), 'authError' => __('You are not authorized to access that location.') @@ -597,8 +588,7 @@ class AuthComponent extends Component { } if ($key == null) { - $model = $this->getModel(); - return array($model->alias => $this->Session->read($this->sessionKey)); + return $this->Session->read($this->sessionKey); } else { $user = $this->Session->read($this->sessionKey); if (isset($user[$key])) { diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index baac8287d..df63a5019 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -582,12 +582,12 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); - $expected = array('AuthUser' => array( + $expected = array( 'id' => 1, 'username' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s') - )); + ); $this->assertEqual($user, $expected); $this->Controller->Session->delete('Auth'); @@ -660,7 +660,7 @@ class AuthTest extends CakeTestCase { function testAuthorizeFalse() { $this->AuthUser = new AuthUser(); $user = $this->AuthUser->find(); - $this->Controller->Session->write('Auth', $user); + $this->Controller->Session->write('Auth.User', $user['AuthUser']); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->authorize = false; $this->Controller->request->addParams(Router::parse('auth_test/add')); @@ -1008,7 +1008,7 @@ class AuthTest extends CakeTestCase { ); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->startup($this->Controller); - $expected = Router::normalize('/'); + $expected = Router::normalize('/AuthTest/login'); $this->assertEqual($expected, $this->Controller->testUrl); $this->Controller->Session->delete('Auth'); @@ -1292,25 +1292,14 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->startup($this->Controller); $user = $this->Controller->Auth->user(); $expected = array( - 'TestPluginAuthUser' => array( - 'id' => 1, - 'username' => 'gwoo', - 'created' => '2007-03-17 01:16:23', - 'updated' => date('Y-m-d H:i:s') - )); + 'id' => 1, + 'username' => 'gwoo', + 'created' => '2007-03-17 01:16:23', + 'updated' => date('Y-m-d H:i:s') + ); $this->assertEqual($user, $expected); $sessionKey = $this->Controller->Auth->sessionKey; - $this->assertEqual('Auth.TestPluginAuthUser', $sessionKey); - - $this->Controller->Auth->loginAction = null; - $this->Controller->Auth->__setDefaults(); - $loginAction = $this->Controller->Auth->loginAction; - $expected = array( - 'controller' => 'test_plugin_auth_users', - 'action' => 'login', - 'plugin' => 'test_plugin' - ); - $this->assertEqual($loginAction, $expected); + $this->assertEqual('Auth.User', $sessionKey); // Reverting changes Cache::delete('object_map', '_cake_core_'); @@ -1529,7 +1518,7 @@ class AuthTest extends CakeTestCase { * @return void */ function testFlashSettings() { - $this->Controller->Auth->Session = $this->getMock('SessionComponent', array(), array(), '', zfalse); + $this->Controller->Auth->Session = $this->getMock('SessionComponent', array(), array(), '', false); $this->Controller->Auth->Session->expects($this->once()) ->method('setFlash') ->with('Auth failure', 'custom', array(1), 'auth-key'); From dc8c99308efc6754feda5beea7fdebd6d2647c78 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 20 Jan 2011 17:50:18 -0500 Subject: [PATCH 250/668] Starting to remove magical login process. Updating tests to actually test the methods they are named after. --- cake/libs/controller/components/auth.php | 20 +---- .../libs/controller/components/auth.test.php | 84 ++++++------------- 2 files changed, 27 insertions(+), 77 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index fafce8af8..1361a8797 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -333,29 +333,11 @@ class AuthComponent extends Component { } if ($loginAction == $url) { - $model = $this->getModel(); - if (empty($request->data) || !isset($request->data[$model->alias])) { + if (empty($request->data)) { if (!$this->Session->check('Auth.redirect') && !$this->loginRedirect && env('HTTP_REFERER')) { $this->Session->write('Auth.redirect', $controller->referer(null, true)); } - return false; } - - $isValid = !empty($request->data[$model->alias][$this->fields['username']]) && - !empty($request->data[$model->alias][$this->fields['password']]); - - if ($isValid) { - if ($this->login()) { - if ($this->autoRedirect) { - $controller->redirect($this->redirect(), null, true); - } - return true; - } - } - - $this->flash($this->loginError); - $request->data[$model->alias][$this->fields['password']] = null; - return false; } else { if (!$this->user()) { if (!$request->is('ajax')) { diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index df63a5019..923aa7e70 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -505,6 +505,8 @@ class AuthTest extends CakeTestCase { $this->initialized = true; Router::reload(); + + ClassRegistry::init('AuthUser')->updateAll(array('password' => '"' . Security::hash('cake', null, true) . '"')); } /** @@ -560,71 +562,37 @@ class AuthTest extends CakeTestCase { * @return void */ function testLogin() { - $this->AuthUser = new AuthUser(); - $user['id'] = 1; - $user['username'] = 'mariano'; - $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); - $this->AuthUser->save($user, false); + $this->getMock('FormAuthenticate', array(), array(), 'AuthLoginFormAuthenticate', false); + $this->Controller->Auth->authenticate = array( + 'AuthLoginForm' => array( + 'userModel' => 'AuthUser' + ) + ); + $mocks = $this->Controller->Auth->constructAuthenticate(); + $this->mockObjects[] = $mocks[0]; - $authUser = $this->AuthUser->find(); - - $this->Controller->request->data['AuthUser'] = array( - 'username' => $authUser['AuthUser']['username'], 'password' => 'cake' + $this->Controller->Auth->request->data = array( + 'AuthUser' => array( + 'username' => 'mark', + 'password' => Security::hash('cake', null, true) + ) ); - $this->Controller->request->addParams(Router::parse('auth_test/login')); - $this->Controller->request->query['url'] = 'auth_test/login'; - - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->loginAction = 'auth_test/login'; - $this->Controller->Auth->userModel = 'AuthUser'; - - $this->Controller->Auth->startup($this->Controller); - $user = $this->Controller->Auth->user(); - $expected = array( - 'id' => 1, - 'username' => 'mariano', - 'created' => '2007-03-17 01:16:23', - 'updated' => date('Y-m-d H:i:s') - ); - $this->assertEqual($user, $expected); - $this->Controller->Session->delete('Auth'); - - $this->Controller->request->data['AuthUser'] = array( - 'username' => 'blah', - 'password' => '' + $user = array( + 'id' => 1, + 'username' => 'mark' ); - $this->Controller->Auth->startup($this->Controller); + $mocks[0]->expects($this->once()) + ->method('authenticate') + ->with($this->Controller->Auth->request) + ->will($this->returnValue($user)); - $user = $this->Controller->Auth->user(); - $this->assertNull($user); - $this->Controller->Session->delete('Auth'); + $result = $this->Controller->Auth->login(); + $this->assertTrue($result); - $this->Controller->request->data['AuthUser'] = array( - 'username' => 'now() or 1=1 --', - 'password' => '' - ); - - $this->Controller->Auth->startup($this->Controller); - - $user = $this->Controller->Auth->user(); - $this->assertNull($user); - $this->Controller->Session->delete('Auth'); - - $this->Controller->request->data['AuthUser'] = array( - 'username' => 'now() or 1=1 #something', - 'password' => '' - ); - - $this->Controller->Auth->startup($this->Controller); - - $user = $this->Controller->Auth->user(); - $this->assertNull($user); - $this->Controller->Session->delete('Auth'); - - $this->Controller->Session->delete('Auth'); + $this->assertTrue($this->Controller->Auth->loggedIn()); + $this->assertEquals($user, $this->Controller->Auth->user()); } /** From 6eb31dfc94f83cda055f6dba3a679611cc7b7d86 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 20 Jan 2011 20:01:18 -0500 Subject: [PATCH 251/668] Removing test cases that were doing integration testing with router, and plugin models. Plugin model tests are in FormAuthenticate. And there is no more automatic login. --- .../libs/controller/components/auth.test.php | 109 +----------------- 1 file changed, 1 insertion(+), 108 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 923aa7e70..12ba3e878 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -1137,60 +1137,6 @@ class AuthTest extends CakeTestCase { $this->assertEqual($return, $expected); } -/** - * testCustomRoute method - * - * @access public - * @return void - */ - function testCustomRoute() { - Router::reload(); - Router::connect( - '/:lang/:controller/:action/*', - array('lang' => null), - array('lang' => '[a-z]{2,3}') - ); - - $url = '/en/users/login'; - $this->Controller->request->addParams(Router::parse($url)); - Router::setRequestInfo($this->Controller->request); - - $this->AuthUser = new AuthUser(); - $user = array( - 'id' => 1, 'username' => 'felix', - 'password' => Security::hash(Configure::read('Security.salt') . 'cake' - )); - $user = $this->AuthUser->save($user, false); - - $this->Controller->request->data['AuthUser'] = array('username' => 'felix', 'password' => 'cake'); - $this->Controller->request->query['url'] = substr($url, 1); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('lang' => 'en', 'controller' => 'users', 'action' => 'login'); - $this->Controller->Auth->userModel = 'AuthUser'; - - $this->Controller->Auth->startup($this->Controller); - $user = $this->Controller->Auth->user(); - $this->assertTrue(!!$user); - - $this->Controller->Session->delete('Auth'); - Router::reload(); - Router::connect('/', array('controller' => 'people', 'action' => 'login')); - $url = '/'; - $this->Controller->request->addParams(Router::parse($url)); - Router::setRequestInfo(array($this->Controller->passedArgs, array( - 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), - 'argSeparator' => ':', 'namedArgs' => array() - ))); - $this->Controller->request->data['AuthUser'] = array('username' => 'felix', 'password' => 'cake'); - $this->Controller->request->query['url'] = substr($url, 1); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('controller' => 'people', 'action' => 'login'); - $this->Controller->Auth->userModel = 'AuthUser'; - - $this->Controller->Auth->startup($this->Controller); - $user = $this->Controller->Auth->user(); - $this->assertTrue(!!$user); - } /** * testAdminRoute method @@ -1221,60 +1167,6 @@ class AuthTest extends CakeTestCase { Configure::write('Routing.prefixes', $prefixes); } -/** - * testPluginModel method - * - * @access public - * @return void - */ - function testPluginModel() { - // Adding plugins - Cache::delete('object_map', '_cake_core_'); - App::build(array( - 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), - 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS) - ), true); - App::objects('plugin', null, false); - - $PluginModel = ClassRegistry::init('TestPlugin.TestPluginAuthUser'); - $user['id'] = 1; - $user['username'] = 'gwoo'; - $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); - $PluginModel->save($user, false); - - $authUser = $PluginModel->find(); - - $this->Controller->request->data['TestPluginAuthUser'] = array( - 'username' => $authUser['TestPluginAuthUser']['username'], - 'password' => 'cake' - ); - - $this->Controller->request->addParams(Router::parse('auth_test/login')); - $this->Controller->request->query['url'] = 'auth_test/login'; - - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->loginAction = 'auth_test/login'; - $this->Controller->Auth->userModel = 'TestPlugin.TestPluginAuthUser'; - - $this->Controller->Auth->startup($this->Controller); - $user = $this->Controller->Auth->user(); - $expected = array( - 'id' => 1, - 'username' => 'gwoo', - 'created' => '2007-03-17 01:16:23', - 'updated' => date('Y-m-d H:i:s') - ); - $this->assertEqual($user, $expected); - $sessionKey = $this->Controller->Auth->sessionKey; - $this->assertEqual('Auth.User', $sessionKey); - - // Reverting changes - Cache::delete('object_map', '_cake_core_'); - App::build(); - App::objects('plugin', null, false); - } - /** * testAjaxLogin method * @@ -1389,6 +1281,7 @@ class AuthTest extends CakeTestCase { ); $this->Controller->request->query['url'] = substr($url, 1); $this->Controller->Auth->startup($this->Controller); + $this->Controller->Auth->login(); $user = $this->Controller->Auth->user(); $this->assertTrue(!!$user); From f2bba3d36e58347e7c444272c51007615550e8d4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 20 Jan 2011 20:10:46 -0500 Subject: [PATCH 252/668] Adding tests for AuthComponent::redirect() previously there weren't any. --- .../libs/controller/components/auth.test.php | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 12ba3e878..685c48740 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -1391,4 +1391,46 @@ class AuthTest extends CakeTestCase { ); $this->Controller->Auth->flash('Auth failure'); } + +/** + * test the various states of Auth::redirect() + * + * @return void + */ + function testRedirectSet() { + $value = array('controller' => 'users', 'action' => 'home'); + $result = $this->Controller->Auth->redirect($value); + $this->assertEquals('/users/home', $result); + $this->assertEquals($value, $this->Controller->Session->read('Auth.redirect')); + } + +/** + * test redirect using Auth.redirect from the session. + * + * @return void + */ + function testRedirectSessionRead() { + $this->Controller->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); + $this->Controller->Session->write('Auth.redirect', '/users/home'); + + $result = $this->Controller->Auth->redirect(); + $this->assertEquals('/users/home', $result); + $this->assertFalse($this->Controller->Session->check('Auth.redirect')); + } + +/** + * test that redirect does not return loginAction if that is what's stored in Auth.redirect. + * instead loginRedirect should be used. + * + * @return void + */ + function testRedirectSessionReadEqualToLoginAction() { + $this->Controller->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); + $this->Controller->Auth->loginRedirect = array('controller' => 'users', 'action' => 'home'); + $this->Controller->Session->write('Auth.redirect', array('controller' => 'users', 'action' => 'login')); + + $result = $this->Controller->Auth->redirect(); + $this->assertEquals('/users/home', $result); + $this->assertFalse($this->Controller->Session->check('Auth.redirect')); + } } From ed122c70f46a6e591727e6c8743a009f4ac7bf5e Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 20 Jan 2011 21:22:54 -0500 Subject: [PATCH 253/668] Removing custom request reversal code, and using Router::reverse() Removing dead tests that are covered by Router tests. Removing check for TestsController, it hasn't existed in forever. --- cake/libs/controller/components/auth.php | 21 ++++--------------- .../libs/controller/components/auth.test.php | 15 +------------ 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 1361a8797..d398392de 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -288,11 +288,7 @@ class AuthComponent extends Component { * @return boolean */ public function startup($controller) { - $isErrorOrTests = ( - strtolower($controller->name) == 'cakeerror' || - (strtolower($controller->name) == 'tests' && Configure::read('debug') > 0) - ); - if ($isErrorOrTests) { + if ($controller->name == 'CakeError') { return true; } @@ -342,12 +338,7 @@ class AuthComponent extends Component { if (!$this->user()) { if (!$request->is('ajax')) { $this->flash($this->authError); - if (!empty($request->query) && count($request->query) >= 2) { - $query = $request->query; - unset($query['url'], $query['ext']); - $url .= Router::queryString($query, array()); - } - $this->Session->write('Auth.redirect', $url); + $this->Session->write('Auth.redirect', Router::reverse($request)); $controller->redirect($loginAction); return false; } elseif (!empty($this->ajaxLogin)) { @@ -361,11 +352,7 @@ class AuthComponent extends Component { } } - if (!$this->authorize) { - return true; - } - - if ($this->isAuthorized()) { + if (empty($this->authorize) || $this->isAuthorized()) { return true; } @@ -519,7 +506,7 @@ class AuthComponent extends Component { /** * Log a user in. If a $user is provided that data will be stored as the logged in user. If `$user` is empty or not - * specified, POST data from the current request will be used to identify a user. If the login was successful, + * specified, the request will be used to identify a user. If the identification was successful, * the user record is written to the session key specified in AuthComponent::$sessionKey. * * @param mixed $user Either an array of user data, or null to identify a user using the current request. diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 685c48740..7783c5d29 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -943,17 +943,6 @@ class AuthTest extends CakeTestCase { $this->Controller->Session->delete('Auth'); - $this->Controller->request->query['url'] = 'admin/'; - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->loginRedirect = null; - $this->Controller->Auth->startup($this->Controller); - $expected = Router::normalize('admin/'); - $this->assertTrue($this->Controller->Session->check('Message.auth')); - $this->assertEqual($expected, $this->Controller->Auth->redirect()); - - $this->Controller->Session->delete('Auth'); - //empty referer no session $_SERVER['HTTP_REFERER'] = false; $_ENV['HTTP_REFERER'] = false; @@ -969,7 +958,6 @@ class AuthTest extends CakeTestCase { $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->authorize = 'controller'; - $this->Controller->request['testControllerAuth'] = true; $this->Controller->Auth->loginAction = array( 'controller' => 'AuthTest', 'action' => 'login' @@ -1041,8 +1029,7 @@ class AuthTest extends CakeTestCase { $_GET = array( 'url' => '/posts/index/29', 'print' => 'true', - 'refer' => 'menu', - 'ext' => 'html' + 'refer' => 'menu' ); $this->Controller->Session->delete('Auth'); $url = '/posts/index/29'; From e155e6acbaa35a16339ce93d6a4ca52c9d769743 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 20 Jan 2011 21:34:39 -0500 Subject: [PATCH 254/668] Adding doc block usage information. --- cake/libs/controller/components/auth.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index d398392de..ad2ab464b 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -444,6 +444,15 @@ class AuthComponent extends Component { * Takes a list of actions in the current controller for which authentication is not required, or * no parameters to allow all actions. * + * You can use allow with either an array, or var args. + * + * `$this->Auth->allow(array('edit', 'add'));` + * `$this->Auth->allow('edit', 'add');` + * + * allow() also supports '*' as a wildcard to mean all actions. + * + * `$this->Auth->allow('*');` + * * @param mixed $action Controller action name or array of actions * @param string $action Controller action name * @param string ... etc. @@ -463,7 +472,12 @@ class AuthComponent extends Component { } /** - * Removes items from the list of allowed actions. + * Removes items from the list of allowed/no authentication required actions. + * + * You can use deny with either an array, or var args. + * + * `$this->Auth->deny(array('edit', 'add'));` + * `$this->Auth->deny('edit', 'add');` * * @param mixed $action Controller action name or array of actions * @param string $action Controller action name From 23db2f086efcacaeb982eac134ae7163807ea59a Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 20 Jan 2011 21:39:59 -0500 Subject: [PATCH 255/668] Adding more documentation. --- cake/libs/controller/components/auth.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index ad2ab464b..5a477cae4 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -582,7 +582,9 @@ class AuthComponent extends Component { } /** - * If no parameter is passed, gets the authentication redirect URL. + * If no parameter is passed, gets the authentication redirect URL. Pass a url in to + * set the destination a user should be redirected to upon logging in. Will fallback to + * AuthComponent::$loginRedirect if there is no stored redirect value. * * @param mixed $url Optional URL to write as the login redirect URL. * @return string Redirect URL From fd8fb1225d3da750c465f972758c98a9741607b5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 16:22:29 -0500 Subject: [PATCH 256/668] Removing automatic password hashing from AuthComponent. Its a frustrating feature that often befuddles new users, and can be plain annoying sometimes. Moving hashing into FormAuthenticate. Updating tests. --- cake/libs/controller/components/auth.php | 27 +------------- .../components/auth/form_authenticate.php | 12 ++++++- .../libs/controller/components/auth.test.php | 36 ------------------- .../auth/form_authenticate.test.php | 10 +++--- 4 files changed, 17 insertions(+), 68 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 5a477cae4..fb878472f 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -308,8 +308,7 @@ class AuthComponent extends Component { return false; } $request = $controller->request; - - $this->request->data = $controller->request->data = $this->hashPasswords($request->data); + $url = ''; if (isset($request->query['url'])) { @@ -717,30 +716,6 @@ class AuthComponent extends Component { return $this->_authenticateObjects; } -/** - * Hash any passwords found in $data using $userModel and $fields['password'] - * - * @param array $data Set of data to look for passwords - * @return array Data with passwords hashed - * @link http://book.cakephp.org/view/1259/hashPasswords - */ - public function hashPasswords($data) { - if (is_object($this->authenticate) && method_exists($this->authenticate, 'hashPasswords')) { - return $this->authenticate->hashPasswords($data); - } - - if (is_array($data)) { - $model = $this->getModel(); - - if(isset($data[$model->alias])) { - if (isset($data[$model->alias][$this->fields['username']]) && isset($data[$model->alias][$this->fields['password']])) { - $data[$model->alias][$this->fields['password']] = $this->password($data[$model->alias][$this->fields['password']]); - } - } - } - return $data; - } - /** * Hash a password with the application's salt value (as defined with Configure::write('Security.salt'); * diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/cake/libs/controller/components/auth/form_authenticate.php index d536499b5..f0d9f862c 100644 --- a/cake/libs/controller/components/auth/form_authenticate.php +++ b/cake/libs/controller/components/auth/form_authenticate.php @@ -86,7 +86,7 @@ class FormAuthenticate { } $conditions = array( $model . '.' . $fields['username'] => $request->data[$model][$fields['username']], - $model . '.' . $fields['password'] => $request->data[$model][$fields['password']], + $model . '.' . $fields['password'] => $this->hash($request->data[$model][$fields['password']]), ); if (!empty($this->settings['scope'])) { $conditions = array_merge($conditions, $this->settings['scope']); @@ -101,4 +101,14 @@ class FormAuthenticate { unset($result[$model][$fields['password']]); return $result[$model]; } + +/** + * Hash the supplied password using the configured hashing method. + * + * @param string $password The password to hash. + * @return string Hashed string + */ + public function hash($password) { + return Security::hash($password, null, true); + } } \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 7783c5d29..4180256f9 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -1089,42 +1089,6 @@ class AuthTest extends CakeTestCase { $this->assertTrue($result, 'Auth redirected a missing action %s'); } -/** - * test Hashing of passwords - * - * @return void - */ - function testHashPasswords() { - $this->Controller->Auth->userModel = 'AuthUser'; - - $data['AuthUser']['password'] = 'superSecret'; - $data['AuthUser']['username'] = 'superman@dailyplanet.com'; - $return = $this->Controller->Auth->hashPasswords($data); - $expected = $data; - $expected['AuthUser']['password'] = Security::hash($expected['AuthUser']['password'], null, true); - $this->assertEqual($return, $expected); - - $data['Wrong']['password'] = 'superSecret'; - $data['Wrong']['username'] = 'superman@dailyplanet.com'; - $data['AuthUser']['password'] = 'IcantTellYou'; - $return = $this->Controller->Auth->hashPasswords($data); - $expected = $data; - $expected['AuthUser']['password'] = Security::hash($expected['AuthUser']['password'], null, true); - $this->assertEqual($return, $expected); - - $xml = array( - 'User' => array( - 'username' => 'batman@batcave.com', - 'password' => 'bruceWayne', - ) - ); - $data = new Xml($xml); - $return = $this->Controller->Auth->hashPasswords($data); - $expected = $data; - $this->assertEqual($return, $expected); - } - - /** * testAdminRoute method * diff --git a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php index 0c5e36a18..de4600e6d 100644 --- a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php @@ -41,8 +41,8 @@ class FormAuthenticateTest extends CakeTestCase { 'fields' => array('username' => 'user', 'password' => 'password'), 'userModel' => 'User' )); - $this->password = Security::hash('password', null, true); - ClassRegistry::init('User')->updateAll(array('password' => '"' . $this->password . '"')); + $password = Security::hash('password', null, true); + ClassRegistry::init('User')->updateAll(array('password' => '"' . $password . '"')); } /** @@ -116,7 +116,7 @@ class FormAuthenticateTest extends CakeTestCase { $request = new CakeRequest('posts/index', false); $request->data = array('User' => array( 'user' => 'mariano', - 'password' => $this->password + 'password' => 'password' )); $result = $this->auth->authenticate($request); $expected = array( @@ -138,7 +138,7 @@ class FormAuthenticateTest extends CakeTestCase { $request = new CakeRequest('posts/index', false); $request->data = array('User' => array( 'user' => 'mariano', - 'password' => $this->password + 'password' => 'password' )); $this->assertFalse($this->auth->authenticate($request)); @@ -168,7 +168,7 @@ class FormAuthenticateTest extends CakeTestCase { $request = new CakeRequest('posts/index', false); $request->data = array('TestPluginAuthUser' => array( 'username' => 'gwoo', - 'password' => Security::hash('cake', null, true) + 'password' => 'cake' )); $result = $this->auth->authenticate($request); From dc03e4f26cef743ef216189134b9e8b2531cf317 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 16:24:43 -0500 Subject: [PATCH 257/668] Moving an import. --- cake/libs/controller/components/auth/form_authenticate.php | 1 + .../libs/controller/components/auth/form_authenticate.test.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/cake/libs/controller/components/auth/form_authenticate.php index f0d9f862c..ce4a6e7c9 100644 --- a/cake/libs/controller/components/auth/form_authenticate.php +++ b/cake/libs/controller/components/auth/form_authenticate.php @@ -12,6 +12,7 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::import('Core', 'Security'); /** * An authentication adapter for AuthComponent. Provides the ability to authenticate using POST diff --git a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php index de4600e6d..b2218a75b 100644 --- a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php @@ -17,7 +17,6 @@ App::import('Component', 'auth/form_authenticate'); App::import('Model', 'AppModel'); App::import('Core', 'CakeRequest'); -App::import('Core', 'Security'); require_once CAKE_TESTS . 'cases' . DS . 'libs' . DS . 'model' . DS . 'models.php'; From 28ad51c92b205ebef2447acd5b9ab3d8094a7883 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 16:25:04 -0500 Subject: [PATCH 258/668] Removing action() from AuthComponent, its in the authorization objects now. Updating tests. --- cake/libs/controller/components/auth.php | 18 ------------ .../libs/controller/components/auth.test.php | 29 ------------------- 2 files changed, 47 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index fb878472f..ea7b6e69c 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -627,24 +627,6 @@ class AuthComponent extends Component { return $this->Acl->check($user, $object, $action); } -/** - * Returns the path to the ACO node bound to a controller/action. - * - * @param string $action Optional. The controller/action path to validate the - * user against. The current request action is used if - * none is specified. - * @return boolean ACO node path - * @link http://book.cakephp.org/view/1256/action - */ - public function action($action = ':plugin/:controller/:action') { - $plugin = empty($this->request['plugin']) ? null : Inflector::camelize($this->request['plugin']) . '/'; - return str_replace( - array(':controller', ':action', ':plugin/'), - array(Inflector::camelize($this->request['controller']), $this->request['action'], $plugin), - $this->actionPath . $action - ); - } - /** * Returns a reference to the model object specified, and attempts * to load it if it is not found. diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 4180256f9..94f3b8d7b 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -817,35 +817,6 @@ class AuthTest extends CakeTestCase { $this->assertFalse($this->Controller->Auth->startup($this->Controller)); } -/** - * test the action() method - * - * @return void - */ - function testActionMethod() { - $this->Controller->request['controller'] = 'auth_test'; - $this->Controller->request['action'] = 'add'; - - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->actionPath = 'ROOT/'; - - $result = $this->Controller->Auth->action(); - $this->assertEqual($result, 'ROOT/AuthTest/add'); - - $result = $this->Controller->Auth->action(':controller'); - $this->assertEqual($result, 'ROOT/AuthTest'); - - $result = $this->Controller->Auth->action(':controller'); - $this->assertEqual($result, 'ROOT/AuthTest'); - - $this->Controller->request['plugin'] = 'test_plugin'; - $this->Controller->request['controller'] = 'auth_test'; - $this->Controller->request['action'] = 'add'; - $this->Controller->Auth->initialize($this->Controller); - $result = $this->Controller->Auth->action(); - $this->assertEqual($result, 'ROOT/TestPlugin/AuthTest/add'); - } - /** * test that deny() converts camel case inputs to lowercase. * From 66f5ae07ed4a9a376b6340a604b6573670b0c100 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 16:27:52 -0500 Subject: [PATCH 259/668] Removing AuthComponent::validate() there are no tests and no documentation on this method. It also uses components that may or may not exist even in the old implementation. --- cake/libs/controller/components/auth.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index ea7b6e69c..c6b1e412a 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -605,28 +605,6 @@ class AuthComponent extends Component { return Router::normalize($redir); } -/** - * Validates a user against an abstract object. - * - * @param mixed $object The object to validate the user against. - * @param mixed $user Optional. The identity of the user to be validated. - * Uses the current user session if none specified. For - * valid forms of identifying users, see - * AuthComponent::identify(). - * @param string $action Optional. The action to validate against. - * @see AuthComponent::identify() - * @return boolean True if the user validates, false otherwise. - */ - public function validate($object, $user = null, $action = null) { - if (empty($user)) { - $user = $this->user(); - } - if (empty($user)) { - return false; - } - return $this->Acl->check($user, $object, $action); - } - /** * Returns a reference to the model object specified, and attempts * to load it if it is not found. From 35864c2a02c5bb54731a7eba41878e4524b85830 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 16:28:59 -0500 Subject: [PATCH 260/668] Removing AuthComponent::getModel(). Auth no longer directly interacts with models. --- cake/libs/controller/components/auth.php | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index c6b1e412a..6e02e13d3 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -605,29 +605,6 @@ class AuthComponent extends Component { return Router::normalize($redir); } -/** - * Returns a reference to the model object specified, and attempts - * to load it if it is not found. - * - * @param string $name Model name (defaults to AuthComponent::$userModel) - * @return object A reference to a model object - */ - public function &getModel($name = null) { - $model = null; - if (!$name) { - $name = $this->userModel; - } - - $model = ClassRegistry::init($name); - - if (empty($model)) { - trigger_error(__('Auth::getModel() - Model is not set or could not be found'), E_USER_WARNING); - return null; - } - - return $model; - } - /** * Use the configured authentication adapters, and attempt to identify the user * by credentials contained in $request. From b207ee8cbe2716f241137ba000e2c91132b740f2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 16:55:02 -0500 Subject: [PATCH 261/668] Making AuthComponent::user static, so user data can be fetched from anywhere. --- cake/libs/controller/components/auth.php | 20 +++++++++---------- .../libs/controller/components/auth.test.php | 7 ++----- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 6e02e13d3..7dd94840e 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -21,6 +21,7 @@ App::import('Core', 'Router', false); App::import('Core', 'Security', false); +App::import('Core', 'CakeSession', false); App::import('Component', 'auth/base_authorize'); /** @@ -159,7 +160,7 @@ class AuthComponent extends Component { * @var string * @link http://book.cakephp.org/view/1276/sessionKey */ - public $sessionKey = 'Auth.User'; + public static $sessionKey = 'Auth.User'; /** * If using action-based access control, this defines how the paths to action @@ -445,7 +446,7 @@ class AuthComponent extends Component { * * You can use allow with either an array, or var args. * - * `$this->Auth->allow(array('edit', 'add'));` + * `$this->Auth->allow(array('edit', 'add'));` or * `$this->Auth->allow('edit', 'add');` * * allow() also supports '*' as a wildcard to mean all actions. @@ -475,7 +476,7 @@ class AuthComponent extends Component { * * You can use deny with either an array, or var args. * - * `$this->Auth->deny(array('edit', 'add'));` + * `$this->Auth->deny(array('edit', 'add'));` or * `$this->Auth->deny('edit', 'add');` * * @param mixed $action Controller action name or array of actions @@ -534,7 +535,7 @@ class AuthComponent extends Component { $user = $this->identify($this->request); } if ($user) { - $this->Session->write($this->sessionKey, $user); + $this->Session->write(self::$sessionKey, $user); $this->_loggedIn = true; } return $this->_loggedIn; @@ -550,7 +551,7 @@ class AuthComponent extends Component { */ public function logout() { $this->__setDefaults(); - $this->Session->delete($this->sessionKey); + $this->Session->delete(self::$sessionKey); $this->Session->delete('Auth.redirect'); $this->_loggedIn = false; return Router::normalize($this->logoutRedirect); @@ -563,16 +564,15 @@ class AuthComponent extends Component { * @return mixed User record. or null if no user is logged in. * @link http://book.cakephp.org/view/1264/user */ - public function user($key = null) { - $this->__setDefaults(); - if (!$this->Session->check($this->sessionKey)) { + public static function user($key = null) { + if (!CakeSession::check(self::$sessionKey)) { return null; } if ($key == null) { - return $this->Session->read($this->sessionKey); + return CakeSession::read(self::$sessionKey); } else { - $user = $this->Session->read($this->sessionKey); + $user = CakeSession::read(self::$sessionKey); if (isset($user[$key])) { return $user[$key]; } diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 94f3b8d7b..1f3a2a49b 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -1178,8 +1178,7 @@ class AuthTest extends CakeTestCase { 'Auth' => array( 'fields' => array('username' => 'email', 'password' => 'password'), 'loginAction' => array('controller' => 'people', 'action' => 'login'), - 'userModel' => 'AuthUserCustomField', - 'sessionKey' => 'AltAuth.AuthUserCustomField' + 'userModel' => 'AuthUserCustomField' ), 'Session' ); @@ -1212,14 +1211,12 @@ class AuthTest extends CakeTestCase { 'fields' => array('username' => 'email', 'password' => 'password'), 'loginAction' => array('controller' => 'people', 'action' => 'login'), 'logoutRedirect' => array('controller' => 'people', 'action' => 'login'), - 'userModel' => 'AuthUserCustomField', - 'sessionKey' => 'AltAuth.AuthUserCustomField' + 'userModel' => 'AuthUserCustomField' ); $this->assertEqual($expected['fields'], $this->Controller->Auth->fields); $this->assertEqual($expected['loginAction'], $this->Controller->Auth->loginAction); $this->assertEqual($expected['logoutRedirect'], $this->Controller->Auth->logoutRedirect); $this->assertEqual($expected['userModel'], $this->Controller->Auth->userModel); - $this->assertEqual($expected['sessionKey'], $this->Controller->Auth->sessionKey); } /** From 41819975e869beeb9b42ffe10c68612f7baf5d62 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 17:04:10 -0500 Subject: [PATCH 262/668] Removing a dead property. --- cake/libs/controller/components/auth.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 7dd94840e..7b41e499f 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -209,12 +209,6 @@ class AuthComponent extends Component { */ public $logoutRedirect = null; -/** - * The name of model or model object, or any other object has an isAuthorized method. - * - * @var string - */ - public $object = null; /** * Error to display when user login fails. For security purposes, only one error is used for all From ee804c6f8cef2c4f0b99f678847cc7a126086222 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 17:55:04 -0500 Subject: [PATCH 263/668] Removing properties from AuthComponent that have been moved to authentication and authorization objects. Adding the '*' key to allow code to stay DRY, also adding a constant for ALL, so there aren't as many magic strings around. Updating tests. --- cake/libs/controller/components/auth.php | 145 ++++++++---------- .../libs/controller/components/auth.test.php | 24 +-- 2 files changed, 76 insertions(+), 93 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 7b41e499f..5f4631ab8 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -34,6 +34,8 @@ App::import('Component', 'auth/base_authorize'); */ class AuthComponent extends Component { + const ALL = '*'; + /** * Maintains current user login state. * @@ -52,7 +54,30 @@ class AuthComponent extends Component { * An array of authentication objects to use for authenticating users. You can configure * multiple adapters and they will be checked sequentially when users are identified. * - * @var object + * {{{ + * $this->Auth->authenticate = array( + * 'Form' => array( + * 'userModel' => 'Users.User' + * ) + * ); + * }}} + * + * Using the class name without 'Authenticate' as the key, you can pass in an array of settings for each + * authentication object. Additionally you can define settings that should be set to all authentications objects + * using the '*' key: + * + * {{{ + * $this->Auth->authenticate = array( + * '*' => array( + * 'userModel' => 'Users.User', + * 'scope' => array('User.active' => 1) + * ), + * 'Form', + * 'Basic' + * ); + * }}} + * + * @var array * @link http://book.cakephp.org/view/1278/authenticate */ public $authenticate = array('Form'); @@ -64,22 +89,32 @@ class AuthComponent extends Component { */ protected $_authenticateObjects = array(); -/** - * A hash mapping legacy properties => to settings passed into Authenticate objects. - * - * @var string - * @deprecated Will be removed in 2.1+ - */ - protected $_authenticateLegacyMap = array( - 'userModel' => 'userModel', - 'userScope' => 'scope', - 'fields' => 'fields' - ); - /** * An array of authorization objects to use for authorizing users. You can configure * multiple adapters and they will be checked sequentially when authorization checks are done. * + * {{{ + * $this->Auth->authorize = array( + * 'Crud' => array( + * 'actionPath' => 'controllers/' + * ) + * ); + * }}} + * + * Using the class name without 'Authorize' as the key, you can pass in an array of settings for each + * authorization object. Additionally you can define settings that should be set to all authorization objects + * using the '*' key: + * + * {{{ + * $this->Auth->authorize = array( + * '*' => array( + * 'actionPath' => 'controllers/' + * ), + * 'Crud', + * 'CustomAuth' + * ); + * }}} + * * @var mixed * @link http://book.cakephp.org/view/1275/authorize */ @@ -92,16 +127,6 @@ class AuthComponent extends Component { */ protected $_authorizeObjects = array(); -/** - * A hash mapping legacy properties => to settings passed into Authorize objects. - * - * @var string - * @deprecated Will be removed in 2.1+ - */ - protected $_authorizeLegacyMap = array( - 'actionPath' => 'actionPath', - ); - /** * The name of an optional view element to render when an Ajax request is made * with an invalid or expired session @@ -127,32 +152,6 @@ class AuthComponent extends Component { 'params' => array() ); -/** - * The name of the model that represents users which will be authenticated. Defaults to 'User'. - * - * @var string - * @link http://book.cakephp.org/view/1266/userModel - */ - public $userModel = 'User'; - -/** - * Additional query conditions to use when looking up and authenticating users, - * i.e. array('User.is_active' => 1). - * - * @var array - * @link http://book.cakephp.org/view/1268/userScope - */ - public $userScope = array(); - -/** - * Allows you to specify non-default login name and password fields used in - * $userModel, i.e. array('username' => 'login_name', 'password' => 'passwd'). - * - * @var array - * @link http://book.cakephp.org/view/1267/fields - */ - public $fields = array('username' => 'username', 'password' => 'password'); - /** * The session key name where the record of the current user is stored. If * unspecified, it will be "Auth.User". @@ -162,17 +161,6 @@ class AuthComponent extends Component { */ public static $sessionKey = 'Auth.User'; -/** - * If using action-based access control, this defines how the paths to action - * ACO nodes is computed. If, for example, all controller nodes are nested - * under an ACO node named 'Controllers', $actionPath should be set to - * "Controllers/". - * - * @var string - * @link http://book.cakephp.org/view/1279/actionPath - */ - public $actionPath = null; - /** * A URL (defined as a string or array) to the controller action that handles * logins. Defaults to `/users/login` @@ -209,7 +197,6 @@ class AuthComponent extends Component { */ public $logoutRedirect = null; - /** * Error to display when user login fails. For security purposes, only one error is used for all * login failures, so as not to expose information on why the login failed. @@ -228,14 +215,6 @@ class AuthComponent extends Component { */ public $authError = null; -/** - * Determines whether AuthComponent will automatically redirect and exit if login is successful. - * - * @var boolean - * @link http://book.cakephp.org/view/1274/autoRedirect - */ - public $autoRedirect = true; - /** * Controller actions for which user validation is not required. * @@ -416,7 +395,13 @@ class AuthComponent extends Component { return; } $this->_authorizeObjects = array(); - foreach (Set::normalize($this->authorize) as $class => $settings) { + $config = Set::normalize($this->authorize); + $global = array(); + if (isset($config[AuthComponent::ALL])) { + $global = $config[AuthComponent::ALL]; + unset($config[AuthComponent::ALL]); + } + foreach ($config as $class => $settings) { $className = $class . 'Authorize'; if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authorize')) { throw new CakeException(__('Authorization adapter "%s" was not found.', $class)); @@ -424,11 +409,7 @@ class AuthComponent extends Component { if (!method_exists($className, 'authorize')) { throw new CakeException(__('Authorization objects must implement an authorize method.')); } - foreach ($this->_authorizeLegacyMap as $old => $new) { - if (empty($settings[$new]) && !empty($this->{$old})) { - $settings[$new] = $this->{$old}; - } - } + $settings = array_merge($global, (array)$settings); $this->_authorizeObjects[] = new $className($this->_Collection->getController(), $settings); } return $this->_authorizeObjects; @@ -629,7 +610,13 @@ class AuthComponent extends Component { return; } $this->_authenticateObjects = array(); - foreach (Set::normalize($this->authenticate) as $class => $settings) { + $config = Set::normalize($this->authenticate); + $global = array(); + if (isset($config[AuthComponent::ALL])) { + $global = $config[AuthComponent::ALL]; + unset($config[AuthComponent::ALL]); + } + foreach ($config as $class => $settings) { $className = $class . 'Authenticate'; if (!class_exists($className) && !App::import('Component', 'auth/' . $class . '_authenticate')) { throw new CakeException(__('Authentication adapter "%s" was not found.', $class)); @@ -637,11 +624,7 @@ class AuthComponent extends Component { if (!method_exists($className, 'authenticate')) { throw new CakeException(__('Authentication objects must implement an authenticate method.')); } - foreach ($this->_authenticateLegacyMap as $old => $new) { - if (empty($settings[$new]) && !empty($this->{$old})) { - $settings[$new] = $this->{$old}; - } - } + $settings = array_merge((array)$settings, $global); $this->_authenticateObjects[] = new $className($settings); } return $this->_authenticateObjects; diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 1f3a2a49b..bb5d5e29b 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -744,14 +744,15 @@ class AuthTest extends CakeTestCase { } /** - * test that loadAuthorize merges in legacy authorize settings. + * test the * key with authenticate * * @return void */ - function testLoadAuthorizeSettingsPass() { - $this->Controller->Auth->actionPath = 'controllers/'; - - $this->Controller->Auth->authorize = array('Actions'); + function testAllConfigWithAuthorize() { + $this->Controller->Auth->authorize = array( + AuthComponent::ALL => array('actionPath' => 'controllers/'), + 'Actions' + ); $objects = $this->Controller->Auth->constructAuthorize(); $result = $objects[0]; $this->assertEquals($result->settings['actionPath'], 'controllers/'); @@ -774,16 +775,15 @@ class AuthTest extends CakeTestCase { } /** - * test that loadAuthenticate merges in legacy authentication settings. + * test the * key with authenticate * * @return void */ - function testLoadAuthenticateSettingsPass() { - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->userScope = array('AuthUser.active' => 1); - $this->Controller->Auth->fields = array('username' => 'user', 'password' => 'passwd'); - - $this->Controller->Auth->authenticate = array('Form'); + function testAllConfigWithAuthenticate() { + $this->Controller->Auth->authenticate = array( + AuthComponent::ALL => array('userModel' => 'AuthUser'), + 'Form' + ); $objects = $this->Controller->Auth->constructAuthenticate(); $result = $objects[0]; $this->assertEquals($result->settings['userModel'], 'AuthUser'); From 041e0a65aca39e77f960e127228953b3947d003a Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 18:09:41 -0500 Subject: [PATCH 264/668] Extracting a base class. --- .../components/auth/base_authenticate.php | 69 +++++++++++++++++++ .../components/auth/form_authenticate.php | 41 +---------- 2 files changed, 71 insertions(+), 39 deletions(-) create mode 100644 cake/libs/controller/components/auth/base_authenticate.php diff --git a/cake/libs/controller/components/auth/base_authenticate.php b/cake/libs/controller/components/auth/base_authenticate.php new file mode 100644 index 000000000..2bc8ad725 --- /dev/null +++ b/cake/libs/controller/components/auth/base_authenticate.php @@ -0,0 +1,69 @@ + 1).` + * + * @var array + */ + public $settings = array( + 'fields' => array( + 'username' => 'username', + 'password' => 'password' + ), + 'userModel' => 'User', + 'scope' => array() + ); + +/** + * Constructor + * + * @param array $settings Array of settings to use. + */ + public function __construct($settings) { + $this->settings = Set::merge($this->settings, $settings); + } + +/** + * Hash the supplied password using the configured hashing method. + * + * @param string $password The password to hash. + * @return string Hashed string + */ + public function hash($password) { + return Security::hash($password, null, true); + } + +/** + * Authenticate a user based on the request information. + * + * @param CakeRequest $request Request to get authentication information from. + * @return mixed Either false on failure, or an array of user data on success. + */ + abstract public function authenticate(CakeRequest $request); +} \ No newline at end of file diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/cake/libs/controller/components/auth/form_authenticate.php index ce4a6e7c9..3f284eaf2 100644 --- a/cake/libs/controller/components/auth/form_authenticate.php +++ b/cake/libs/controller/components/auth/form_authenticate.php @@ -12,7 +12,7 @@ * @link http://cakephp.org CakePHP(tm) Project * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Security'); +App::import('Component', 'auth/base_authenticate'); /** * An authentication adapter for AuthComponent. Provides the ability to authenticate using POST @@ -33,35 +33,7 @@ App::import('Core', 'Security'); * @since 2.0 * @see AuthComponent::$authenticate */ -class FormAuthenticate { - -/** - * Settings for this object. - * - * - `fields` The fields to use to identify a user by. - * - `userModel` The model name of the User, defaults to User. - * - `scope` Additional conditions to use when looking up and authenticating users, - * i.e. `array('User.is_active' => 1).` - * - * @var array - */ - public $settings = array( - 'fields' => array( - 'username' => 'username', - 'password' => 'password' - ), - 'userModel' => 'User', - 'scope' => array() - ); - -/** - * Constructor - * - * @param array $settings Array of settings to use. - */ - public function __construct($settings) { - $this->settings = Set::merge($this->settings, $settings); - } +class FormAuthenticate extends BaseAuthenticate { /** * Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields` @@ -103,13 +75,4 @@ class FormAuthenticate { return $result[$model]; } -/** - * Hash the supplied password using the configured hashing method. - * - * @param string $password The password to hash. - * @return string Hashed string - */ - public function hash($password) { - return Security::hash($password, null, true); - } } \ No newline at end of file From 332b6cfc223fb10c7860486a0c03f6f06edc6345 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 18:10:45 -0500 Subject: [PATCH 265/668] Adding basic authentication skeleton. --- .../components/auth/basic_authenticate.php | 27 ++++ .../auth/basic_authenticate.test.php | 146 ++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 cake/libs/controller/components/auth/basic_authenticate.php create mode 100644 cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/cake/libs/controller/components/auth/basic_authenticate.php new file mode 100644 index 000000000..af1361bd1 --- /dev/null +++ b/cake/libs/controller/components/auth/basic_authenticate.php @@ -0,0 +1,27 @@ +auth = new BasicAuthenticate(array( + 'fields' => array('username' => 'user', 'password' => 'password'), + 'userModel' => 'User' + )); + $password = Security::hash('password', null, true); + ClassRegistry::init('User')->updateAll(array('password' => '"' . $password . '"')); + } + +/** + * test applying settings in the constructor + * + * @return void + */ + function testConstructor() { + $object = new BasicAuthenticate(array( + 'userModel' => 'AuthUser', + 'fields' => array('username' => 'user', 'password' => 'password') + )); + $this->assertEquals('AuthUser', $object->settings['userModel']); + $this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->settings['fields']); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateNoData() { + $request = new CakeRequest('posts/index', false); + $request->data = array(); + $this->assertFalse($this->auth->authenticate($request)); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateNoUsername() { + $request = new CakeRequest('posts/index', false); + $request->data = array('User' => array('password' => 'foobar')); + $this->assertFalse($this->auth->authenticate($request)); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateNoPassword() { + $request = new CakeRequest('posts/index', false); + $request->data = array('User' => array('user' => 'mariano')); + $this->assertFalse($this->auth->authenticate($request)); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateInjection() { + $request = new CakeRequest('posts/index', false); + $request->data = array( + 'User' => array( + 'user' => '> 1', + 'password' => "' OR 1 = 1" + )); + $this->assertFalse($this->auth->authenticate($request)); + } + +/** + * test authenticate sucesss + * + * @return void + */ + function testAuthenticateSuccess() { + $request = new CakeRequest('posts/index', false); + $request->data = array('User' => array( + 'user' => 'mariano', + 'password' => 'password' + )); + $result = $this->auth->authenticate($request); + $expected = array( + 'id' => 1, + 'user' => 'mariano', + 'created' => '2007-03-17 01:16:23', + 'updated' => '2007-03-17 01:18:31' + ); + $this->assertEquals($expected, $result); + } + +/** + * test scope failure. + * + * @return void + */ + function testAuthenticateScopeFail() { + $this->auth->settings['scope'] = array('user' => 'nate'); + $request = new CakeRequest('posts/index', false); + $request->data = array('User' => array( + 'user' => 'mariano', + 'password' => 'password' + )); + + $this->assertFalse($this->auth->authenticate($request)); + } + +} \ No newline at end of file From ba02483ae8b641c64cec5122dffa4d3df4060a5c Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 19:56:23 -0500 Subject: [PATCH 266/668] Adding a response parameter to authenticate() both basic and digest auth need to set response headers. --- cake/libs/controller/components/auth.php | 16 ++++++++++++---- .../components/auth/base_authenticate.php | 3 ++- .../components/auth/form_authenticate.php | 3 ++- .../components/auth/form_authenticate.test.php | 16 +++++++++------- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 5f4631ab8..7f12d9842 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -34,7 +34,7 @@ App::import('Component', 'auth/base_authorize'); */ class AuthComponent extends Component { - const ALL = '*'; + const ALL = 'all'; /** * Maintains current user login state. @@ -231,6 +231,13 @@ class AuthComponent extends Component { */ public $request; +/** + * Response object + * + * @var CakeResponse + */ + public $response; + /** * Method list for bound controller * @@ -246,6 +253,7 @@ class AuthComponent extends Component { */ public function initialize($controller) { $this->request = $controller->request; + $this->response = $controller->response; $this->_methods = $controller->methods; if (Configure::read('debug') > 0) { @@ -507,7 +515,7 @@ class AuthComponent extends Component { $this->_loggedIn = false; if (empty($user)) { - $user = $this->identify($this->request); + $user = $this->identify($this->request, $this->response); } if ($user) { $this->Session->write(self::$sessionKey, $user); @@ -587,12 +595,12 @@ class AuthComponent extends Component { * @param CakeRequest $request The request that contains authentication data. * @return array User record data, or false, if the user could not be identified. */ - public function identify(CakeRequest $request) { + public function identify(CakeRequest $request, CakeResponse $response) { if (empty($this->_authenticateObjects)) { $this->constructAuthenticate(); } foreach ($this->_authenticateObjects as $auth) { - $result = $auth->authenticate($request); + $result = $auth->authenticate($request, $response); if (!empty($result) && is_array($result)) { return $result; } diff --git a/cake/libs/controller/components/auth/base_authenticate.php b/cake/libs/controller/components/auth/base_authenticate.php index 2bc8ad725..8c9fb145d 100644 --- a/cake/libs/controller/components/auth/base_authenticate.php +++ b/cake/libs/controller/components/auth/base_authenticate.php @@ -63,7 +63,8 @@ abstract class BaseAuthenticate { * Authenticate a user based on the request information. * * @param CakeRequest $request Request to get authentication information from. + * @param CakeResponse $response A response object that can have headers added. * @return mixed Either false on failure, or an array of user data on success. */ - abstract public function authenticate(CakeRequest $request); + abstract public function authenticate(CakeRequest $request, CakeResponse $response); } \ No newline at end of file diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/cake/libs/controller/components/auth/form_authenticate.php index 3f284eaf2..24b472376 100644 --- a/cake/libs/controller/components/auth/form_authenticate.php +++ b/cake/libs/controller/components/auth/form_authenticate.php @@ -41,9 +41,10 @@ class FormAuthenticate extends BaseAuthenticate { * there is no post data, either username or password is missing, of if the scope conditions have not been met. * * @param CakeRequest $request The request that contains login information. + * @param CakeResponse $response Unused response object. * @return mixed. False on login failure. An array of User data on success. */ - public function authenticate(CakeRequest $request) { + public function authenticate(CakeRequest $request, CakeResponse $response) { $userModel = $this->settings['userModel']; list($plugin, $model) = pluginSplit($userModel); diff --git a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php index b2218a75b..e6b5a4aa7 100644 --- a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php @@ -17,6 +17,7 @@ App::import('Component', 'auth/form_authenticate'); App::import('Model', 'AppModel'); App::import('Core', 'CakeRequest'); +App::import('Core', 'CakeResponse'); require_once CAKE_TESTS . 'cases' . DS . 'libs' . DS . 'model' . DS . 'models.php'; @@ -42,6 +43,7 @@ class FormAuthenticateTest extends CakeTestCase { )); $password = Security::hash('password', null, true); ClassRegistry::init('User')->updateAll(array('password' => '"' . $password . '"')); + $this->response = $this->getMock('CakeResponse'); } /** @@ -66,7 +68,7 @@ class FormAuthenticateTest extends CakeTestCase { function testAuthenticateNoData() { $request = new CakeRequest('posts/index', false); $request->data = array(); - $this->assertFalse($this->auth->authenticate($request)); + $this->assertFalse($this->auth->authenticate($request, $this->response)); } /** @@ -77,7 +79,7 @@ class FormAuthenticateTest extends CakeTestCase { function testAuthenticateNoUsername() { $request = new CakeRequest('posts/index', false); $request->data = array('User' => array('password' => 'foobar')); - $this->assertFalse($this->auth->authenticate($request)); + $this->assertFalse($this->auth->authenticate($request, $this->response)); } /** @@ -88,7 +90,7 @@ class FormAuthenticateTest extends CakeTestCase { function testAuthenticateNoPassword() { $request = new CakeRequest('posts/index', false); $request->data = array('User' => array('user' => 'mariano')); - $this->assertFalse($this->auth->authenticate($request)); + $this->assertFalse($this->auth->authenticate($request, $this->response)); } /** @@ -103,7 +105,7 @@ class FormAuthenticateTest extends CakeTestCase { 'user' => '> 1', 'password' => "' OR 1 = 1" )); - $this->assertFalse($this->auth->authenticate($request)); + $this->assertFalse($this->auth->authenticate($request, $this->response)); } /** @@ -117,7 +119,7 @@ class FormAuthenticateTest extends CakeTestCase { 'user' => 'mariano', 'password' => 'password' )); - $result = $this->auth->authenticate($request); + $result = $this->auth->authenticate($request, $this->response); $expected = array( 'id' => 1, 'user' => 'mariano', @@ -140,7 +142,7 @@ class FormAuthenticateTest extends CakeTestCase { 'password' => 'password' )); - $this->assertFalse($this->auth->authenticate($request)); + $this->assertFalse($this->auth->authenticate($request, $this->response)); } /** @@ -170,7 +172,7 @@ class FormAuthenticateTest extends CakeTestCase { 'password' => 'cake' )); - $result = $this->auth->authenticate($request); + $result = $this->auth->authenticate($request, $this->response); $expected = array( 'id' => 1, 'username' => 'gwoo', From 67c4c9a693b4f2a0ad3f56577d57a1c6f278ed71 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 20:28:03 -0500 Subject: [PATCH 267/668] Fix failing test and removing tests for settings that no longer exist. --- .../libs/controller/components/auth.test.php | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index bb5d5e29b..502c5dfe5 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -740,7 +740,7 @@ class AuthTest extends CakeTestCase { */ function testLoadAuthenticateNoFile() { $this->Controller->Auth->authenticate = 'Missing'; - $this->Controller->Auth->identify($this->Controller->request); + $this->Controller->Auth->identify($this->Controller->request, $this->Controller->response); } /** @@ -1176,9 +1176,7 @@ class AuthTest extends CakeTestCase { $this->Controller->components = array( 'Auth' => array( - 'fields' => array('username' => 'email', 'password' => 'password'), 'loginAction' => array('controller' => 'people', 'action' => 'login'), - 'userModel' => 'AuthUserCustomField' ), 'Session' ); @@ -1186,37 +1184,12 @@ class AuthTest extends CakeTestCase { $this->Controller->Components->trigger('initialize', array(&$this->Controller)); Router::reload(); - $this->AuthUserCustomField = new AuthUserCustomField(); - $user = array( - 'id' => 1, 'email' => 'harking@example.com', - 'password' => Security::hash(Configure::read('Security.salt') . 'cake' - )); - $user = $this->AuthUserCustomField->save($user, false); - - Router::connect('/', array('controller' => 'people', 'action' => 'login')); - $url = '/'; - $this->Controller->request->addParams(Router::parse($url)); - Router::setRequestInfo($this->Controller->request); - $this->Controller->request->data['AuthUserCustomField'] = array( - 'email' => 'harking@example.com', 'password' => 'cake' - ); - $this->Controller->request->query['url'] = substr($url, 1); - $this->Controller->Auth->startup($this->Controller); - $this->Controller->Auth->login(); - - $user = $this->Controller->Auth->user(); - $this->assertTrue(!!$user); - $expected = array( - 'fields' => array('username' => 'email', 'password' => 'password'), 'loginAction' => array('controller' => 'people', 'action' => 'login'), 'logoutRedirect' => array('controller' => 'people', 'action' => 'login'), - 'userModel' => 'AuthUserCustomField' ); - $this->assertEqual($expected['fields'], $this->Controller->Auth->fields); $this->assertEqual($expected['loginAction'], $this->Controller->Auth->loginAction); $this->assertEqual($expected['logoutRedirect'], $this->Controller->Auth->logoutRedirect); - $this->assertEqual($expected['userModel'], $this->Controller->Auth->userModel); } /** From e8bf6ed176136b6923486d88eefa104755e7f6c4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 20:28:24 -0500 Subject: [PATCH 268/668] Basic tests for BasicAuthenticate are passing. --- .../components/auth/basic_authenticate.php | 77 +++++++++++- .../auth/basic_authenticate.test.php | 111 ++++++++++++++---- 2 files changed, 162 insertions(+), 26 deletions(-) diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/cake/libs/controller/components/auth/basic_authenticate.php index af1361bd1..085b0770c 100644 --- a/cake/libs/controller/components/auth/basic_authenticate.php +++ b/cake/libs/controller/components/auth/basic_authenticate.php @@ -13,15 +13,88 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Component', 'auth/base_authenticate'); +App::import('Core', 'String'); + class BasicAuthenticate extends BaseAuthenticate { +/** + * Settings for this object. + * + * - `fields` The fields to use to identify a user by. + * - `userModel` The model name of the User, defaults to User. + * - `scope` Additional conditions to use when looking up and authenticating users, + * i.e. `array('User.is_active' => 1).` + * + * @var array + */ + public $settings = array( + 'fields' => array( + 'username' => 'username', + 'password' => 'password' + ), + 'userModel' => 'User', + 'scope' => array(), + 'realm' => '', + ); + +/** + * Constructor, completes configuration for basic authentication. + * + * @return void + */ + public function __construct($settings) { + parent::__construct($settings); + if (empty($this->settings['realm'])) { + $this->settings['realm'] = env('SERVER_NAME'); + } + } /** * Authenticate a user using basic HTTP auth. Will use the configured User model and attempt a * login using basic HTTP auth. * + * @param CakeRequest $request The request to authenticate with. + * @param CakeResponse $response The response to add headers to. * @return mixed Either false on failure, or an array of user data on success. */ - public function authenticate(CakeRequest $request) { - + public function authenticate(CakeRequest $request, CakeResponse $response) { + $username = env('PHP_AUTH_USER'); + $pass = env('PHP_AUTH_PW'); + if (empty($username) || empty($pass)) { + $response->header($this->loginHeaders()); + return false; + } + $userModel = $this->settings['userModel']; + list($plugin, $model) = pluginSplit($userModel); + $fields = $this->settings['fields']; + + $conditions = array( + $model . '.' . $fields['username'] => $username, + $model . '.' . $fields['password'] => $this->hash($pass), + ); + if (!empty($this->settings['scope'])) { + $conditions = array_merge($conditions, $this->settings['scope']); + } + $result = ClassRegistry::init($userModel)->find('first', array( + 'conditions' => $conditions, + 'recursive' => 0 + )); + if (empty($result) || empty($result[$model])) { + $response->header($this->loginHeaders()); + $response->header('Location', Router::reverse($request)); + $response->statusCode(401); + $response->send(); + return false; + } + unset($result[$model][$fields['password']]); + return $result[$model]; + } + +/** + * Generate the login headers + * + * @return string Headers for logging in. + */ + public function loginHeaders() { + return sprintf('WWW-Authenticate: Basic realm="%s"', $this->settings['realm']); } } \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php index 7da7e692b..867b50c11 100644 --- a/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php @@ -17,6 +17,8 @@ App::import('Component', 'auth/basic_authenticate'); App::import('Model', 'AppModel'); App::import('Core', 'CakeRequest'); +App::import('Core', 'CakeResponse'); + require_once CAKE_TESTS . 'cases' . DS . 'libs' . DS . 'model' . DS . 'models.php'; @@ -38,10 +40,24 @@ class BasicAuthenticateTest extends CakeTestCase { parent::setUp(); $this->auth = new BasicAuthenticate(array( 'fields' => array('username' => 'user', 'password' => 'password'), - 'userModel' => 'User' + 'userModel' => 'User', + 'realm' => 'localhost', )); + $password = Security::hash('password', null, true); ClassRegistry::init('User')->updateAll(array('password' => '"' . $password . '"')); + $this->server = $_SERVER; + $this->response = $this->getMock('CakeResponse'); + } + +/** + * teardown + * + * @return void + */ + function tearDown() { + parent::tearDown(); + $_SERVER = $this->server; } /** @@ -56,6 +72,7 @@ class BasicAuthenticateTest extends CakeTestCase { )); $this->assertEquals('AuthUser', $object->settings['userModel']); $this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->settings['fields']); + $this->assertEquals(env('SERVER_NAME'), $object->settings['realm']); } /** @@ -65,8 +82,12 @@ class BasicAuthenticateTest extends CakeTestCase { */ function testAuthenticateNoData() { $request = new CakeRequest('posts/index', false); - $request->data = array(); - $this->assertFalse($this->auth->authenticate($request)); + + $this->response->expects($this->once()) + ->method('header') + ->with('WWW-Authenticate: Basic realm="localhost"'); + + $this->assertFalse($this->auth->authenticate($request, $this->response)); } /** @@ -76,8 +97,13 @@ class BasicAuthenticateTest extends CakeTestCase { */ function testAuthenticateNoUsername() { $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array('password' => 'foobar')); - $this->assertFalse($this->auth->authenticate($request)); + $_SERVER['PHP_AUTH_PW'] = 'foobar'; + + $this->response->expects($this->once()) + ->method('header') + ->with('WWW-Authenticate: Basic realm="localhost"'); + + $this->assertFalse($this->auth->authenticate($request, $this->response)); } /** @@ -87,8 +113,13 @@ class BasicAuthenticateTest extends CakeTestCase { */ function testAuthenticateNoPassword() { $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array('user' => 'mariano')); - $this->assertFalse($this->auth->authenticate($request)); + $_SERVER['PHP_AUTH_USER'] = 'mariano'; + + $this->response->expects($this->once()) + ->method('header') + ->with('WWW-Authenticate: Basic realm="localhost"'); + + $this->assertFalse($this->auth->authenticate($request, $this->response)); } /** @@ -98,14 +129,30 @@ class BasicAuthenticateTest extends CakeTestCase { */ function testAuthenticateInjection() { $request = new CakeRequest('posts/index', false); - $request->data = array( - 'User' => array( - 'user' => '> 1', - 'password' => "' OR 1 = 1" - )); - $this->assertFalse($this->auth->authenticate($request)); + $request->addParams(array('pass' => array(), 'named' => array())); + + $_SERVER['PHP_AUTH_USER'] = '> 1'; + $_SERVER['PHP_AUTH_PW'] = "' OR 1 = 1"; + + $this->assertFalse($this->auth->authenticate($request, $this->response)); } +/** + * test that challenge headers are sent when no credentials are found. + * + * @return void + */ + function testAuthenticateChallenge() { + $request = new CakeRequest('posts/index', false); + $request->addParams(array('pass' => array(), 'named' => array())); + + $this->response->expects($this->once()) + ->method('header') + ->with('WWW-Authenticate: Basic realm="localhost"'); + + $result = $this->auth->authenticate($request, $this->response); + $this->assertFalse($result); + } /** * test authenticate sucesss * @@ -113,11 +160,12 @@ class BasicAuthenticateTest extends CakeTestCase { */ function testAuthenticateSuccess() { $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array( - 'user' => 'mariano', - 'password' => 'password' - )); - $result = $this->auth->authenticate($request); + $request->addParams(array('pass' => array(), 'named' => array())); + + $_SERVER['PHP_AUTH_USER'] = 'mariano'; + $_SERVER['PHP_AUTH_PW'] = 'password'; + + $result = $this->auth->authenticate($request, $this->response); $expected = array( 'id' => 1, 'user' => 'mariano', @@ -132,15 +180,30 @@ class BasicAuthenticateTest extends CakeTestCase { * * @return void */ - function testAuthenticateScopeFail() { + function testAuthenticateFailReChallenge() { $this->auth->settings['scope'] = array('user' => 'nate'); $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array( - 'user' => 'mariano', - 'password' => 'password' - )); + $request->addParams(array('pass' => array(), 'named' => array())); - $this->assertFalse($this->auth->authenticate($request)); + $_SERVER['PHP_AUTH_USER'] = 'mariano'; + $_SERVER['PHP_AUTH_PW'] = 'password'; + + $this->response->expects($this->at(0)) + ->method('header') + ->with('WWW-Authenticate: Basic realm="localhost"'); + + $this->response->expects($this->at(1)) + ->method('header') + ->with('Location', Router::reverse($request)); + + $this->response->expects($this->at(2)) + ->method('statusCode') + ->with(401); + + $this->response->expects($this->at(3)) + ->method('send'); + + $this->assertFalse($this->auth->authenticate($request, $this->response)); } } \ No newline at end of file From 4610a0bf3cda634cf66c07bd411e1553d0caf14e Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 20:41:02 -0500 Subject: [PATCH 269/668] Adding some more tests for basic auth challenge headers. --- cake/libs/controller/components/auth/basic_authenticate.php | 3 +++ .../controller/components/auth/basic_authenticate.test.php | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/cake/libs/controller/components/auth/basic_authenticate.php index 085b0770c..0ce840ca5 100644 --- a/cake/libs/controller/components/auth/basic_authenticate.php +++ b/cake/libs/controller/components/auth/basic_authenticate.php @@ -59,10 +59,13 @@ class BasicAuthenticate extends BaseAuthenticate { public function authenticate(CakeRequest $request, CakeResponse $response) { $username = env('PHP_AUTH_USER'); $pass = env('PHP_AUTH_PW'); + if (empty($username) || empty($pass)) { $response->header($this->loginHeaders()); + $response->send(); return false; } + $userModel = $this->settings['userModel']; list($plugin, $model) = pluginSplit($userModel); $fields = $this->settings['fields']; diff --git a/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php index 867b50c11..656ca0fbb 100644 --- a/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php @@ -146,10 +146,13 @@ class BasicAuthenticateTest extends CakeTestCase { $request = new CakeRequest('posts/index', false); $request->addParams(array('pass' => array(), 'named' => array())); - $this->response->expects($this->once()) + $this->response->expects($this->at(0)) ->method('header') ->with('WWW-Authenticate: Basic realm="localhost"'); + $this->response->expects($this->at(1)) + ->method('send'); + $result = $this->auth->authenticate($request, $this->response); $this->assertFalse($result); } From bcd8dcd0f7f997ed1094e6391ff6ce5e879d6fd0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 21 Jan 2011 20:52:38 -0500 Subject: [PATCH 270/668] Extracting common logic into the base class. --- .../components/auth/base_authenticate.php | 30 +++++++++++++++++++ .../components/auth/basic_authenticate.php | 20 ++----------- .../components/auth/form_authenticate.php | 18 ++--------- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/cake/libs/controller/components/auth/base_authenticate.php b/cake/libs/controller/components/auth/base_authenticate.php index 8c9fb145d..0753640f8 100644 --- a/cake/libs/controller/components/auth/base_authenticate.php +++ b/cake/libs/controller/components/auth/base_authenticate.php @@ -59,6 +59,36 @@ abstract class BaseAuthenticate { return Security::hash($password, null, true); } +/** + * Find a user record using the standard options. + * + * @param string $username The username/identifier. + * @param string $password The unhashed password. + * @return Mixed Either false on failure, or an array of user data. + */ + protected function _findUser($username, $password) { + $userModel = $this->settings['userModel']; + list($plugin, $model) = pluginSplit($userModel); + $fields = $this->settings['fields']; + + $conditions = array( + $model . '.' . $fields['username'] => $username, + $model . '.' . $fields['password'] => $this->hash($password), + ); + if (!empty($this->settings['scope'])) { + $conditions = array_merge($conditions, $this->settings['scope']); + } + $result = ClassRegistry::init($userModel)->find('first', array( + 'conditions' => $conditions, + 'recursive' => 0 + )); + if (empty($result) || empty($result[$model])) { + return false; + } + unset($result[$model][$fields['password']]); + return $result[$model]; + } + /** * Authenticate a user based on the request information. * diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/cake/libs/controller/components/auth/basic_authenticate.php index 0ce840ca5..3d6cbc845 100644 --- a/cake/libs/controller/components/auth/basic_authenticate.php +++ b/cake/libs/controller/components/auth/basic_authenticate.php @@ -66,30 +66,16 @@ class BasicAuthenticate extends BaseAuthenticate { return false; } - $userModel = $this->settings['userModel']; - list($plugin, $model) = pluginSplit($userModel); - $fields = $this->settings['fields']; + $result = $this->_findUser($username, $pass); - $conditions = array( - $model . '.' . $fields['username'] => $username, - $model . '.' . $fields['password'] => $this->hash($pass), - ); - if (!empty($this->settings['scope'])) { - $conditions = array_merge($conditions, $this->settings['scope']); - } - $result = ClassRegistry::init($userModel)->find('first', array( - 'conditions' => $conditions, - 'recursive' => 0 - )); - if (empty($result) || empty($result[$model])) { + if (empty($result)) { $response->header($this->loginHeaders()); $response->header('Location', Router::reverse($request)); $response->statusCode(401); $response->send(); return false; } - unset($result[$model][$fields['password']]); - return $result[$model]; + return $result; } /** diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/cake/libs/controller/components/auth/form_authenticate.php index 24b472376..d24d9acf2 100644 --- a/cake/libs/controller/components/auth/form_authenticate.php +++ b/cake/libs/controller/components/auth/form_authenticate.php @@ -58,22 +58,10 @@ class FormAuthenticate extends BaseAuthenticate { ) { return false; } - $conditions = array( - $model . '.' . $fields['username'] => $request->data[$model][$fields['username']], - $model . '.' . $fields['password'] => $this->hash($request->data[$model][$fields['password']]), + return $this->_findUser( + $request->data[$model][$fields['username']], + $request->data[$model][$fields['password']] ); - if (!empty($this->settings['scope'])) { - $conditions = array_merge($conditions, $this->settings['scope']); - } - $result = ClassRegistry::init($userModel)->find('first', array( - 'conditions' => $conditions, - 'recursive' => 0 - )); - if (empty($result) || empty($result[$model])) { - return false; - } - unset($result[$model][$fields['password']]); - return $result[$model]; } } \ No newline at end of file From 945e49ad09816c79892fdddbf9fe313317316fd9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 22 Jan 2011 13:29:56 -0500 Subject: [PATCH 271/668] Starting Digest auth, using Basic auth as a starting base. --- .../components/auth/digest_authenticate.php | 108 +++++++++ .../auth/digest_authenticate.test.php | 216 ++++++++++++++++++ 2 files changed, 324 insertions(+) create mode 100644 cake/libs/controller/components/auth/digest_authenticate.php create mode 100644 cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/cake/libs/controller/components/auth/digest_authenticate.php new file mode 100644 index 000000000..f58623315 --- /dev/null +++ b/cake/libs/controller/components/auth/digest_authenticate.php @@ -0,0 +1,108 @@ + 1).` + * + * @var array + */ + public $settings = array( + 'fields' => array( + 'username' => 'username', + 'password' => 'password' + ), + 'userModel' => 'User', + 'scope' => array(), + 'realm' => '', + 'qop' => 'auth', + 'nonce' => '', + 'opaque' => '' + ); + +/** + * Constructor, completes configuration for digest authentication. + * + * @return void + */ + public function __construct($settings) { + parent::__construct($settings); + if (empty($this->settings['realm'])) { + $this->settings['realm'] = env('SERVER_NAME'); + } + if (empty($this->settings['nonce'])) { + $this->settings['realm'] = uniqid(''); + } + if (empty($this->settings['opaque'])) { + $this->settings['opaque'] = md5($this->settings['realm']); + } + } +/** + * Authenticate a user using Digest HTTP auth. Will use the configured User model and attempt a + * login using Digest HTTP auth. + * + * @param CakeRequest $request The request to authenticate with. + * @param CakeResponse $response The response to add headers to. + * @return mixed Either false on failure, or an array of user data on success. + */ + public function authenticate(CakeRequest $request, CakeResponse $response) { + $username = env('PHP_AUTH_USER'); + $pass = env('PHP_AUTH_PW'); + + if (empty($username) || empty($pass)) { + $response->header($this->loginHeaders()); + $response->send(); + return false; + } + + $result = $this->_findUser($username, $pass); + + if (empty($result)) { + $response->header($this->loginHeaders()); + $response->header('Location', Router::reverse($request)); + $response->statusCode(401); + $response->send(); + return false; + } + return $result; + } + +/** + * Generate the login headers + * + * @return string Headers for logging in. + */ + public function loginHeaders() { + $options = array( + 'realm' => $this->settings['realm'], + 'qop' => $this->settings['qop'], + 'nonce' => $this->settings['nonce'], + 'opaque' => $this->settings['opaque'] + ); + $opts = array(); + foreach ($options as $k => $v) { + $opts[] = sprintf('%s="%s"', $k, $v); + } + return 'WWW-Authenticate: Digest ' . implode(',', $opts); + } +} \ No newline at end of file diff --git a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php new file mode 100644 index 000000000..40a5a6b71 --- /dev/null +++ b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php @@ -0,0 +1,216 @@ +auth = new DigestAuthenticate(array( + 'fields' => array('username' => 'user', 'password' => 'password'), + 'userModel' => 'User', + 'realm' => 'localhost', + 'nonce' => 123, + 'opaque' => '123abc' + )); + + $password = Security::hash('password', null, true); + ClassRegistry::init('User')->updateAll(array('password' => '"' . $password . '"')); + $this->server = $_SERVER; + $this->response = $this->getMock('CakeResponse'); + } + +/** + * teardown + * + * @return void + */ + function tearDown() { + parent::tearDown(); + $_SERVER = $this->server; + } + +/** + * test applying settings in the constructor + * + * @return void + */ + function testConstructor() { + $object = new DigestAuthenticate(array( + 'userModel' => 'AuthUser', + 'fields' => array('username' => 'user', 'password' => 'password'), + 'nonce' => 123456 + )); + $this->assertEquals('AuthUser', $object->settings['userModel']); + $this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->settings['fields']); + $this->assertEquals(123456, $object->settings['nonce']); + $this->assertEquals(env('SERVER_NAME'), $object->settings['realm']); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateNoData() { + $request = new CakeRequest('posts/index', false); + + $this->response->expects($this->once()) + ->method('header') + ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); + + $this->assertFalse($this->auth->authenticate($request, $this->response)); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateNoUsername() { + $request = new CakeRequest('posts/index', false); + $_SERVER['PHP_AUTH_PW'] = 'foobar'; + + $this->response->expects($this->once()) + ->method('header') + ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); + + $this->assertFalse($this->auth->authenticate($request, $this->response)); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateNoPassword() { + $request = new CakeRequest('posts/index', false); + $_SERVER['PHP_AUTH_USER'] = 'mariano'; + + $this->response->expects($this->once()) + ->method('header') + ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); + + $this->assertFalse($this->auth->authenticate($request, $this->response)); + } + +/** + * test the authenticate method + * + * @return void + */ + function testAuthenticateInjection() { + $request = new CakeRequest('posts/index', false); + $request->addParams(array('pass' => array(), 'named' => array())); + + $_SERVER['PHP_AUTH_USER'] = '> 1'; + $_SERVER['PHP_AUTH_PW'] = "' OR 1 = 1"; + + $this->assertFalse($this->auth->authenticate($request, $this->response)); + } + +/** + * test that challenge headers are sent when no credentials are found. + * + * @return void + */ + function testAuthenticateChallenge() { + $request = new CakeRequest('posts/index', false); + $request->addParams(array('pass' => array(), 'named' => array())); + + $this->response->expects($this->at(0)) + ->method('header') + ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); + + $this->response->expects($this->at(1)) + ->method('send'); + + $result = $this->auth->authenticate($request, $this->response); + $this->assertFalse($result); + } +/** + * test authenticate sucesss + * + * @return void + */ + function testAuthenticateSuccess() { + $request = new CakeRequest('posts/index', false); + $request->addParams(array('pass' => array(), 'named' => array())); + + $_SERVER['PHP_AUTH_USER'] = 'mariano'; + $_SERVER['PHP_AUTH_PW'] = 'password'; + + $result = $this->auth->authenticate($request, $this->response); + $expected = array( + 'id' => 1, + 'user' => 'mariano', + 'created' => '2007-03-17 01:16:23', + 'updated' => '2007-03-17 01:18:31' + ); + $this->assertEquals($expected, $result); + } + +/** + * test scope failure. + * + * @return void + */ + function testAuthenticateFailReChallenge() { + $this->auth->settings['scope'] = array('user' => 'nate'); + $request = new CakeRequest('posts/index', false); + $request->addParams(array('pass' => array(), 'named' => array())); + + $_SERVER['PHP_AUTH_USER'] = 'mariano'; + $_SERVER['PHP_AUTH_PW'] = 'password'; + + $this->response->expects($this->at(0)) + ->method('header') + ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); + + $this->response->expects($this->at(1)) + ->method('header') + ->with('Location', Router::reverse($request)); + + $this->response->expects($this->at(2)) + ->method('statusCode') + ->with(401); + + $this->response->expects($this->at(3)) + ->method('send'); + + $this->assertFalse($this->auth->authenticate($request, $this->response)); + } + +} \ No newline at end of file From 705b3288e1dccd80eb0fc32422a546add7a879f9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 22 Jan 2011 14:48:12 -0500 Subject: [PATCH 272/668] Basics of DigestAuth are working. --- .../components/auth/digest_authenticate.php | 108 +++++++++++- .../auth/digest_authenticate.test.php | 159 +++++++++++++----- 2 files changed, 222 insertions(+), 45 deletions(-) diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/cake/libs/controller/components/auth/digest_authenticate.php index f58623315..10212f1a0 100644 --- a/cake/libs/controller/components/auth/digest_authenticate.php +++ b/cake/libs/controller/components/auth/digest_authenticate.php @@ -66,18 +66,19 @@ class DigestAuthenticate extends BaseAuthenticate { * @return mixed Either false on failure, or an array of user data on success. */ public function authenticate(CakeRequest $request, CakeResponse $response) { - $username = env('PHP_AUTH_USER'); - $pass = env('PHP_AUTH_PW'); + $digest = $this->_getDigest(); - if (empty($username) || empty($pass)) { + if (empty($digest)) { $response->header($this->loginHeaders()); $response->send(); return false; } - $result = $this->_findUser($username, $pass); + $result = $this->_findUser($digest['username'], null); + $password = $result[$this->settings['fields']['password']]; + unset($result[$this->settings['fields']['password']]); - if (empty($result)) { + if (empty($result) || $digest['response'] !== $this->generateResponseHash($digest, $password)) { $response->header($this->loginHeaders()); $response->header('Location', Router::reverse($request)); $response->statusCode(401); @@ -87,6 +88,103 @@ class DigestAuthenticate extends BaseAuthenticate { return $result; } +/** + * Find a user record using the standard options. + * + * @param string $username The username/identifier. + * @param string $password Unused password, digest doesn't require passwords. + * @return Mixed Either false on failure, or an array of user data. + */ + protected function _findUser($username, $password) { + $userModel = $this->settings['userModel']; + list($plugin, $model) = pluginSplit($userModel); + $fields = $this->settings['fields']; + + $conditions = array( + $model . '.' . $fields['username'] => $username, + ); + if (!empty($this->settings['scope'])) { + $conditions = array_merge($conditions, $this->settings['scope']); + } + $result = ClassRegistry::init($userModel)->find('first', array( + 'conditions' => $conditions, + 'recursive' => 0 + )); + if (empty($result) || empty($result[$model])) { + return false; + } + return $result[$model]; + } + +/** + * Gets the digest headers from the request/environment. + * + * @return array Array of digest information. + */ + protected function _getDigest() { + $digest = env('PHP_AUTH_DIGEST'); + if (empty($digest) && function_exists('apache_request_headers')) { + $headers = apache_request_headers(); + if (!empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) == 'Digest ') { + $digest = substr($headers['Authorization'], 7); + } + } + if (empty($digest)) { + return false; + } + return $this->parseAuthData($digest); + } + +/** + * Parse the digest authentication headers and split them up. + * + * @param string $digest The raw digest authentication headers. + * @return array An array of digest authentication headers + */ + public function parseAuthData($digest) { + if (substr($digest, 0, 7) == 'Digest ') { + $digest = substr($digest, 7); + } + $keys = $match = array(); + $req = array('nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1); + preg_match_all('/(\w+)=([\'"]?)([a-zA-Z0-9@=.\/_-]+)\2/', $digest, $match, PREG_SET_ORDER); + + foreach ($match as $i) { + $keys[$i[1]] = $i[3]; + unset($req[$i[1]]); + } + + if (empty($req)) { + return $keys; + } + return null; + } + +/** + * Generate the response hash for a given digest array. + * + * @param array $digest Digest information containing data from DigestAuthenticate::parseAuthData(). + * @param string $password The digest hash password generated with DigestAuthenticate::password() + * @return string Response hash + */ + public function generateResponseHash($digest, $password) { + return md5( + $password . + ':' . $digest['nonce'] . ':' . $digest['nc'] . ':' . $digest['cnonce'] . ':' . $digest['qop'] . ':' . + md5(env('REQUEST_METHOD') . ':' . $digest['uri']) + ); + } + +/** + * Creates an auth digest password hash to store + * + * @param string $password The unhashed password to make a digest hash for. + * @return string the hashed password that can later be used with Digest authentication. + */ + public static function password($username, $realm, $password) { + return md5($username . ':' . $realm . ':' . $password); + } + /** * Generate the login headers * diff --git a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php index 40a5a6b71..4709890be 100644 --- a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php @@ -46,7 +46,7 @@ class DigestAuthenticateTest extends CakeTestCase { 'opaque' => '123abc' )); - $password = Security::hash('password', null, true); + $password = DigestAuthenticate::password('mariano', 'localhost', 'cake'); ClassRegistry::init('User')->updateAll(array('password' => '"' . $password . '"')); $this->server = $_SERVER; $this->response = $this->getMock('CakeResponse'); @@ -99,44 +99,36 @@ class DigestAuthenticateTest extends CakeTestCase { * * @return void */ - function testAuthenticateNoUsername() { - $request = new CakeRequest('posts/index', false); - $_SERVER['PHP_AUTH_PW'] = 'foobar'; - - $this->response->expects($this->once()) - ->method('header') - ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); - - $this->assertFalse($this->auth->authenticate($request, $this->response)); - } - -/** - * test the authenticate method - * - * @return void - */ - function testAuthenticateNoPassword() { - $request = new CakeRequest('posts/index', false); - $_SERVER['PHP_AUTH_USER'] = 'mariano'; - - $this->response->expects($this->once()) - ->method('header') - ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); - - $this->assertFalse($this->auth->authenticate($request, $this->response)); - } - -/** - * test the authenticate method - * - * @return void - */ - function testAuthenticateInjection() { + function testAuthenticateWrongUsername() { $request = new CakeRequest('posts/index', false); $request->addParams(array('pass' => array(), 'named' => array())); - $_SERVER['PHP_AUTH_USER'] = '> 1'; - $_SERVER['PHP_AUTH_PW'] = "' OR 1 = 1"; + $_SERVER['PHP_AUTH_DIGEST'] = <<response->expects($this->at(0)) + ->method('header') + ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); + + $this->response->expects($this->at(1)) + ->method('header') + ->with('Location', Router::reverse($request)); + + $this->response->expects($this->at(2)) + ->method('statusCode') + ->with(401); + + $this->response->expects($this->at(3)) + ->method('send'); $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -160,6 +152,7 @@ class DigestAuthenticateTest extends CakeTestCase { $result = $this->auth->authenticate($request, $this->response); $this->assertFalse($result); } + /** * test authenticate sucesss * @@ -169,8 +162,17 @@ class DigestAuthenticateTest extends CakeTestCase { $request = new CakeRequest('posts/index', false); $request->addParams(array('pass' => array(), 'named' => array())); - $_SERVER['PHP_AUTH_USER'] = 'mariano'; - $_SERVER['PHP_AUTH_PW'] = 'password'; + $_SERVER['PHP_AUTH_DIGEST'] = <<auth->authenticate($request, $this->response); $expected = array( @@ -192,8 +194,17 @@ class DigestAuthenticateTest extends CakeTestCase { $request = new CakeRequest('posts/index', false); $request->addParams(array('pass' => array(), 'named' => array())); - $_SERVER['PHP_AUTH_USER'] = 'mariano'; - $_SERVER['PHP_AUTH_PW'] = 'password'; + $_SERVER['PHP_AUTH_DIGEST'] = <<response->expects($this->at(0)) ->method('header') @@ -213,4 +224,72 @@ class DigestAuthenticateTest extends CakeTestCase { $this->assertFalse($this->auth->authenticate($request, $this->response)); } +/** + * testParseDigestAuthData method + * + * @access public + * @return void + */ + function testParseAuthData() { + $digest = << 'Mufasa', + 'realm' => 'testrealm@host.com', + 'nonce' => 'dcd98b7102dd2f0e8b11d0f600bfb0c093', + 'uri' => '/dir/index.html', + 'qop' => 'auth', + 'nc' => '00000001', + 'cnonce' => '0a4f113b', + 'response' => '6629fae49393a05397450978507c4ef1', + 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41' + ); + $result = $this->auth->parseAuthData($digest); + $this->assertSame($expected, $result); + + $result = $this->auth->parseAuthData(''); + $this->assertNull($result); + } + +/** + * test parsing digest information with email addresses + * + * @return void + */ + function testParseAuthEmailAddress() { + $digest = << 'mark@example.com', + 'realm' => 'testrealm@host.com', + 'nonce' => 'dcd98b7102dd2f0e8b11d0f600bfb0c093', + 'uri' => '/dir/index.html', + 'qop' => 'auth', + 'nc' => '00000001', + 'cnonce' => '0a4f113b', + 'response' => '6629fae49393a05397450978507c4ef1', + 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41' + ); + $result = $this->auth->parseAuthData($digest); + $this->assertIdentical($expected, $result); + } + } \ No newline at end of file From d5f5ae3271e3915abe4c5f4d2c4d67bb4e22d2d4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 22 Jan 2011 15:46:21 -0500 Subject: [PATCH 273/668] Fixing typo where realm would be wrong if not specified. --- .../controller/components/auth/digest_authenticate.php | 2 +- .../components/auth/digest_authenticate.test.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/cake/libs/controller/components/auth/digest_authenticate.php index 10212f1a0..9e425f87a 100644 --- a/cake/libs/controller/components/auth/digest_authenticate.php +++ b/cake/libs/controller/components/auth/digest_authenticate.php @@ -51,7 +51,7 @@ class DigestAuthenticate extends BaseAuthenticate { $this->settings['realm'] = env('SERVER_NAME'); } if (empty($this->settings['nonce'])) { - $this->settings['realm'] = uniqid(''); + $this->settings['nonce'] = uniqid(''); } if (empty($this->settings['opaque'])) { $this->settings['opaque'] = md5($this->settings['realm']); diff --git a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php index 4709890be..08cba463b 100644 --- a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php @@ -292,4 +292,14 @@ DIGEST; $this->assertIdentical($expected, $result); } +/** + * test password hashing + * + * @return void + */ + function testPassword() { + $result = DigestAuthenticate::password('mark', 'localhost', 'password'); + $expected = md5('mark:localhost:password'); + $this->assertEquals($expected, $result); + } } \ No newline at end of file From 669672a1a01782620b5ab6227724f21968e9f42c Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 22 Jan 2011 16:27:07 -0500 Subject: [PATCH 274/668] Adding doc blocks. --- .../components/auth/basic_authenticate.php | 30 ++++++++++++- .../components/auth/digest_authenticate.php | 45 ++++++++++++++++++- 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/cake/libs/controller/components/auth/basic_authenticate.php index 3d6cbc845..08a358463 100644 --- a/cake/libs/controller/components/auth/basic_authenticate.php +++ b/cake/libs/controller/components/auth/basic_authenticate.php @@ -13,9 +13,32 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Component', 'auth/base_authenticate'); -App::import('Core', 'String'); - +/** + * Basic Authentication adapter for AuthComponent. + * + * Provides Basic HTTP authentication support for AuthComponent. Basic Auth will authenticate users + * against the configured userModel and verify the username and passwords match. Clients using Basic Authentication + * must support cookies. Since AuthComponent identifies users based on Session contents, clients using Basic + * Auth must support cookies. + * + * ### Using Basic auth + * + * In your controller's components array, add auth + the required settings. + * {{{ + * var $components = array( + * 'Auth' => array( + * 'authenticate' => array('Basic') + * ) + * ); + * }}} + * + * In your login function just call `$this->Auth->login()` without any checks for POST data. This + * will send the authentication headers, and trigger the login dialog in the browser/client. + * + * @package cake.libs.controller.components.auth + * @since 2.0 + */ class BasicAuthenticate extends BaseAuthenticate { /** * Settings for this object. @@ -24,6 +47,7 @@ class BasicAuthenticate extends BaseAuthenticate { * - `userModel` The model name of the User, defaults to User. * - `scope` Additional conditions to use when looking up and authenticating users, * i.e. `array('User.is_active' => 1).` + * - `realm` The realm authentication is for. Defaults the server name. * * @var array */ @@ -40,6 +64,7 @@ class BasicAuthenticate extends BaseAuthenticate { /** * Constructor, completes configuration for basic authentication. * + * @param array $settings An array of settings. * @return void */ public function __construct($settings) { @@ -48,6 +73,7 @@ class BasicAuthenticate extends BaseAuthenticate { $this->settings['realm'] = env('SERVER_NAME'); } } + /** * Authenticate a user using basic HTTP auth. Will use the configured User model and attempt a * login using basic HTTP auth. diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/cake/libs/controller/components/auth/digest_authenticate.php index 9e425f87a..899701182 100644 --- a/cake/libs/controller/components/auth/digest_authenticate.php +++ b/cake/libs/controller/components/auth/digest_authenticate.php @@ -15,7 +15,45 @@ App::import('Component', 'auth/base_authenticate'); App::import('Core', 'String'); - +/** + * Digest Authentication adapter for AuthComponent. + * + * Provides Digest HTTP authentication support for AuthComponent. Unlike most AuthComponent adapters, + * DigestAuthenticate requires a special password hash that conforms to RFC2617. You can create this + * password using `DigestAuthenticate::password()`. If you wish to use digest authentication alongside other + * authentication methods, its recommended that you store the digest authentication separately. + * + * Clients using Digest Authentication must support cookies. Since AuthComponent identifies users based + * on Session contents, clients without support for cookies will not function properly. + * + * ### Using Digest auth + * + * In your controller's components array, add auth + the required settings. + * {{{ + * var $components = array( + * 'Auth' => array( + * 'authenticate' => array('Digest') + * ) + * ); + * }}} + * + * In your login function just call `$this->Auth->login()` without any checks for POST data. This + * will send the authentication headers, and trigger the login dialog in the browser/client. + * + * ### Generating passwords compatible with Digest authentication. + * + * Due to the Digest authentication specification, digest auth requires a special password value. You + * can generate this password using `DigestAuthenticate::password()` + * + * `$digestPass = DigestAuthenticate::password($username, env('SERVER_NAME'), $password);` + * + * Its recommended that you store this digest auth only password separate from password hashes used for other + * login methods. For example `User.digest_pass` could be used for a digest password, while `User.password` would + * store the password hash for use with other methods like Basic or Form. + * + * @package cake.libs.controller.components.auth + * @since 2.0 + */ class DigestAuthenticate extends BaseAuthenticate { /** * Settings for this object. @@ -24,6 +62,10 @@ class DigestAuthenticate extends BaseAuthenticate { * - `userModel` The model name of the User, defaults to User. * - `scope` Additional conditions to use when looking up and authenticating users, * i.e. `array('User.is_active' => 1).` + * - `realm` The realm authentication is for, Defaults to the servername. + * - `nonce` A nonce used for authentication. Defaults to `uniqid()`. + * - `qop` Defaults to auth, no other values are supported at this time. + * - `opaque` A string that must be returned unchanged by clients. Defaults to `md5($settings['realm'])` * * @var array */ @@ -43,6 +85,7 @@ class DigestAuthenticate extends BaseAuthenticate { /** * Constructor, completes configuration for digest authentication. * + * @param array $settings An array of settings. * @return void */ public function __construct($settings) { From 0e7f49048987f77baf493cc5cc156987643adc80 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 22 Jan 2011 16:29:07 -0500 Subject: [PATCH 275/668] Fixing failing test. --- .../libs/controller/components/auth/actions_authorize.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php index 7af508c9c..69d0feb9f 100644 --- a/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php +++ b/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php @@ -33,7 +33,7 @@ class ActionsAuthorizeTest extends CakeTestCase { $this->controller->Components = $this->getMock('ComponentCollection'); $this->auth = new ActionsAuthorize($this->controller); - $this->auth->actionPath = '/controllers'; + $this->auth->settings['actionPath'] = '/controllers'; } /** From 91a3fc4aeecb427b70ce0ebdbf619c40fd3b3e38 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 22 Jan 2011 17:15:55 -0500 Subject: [PATCH 276/668] Fixing tests so they run in the webrunner. --- .../controller/components/auth/digest_authenticate.test.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php index 08cba463b..40b8ef4c1 100644 --- a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php @@ -38,6 +38,7 @@ class DigestAuthenticateTest extends CakeTestCase { */ function setUp() { parent::setUp(); + $this->server = $_SERVER; $this->auth = new DigestAuthenticate(array( 'fields' => array('username' => 'user', 'password' => 'password'), 'userModel' => 'User', @@ -48,7 +49,8 @@ class DigestAuthenticateTest extends CakeTestCase { $password = DigestAuthenticate::password('mariano', 'localhost', 'cake'); ClassRegistry::init('User')->updateAll(array('password' => '"' . $password . '"')); - $this->server = $_SERVER; + + $_SERVER['REQUEST_METHOD'] = 'GET'; $this->response = $this->getMock('CakeResponse'); } @@ -170,7 +172,7 @@ uri="/dir/index.html", qop=auth, nc=1, cnonce="123", -response="5e064cc2f3b20894a806b2de3edf9536", +response="06b257a54befa2ddfb9bfa134224aa29", opaque="123abc" DIGEST; From 82851895ef16e0cb4058f6d88611a89b647ce888 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 23 Jan 2011 11:09:01 -0500 Subject: [PATCH 277/668] Shifting includes around. --- cake/libs/controller/components/auth.php | 1 + cake/libs/controller/components/auth/digest_authenticate.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 7f12d9842..fb2e0e48e 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -23,6 +23,7 @@ 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'); /** * Authentication control component class diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/cake/libs/controller/components/auth/digest_authenticate.php index 899701182..91d8ed270 100644 --- a/cake/libs/controller/components/auth/digest_authenticate.php +++ b/cake/libs/controller/components/auth/digest_authenticate.php @@ -13,7 +13,6 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::import('Component', 'auth/base_authenticate'); -App::import('Core', 'String'); /** * Digest Authentication adapter for AuthComponent. From 2f917674d12e59e2a1cef320c9656f3a9d326819 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 24 Jan 2011 22:13:39 -0500 Subject: [PATCH 278/668] Fixing docblock to reflect change from '*' to 'all'. Adding note about constant. --- cake/libs/controller/components/auth.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index fb2e0e48e..543012c91 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -65,11 +65,11 @@ class AuthComponent extends Component { * * Using the class name without 'Authenticate' as the key, you can pass in an array of settings for each * authentication object. Additionally you can define settings that should be set to all authentications objects - * using the '*' key: + * using the 'all' key: * * {{{ * $this->Auth->authenticate = array( - * '*' => array( + * 'all' => array( * 'userModel' => 'Users.User', * 'scope' => array('User.active' => 1) * ), @@ -78,6 +78,8 @@ class AuthComponent extends Component { * ); * }}} * + * You can also use AuthComponent::ALL instead of the string 'all'. + * * @var array * @link http://book.cakephp.org/view/1278/authenticate */ @@ -104,11 +106,11 @@ class AuthComponent extends Component { * * Using the class name without 'Authorize' as the key, you can pass in an array of settings for each * authorization object. Additionally you can define settings that should be set to all authorization objects - * using the '*' key: + * using the 'all' key: * * {{{ * $this->Auth->authorize = array( - * '*' => array( + * 'all' => array( * 'actionPath' => 'controllers/' * ), * 'Crud', @@ -116,6 +118,8 @@ class AuthComponent extends Component { * ); * }}} * + * You can also use AuthComponent::ALL instead of the string 'all' + * * @var mixed * @link http://book.cakephp.org/view/1275/authorize */ From ffb6c29e7900bd1fde49050d222cf14158c60f86 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 25 Jan 2011 21:55:29 -0500 Subject: [PATCH 279/668] Removing dead fixtures, dead properties and dead models. --- .../libs/controller/components/auth.test.php | 135 +----------------- 1 file changed, 3 insertions(+), 132 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 502c5dfe5..a34d7a070 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -20,7 +20,6 @@ App::import('Core', 'Controller'); App::import('Component', array('Auth', 'Acl')); App::import('Component', 'auth/form_authenticate'); App::import('Model', 'DbAcl'); -App::import('Core', 'Xml'); /** * TestAuthComponent class @@ -38,14 +37,6 @@ class TestAuthComponent extends AuthComponent { */ public $testStop = false; -/** - * Sets default login state - * - * @var bool true - * @access protected - */ - protected $_loggedIn = true; - /** * stop method * @@ -120,92 +111,6 @@ class AuthUser extends CakeTestModel { } } -/** - * AuthUserCustomField class - * - * @package cake.tests.cases.libs.controller.components - */ -class AuthUserCustomField extends AuthUser { - -/** - * name property - * - * @var string 'AuthUser' - * @access public - */ - public $name = 'AuthUserCustomField'; -} - -/** -* UuidUser class -* -* @package cake -* @package cake.tests.cases.libs.controller.components -*/ -class UuidUser extends CakeTestModel { - -/** - * name property - * - * @var string 'AuthUser' - * @access public - */ - public $name = 'UuidUser'; - -/** - * useDbConfig property - * - * @var string 'test' - * @access public - */ - public $useDbConfig = 'test'; - -/** - * useTable property - * - * @var string 'uuid' - * @access public - */ - public $useTable = 'uuids'; - -/** - * parentNode method - * - * @access public - * @return void - */ - function parentNode() { - return true; - } - -/** - * bindNode method - * - * @param mixed $object - * @access public - * @return void - */ - function bindNode($object) { - return 'Roles/Admin'; - } - -/** - * isAuthorized method - * - * @param mixed $user - * @param mixed $controller - * @param mixed $action - * @access public - * @return void - */ - function isAuthorized($user, $controller = null, $action = null) { - if (!empty($user)) { - return true; - } - return false; - } -} - /** * AuthTestController class * @@ -295,7 +200,7 @@ class AuthTestController extends Controller { * @return void */ function logout() { - // $this->redirect($this->Auth->logout()); + } /** @@ -461,7 +366,7 @@ class AuthTest extends CakeTestCase { * @var array * @access public */ - public $fixtures = array('core.uuid', 'core.auth_user', 'core.auth_user_custom_field', 'core.aro', 'core.aco', 'core.aros_aco', 'core.aco_action'); + public $fixtures = array('core.auth_user'); /** * initialized property @@ -485,9 +390,6 @@ class AuthTest extends CakeTestCase { Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi'); Configure::write('Security.cipherSeed', 770011223369876); - Configure::write('Acl.database', 'test'); - Configure::write('Acl.classname', 'DbAcl'); - $request = new CakeRequest(null, false); $this->Controller = new AuthTestController($request); @@ -497,9 +399,6 @@ class AuthTest extends CakeTestCase { ); $this->Controller->beforeFilter(); - $view = new View($this->Controller); - ClassRegistry::addObject('view', $view); - $this->Controller->Session->delete('Auth'); $this->Controller->Session->delete('Message.auth'); @@ -645,35 +544,6 @@ class AuthTest extends CakeTestCase { $this->assertFalse($result); } - -/** - * testAuthorizeModel method - * - * @access public - * @return void - */ - function testAuthorizeModel() { - $this->markTestSkipped('This is not implemented'); - - $this->AuthUser = new AuthUser(); - $user = $this->AuthUser->find(); - $this->Controller->Session->write('Auth', $user); - - $this->Controller->request['controller'] = 'auth_test'; - $this->Controller->request['action'] = 'add'; - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->authorize = array('model'=>'AuthUser'); - $result = $this->Controller->Auth->startup($this->Controller); - $this->assertTrue($result); - - $this->Controller->Session->delete('Auth'); - $this->Controller->Auth->startup($this->Controller); - $this->assertTrue($this->Controller->Session->check('Message.auth')); - $result = $this->Controller->Auth->isAuthorized(); - $this->assertFalse($result); - } - /** * @expectedException CakeException * @return void @@ -1177,6 +1047,7 @@ class AuthTest extends CakeTestCase { $this->Controller->components = array( 'Auth' => array( 'loginAction' => array('controller' => 'people', 'action' => 'login'), + 'logoutRedirect' => array('controller' => 'people', 'action' => 'login'), ), 'Session' ); From af934e3443dc33b61380b97f60e91089f51ce200 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 27 Jan 2011 21:10:57 -0500 Subject: [PATCH 280/668] Removing more dead code in the Auth test. --- .../libs/controller/components/auth.test.php | 55 +------------------ 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index a34d7a070..e1f9e4edd 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -73,42 +73,6 @@ class AuthUser extends CakeTestModel { */ public $useDbConfig = 'test'; -/** - * parentNode method - * - * @access public - * @return void - */ - function parentNode() { - return true; - } - -/** - * bindNode method - * - * @param mixed $object - * @access public - * @return void - */ - function bindNode($object) { - return 'Roles/Admin'; - } - -/** - * isAuthorized method - * - * @param mixed $user - * @param mixed $controller - * @param mixed $action - * @access public - * @return void - */ - function isAuthorized($user, $controller = null, $action = null) { - if (!empty($user)) { - return true; - } - return false; - } } /** @@ -244,26 +208,9 @@ class AuthTestController extends Controller { * @return void */ function isAuthorized() { - if (isset($this->request['testControllerAuth'])) { - return false; - } - return true; + } -/** - * Mock delete method - * - * @param mixed $url - * @param mixed $status - * @param mixed $exit - * @access public - * @return void - */ - function delete($id = null) { - if ($this->TestAuth->testStop !== true && $id !== null) { - echo 'Deleted Record: ' . var_export($id, true); - } - } } /** From dc7565ad4771dd3bc28fc84e0a61c3c29dd3da1d Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 27 Jan 2011 21:55:28 -0500 Subject: [PATCH 281/668] Removing crufty methods Removing additiona ->Controller all over the place --- .../libs/controller/components/auth.test.php | 247 ++++++++---------- 1 file changed, 112 insertions(+), 135 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index e1f9e4edd..f2fed0110 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -105,7 +105,7 @@ class AuthTestController extends Controller { * @var array * @access public */ - public $components = array('Session', 'Auth', 'Acl'); + public $components = array('Session', 'Auth'); /** * testUrl property @@ -129,16 +129,6 @@ class AuthTestController extends Controller { parent::__construct($request); } -/** - * beforeFilter method - * - * @access public - * @return void - */ - function beforeFilter() { - $this->Auth->userModel = 'AuthUser'; - } - /** * login method * @@ -340,14 +330,14 @@ class AuthTest extends CakeTestCase { $request = new CakeRequest(null, false); $this->Controller = new AuthTestController($request); - $this->Controller->Components->init($this->Controller); - $this->Controller->Components->trigger( - 'initialize', array(&$this->Controller), array('triggerDisabled' => true) - ); - $this->Controller->beforeFilter(); - $this->Controller->Session->delete('Auth'); - $this->Controller->Session->delete('Message.auth'); + $collection = new ComponentCollection(); + $collection->init($this->Controller); + $this->Auth = new TestAuthComponent($collection); + $this->Auth->request = $request; + $this->Auth->response = $this->getMock('CakeResponse'); + + $this->Controller->Components->init($this->Controller); $this->initialized = true; Router::reload(); @@ -367,7 +357,7 @@ class AuthTest extends CakeTestCase { $this->Controller->Session->delete('Auth'); $this->Controller->Session->delete('Message.auth'); - unset($this->Controller, $this->AuthUser); + unset($this->Controller, $this->Auth); } /** @@ -377,7 +367,7 @@ class AuthTest extends CakeTestCase { * @return void */ function testNoAuth() { - $this->assertFalse($this->Controller->Auth->isAuthorized()); + $this->assertFalse($this->Auth->isAuthorized()); } /** @@ -409,15 +399,15 @@ class AuthTest extends CakeTestCase { */ function testLogin() { $this->getMock('FormAuthenticate', array(), array(), 'AuthLoginFormAuthenticate', false); - $this->Controller->Auth->authenticate = array( + $this->Auth->authenticate = array( 'AuthLoginForm' => array( 'userModel' => 'AuthUser' ) ); - $mocks = $this->Controller->Auth->constructAuthenticate(); + $mocks = $this->Auth->constructAuthenticate(); $this->mockObjects[] = $mocks[0]; - $this->Controller->Auth->request->data = array( + $this->Auth->request->data = array( 'AuthUser' => array( 'username' => 'mark', 'password' => Security::hash('cake', null, true) @@ -431,14 +421,14 @@ class AuthTest extends CakeTestCase { $mocks[0]->expects($this->once()) ->method('authenticate') - ->with($this->Controller->Auth->request) + ->with($this->Auth->request) ->will($this->returnValue($user)); - $result = $this->Controller->Auth->login(); + $result = $this->Auth->login(); $this->assertTrue($result); - $this->assertTrue($this->Controller->Auth->loggedIn()); - $this->assertEquals($user, $this->Controller->Auth->user()); + $this->assertTrue($this->Auth->loggedIn()); + $this->assertEquals($user, $this->Auth->user()); } /** @@ -456,11 +446,11 @@ class AuthTest extends CakeTestCase { $this->Controller->request->query['url'] = 'auth_test/login'; $this->Controller->Session->delete('Auth'); - $this->Controller->Auth->loginRedirect = '/users/dashboard'; - $this->Controller->Auth->loginAction = 'auth_test/login'; - $this->Controller->Auth->userModel = 'AuthUser'; + $this->Auth->loginRedirect = '/users/dashboard'; + $this->Auth->loginAction = 'auth_test/login'; + $this->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); + $this->Auth->startup($this->Controller); $redirect = $this->Controller->Session->read('Auth.redirect'); $this->assertNull($redirect); } @@ -717,17 +707,16 @@ class AuthTest extends CakeTestCase { 'AuthUser' => array('id' => '1', 'username' => 'nate') )); - $this->Controller->request->addParams(Router::parse('users/login')); - $this->Controller->request->query['url'] = 'users/login'; - $this->Controller->Auth->initialize($this->Controller); + $this->Auth->request->addParams(Router::parse('users/login')); + $this->Auth->request->query['url'] = 'users/login'; + $this->Auth->initialize($this->Controller); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->loginRedirect = array( + $this->Auth->loginRedirect = array( 'controller' => 'pages', 'action' => 'display', 'welcome' ); - $this->Controller->Auth->startup($this->Controller); - $expected = Router::normalize($this->Controller->Auth->loginRedirect); - $this->assertEqual($expected, $this->Controller->Auth->redirect()); + $this->Auth->startup($this->Controller); + $expected = Router::normalize($this->Auth->loginRedirect); + $this->assertEqual($expected, $this->Auth->redirect()); $this->Controller->Session->delete('Auth'); @@ -741,17 +730,16 @@ class AuthTest extends CakeTestCase { 'AuthUser' => array('id' => '1', 'username' => 'nate')) ); $this->Controller->testUrl = null; - $this->Controller->request->addParams(Router::parse($url)); + $this->Auth->request->addParams(Router::parse($url)); array_push($this->Controller->methods, 'view', 'edit', 'index'); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->authorize = 'controller'; + $this->Auth->initialize($this->Controller); + $this->Auth->authorize = 'controller'; - $this->Controller->Auth->loginAction = array( + $this->Auth->loginAction = array( 'controller' => 'AuthTest', 'action' => 'login' ); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); + $this->Auth->startup($this->Controller); $expected = Router::normalize('/AuthTest/login'); $this->assertEqual($expected, $this->Controller->testUrl); @@ -760,38 +748,35 @@ class AuthTest extends CakeTestCase { $this->Controller->Session->write('Auth', array( 'AuthUser' => array('id'=>'1', 'username' => 'nate') )); - $this->Controller->request->params['action'] = 'login'; - $this->Controller->request->query['url'] = 'auth_test/login'; - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = 'auth_test/login'; - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->loginRedirect = false; - $this->Controller->Auth->startup($this->Controller); + $this->Auth->request->params['action'] = 'login'; + $this->Auth->request->query['url'] = 'auth_test/login'; + $this->Auth->initialize($this->Controller); + $this->Auth->loginAction = 'auth_test/login'; + $this->Auth->loginRedirect = false; + $this->Auth->startup($this->Controller); $expected = Router::normalize('/admin'); - $this->assertEqual($expected, $this->Controller->Auth->redirect()); + $this->assertEqual($expected, $this->Auth->redirect()); //Ticket #4750 //named params $this->Controller->Session->delete('Auth'); $url = '/posts/index/year:2008/month:feb'; - $this->Controller->request->addParams(Router::parse($url)); - $this->Controller->request->query['url'] = Router::normalize($url); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); + $this->Auth->request->addParams(Router::parse($url)); + $this->Auth->request->query['url'] = Router::normalize($url); + $this->Auth->initialize($this->Controller); + $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/year:2008/month:feb'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); //passed args $this->Controller->Session->delete('Auth'); $url = '/posts/view/1'; - $this->Controller->request->addParams(Router::parse($url)); - $this->Controller->request->query['url'] = Router::normalize($url); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); + $this->Auth->request->addParams(Router::parse($url)); + $this->Auth->request->query['url'] = Router::normalize($url); + $this->Auth->initialize($this->Controller); + $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/view/1'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); @@ -804,13 +789,12 @@ class AuthTest extends CakeTestCase { ); $this->Controller->Session->delete('Auth'); $url = '/posts/index/29'; - $this->Controller->request = new CakeRequest($url); - $this->Controller->request->addParams(Router::parse($url)); + $this->Auth->request = $this->Controller->request = new CakeRequest($url); + $this->Auth->request->addParams(Router::parse($url)); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); + $this->Auth->initialize($this->Controller); + $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/29?print=true&refer=menu'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); @@ -821,13 +805,12 @@ class AuthTest extends CakeTestCase { ); $this->Controller->Session->delete('Auth'); $url = '/posts/index/29'; - $this->Controller->request = new CakeRequest($url); - $this->Controller->request->addParams(Router::parse($url)); + $this->Auth->request = $this->Controller->request = new CakeRequest($url); + $this->Auth->request->addParams(Router::parse($url)); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); + $this->Auth->initialize($this->Controller); + $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/29?print=true&refer=menu'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); $_GET = $_back; @@ -836,13 +819,12 @@ class AuthTest extends CakeTestCase { $_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message'; $this->Controller->Session->delete('Auth'); $url = '/posts/edit/1'; - $this->Controller->request = new CakeRequest($url); - $this->Controller->request->addParams(Router::parse($url)); - $this->Controller->request->query = array('url' => Router::normalize($url)); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); + $this->Auth->request = $this->Controller->request = new CakeRequest($url); + $this->Auth->request->addParams(Router::parse($url)); + $this->Auth->request->query = array('url' => Router::normalize($url)); + $this->Auth->initialize($this->Controller); + $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->startup($this->Controller); $expected = Router::normalize('/posts/edit/1'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); @@ -850,13 +832,12 @@ class AuthTest extends CakeTestCase { $_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message'; $this->Controller->Session->delete('Auth'); $url = '/AuthTest/login'; - $this->Controller->request = new CakeRequest($url); - $this->Controller->request->addParams(Router::parse($url)); - $this->Controller->request->query['url'] = Router::normalize($url); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); + $this->Auth->request = $this->Controller->request = new CakeRequest($url); + $this->Auth->request->addParams(Router::parse($url)); + $this->Auth->request->query['url'] = Router::normalize($url); + $this->Auth->initialize($this->Controller); + $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->startup($this->Controller); $expected = Router::normalize('/'); $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); @@ -871,9 +852,9 @@ class AuthTest extends CakeTestCase { */ function testNoRedirectOn404() { $this->Controller->Session->delete('Auth'); - $this->Controller->Auth->initialize($this->Controller); - $this->Controller->request->addParams(Router::parse('auth_test/something_totally_wrong')); - $result = $this->Controller->Auth->startup($this->Controller); + $this->Auth->initialize($this->Controller); + $this->Auth->request->addParams(Router::parse('auth_test/something_totally_wrong')); + $result = $this->Auth->startup($this->Controller); $this->assertTrue($result, 'Auth redirected a missing action %s'); } @@ -889,18 +870,17 @@ class AuthTest extends CakeTestCase { Router::reload(); $url = '/admin/auth_test/add'; - $this->Controller->request->addParams(Router::parse($url)); - $this->Controller->request->query['url'] = ltrim($url, '/'); - $this->Controller->request->base = ''; - Router::setRequestInfo($this->Controller->request); - $this->Controller->Auth->initialize($this->Controller); + $this->Auth->request->addParams(Router::parse($url)); + $this->Auth->request->query['url'] = ltrim($url, '/'); + $this->Auth->request->base = ''; + Router::setRequestInfo($this->Auth->request); + $this->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array( + $this->Auth->loginAction = array( 'admin' => true, 'controller' => 'auth_test', 'action' => 'login' ); - $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->startup($this->Controller); + $this->Auth->startup($this->Controller); $this->assertEqual($this->Controller->testUrl, '/admin/auth_test/login'); Configure::write('Routing.prefixes', $prefixes); @@ -941,12 +921,12 @@ class AuthTest extends CakeTestCase { Router::reload(); $url = '/admin/auth_test/login'; - $this->Controller->request->addParams(Router::parse($url)); - $this->Controller->request->query['url'] = ltrim($url, '/'); + $this->Auth->request->addParams(Router::parse($url)); + $this->Auth->request->query['url'] = ltrim($url, '/'); Router::setRequestInfo(array( array( 'pass' => array(), 'action' => 'admin_login', 'plugin' => null, 'controller' => 'auth_test', - 'admin' => true, 'url' => array('url' => $this->Controller->request->query['url']), + 'admin' => true, 'url' => array('url' => $this->Auth->request->query['url']), ), array( 'base' => null, 'here' => $url, @@ -954,12 +934,9 @@ class AuthTest extends CakeTestCase { ) )); - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->loginAction = array('admin' => true, 'controller' => 'auth_test', 'action' => 'login'); - $this->Controller->Auth->userModel = 'AuthUser'; - - $this->Controller->Auth->startup($this->Controller); + $this->Auth->initialize($this->Controller); + $this->Auth->loginAction = array('admin' => true, 'controller' => 'auth_test', 'action' => 'login'); + $this->Auth->startup($this->Controller); $this->assertNull($this->Controller->testUrl); @@ -1018,8 +995,8 @@ class AuthTest extends CakeTestCase { function testLogout() { $this->Controller->Session->write('Auth.User.id', '1'); $this->Controller->Session->write('Auth.redirect', '/users/login'); - $this->Controller->Auth->logoutRedirect = '/'; - $result = $this->Controller->Auth->logout(); + $this->Auth->logoutRedirect = '/'; + $result = $this->Auth->logout(); $this->assertEqual($result, '/'); $this->assertNull($this->Controller->Session->read('Auth.AuthUser')); @@ -1033,13 +1010,13 @@ class AuthTest extends CakeTestCase { */ function testMapActionsDelegation() { $this->getMock('BaseAuthorize', array('authorize'), array(), 'MapActionMockAuthorize', false); - $this->Controller->Auth->authorize = array('MapActionMock'); - $mock = $this->Controller->Auth->constructAuthorize(); + $this->Auth->authorize = array('MapActionMock'); + $mock = $this->Auth->constructAuthorize(); $mock[0]->expects($this->once()) ->method('mapActions') ->with(array('create' => array('my_action'))); - $this->Controller->Auth->mapActions(array('create' => array('my_action'))); + $this->Auth->mapActions(array('create' => array('my_action'))); } /** @@ -1052,16 +1029,16 @@ class AuthTest extends CakeTestCase { $request = new CakeRequest('users/login', false); $user = array('username' => 'mark', 'role' => 'admin'); - $this->Controller->Auth->request = $request; - $this->Controller->Auth->authenticate = array('RequestLoginMock'); - $mock = $this->Controller->Auth->constructAuthenticate(); + $this->Auth->request = $request; + $this->Auth->authenticate = array('RequestLoginMock'); + $mock = $this->Auth->constructAuthenticate(); $mock[0]->expects($this->once()) ->method('authenticate') ->with($request) ->will($this->returnValue($user)); - $this->assertTrue($this->Controller->Auth->login()); - $this->assertEquals($user['username'], $this->Controller->Auth->user('username')); + $this->assertTrue($this->Auth->login()); + $this->assertEquals($user['username'], $this->Auth->user('username')); } /** @@ -1070,7 +1047,7 @@ class AuthTest extends CakeTestCase { * @return void */ function testLoginWithUserData() { - $this->assertFalse($this->Controller->Auth->loggedIn()); + $this->assertFalse($this->Auth->loggedIn()); $user = array( 'username' => 'mariano', @@ -1078,9 +1055,9 @@ class AuthTest extends CakeTestCase { 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' ); - $this->assertTrue($this->Controller->Auth->login($user)); - $this->assertTrue($this->Controller->Auth->loggedIn()); - $this->assertEquals($user['username'], $this->Controller->Auth->user('username')); + $this->assertTrue($this->Auth->login($user)); + $this->assertTrue($this->Auth->loggedIn()); + $this->assertEquals($user['username'], $this->Auth->user('username')); } /** @@ -1089,17 +1066,17 @@ class AuthTest extends CakeTestCase { * @return void */ function testFlashSettings() { - $this->Controller->Auth->Session = $this->getMock('SessionComponent', array(), array(), '', false); - $this->Controller->Auth->Session->expects($this->once()) + $this->Auth->Session = $this->getMock('SessionComponent', array(), array(), '', false); + $this->Auth->Session->expects($this->once()) ->method('setFlash') ->with('Auth failure', 'custom', array(1), 'auth-key'); - $this->Controller->Auth->flash = array( + $this->Auth->flash = array( 'element' => 'custom', 'params' => array(1), 'key' => 'auth-key' ); - $this->Controller->Auth->flash('Auth failure'); + $this->Auth->flash('Auth failure'); } /** @@ -1109,7 +1086,7 @@ class AuthTest extends CakeTestCase { */ function testRedirectSet() { $value = array('controller' => 'users', 'action' => 'home'); - $result = $this->Controller->Auth->redirect($value); + $result = $this->Auth->redirect($value); $this->assertEquals('/users/home', $result); $this->assertEquals($value, $this->Controller->Session->read('Auth.redirect')); } @@ -1120,10 +1097,10 @@ class AuthTest extends CakeTestCase { * @return void */ function testRedirectSessionRead() { - $this->Controller->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); + $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); $this->Controller->Session->write('Auth.redirect', '/users/home'); - $result = $this->Controller->Auth->redirect(); + $result = $this->Auth->redirect(); $this->assertEquals('/users/home', $result); $this->assertFalse($this->Controller->Session->check('Auth.redirect')); } @@ -1135,11 +1112,11 @@ class AuthTest extends CakeTestCase { * @return void */ function testRedirectSessionReadEqualToLoginAction() { - $this->Controller->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); - $this->Controller->Auth->loginRedirect = array('controller' => 'users', 'action' => 'home'); + $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); + $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'home'); $this->Controller->Session->write('Auth.redirect', array('controller' => 'users', 'action' => 'login')); - $result = $this->Controller->Auth->redirect(); + $result = $this->Auth->redirect(); $this->assertEquals('/users/home', $result); $this->assertFalse($this->Controller->Session->check('Auth.redirect')); } From 060360c787875015d46735fbf797f6c5598d457e Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 29 Jan 2011 20:55:48 -0500 Subject: [PATCH 282/668] Switching Controller->Session => Auth->Session. --- .../libs/controller/components/auth.test.php | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index f2fed0110..fc5788ebc 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -355,8 +355,8 @@ class AuthTest extends CakeTestCase { $_SERVER = $this->_server; $_ENV = $this->_env; - $this->Controller->Session->delete('Auth'); - $this->Controller->Session->delete('Message.auth'); + $this->Auth->Session->delete('Auth'); + $this->Auth->Session->delete('Message.auth'); unset($this->Controller, $this->Auth); } @@ -444,14 +444,14 @@ class AuthTest extends CakeTestCase { $this->Controller->data = array(); $this->Controller->request->addParams(Router::parse('auth_test/login')); $this->Controller->request->query['url'] = 'auth_test/login'; - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); $this->Auth->loginRedirect = '/users/dashboard'; $this->Auth->loginAction = 'auth_test/login'; $this->Auth->userModel = 'AuthUser'; $this->Auth->startup($this->Controller); - $redirect = $this->Controller->Session->read('Auth.redirect'); + $redirect = $this->Auth->Session->read('Auth.redirect'); $this->assertNull($redirect); } @@ -464,17 +464,17 @@ class AuthTest extends CakeTestCase { function testAuthorizeFalse() { $this->AuthUser = new AuthUser(); $user = $this->AuthUser->find(); - $this->Controller->Session->write('Auth.User', $user['AuthUser']); + $this->Auth->Session->write('Auth.User', $user['AuthUser']); $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->authorize = false; $this->Controller->request->addParams(Router::parse('auth_test/add')); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result); - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); $result = $this->Controller->Auth->startup($this->Controller); $this->assertFalse($result); - $this->assertTrue($this->Controller->Session->check('Message.auth')); + $this->assertTrue($this->Auth->Session->check('Message.auth')); $this->Controller->request->addParams(Router::parse('auth_test/camelCase')); $result = $this->Controller->Auth->startup($this->Controller); @@ -703,7 +703,7 @@ class AuthTest extends CakeTestCase { $_ENV['HTTP_REFERER'] = false; putenv('HTTP_REFERER='); - $this->Controller->Session->write('Auth', array( + $this->Auth->Session->write('Auth', array( 'AuthUser' => array('id' => '1', 'username' => 'nate') )); @@ -718,7 +718,7 @@ class AuthTest extends CakeTestCase { $expected = Router::normalize($this->Auth->loginRedirect); $this->assertEqual($expected, $this->Auth->redirect()); - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); //empty referer no session $_SERVER['HTTP_REFERER'] = false; @@ -726,7 +726,7 @@ class AuthTest extends CakeTestCase { putenv('HTTP_REFERER='); $url = '/posts/view/1'; - $this->Controller->Session->write('Auth', array( + $this->Auth->Session->write('Auth', array( 'AuthUser' => array('id' => '1', 'username' => 'nate')) ); $this->Controller->testUrl = null; @@ -743,9 +743,9 @@ class AuthTest extends CakeTestCase { $expected = Router::normalize('/AuthTest/login'); $this->assertEqual($expected, $this->Controller->testUrl); - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); $_SERVER['HTTP_REFERER'] = $_ENV['HTTP_REFERER'] = Router::url('/admin', true); - $this->Controller->Session->write('Auth', array( + $this->Auth->Session->write('Auth', array( 'AuthUser' => array('id'=>'1', 'username' => 'nate') )); $this->Auth->request->params['action'] = 'login'; @@ -759,7 +759,7 @@ class AuthTest extends CakeTestCase { //Ticket #4750 //named params - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); $url = '/posts/index/year:2008/month:feb'; $this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->query['url'] = Router::normalize($url); @@ -767,10 +767,10 @@ class AuthTest extends CakeTestCase { $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/year:2008/month:feb'); - $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); + $this->assertEqual($expected, $this->Auth->Session->read('Auth.redirect')); //passed args - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); $url = '/posts/view/1'; $this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->query['url'] = Router::normalize($url); @@ -778,7 +778,7 @@ class AuthTest extends CakeTestCase { $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/view/1'); - $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); + $this->assertEqual($expected, $this->Auth->Session->read('Auth.redirect')); // QueryString parameters $_back = $_GET; @@ -787,7 +787,7 @@ class AuthTest extends CakeTestCase { 'print' => 'true', 'refer' => 'menu' ); - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); $url = '/posts/index/29'; $this->Auth->request = $this->Controller->request = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); @@ -796,14 +796,14 @@ class AuthTest extends CakeTestCase { $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/29?print=true&refer=menu'); - $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); + $this->assertEqual($expected, $this->Auth->Session->read('Auth.redirect')); $_GET = array( 'url' => '/posts/index/29', 'print' => 'true', 'refer' => 'menu' ); - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); $url = '/posts/index/29'; $this->Auth->request = $this->Controller->request = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); @@ -812,12 +812,12 @@ class AuthTest extends CakeTestCase { $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/29?print=true&refer=menu'); - $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); + $this->assertEqual($expected, $this->Auth->Session->read('Auth.redirect')); $_GET = $_back; //external authed action $_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message'; - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); $url = '/posts/edit/1'; $this->Auth->request = $this->Controller->request = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); @@ -826,11 +826,11 @@ class AuthTest extends CakeTestCase { $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->startup($this->Controller); $expected = Router::normalize('/posts/edit/1'); - $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); + $this->assertEqual($expected, $this->Auth->Session->read('Auth.redirect')); //external direct login link $_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message'; - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); $url = '/AuthTest/login'; $this->Auth->request = $this->Controller->request = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); @@ -839,9 +839,9 @@ class AuthTest extends CakeTestCase { $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->startup($this->Controller); $expected = Router::normalize('/'); - $this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect')); + $this->assertEqual($expected, $this->Auth->Session->read('Auth.redirect')); - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); } /** @@ -851,7 +851,7 @@ class AuthTest extends CakeTestCase { * @return void */ function testNoRedirectOn404() { - $this->Controller->Session->delete('Auth'); + $this->Auth->Session->delete('Auth'); $this->Auth->initialize($this->Controller); $this->Auth->request->addParams(Router::parse('auth_test/something_totally_wrong')); $result = $this->Auth->startup($this->Controller); @@ -951,11 +951,11 @@ class AuthTest extends CakeTestCase { */ function testShutDown() { $this->Controller->Auth->initialize($this->Controller, array('_loggedIn' => true)); - $this->Controller->Session->write('Auth.redirect', 'foo'); + $this->Auth->Session->write('Auth.redirect', 'foo'); $this->Controller->Auth->loggedIn(true); $this->Controller->Auth->shutdown($this->Controller); - $this->assertNull($this->Controller->Session->read('Auth.redirect')); + $this->assertNull($this->Auth->Session->read('Auth.redirect')); } /** @@ -993,14 +993,14 @@ class AuthTest extends CakeTestCase { * @return void */ function testLogout() { - $this->Controller->Session->write('Auth.User.id', '1'); - $this->Controller->Session->write('Auth.redirect', '/users/login'); + $this->Auth->Session->write('Auth.User.id', '1'); + $this->Auth->Session->write('Auth.redirect', '/users/login'); $this->Auth->logoutRedirect = '/'; $result = $this->Auth->logout(); $this->assertEqual($result, '/'); - $this->assertNull($this->Controller->Session->read('Auth.AuthUser')); - $this->assertNull($this->Controller->Session->read('Auth.redirect')); + $this->assertNull($this->Auth->Session->read('Auth.AuthUser')); + $this->assertNull($this->Auth->Session->read('Auth.redirect')); } /** @@ -1088,7 +1088,7 @@ class AuthTest extends CakeTestCase { $value = array('controller' => 'users', 'action' => 'home'); $result = $this->Auth->redirect($value); $this->assertEquals('/users/home', $result); - $this->assertEquals($value, $this->Controller->Session->read('Auth.redirect')); + $this->assertEquals($value, $this->Auth->Session->read('Auth.redirect')); } /** @@ -1098,11 +1098,11 @@ class AuthTest extends CakeTestCase { */ function testRedirectSessionRead() { $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); - $this->Controller->Session->write('Auth.redirect', '/users/home'); + $this->Auth->Session->write('Auth.redirect', '/users/home'); $result = $this->Auth->redirect(); $this->assertEquals('/users/home', $result); - $this->assertFalse($this->Controller->Session->check('Auth.redirect')); + $this->assertFalse($this->Auth->Session->check('Auth.redirect')); } /** @@ -1114,10 +1114,10 @@ class AuthTest extends CakeTestCase { function testRedirectSessionReadEqualToLoginAction() { $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'home'); - $this->Controller->Session->write('Auth.redirect', array('controller' => 'users', 'action' => 'login')); + $this->Auth->Session->write('Auth.redirect', array('controller' => 'users', 'action' => 'login')); $result = $this->Auth->redirect(); $this->assertEquals('/users/home', $result); - $this->assertFalse($this->Controller->Session->check('Auth.redirect')); + $this->assertFalse($this->Auth->Session->check('Auth.redirect')); } } From 59dac2255ec2d4c310e28fddc71d04f85bc6e1d9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 29 Jan 2011 21:02:51 -0500 Subject: [PATCH 283/668] Expanding test coverage. --- .../libs/controller/components/auth.test.php | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index fc5788ebc..e7c689ae0 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -500,13 +500,13 @@ class AuthTest extends CakeTestCase { $this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockTwoAuthorize', false); $this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockThreeAuthorize', false); - $this->Controller->Auth->authorize = array( + $this->Auth->authorize = array( 'AuthMockOne', 'AuthMockTwo', 'AuthMockThree' ); - $mocks = $this->Controller->Auth->constructAuthorize(); - $request = $this->Controller->request; + $mocks = $this->Auth->constructAuthorize(); + $request = $this->Auth->request; $this->assertEquals(3, count($mocks)); $mocks[0]->expects($this->once()) @@ -522,7 +522,29 @@ class AuthTest extends CakeTestCase { $mocks[2]->expects($this->never()) ->method('authorize'); - $this->assertTrue($this->Controller->Auth->isAuthorized(array('User'), $request)); + $this->assertTrue($this->Auth->isAuthorized(array('User'), $request)); + } + +/** + * test that isAuthorized will use the session user if none is given. + * + * @return void + */ + function testIsAuthorizedUsingUserInSession() { + $this->getMock('BaseAuthorize', array('authorize'), array(), 'AuthMockFourAuthorize', false); + $this->Auth->authorize = array('AuthMockFour'); + + $user = array('user' => 'mark'); + $this->Auth->Session->write('Auth.User', $user); + $mocks = $this->Auth->constructAuthorize(); + $request = $this->Controller->request; + + $mocks[0]->expects($this->once()) + ->method('authorize') + ->with($user, $request) + ->will($this->returnValue(true)); + + $this->assertTrue($this->Auth->isAuthorized(null, $request)); } /** @@ -1120,4 +1142,16 @@ class AuthTest extends CakeTestCase { $this->assertEquals('/users/home', $result); $this->assertFalse($this->Auth->Session->check('Auth.redirect')); } + +/** + * test password hashing + * + * @return void + */ + function testPassword() { + $result = $this->Auth->password('password'); + $expected = Security::hash('password', null, true); + $this->assertEquals($expected, $result); + + } } From a5d9a64e1a741b7acb9e622e2d01e070de3fa319 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 30 Jan 2011 15:58:37 -0500 Subject: [PATCH 284/668] Removing loginError, its not used anymore. --- cake/libs/controller/components/auth.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 543012c91..123f7697c 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -202,15 +202,6 @@ class AuthComponent extends Component { */ public $logoutRedirect = null; -/** - * Error to display when user login fails. For security purposes, only one error is used for all - * login failures, so as not to expose information on why the login failed. - * - * @var string - * @link http://book.cakephp.org/view/1272/loginError - */ - public $loginError = null; - /** * Error to display when user attempts to access an object or action to which they do not have * acccess. @@ -358,7 +349,6 @@ class AuthComponent extends Component { function __setDefaults() { $defaults = array( 'logoutRedirect' => $this->loginAction, - 'loginError' => __('Login failed. Invalid username or password.'), 'authError' => __('You are not authorized to access that location.') ); foreach ($defaults as $key => $value) { From 5834225cc3f0c06e2cbc82bd3c17c5f2de34fb64 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 30 Jan 2011 16:06:01 -0500 Subject: [PATCH 285/668] Making AuthComponent::password() static, as it might be needed in places where an instance of AuthComponent is not handy. --- cake/libs/controller/components/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 123f7697c..e07f89e94 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -640,7 +640,7 @@ class AuthComponent extends Component { * @return string Hashed password * @link http://book.cakephp.org/view/1263/password */ - public function password($password) { + public static function password($password) { return Security::hash($password, null, true); } From 9854947d0fd839e7e1bfced48e043583c2379b0c Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 1 Feb 2011 21:24:46 -0500 Subject: [PATCH 286/668] Fixing reversed args. --- cake/libs/controller/components/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index e07f89e94..001bdeef1 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -627,7 +627,7 @@ class AuthComponent extends Component { if (!method_exists($className, 'authenticate')) { throw new CakeException(__('Authentication objects must implement an authenticate method.')); } - $settings = array_merge((array)$settings, $global); + $settings = array_merge($global, (array)$settings); $this->_authenticateObjects[] = new $className($settings); } return $this->_authenticateObjects; From 3875d0ef548fc0c0ee5e5cac8da072f0b17ebe9b Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Feb 2011 23:00:41 -0500 Subject: [PATCH 287/668] Removing a method that is duplicated in AuthComponent. --- .../controller/components/auth/base_authenticate.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/cake/libs/controller/components/auth/base_authenticate.php b/cake/libs/controller/components/auth/base_authenticate.php index 0753640f8..d34789729 100644 --- a/cake/libs/controller/components/auth/base_authenticate.php +++ b/cake/libs/controller/components/auth/base_authenticate.php @@ -49,16 +49,6 @@ abstract class BaseAuthenticate { $this->settings = Set::merge($this->settings, $settings); } -/** - * Hash the supplied password using the configured hashing method. - * - * @param string $password The password to hash. - * @return string Hashed string - */ - public function hash($password) { - return Security::hash($password, null, true); - } - /** * Find a user record using the standard options. * @@ -73,7 +63,7 @@ abstract class BaseAuthenticate { $conditions = array( $model . '.' . $fields['username'] => $username, - $model . '.' . $fields['password'] => $this->hash($password), + $model . '.' . $fields['password'] => AuthComponent::password($password), ); if (!empty($this->settings['scope'])) { $conditions = array_merge($conditions, $this->settings['scope']); From 7b34d879dcbcc3dc9338855724803ef91fa07e81 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 4 Feb 2011 17:11:49 -0500 Subject: [PATCH 288/668] Making exception class names visible in the WebTest runner. Fixes #1506 --- cake/tests/lib/reporter/cake_html_reporter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 63153ba9c..73d6eb8f1 100755 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -271,7 +271,7 @@ class CakeHtmlReporter extends CakeBaseReporter { $testName = get_class($test) . '(' . $test->getName() . ')'; echo "
  • \n"; - echo "Exception"; + echo "" . get_class($message) . ""; echo "
    " . $this->_htmlEntities($message->getMessage()) . "
    \n"; echo "
    " . __('Test case: %s', $testName) . "
    \n"; From 8e267f7be25b1ad657d3530b9e5520667606ca97 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 4 Feb 2011 21:56:24 -0500 Subject: [PATCH 289/668] Fixing bake's unit test detection so it checks for PHPUnit properly. Fixes #1505 --- cake/console/shells/shell.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/console/shells/shell.php b/cake/console/shells/shell.php index dd59dbb2c..a143ba4e9 100644 --- a/cake/console/shells/shell.php +++ b/cake/console/shells/shell.php @@ -628,7 +628,10 @@ class Shell extends Object { * @return boolean Success */ protected function _checkUnitTest() { - if (App::import('vendor', 'simpletest' . DS . 'simpletest')) { + if (App::import('Vendor', 'phpunit', array('file' => 'PHPUnit' . DS . 'Autoload.php'))) { + return true; + } + if (@include 'PHPUnit' . DS . 'Autoload.php') { return true; } $prompt = 'PHPUnit is not installed. Do you want to bake unit test files anyway?'; From 304f12d0edde3347bce6b79c26dabcf415f26b29 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 01:28:41 -0500 Subject: [PATCH 290/668] Removing a pointless import in CakeRequest. Moving inclusion of ObjectCollection to bootstrap. This avoids repetitive calls to import() --- cake/bootstrap.php | 1 + cake/console/libs/task_collection.php | 2 -- cake/libs/cake_request.php | 1 - cake/libs/controller/component_collection.php | 2 -- cake/libs/model/behavior_collection.php | 2 -- cake/libs/view/helper_collection.php | 2 -- 6 files changed, 1 insertion(+), 9 deletions(-) diff --git a/cake/bootstrap.php b/cake/bootstrap.php index 65931eb39..aa30770fc 100644 --- a/cake/bootstrap.php +++ b/cake/bootstrap.php @@ -27,6 +27,7 @@ require CORE_PATH . 'cake' . DS . 'basics.php'; require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php'; require LIBS . 'error' . DS . 'exceptions.php'; require LIBS . 'object.php'; +require LIBS . 'object_collection.php'; require LIBS . 'inflector.php'; require LIBS . 'app.php'; require LIBS . 'configure.php'; diff --git a/cake/console/libs/task_collection.php b/cake/console/libs/task_collection.php index df29d3d26..da476f220 100644 --- a/cake/console/libs/task_collection.php +++ b/cake/console/libs/task_collection.php @@ -15,8 +15,6 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'ObjectCollection'); - class TaskCollection extends ObjectCollection { /** * Shell to use to set params to tasks. diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index b7a10058e..90ffa8cbf 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -15,7 +15,6 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'Set'); /** * A class that helps wrap Request information and particulars about a single request. diff --git a/cake/libs/controller/component_collection.php b/cake/libs/controller/component_collection.php index 2a483cc21..07a2a6eef 100644 --- a/cake/libs/controller/component_collection.php +++ b/cake/libs/controller/component_collection.php @@ -15,8 +15,6 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'ObjectCollection'); - class ComponentCollection extends ObjectCollection { /** diff --git a/cake/libs/model/behavior_collection.php b/cake/libs/model/behavior_collection.php index 30c9c1469..8bd92198f 100644 --- a/cake/libs/model/behavior_collection.php +++ b/cake/libs/model/behavior_collection.php @@ -18,8 +18,6 @@ * @since CakePHP(tm) v 1.2.0.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'ObjectCollection'); - /** * Model behavior collection class. * diff --git a/cake/libs/view/helper_collection.php b/cake/libs/view/helper_collection.php index d90289e21..c967ec676 100644 --- a/cake/libs/view/helper_collection.php +++ b/cake/libs/view/helper_collection.php @@ -15,8 +15,6 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', 'ObjectCollection'); - class HelperCollection extends ObjectCollection { /** From 8d7df1721c93d954d88c1163d0d9503dc6a7fd8b Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 01:29:35 -0500 Subject: [PATCH 291/668] Removing duplicate import. --- cake/libs/cake_session.php | 1 - 1 file changed, 1 deletion(-) diff --git a/cake/libs/cake_session.php b/cake/libs/cake_session.php index a08fd49c3..ec7a86b27 100644 --- a/cake/libs/cake_session.php +++ b/cake/libs/cake_session.php @@ -135,7 +135,6 @@ class CakeSession { * @param boolean $start Should session be started right now */ public static function init($base = null, $start = true) { - App::import('Core', 'Security'); self::$time = time(); $checkAgent = Configure::read('Session.checkAgent'); From f5383a2243da4898f2310e96a292c498fc3083b2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 01:40:14 -0500 Subject: [PATCH 292/668] Fixing some failing tests. --- cake/tests/cases/console/shells/api.test.php | 43 ++++++++++--------- .../cases/console/shells/tasks/test.test.php | 8 ++-- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/cake/tests/cases/console/shells/api.test.php b/cake/tests/cases/console/shells/api.test.php index e43c55d33..79deea551 100644 --- a/cake/tests/cases/console/shells/api.test.php +++ b/cake/tests/cases/console/shells/api.test.php @@ -58,27 +58,28 @@ class ApiShellTest extends CakeTestCase { $expected = array( '1. afterFilter()', '2. beforeFilter()', - '3. beforeRender()', - '4. constructClasses()', - '5. disableCache()', - '6. flash($message, $url, $pause = 1, $layout = \'flash\')', - '7. getResponse()', - '8. header($status)', - '9. httpCodes($code = NULL)', - '10. isAuthorized()', - '11. loadModel($modelClass = NULL, $id = NULL)', - '12. paginate($object = NULL, $scope = array (), $whitelist = array ())', - '13. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)', - '14. redirect($url, $status = NULL, $exit = true)', - '15. referer($default = NULL, $local = false)', - '16. render($action = NULL, $layout = NULL, $file = NULL)', - '17. set($one, $two = NULL)', - '18. setAction($action)', - '19. setRequest($request)', - '20. shutdownProcess()', - '21. startupProcess()', - '22. validate()', - '23. validateErrors()' + '3. beforeRedirect($url, $status = NULL, $exit = true)', + '4. beforeRender()', + '5. constructClasses()', + '6. disableCache()', + '7. flash($message, $url, $pause = 1, $layout = \'flash\')', + '8. getResponse()', + '9. header($status)', + '10. httpCodes($code = NULL)', + '11. isAuthorized()', + '12. loadModel($modelClass = NULL, $id = NULL)', + '13. paginate($object = NULL, $scope = array (), $whitelist = array ())', + '14. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)', + '15. redirect($url, $status = NULL, $exit = true)', + '16. referer($default = NULL, $local = false)', + '17. render($action = NULL, $layout = NULL, $file = NULL)', + '18. set($one, $two = NULL)', + '19. setAction($action)', + '20. setRequest($request)', + '21. shutdownProcess()', + '22. startupProcess()', + '23. validate()', + '24. validateErrors()' ); $this->Shell->expects($this->at(2))->method('out')->with($expected); diff --git a/cake/tests/cases/console/shells/tasks/test.test.php b/cake/tests/cases/console/shells/tasks/test.test.php index b57ec9d2f..5b25fb0b0 100644 --- a/cake/tests/cases/console/shells/tasks/test.test.php +++ b/cake/tests/cases/console/shells/tasks/test.test.php @@ -441,10 +441,10 @@ class TestTaskTest extends CakeTestCase { $this->assertContains("App::import('Model', 'TestTaskArticle')", $result); $this->assertContains('class TestTaskArticleTestCase extends CakeTestCase', $result); - $this->assertContains('function startTest()', $result); + $this->assertContains('function setUp()', $result); $this->assertContains("\$this->TestTaskArticle = ClassRegistry::init('TestTaskArticle')", $result); - $this->assertContains('function endTest()', $result); + $this->assertContains('function tearDown()', $result); $this->assertContains('unset($this->TestTaskArticle)', $result); $this->assertContains('function testDoSomething()', $result); @@ -476,11 +476,11 @@ class TestTaskTest extends CakeTestCase { $this->assertContains('public $autoRender = false', $result); $this->assertContains('function redirect($url, $status = null, $exit = true)', $result); - $this->assertContains('function startTest()', $result); + $this->assertContains('function setUp()', $result); $this->assertContains("\$this->TestTaskComments = new TestTestTaskCommentsController()", $result); $this->assertContains("\$this->TestTaskComments->constructClasses()", $result); - $this->assertContains('function endTest()', $result); + $this->assertContains('function tearDown()', $result); $this->assertContains('unset($this->TestTaskComments)', $result); $this->assertContains("'app.test_task_article'", $result); From 8f66fe6ed424797e3d2ae7e7122da142690dd0e0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 01:48:52 -0500 Subject: [PATCH 293/668] Removing additional spaces in tags. --- cake/libs/view/helpers/html.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/libs/view/helpers/html.php b/cake/libs/view/helpers/html.php index 436941a81..52458329c 100644 --- a/cake/libs/view/helpers/html.php +++ b/cake/libs/view/helpers/html.php @@ -35,11 +35,11 @@ class HtmlHelper extends AppHelper { 'metalink' => '', 'link' => '%s', 'mailto' => '%s', - 'form' => '
    ', + 'form' => '', 'formend' => '', - 'input' => '', - 'textarea' => '', - 'hidden' => '', + 'input' => '', + 'textarea' => '', + 'hidden' => '', 'checkbox' => '', 'checkboxmultiple' => '', 'radio' => '%s', From f58f3763ebab43cfdfe640d274aa0f02afe20736 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 05:52:18 -0500 Subject: [PATCH 294/668] Updating tests to account for attribute whitespace change. --- cake/tests/cases/libs/view/helpers/form.test.php | 4 ++-- cake/tests/cases/libs/view/helpers/html.test.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index ed3af90d1..949857f1b 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -5251,7 +5251,7 @@ class FormHelperTest extends CakeTestCase { )); $result = $this->Form->postButton('Send', '/', array('data' => array('extra' => 'value'))); - $this->assertTrue(strpos($result, '') !== false); + $this->assertTrue(strpos($result, '') !== false); } /** @@ -5291,7 +5291,7 @@ class FormHelperTest extends CakeTestCase { )); $result = $this->Form->postLink('Delete', '/posts/delete', array('data' => array('id' => 1))); - $this->assertTrue(strpos($result, '') !== false); + $this->assertTrue(strpos($result, '') !== false); } /** diff --git a/cake/tests/cases/libs/view/helpers/html.test.php b/cake/tests/cases/libs/view/helpers/html.test.php index 4da61890d..fc9c21936 100644 --- a/cake/tests/cases/libs/view/helpers/html.test.php +++ b/cake/tests/cases/libs/view/helpers/html.test.php @@ -1298,7 +1298,7 @@ class HtmlHelperTest extends CakeTestCase { $result = $this->Html->useTag('formend'); $this->assertTags($result, '/form'); - $result = $this->Html->useTag('form', 'test'); + $result = $this->Html->useTag('form', ' test'); $this->assertEqual($result, '
    '); $result = $this->Html->useTag('form', array('test' => 'ok')); From 0a266fa1fc8c2f6c55960292e8d3200322c68762 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 05:54:38 -0500 Subject: [PATCH 295/668] Fixing typo. --- cake/libs/view/helper_collection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/view/helper_collection.php b/cake/libs/view/helper_collection.php index c967ec676..4a6fd5d88 100644 --- a/cake/libs/view/helper_collection.php +++ b/cake/libs/view/helper_collection.php @@ -41,7 +41,7 @@ class HelperCollection extends ObjectCollection { * * You can alias your helper as an existing helper by setting the 'className' key, i.e., * {{{ - * public $components = array( + * public $helpers = array( * 'Html' => array( * 'className' => 'AliasedHtml' * ); From cf50cbdd9d40595a2cd32768888467fe5c374d99 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 06:43:00 -0500 Subject: [PATCH 296/668] Fixing issue in FormHelper where CURRENT_TIMESTAMP or other invalid data could cause a notice error. Fixes #1508 --- cake/libs/view/helpers/form.php | 7 +++++-- cake/tests/cases/libs/view/helpers/form.test.php | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 7026d5afb..7b6dd35a5 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -1843,8 +1843,11 @@ class FormHelper extends AppHelper { if ($time[0] == 0 && $timeFormat == '12') { $time[0] = 12; } - $hour = $time[0]; - $min = $time[1]; + $hour = $min = null; + if (isset($time[1])) { + $hour = $time[0]; + $min = $time[1]; + } } } } diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 27815a8b0..3aea5e665 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -4494,6 +4494,16 @@ class FormHelperTest extends CakeTestCase { $this->assertPattern('/]+value="06"[^<>]+selected="selected"[^>]*>June<\/option>/', $result); } +/** + * test that bogus non-date time data doesn't cause errors. + * + * @return void + */ + function testDateTimeWithBogusData() { + $result = $this->Form->dateTime('Contact.updated', 'DMY', '12', 'CURRENT_TIMESTAMP'); + $this->assertNoPattern('/selected="selected">\d/', $result); + } + /** * testFormDateTimeMulti method * From 79bbd227e377d68a8410ce4139329e14398fccd2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 10:30:28 -0500 Subject: [PATCH 297/668] Cache::configured() and in_array() are faster than calling Cache::config() 6 times. --- cake/libs/configure.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 1546ae087..5c4cc74b8 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -93,15 +93,16 @@ class Configure { } else { $duration = '+999 days'; } + $cacheConfigs = Cache::configured(); - if (Cache::config('_cake_core_') === false) { + if (!in_array('_cake_core_', $cacheConfigs)) { Cache::config('_cake_core_', array_merge((array)$cache['settings'], array( 'prefix' => $prefix . 'cake_core_', 'path' => $path . DS . 'persistent' . DS, 'serialize' => true, 'duration' => $duration ))); } - if (Cache::config('_cake_model_') === false) { + if (!in_array('_cake_model_', $cacheConfigs)) { Cache::config('_cake_model_', array_merge((array)$cache['settings'], array( 'prefix' => $prefix . 'cake_model_', 'path' => $path . DS . 'models' . DS, 'serialize' => true, 'duration' => $duration From ca22624b2ba3c7b5b37feeac6c49763e6607ea4d Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 10:43:30 -0500 Subject: [PATCH 298/668] Tiny tweak to remove a duplicated line. --- cake/libs/app.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cake/libs/app.php b/cake/libs/app.php index ce7fb4a05..2e3e608b0 100644 --- a/cake/libs/app.php +++ b/cake/libs/app.php @@ -272,11 +272,10 @@ class App { $path = array_flip(array_flip(array_merge( (array)$paths[$type], self::${$type}, $merge ))); - self::${$type} = array_values($path); } else { $path = array_flip(array_flip(array_merge(self::${$type}, $merge))); - self::${$type} = array_values($path); } + self::${$type} = array_values($path); } } From 8d5e68d582ef13f32534d1d185176acecf8c5060 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 11:19:05 -0500 Subject: [PATCH 299/668] Fixing issue where habtm tables would not have the connection prefix removed when generating schema. Fixes #1180 --- cake/libs/model/cake_schema.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index fefc41f7f..4acf9a18d 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -274,11 +274,16 @@ class CakeSchema extends Object { } if (is_object($Object->$class)) { $withTable = $db->fullTableName($Object->$class, false); + if ($prefix && strpos($withTable, $prefix) !== 0) { + continue; + } if (in_array($withTable, $currentTables)) { $key = array_search($withTable, $currentTables); - $tables[$withTable] = $this->__columns($Object->$class); - $tables[$withTable]['indexes'] = $db->index($Object->$class); - $tables[$withTable]['tableParameters'] = $db->readTableParameters($withTable); + $noPrefixWith = str_replace($prefix, '', $withTable); + + $tables[$noPrefixWith] = $this->__columns($Object->$class); + $tables[$noPrefixWith]['indexes'] = $db->index($Object->$class); + $tables[$noPrefixWith]['tableParameters'] = $db->readTableParameters($withTable); unset($currentTables[$key]); } } From 11d20f80d0fc96f5476a0456056c55cb9402f8d3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 15:24:46 -0500 Subject: [PATCH 300/668] Fixing failing tests imported with the merge. --- cake/libs/model/cake_schema.php | 1 + cake/tests/cases/libs/model/cake_schema.test.php | 1 + cake/tests/cases/libs/view/helpers/form.test.php | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index ab8d01b67..3542a6300 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -577,6 +577,7 @@ class CakeSchema extends Object { public function __columns(&$Obj) { $db = ConnectionManager::getDataSource($Obj->useDbConfig); $fields = $Obj->schema(true); + $columns = $props = array(); foreach ($fields as $name => $value) { if ($Obj->primaryKey == $name) { diff --git a/cake/tests/cases/libs/model/cake_schema.test.php b/cake/tests/cases/libs/model/cake_schema.test.php index 62050194d..69fb920d2 100644 --- a/cake/tests/cases/libs/model/cake_schema.test.php +++ b/cake/tests/cases/libs/model/cake_schema.test.php @@ -208,6 +208,7 @@ class TestAppSchema extends CakeSchema { public $datatypes = array( 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), 'float_field' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => '', 'collate' => null, 'comment' => null), + 'bool' => array('type' => 'boolean', 'null' => false, 'default' => false), 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), 'tableParameters' => array() ); diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index a7ca5da9e..872681ebb 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -1079,7 +1079,7 @@ class FormHelperTest extends CakeTestCase { * @return void */ function testFormSecureWithCustomNameAttribute() { - $this->Form->params['_Token']['key'] = 'testKey'; + $this->Form->request->params['_Token']['key'] = 'testKey'; $this->Form->text('UserForm.published', array('name' => 'data[User][custom]')); $this->assertEqual('User.custom', $this->Form->fields[0]); @@ -4487,7 +4487,7 @@ class FormHelperTest extends CakeTestCase { * @return void */ function testDateTimeWithBogusData() { - $result = $this->Form->dateTime('Contact.updated', 'DMY', '12', 'CURRENT_TIMESTAMP'); + $result = $this->Form->dateTime('Contact.updated', 'DMY', '12', array('value' => 'CURRENT_TIMESTAMP')); $this->assertNoPattern('/selected="selected">\d/', $result); } From 7388d900b4d577cb9a8b8ed9473770d07eb46ead Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 16:12:50 -0500 Subject: [PATCH 301/668] Fixing IIS test cases to match what should actually happen. --- cake/tests/cases/libs/cake_request.test.php | 60 ++++++++------------- 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index 0d276169d..df018ad0b 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -988,15 +988,15 @@ class CakeRequestTestCase extends CakeTestCase { * @return void */ public function testEnvironmentDetection() { - $dispatcher = new Dispatcher(); - $environments = array( 'IIS' => array( 'No rewrite base path' => array( 'App' => array( 'base' => false, 'baseUrl' => '/index.php?', - 'server' => 'IIS' + 'server' => 'IIS', + 'dir' => 'app', + 'webroot' => 'webroot' ), 'SERVER' => array( 'HTTPS' => 'off', @@ -1008,29 +1008,24 @@ class CakeRequestTestCase extends CakeTestCase { 'REQUEST_METHOD' => 'GET', 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => '80', - 'SERVER_PROTOCOL' => 'HTTP/1.1', - 'SERVER_SOFTWARE' => 'Microsoft-IIS/5.1', - 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', - 'REQUEST_URI' => '/index.php', - 'URL' => '/index.php', - 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', - 'ORIG_PATH_INFO' => '/index.php', - 'PATH_INFO' => '', - 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', - 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', - 'PHP_SELF' => '/index.php', - 'HTTP_ACCEPT' => '*/*', - 'HTTP_ACCEPT_LANGUAGE' => 'en-us', - 'HTTP_CONNECTION' => 'Keep-Alive', - 'HTTP_HOST' => 'localhost', - 'HTTP_USER_AGENT' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)', - 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', + 'SERVER_PROTOCOL' => 'HTTP/1.1', + 'SERVER_SOFTWARE' => 'Microsoft-IIS/5.1', + 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', + 'REQUEST_URI' => '/index.php', + 'URL' => '/index.php', + 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', + 'ORIG_PATH_INFO' => '/index.php', + 'PATH_INFO' => '', + 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', + 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', + 'PHP_SELF' => '/index.php', + 'HTTP_HOST' => 'localhost', 'argv' => array(), 'argc' => 0 ), 'reload' => true, 'base' => '/index.php?', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => '' ), 'No rewrite with path' => array( @@ -1044,7 +1039,7 @@ class CakeRequestTestCase extends CakeTestCase { 'reload' => false, 'url' => 'posts/add', 'base' => '/index.php?', - 'webroot' => '/' + 'webroot' => '/app/webroot/' ), 'No rewrite sub dir 1' => array( 'GET' => array(), @@ -1064,7 +1059,7 @@ class CakeRequestTestCase extends CakeTestCase { 'reload' => false, 'url' => '', 'base' => '/index.php?', - 'webroot' => '/' + 'webroot' => '/app/webroot/' ), 'No rewrite sub dir 1 with path' => array( 'GET' => array('/posts/add' => ''), @@ -1079,7 +1074,7 @@ class CakeRequestTestCase extends CakeTestCase { 'reload' => false, 'url' => 'posts/add', 'base' => '/index.php?', - 'webroot' => '/' + 'webroot' => '/app/webroot/' ), 'No rewrite sub dir 2' => array( 'App' => array( @@ -1141,7 +1136,7 @@ class CakeRequestTestCase extends CakeTestCase { 'SERVER_ADDR' => '::1', 'SERVER_PORT' => '80', 'REMOTE_ADDR' => '::1', - 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => '', @@ -1158,15 +1153,9 @@ class CakeRequestTestCase extends CakeTestCase { ), 'No rewrite with path' => array( 'SERVER' => array( - 'UNIQUE_ID' => 'VardGqn@17IAAAu7LY8AAAAK', - 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-us) AppleWebKit/523.10.5 (KHTML, like Gecko) Version/3.0.4 Safari/523.10.6', - 'HTTP_ACCEPT' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', - 'HTTP_ACCEPT_LANGUAGE' => 'en-us', - 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', - 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'localhost', - 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/officespace/app/webroot', - 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/officespace/app/webroot/index.php', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'QUERY_STRING' => '', 'REQUEST_URI' => '/index.php/posts/add', 'SCRIPT_NAME' => '/index.php', @@ -1188,11 +1177,6 @@ class CakeRequestTestCase extends CakeTestCase { 'webroot' => 'webroot' ), 'SERVER' => array( - 'UNIQUE_ID' => '2A-v8sCoAQ8AAAc-2xUAAAAB', - 'HTTP_ACCEPT_LANGUAGE' => 'en-us', - 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', - 'HTTP_COOKIE' => 'CAKEPHP=jcbv51apn84kd9ucv5aj2ln3t3', - 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_HOST' => 'cake.1.2', 'SERVER_NAME' => 'cake.1.2', 'SERVER_ADDR' => '127.0.0.1', From 3629925a40f6085c50324d593cbe52046e16d2ec Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 5 Feb 2011 18:41:00 -0500 Subject: [PATCH 302/668] Refactoring authentication objects so basic and digest authentication can work without cookies. This makes non browser clients able to use Basic and Digest auth. Updating test cases. --- cake/libs/controller/components/auth.php | 25 +++++++++++- .../components/auth/base_authenticate.php | 11 +++++ .../components/auth/basic_authenticate.php | 29 +++++++++----- .../components/auth/digest_authenticate.php | 40 ++++++++++++------- .../auth/basic_authenticate.test.php | 8 ++-- .../auth/digest_authenticate.test.php | 18 ++++----- 6 files changed, 89 insertions(+), 42 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 001bdeef1..41b3c5146 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -312,7 +312,7 @@ class AuthComponent extends Component { } } } else { - if (!$this->user()) { + if (!$this->_getUser()) { if (!$request->is('ajax')) { $this->flash($this->authError); $this->Session->write('Auth.redirect', Router::reverse($request)); @@ -558,6 +558,29 @@ class AuthComponent extends Component { } } +/** + * Similar to AuthComponent::user() except if the session user cannot be found, connected authentication + * objects will have their getUser() methods called. This lets stateless authentication methods function correctly. + * + * @return boolean true if a user can be found, false if one cannot. + */ + protected function _getUser() { + $user = $this->user(); + if ($user) { + return true; + } + if (empty($this->_authenticateObjects)) { + $this->constructAuthenticate(); + } + foreach ($this->_authenticateObjects as $auth) { + $result = $auth->getUser($this->request); + if (!empty($result) && is_array($result)) { + return true; + } + } + return false; + } + /** * If no parameter is passed, gets the authentication redirect URL. Pass a url in to * set the destination a user should be redirected to upon logging in. Will fallback to diff --git a/cake/libs/controller/components/auth/base_authenticate.php b/cake/libs/controller/components/auth/base_authenticate.php index d34789729..575b7544e 100644 --- a/cake/libs/controller/components/auth/base_authenticate.php +++ b/cake/libs/controller/components/auth/base_authenticate.php @@ -87,4 +87,15 @@ abstract class BaseAuthenticate { * @return mixed Either false on failure, or an array of user data on success. */ abstract public function authenticate(CakeRequest $request, CakeResponse $response); + +/** + * Get a user based on information in the request. Primarily used by stateless authentication + * systems like basic and digest auth. + * + * @param CakeRequest $request Request object. + * @return mixed Either false or an array of user information + */ + public function getUser($request) { + return false; + } } \ No newline at end of file diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/cake/libs/controller/components/auth/basic_authenticate.php index 08a358463..9bf68d386 100644 --- a/cake/libs/controller/components/auth/basic_authenticate.php +++ b/cake/libs/controller/components/auth/basic_authenticate.php @@ -83,20 +83,10 @@ class BasicAuthenticate extends BaseAuthenticate { * @return mixed Either false on failure, or an array of user data on success. */ public function authenticate(CakeRequest $request, CakeResponse $response) { - $username = env('PHP_AUTH_USER'); - $pass = env('PHP_AUTH_PW'); - - if (empty($username) || empty($pass)) { - $response->header($this->loginHeaders()); - $response->send(); - return false; - } - - $result = $this->_findUser($username, $pass); + $result = $this->getUser($request); if (empty($result)) { $response->header($this->loginHeaders()); - $response->header('Location', Router::reverse($request)); $response->statusCode(401); $response->send(); return false; @@ -104,6 +94,23 @@ class BasicAuthenticate extends BaseAuthenticate { return $result; } +/** + * Get a user based on information in the request. Primarily used by stateless authentication + * systems like basic and digest auth. + * + * @param CakeRequest $request Request object. + * @return mixed Either false or an array of user information + */ + public function getUser($request) { + $username = env('PHP_AUTH_USER'); + $pass = env('PHP_AUTH_PW'); + + if (empty($username) || empty($pass)) { + return false; + } + return $this->_findUser($username, $pass); + } + /** * Generate the login headers * diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/cake/libs/controller/components/auth/digest_authenticate.php index 91d8ed270..0e5068246 100644 --- a/cake/libs/controller/components/auth/digest_authenticate.php +++ b/cake/libs/controller/components/auth/digest_authenticate.php @@ -108,28 +108,40 @@ class DigestAuthenticate extends BaseAuthenticate { * @return mixed Either false on failure, or an array of user data on success. */ public function authenticate(CakeRequest $request, CakeResponse $response) { - $digest = $this->_getDigest(); + $user = $this->getUser($request); - if (empty($digest)) { + if (empty($user)) { $response->header($this->loginHeaders()); - $response->send(); - return false; - } - - $result = $this->_findUser($digest['username'], null); - $password = $result[$this->settings['fields']['password']]; - unset($result[$this->settings['fields']['password']]); - - if (empty($result) || $digest['response'] !== $this->generateResponseHash($digest, $password)) { - $response->header($this->loginHeaders()); - $response->header('Location', Router::reverse($request)); $response->statusCode(401); $response->send(); return false; } - return $result; + return $user; } +/** + * Get a user based on information in the request. Primarily used by stateless authentication + * systems like basic and digest auth. + * + * @param CakeRequest $request Request object. + * @return mixed Either false or an array of user information + */ + public function getUser($request) { + $digest = $this->_getDigest(); + if (empty($digest)) { + return false; + } + $user = $this->_findUser($digest['username'], null); + if (empty($user)) { + return false; + } + $password = $user[$this->settings['fields']['password']]; + unset($user[$this->settings['fields']['password']]); + if ($digest['response'] === $this->generateResponseHash($digest, $password)) { + return $user; + } + return false; + } /** * Find a user record using the standard options. * diff --git a/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php index 656ca0fbb..b1b2fc2e4 100644 --- a/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php @@ -14,6 +14,7 @@ * @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'); @@ -114,6 +115,7 @@ class BasicAuthenticateTest extends CakeTestCase { function testAuthenticateNoPassword() { $request = new CakeRequest('posts/index', false); $_SERVER['PHP_AUTH_USER'] = 'mariano'; + $_SERVER['PHP_AUTH_PW'] = null; $this->response->expects($this->once()) ->method('header') @@ -196,14 +198,10 @@ class BasicAuthenticateTest extends CakeTestCase { ->with('WWW-Authenticate: Basic realm="localhost"'); $this->response->expects($this->at(1)) - ->method('header') - ->with('Location', Router::reverse($request)); - - $this->response->expects($this->at(2)) ->method('statusCode') ->with(401); - $this->response->expects($this->at(3)) + $this->response->expects($this->at(2)) ->method('send'); $this->assertFalse($this->auth->authenticate($request, $this->response)); diff --git a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php index 40b8ef4c1..1ef4ccc5f 100644 --- a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php @@ -122,14 +122,10 @@ DIGEST; ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); $this->response->expects($this->at(1)) - ->method('header') - ->with('Location', Router::reverse($request)); - - $this->response->expects($this->at(2)) ->method('statusCode') ->with(401); - $this->response->expects($this->at(3)) + $this->response->expects($this->at(2)) ->method('send'); $this->assertFalse($this->auth->authenticate($request, $this->response)); @@ -149,6 +145,10 @@ DIGEST; ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); $this->response->expects($this->at(1)) + ->method('statusCode') + ->with(401); + + $this->response->expects($this->at(2)) ->method('send'); $result = $this->auth->authenticate($request, $this->response); @@ -211,16 +211,12 @@ DIGEST; $this->response->expects($this->at(0)) ->method('header') ->with('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); - - $this->response->expects($this->at(1)) - ->method('header') - ->with('Location', Router::reverse($request)); - $this->response->expects($this->at(2)) + $this->response->expects($this->at(1)) ->method('statusCode') ->with(401); - $this->response->expects($this->at(3)) + $this->response->expects($this->at(2)) ->method('send'); $this->assertFalse($this->auth->authenticate($request, $this->response)); From e32f419d0a7d50447472e0f85cb0e455795d24a5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 6 Feb 2011 00:01:52 -0500 Subject: [PATCH 303/668] Fixing comments. --- cake/libs/controller/components/auth/basic_authenticate.php | 3 +-- cake/libs/controller/components/auth/digest_authenticate.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/cake/libs/controller/components/auth/basic_authenticate.php index 9bf68d386..55bf48c40 100644 --- a/cake/libs/controller/components/auth/basic_authenticate.php +++ b/cake/libs/controller/components/auth/basic_authenticate.php @@ -95,8 +95,7 @@ class BasicAuthenticate extends BaseAuthenticate { } /** - * Get a user based on information in the request. Primarily used by stateless authentication - * systems like basic and digest auth. + * Get a user based on information in the request. Used by cookie-less auth for stateless clients. * * @param CakeRequest $request Request object. * @return mixed Either false or an array of user information diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/cake/libs/controller/components/auth/digest_authenticate.php index 0e5068246..26272894c 100644 --- a/cake/libs/controller/components/auth/digest_authenticate.php +++ b/cake/libs/controller/components/auth/digest_authenticate.php @@ -120,8 +120,7 @@ class DigestAuthenticate extends BaseAuthenticate { } /** - * Get a user based on information in the request. Primarily used by stateless authentication - * systems like basic and digest auth. + * Get a user based on information in the request. Used by cookie-less auth for stateless clients. * * @param CakeRequest $request Request object. * @return mixed Either false or an array of user information From f2a4b1e9599e5e7d4493d8368f20af815e4566f3 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sun, 6 Feb 2011 15:51:28 -0200 Subject: [PATCH 304/668] Supporting %e in windows. Fixes #1510. --- cake/libs/view/helpers/time.php | 9 +++++++++ cake/tests/cases/libs/view/helpers/time.test.php | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index 1f4d0be1c..27c690b5a 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -79,6 +79,15 @@ class TimeHelper extends AppHelper { return sprintf("%02d", date('Y', $this->__time) / 100); case 'D': return '%m/%d/%y'; + case 'e': + if (DS === '/') { + return '%e'; + } + $day = date('j', $this->__time); + if ($day < 10) { + $day = ' ' . $day; + } + return $day; case 'eS' : return date('jS', $this->__time); case 'b': diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index bfdbb9ccd..cbe42d2a1 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -731,6 +731,14 @@ class TimeHelperTest extends CakeTestCase { $expected = 4; $this->assertEqual($result, $expected); + $result = $this->Time->convertSpecifiers('%e', $time); + $expected = '14'; + $this->assertEqual($result, $expected); + + $result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01')); + $expected = ' 1'; + $this->assertEqual($result, $expected); + $result = $this->Time->convertSpecifiers('%x', $time); $expected = '%d/%m/%y'; $this->assertEqual($result, $expected); From 47cdaedc948f14d4fa7231eebebe7b568061b843 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 6 Feb 2011 15:25:36 -0500 Subject: [PATCH 305/668] Fixing $this -> self. --- cake/libs/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/app.php b/cake/libs/app.php index 2e3e608b0..91df0fd78 100644 --- a/cake/libs/app.php +++ b/cake/libs/app.php @@ -604,7 +604,7 @@ class App { if (empty(self::$search)) { return null; } elseif (is_string(self::$search)) { - $this->search = array(self::$search); + self::$search = array(self::$search); } if (empty(self::$__paths)) { From fbd798da6c049bf7526a6adb0e013696c9af36ca Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 6 Feb 2011 16:59:47 -0500 Subject: [PATCH 306/668] Reordering parameters to make it easier to remember the order. --- cake/libs/controller/components/auth/digest_authenticate.php | 4 +++- .../controller/components/auth/digest_authenticate.test.php | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/cake/libs/controller/components/auth/digest_authenticate.php index 26272894c..cde347110 100644 --- a/cake/libs/controller/components/auth/digest_authenticate.php +++ b/cake/libs/controller/components/auth/digest_authenticate.php @@ -231,10 +231,12 @@ class DigestAuthenticate extends BaseAuthenticate { /** * Creates an auth digest password hash to store * + * @param string $username The username to use in the digest hash. * @param string $password The unhashed password to make a digest hash for. + * @param string $realm The realm the password is for. * @return string the hashed password that can later be used with Digest authentication. */ - public static function password($username, $realm, $password) { + public static function password($username, $password, $realm) { return md5($username . ':' . $realm . ':' . $password); } diff --git a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php index 1ef4ccc5f..16b175890 100644 --- a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php @@ -47,7 +47,7 @@ class DigestAuthenticateTest extends CakeTestCase { 'opaque' => '123abc' )); - $password = DigestAuthenticate::password('mariano', 'localhost', 'cake'); + $password = DigestAuthenticate::password('mariano', 'cake', 'localhost'); ClassRegistry::init('User')->updateAll(array('password' => '"' . $password . '"')); $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -296,7 +296,7 @@ DIGEST; * @return void */ function testPassword() { - $result = DigestAuthenticate::password('mark', 'localhost', 'password'); + $result = DigestAuthenticate::password('mark', 'password', 'localhost'); $expected = md5('mark:localhost:password'); $this->assertEquals($expected, $result); } From 584116524bcf9f217122b050a02b7eb3301afa0f Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 7 Feb 2011 19:19:50 -0500 Subject: [PATCH 307/668] Fixing range option for prototype engine. Fixes #1509 --- cake/libs/view/helpers/prototype_engine.php | 8 ++++++-- .../cases/libs/view/helpers/prototype_engine.test.php | 6 ++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cake/libs/view/helpers/prototype_engine.php b/cake/libs/view/helpers/prototype_engine.php index 32805a502..d55dc9a65 100644 --- a/cake/libs/view/helpers/prototype_engine.php +++ b/cake/libs/view/helpers/prototype_engine.php @@ -330,10 +330,14 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { unset($options['handle']); if (isset($options['min']) && isset($options['max'])) { - $options['range'] = array($options['min'], $options['max']); + $options['range'] = sprintf('$R(%s,%s)', $options['min'], $options['max']); unset($options['min'], $options['max']); } - $optionString = $this->_processOptions('slider', $options); + $options = $this->_mapOptions('slider', $options); + $options = $this->_prepareCallbacks('slider', $options); + $optionString = $this->_parseOptions( + $options, array_merge(array_keys($this->_callbackArguments['slider']), array('range')) + ); if (!empty($optionString)) { $optionString = ', {' . $optionString . '}'; } diff --git a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php index b838c7124..e5c63b806 100644 --- a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php +++ b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php @@ -348,9 +348,11 @@ class PrototypeEngineHelperTestCase extends CakeTestCase { 'handle' => '#handle', 'change' => 'change();', 'complete' => 'complete();', - 'value' => 4 + 'value' => 4, + 'min' => 10, + 'max' => 100 )); - $expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, sliderValue:4});'; + $expected = 'var jsSlider = new Control.Slider($("handle"), $("element"), {onChange:function (value) {complete();}, onSlide:function (value) {change();}, range:$R(10,100), sliderValue:4});'; $this->assertEqual($result, $expected); } From 9a940709abc24f0c97bd32973ffdc5639e91fc01 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 7 Feb 2011 20:59:01 -0500 Subject: [PATCH 308/668] Removing unsupported options from PrototypeEngine. Fixes #1516 --- cake/libs/view/helpers/prototype_engine.php | 5 +++-- cake/tests/cases/libs/view/helpers/prototype_engine.test.php | 4 +--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cake/libs/view/helpers/prototype_engine.php b/cake/libs/view/helpers/prototype_engine.php index d55dc9a65..848b676a2 100644 --- a/cake/libs/view/helpers/prototype_engine.php +++ b/cake/libs/view/helpers/prototype_engine.php @@ -45,10 +45,8 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { 'error' => 'onFailure' ), 'sortable' => array( - 'start' => 'onStart', 'sort' => 'onChange', 'complete' => 'onUpdate', - 'distance' => 'snap', ), 'drag' => array( 'snapGrid' => 'snap', @@ -262,6 +260,9 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { * * #### Note: Requires scriptaculous to be loaded. * + * The scriptaculous implementation of sortables does not suppot the 'start' + * and 'distance' options. + * * @param array $options Array of options for the sortable. * @return string Completed sortable script. * @access public diff --git a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php index e5c63b806..0ca94724c 100644 --- a/cake/tests/cases/libs/view/helpers/prototype_engine.test.php +++ b/cake/tests/cases/libs/view/helpers/prototype_engine.test.php @@ -268,13 +268,11 @@ class PrototypeEngineHelperTestCase extends CakeTestCase { function testSortable() { $this->Proto->get('#myList'); $result = $this->Proto->sortable(array( - 'distance' => 5, - 'start' => 'onStart', 'complete' => 'onComplete', 'sort' => 'onSort', 'wrapCallbacks' => false )); - $expected = 'var jsSortable = Sortable.create($("myList"), {onChange:onSort, onStart:onStart, onUpdate:onComplete, snap:5});'; + $expected = 'var jsSortable = Sortable.create($("myList"), {onChange:onSort, onUpdate:onComplete});'; $this->assertEqual($result, $expected); } From a5fb2cf8a73ca5f6095a4b271751ac1488f1f0fe Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 8 Feb 2011 21:53:12 -0500 Subject: [PATCH 309/668] Fixing issue where fixtures without field definitions would drop tables, even though they had no way to re-create them. Fixes #1519 --- cake/tests/cases/libs/cake_test_fixture.test.php | 4 ++++ cake/tests/lib/cake_test_fixture.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/cake/tests/cases/libs/cake_test_fixture.test.php b/cake/tests/cases/libs/cake_test_fixture.test.php index a64d4e3e6..6e6667dde 100644 --- a/cake/tests/cases/libs/cake_test_fixture.test.php +++ b/cake/tests/cases/libs/cake_test_fixture.test.php @@ -391,6 +391,10 @@ class CakeTestFixtureTest extends CakeTestCase { $this->criticDb->setReturnValueAt(1, 'execute', false); $return = $Fixture->drop($this->criticDb); $this->assertFalse($return); + + unset($Fixture->fields); + $return = $Fixture->drop($this->criticDb); + $this->assertFalse($return); } /** diff --git a/cake/tests/lib/cake_test_fixture.php b/cake/tests/lib/cake_test_fixture.php index 00daa38ef..91264d891 100644 --- a/cake/tests/lib/cake_test_fixture.php +++ b/cake/tests/lib/cake_test_fixture.php @@ -153,6 +153,9 @@ class CakeTestFixture extends Object { * @access public */ function drop(&$db) { + if (empty($this->fields)) { + return false; + } $this->Schema->_build(array($this->table => $this->fields)); return ( $db->execute($db->dropSchema($this->Schema), array('log' => false)) !== false From 33390070d34b4987e00c23704e18e5fba8c26a2c Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 8 Feb 2011 22:09:57 -0500 Subject: [PATCH 310/668] Removing HTTP authentication from SecurityComponent. There are new Authentication objects to fill this hole now. --- cake/libs/controller/components/security.php | 219 ------------- .../controller/components/security.test.php | 296 ------------------ 2 files changed, 515 deletions(-) diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index daf0bc8bb..ada4f3eaf 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -89,33 +89,6 @@ class SecurityComponent extends Component { */ public $requireAuth = array(); -/** - * List of actions that require an HTTP-authenticated login (basic or digest) - * - * @var array - * @access public - * @see SecurityComponent::requireLogin() - */ - public $requireLogin = array(); - -/** - * Login options for SecurityComponent::requireLogin() - * - * @var array - * @access public - * @see SecurityComponent::requireLogin() - */ - public $loginOptions = array('type' => '', 'prompt' => null); - -/** - * An associative array of usernames/passwords used for HTTP-authenticated logins. - * - * @var array - * @access public - * @see SecurityComponent::requireLogin() - */ - public $loginUsers = array(); - /** * Controllers from which actions of the current controller are allowed to receive * requests. @@ -215,7 +188,6 @@ class SecurityComponent extends Component { $this->_methodsRequired($controller); $this->_secureRequired($controller); $this->_authRequired($controller); - $this->_loginRequired($controller); $isPost = ($this->request->is('post') || $this->request->is('put')); $isRequestAction = ( @@ -299,134 +271,6 @@ class SecurityComponent extends Component { $this->_requireMethod('Auth', $args); } -/** - * Sets the actions that require an HTTP-authenticated request, or empty for all actions - * - * @return void - * @link http://book.cakephp.org/view/1302/requireLogin - */ - public function requireLogin() { - $args = func_get_args(); - $base = $this->loginOptions; - - foreach ($args as $i => $arg) { - if (is_array($arg)) { - $this->loginOptions = $arg; - unset($args[$i]); - } - } - $this->loginOptions = array_merge($base, $this->loginOptions); - $this->_requireMethod('Login', $args); - if (isset($this->loginOptions['users'])) { - $this->loginUsers =& $this->loginOptions['users']; - } - } - -/** - * Attempts to validate the login credentials for an HTTP-authenticated request - * - * @param string $type Either 'basic', 'digest', or null. If null/empty, will try both. - * @return mixed If successful, returns an array with login name and password, otherwise null. - * @link http://book.cakephp.org/view/1303/loginCredentials-string-type - */ - public function loginCredentials($type = null) { - switch (strtolower($type)) { - case 'basic': - $login = array('username' => env('PHP_AUTH_USER'), 'password' => env('PHP_AUTH_PW')); - if (!empty($login['username'])) { - return $login; - } - break; - case 'digest': - default: - $digest = null; - - if (version_compare(PHP_VERSION, '5.1') != -1) { - $digest = env('PHP_AUTH_DIGEST'); - } elseif (function_exists('apache_request_headers')) { - $headers = apache_request_headers(); - if (isset($headers['Authorization']) && !empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) == 'Digest ') { - $digest = substr($headers['Authorization'], 7); - } - } else { - // Server doesn't support digest-auth headers - trigger_error(__('SecurityComponent::loginCredentials() - Server does not support digest authentication'), E_USER_WARNING); - } - - if (!empty($digest)) { - return $this->parseDigestAuthData($digest); - } - break; - } - return null; - } - -/** - * Generates the text of an HTTP-authentication request header from an array of options. - * - * @param array $options Set of options for header - * @return string HTTP-authentication request header - * @link http://book.cakephp.org/view/1304/loginRequest-array-options - */ - public function loginRequest($options = array()) { - $options = array_merge($this->loginOptions, $options); - $this->_setLoginDefaults($options); - $auth = 'WWW-Authenticate: ' . ucfirst($options['type']); - $out = array('realm="' . $options['realm'] . '"'); - - if (strtolower($options['type']) == 'digest') { - $out[] = 'qop="auth"'; - $out[] = 'nonce="' . uniqid("") . '"'; - $out[] = 'opaque="' . md5($options['realm']) . '"'; - } - - return $auth . ' ' . implode(',', $out); - } - -/** - * Parses an HTTP digest authentication response, and returns an array of the data, or null on failure. - * - * @param string $digest Digest authentication response - * @return array Digest authentication parameters - * @link http://book.cakephp.org/view/1305/parseDigestAuthData-string-digest - */ - public function parseDigestAuthData($digest) { - if (substr($digest, 0, 7) == 'Digest ') { - $digest = substr($digest, 7); - } - $keys = array(); - $match = array(); - $req = array('nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1); - preg_match_all('/(\w+)=([\'"]?)([a-zA-Z0-9@=.\/_-]+)\2/', $digest, $match, PREG_SET_ORDER); - - foreach ($match as $i) { - $keys[$i[1]] = $i[3]; - unset($req[$i[1]]); - } - - if (empty($req)) { - return $keys; - } - return null; - } - -/** - * Generates a hash to be compared with an HTTP digest-authenticated response - * - * @param array $data HTTP digest response data, as parsed by SecurityComponent::parseDigestAuthData() - * @return string Digest authentication hash - * @access public - * @see SecurityComponent::parseDigestAuthData() - * @link http://book.cakephp.org/view/1306/generateDigestResponseHash-array-data - */ - function generateDigestResponseHash($data) { - return md5( - md5($data['username'] . ':' . $this->loginOptions['realm'] . ':' . $this->loginUsers[$data['username']]) . - ':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . - md5(env('REQUEST_METHOD') . ':' . $data['uri']) - ); - } - /** * Black-hole an invalid request with a 404 error or custom callback. If SecurityComponent::$blackHoleCallback * is specified, it will use this callback by executing the method indicated in $error @@ -544,53 +388,6 @@ class SecurityComponent extends Component { return true; } -/** - * Check if login is required - * - * @param object $controller Instantiating controller - * @return bool true if login is required - */ - protected function _loginRequired($controller) { - if (is_array($this->requireLogin) && !empty($this->requireLogin)) { - $requireLogin = $this->requireLogin; - - if (in_array($this->_action, $this->requireLogin) || $this->requireLogin == array('*')) { - $login = $this->loginCredentials($this->loginOptions['type']); - - if ($login == null) { - $controller->header($this->loginRequest()); - - if (!empty($this->loginOptions['prompt'])) { - $this->_callback($controller, $this->loginOptions['prompt']); - } else { - $this->blackHole($controller, 'login'); - } - } else { - if (isset($this->loginOptions['login'])) { - $this->_callback($controller, $this->loginOptions['login'], array($login)); - } else { - if (strtolower($this->loginOptions['type']) == 'digest') { - if ($login && isset($this->loginUsers[$login['username']])) { - if ($login['response'] == $this->generateDigestResponseHash($login)) { - return true; - } - } - $this->blackHole($controller, 'login'); - } else { - if ( - !(in_array($login['username'], array_keys($this->loginUsers)) && - $this->loginUsers[$login['username']] == $login['password']) - ) { - $this->blackHole($controller, 'login'); - } - } - } - } - } - } - return true; - } - /** * Validate submitted form * @@ -738,22 +535,6 @@ class SecurityComponent extends Component { return $tokens; } -/** - * Sets the default login options for an HTTP-authenticated request - * - * @param array $options Default login options - * @return void - */ - protected function _setLoginDefaults(&$options) { - $options = array_merge(array( - 'type' => 'basic', - 'realm' => env('SERVER_NAME'), - 'qop' => 'auth', - 'nonce' => String::uuid() - ), array_filter($options)); - $options = array_merge(array('opaque' => md5($options['realm'])), $options); - } - /** * Calls a controller callback method * diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index cb7197392..f3d1240e6 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -180,10 +180,6 @@ class SecurityComponentTest extends CakeTestCase { 'requireSecure' => array('update_account'), 'requireGet' => array('index'), 'validatePost' => false, - 'loginUsers' => array( - 'mark' => 'password' - ), - 'requireLogin' => array('login'), ); $Security = new SecurityComponent($this->Controller->Components, $settings); $this->Controller->Security->initialize($this->Controller, $settings); @@ -191,8 +187,6 @@ class SecurityComponentTest extends CakeTestCase { $this->assertEqual($Security->requireSecure, $settings['requireSecure']); $this->assertEqual($Security->requireGet, $settings['requireGet']); $this->assertEqual($Security->validatePost, $settings['validatePost']); - $this->assertEqual($Security->loginUsers, $settings['loginUsers']); - $this->assertEqual($Security->requireLogin, $settings['requireLogin']); } /** @@ -367,80 +361,6 @@ class SecurityComponentTest extends CakeTestCase { $this->assertFalse($this->Controller->failed); } -/** - * testRequireLogin method - * - * @access public - * @return void - */ - function testRequireLogin() { - $this->Controller->request['action'] = 'posted'; - $this->Controller->Security->requireLogin( - 'posted', - array('type' => 'basic', 'users' => array('admin' => 'password')) - ); - $_SERVER['PHP_AUTH_USER'] = 'admin'; - $_SERVER['PHP_AUTH_PW'] = 'password'; - $this->Controller->Security->startup($this->Controller); - $this->assertFalse($this->Controller->failed); - - - $this->Controller->request['action'] = 'posted'; - $this->Controller->Security->requireLogin( - array('posted'), - array('type' => 'basic', 'users' => array('admin' => 'password')) - ); - $_SERVER['PHP_AUTH_USER'] = 'admin2'; - $_SERVER['PHP_AUTH_PW'] = 'password'; - $this->Controller->Security->startup($this->Controller); - $this->assertTrue($this->Controller->failed); - - $this->Controller->request['action'] = 'posted'; - $this->Controller->Security->requireLogin( - 'posted', - array('type' => 'basic', 'users' => array('admin' => 'password')) - ); - $_SERVER['PHP_AUTH_USER'] = 'admin'; - $_SERVER['PHP_AUTH_PW'] = 'password2'; - $this->Controller->Security->startup($this->Controller); - $this->assertTrue($this->Controller->failed); - } - -/** - * testDigestAuth method - * - * @access public - * @return void - */ - function testDigestAuth() { - $skip = $this->skipIf((version_compare(PHP_VERSION, '5.1') == -1) XOR (!function_exists('apache_request_headers')), - "%s Cannot run Digest Auth test for PHP versions < 5.1" - ); - - if ($skip) { - return; - } - - $this->Controller->request['action'] = 'posted'; - $_SERVER['PHP_AUTH_DIGEST'] = $digest = <<Controller->Security->requireLogin('posted', array( - 'type' => 'digest', 'users' => array('Mufasa' => 'password'), - 'realm' => 'testrealm@host.com' - )); - $this->Controller->Security->startup($this->Controller); - $this->assertFalse($this->Controller->failed); - } - /** * testRequireGetSucceedWrongMethod method * @@ -539,35 +459,6 @@ DIGEST; $this->assertFalse($this->Controller->failed); } -/** - * testRequireLoginSettings method - * - * @access public - * @return void - */ - function testRequireLoginSettings() { - $this->Controller->Security->requireLogin( - 'add', 'edit', - array('type' => 'basic', 'users' => array('admin' => 'password')) - ); - $this->assertEqual($this->Controller->Security->requireLogin, array('add', 'edit')); - $this->assertEqual($this->Controller->Security->loginUsers, array('admin' => 'password')); - } - -/** - * testRequireLoginAllActions method - * - * @access public - * @return void - */ - function testRequireLoginAllActions() { - $this->Controller->Security->requireLogin( - array('type' => 'basic', 'users' => array('admin' => 'password')) - ); - $this->assertEqual($this->Controller->Security->requireLogin, array('*')); - $this->assertEqual($this->Controller->Security->loginUsers, array('admin' => 'password')); - } - /** * Simple hash validation test * @@ -988,173 +879,6 @@ DIGEST; $this->assertFalse($result); } -/** - * testLoginRequest method - * - * @access public - * @return void - */ - function testLoginRequest() { - $this->Controller->Security->startup($this->Controller); - $realm = 'cakephp.org'; - $options = array('realm' => $realm, 'type' => 'basic'); - $result = $this->Controller->Security->loginRequest($options); - $expected = 'WWW-Authenticate: Basic realm="'.$realm.'"'; - $this->assertEqual($result, $expected); - - $this->Controller->Security->startup($this->Controller); - $options = array('realm' => $realm, 'type' => 'digest'); - $result = $this->Controller->Security->loginRequest($options); - $this->assertPattern('/realm="'.$realm.'"/', $result); - $this->assertPattern('/qop="auth"/', $result); - } - -/** - * testGenerateDigestResponseHash method - * - * @access public - * @return void - */ - function testGenerateDigestResponseHash() { - $this->Controller->Security->startup($this->Controller); - $realm = 'cakephp.org'; - $loginData = array('realm' => $realm, 'users' => array('Willy Smith' => 'password')); - $this->Controller->Security->requireLogin($loginData); - - $data = array( - 'username' => 'Willy Smith', - 'password' => 'password', - 'nonce' => String::uuid(), - 'nc' => 1, - 'cnonce' => 1, - 'realm' => $realm, - 'uri' => 'path_to_identifier', - 'qop' => 'testme' - ); - $_SERVER['REQUEST_METHOD'] = 'POST'; - - $result = $this->Controller->Security->generateDigestResponseHash($data); - $expected = md5( - md5($data['username'] . ':' . $loginData['realm'] . ':' . $data['password']) . ':' . - $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' . - md5(env('REQUEST_METHOD') . ':' . $data['uri']) - ); - $this->assertIdentical($result, $expected); - } - -/** - * testLoginCredentials method - * - * @access public - * @return void - */ - function testLoginCredentials() { - $this->Controller->Security->startup($this->Controller); - $_SERVER['PHP_AUTH_USER'] = $user = 'Willy Test'; - $_SERVER['PHP_AUTH_PW'] = $pw = 'some password for the nice test'; - - $result = $this->Controller->Security->loginCredentials('basic'); - $expected = array('username' => $user, 'password' => $pw); - $this->assertIdentical($result, $expected); - - if (version_compare(PHP_VERSION, '5.1') != -1) { - $_SERVER['PHP_AUTH_DIGEST'] = $digest = << 'Mufasa', - 'realm' => 'testrealm@host.com', - 'nonce' => 'dcd98b7102dd2f0e8b11d0f600bfb0c093', - 'uri' => '/dir/index.html', - 'qop' => 'auth', - 'nc' => '00000001', - 'cnonce' => '0a4f113b', - 'response' => '6629fae49393a05397450978507c4ef1', - 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41' - ); - $result = $this->Controller->Security->loginCredentials('digest'); - $this->assertIdentical($result, $expected); - } - } - -/** - * testParseDigestAuthData method - * - * @access public - * @return void - */ - function testParseDigestAuthData() { - $this->Controller->Security->startup($this->Controller); - $digest = << 'Mufasa', - 'realm' => 'testrealm@host.com', - 'nonce' => 'dcd98b7102dd2f0e8b11d0f600bfb0c093', - 'uri' => '/dir/index.html', - 'qop' => 'auth', - 'nc' => '00000001', - 'cnonce' => '0a4f113b', - 'response' => '6629fae49393a05397450978507c4ef1', - 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41' - ); - $result = $this->Controller->Security->parseDigestAuthData($digest); - $this->assertIdentical($result, $expected); - - $result = $this->Controller->Security->parseDigestAuthData(''); - $this->assertNull($result); - } - -/** - * test parsing digest information with email addresses - * - * @return void - */ - function testParseDigestAuthEmailAddress() { - $this->Controller->Security->startup($this->Controller); - $digest = << 'mark@example.com', - 'realm' => 'testrealm@host.com', - 'nonce' => 'dcd98b7102dd2f0e8b11d0f600bfb0c093', - 'uri' => '/dir/index.html', - 'qop' => 'auth', - 'nc' => '00000001', - 'cnonce' => '0a4f113b', - 'response' => '6629fae49393a05397450978507c4ef1', - 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41' - ); - $result = $this->Controller->Security->parseDigestAuthData($digest); - $this->assertIdentical($result, $expected); - } - /** * testFormDisabledFields method * @@ -1225,26 +949,6 @@ DIGEST; $this->assertTrue($result); } -/** - * testInvalidAuthHeaders method - * - * @access public - * @return void - */ - function testInvalidAuthHeaders() { - $this->Controller->Security->blackHoleCallback = null; - $_SERVER['PHP_AUTH_USER'] = 'admin'; - $_SERVER['PHP_AUTH_PW'] = 'password'; - $realm = 'cakephp.org'; - $loginData = array('type' => 'basic', 'realm' => $realm); - $this->Controller->Security->requireLogin($loginData); - $this->Controller->Security->startup($this->Controller); - - $expected = 'WWW-Authenticate: Basic realm="'.$realm.'"'; - $this->assertEqual(count($this->Controller->testHeaders), 1); - $this->assertEqual(current($this->Controller->testHeaders), $expected); - } - /** * test that a requestAction's controller will have the _Token appended to * the params. From 71f76080a2a254bb203681b3db7047e665915ade Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 9 Feb 2011 21:19:05 -0500 Subject: [PATCH 311/668] Fixing issue where creating cookies in the beforeFilter would result in cookies with the wrong expiry time. Thanks 'RabidFire' for the patch. Fixes #1523 --- cake/libs/controller/components/cookie.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cake/libs/controller/components/cookie.php b/cake/libs/controller/components/cookie.php index 002395b7b..e3a122ca5 100644 --- a/cake/libs/controller/components/cookie.php +++ b/cake/libs/controller/components/cookie.php @@ -166,6 +166,9 @@ class CookieComponent extends Object { function initialize(&$controller, $settings) { $this->key = Configure::read('Security.salt'); $this->_set($settings); + if (isset($this->time)) { + $this->__expire($this->time); + } } /** From 42c2f3011bcef22b4ed13bf9197856e62d51faf4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 11 Feb 2011 21:49:00 -0500 Subject: [PATCH 312/668] Applying fix from 'Mark Mitchell' to expose PeriodicalExecuter in the callback. Fixes #1529 --- cake/libs/view/helpers/ajax.php | 2 +- cake/tests/cases/libs/view/helpers/ajax.test.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index 9c153c3a2..251ea7f18 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -315,7 +315,7 @@ class AjaxHelper extends AppHelper { function remoteTimer($options = null) { $frequency = (isset($options['frequency'])) ? $options['frequency'] : 10; $callback = $this->remoteFunction($options); - $code = "new PeriodicalExecuter(function() {{$callback}}, $frequency)"; + $code = "new PeriodicalExecuter(function(pe) {{$callback}}, $frequency)"; return $this->Javascript->codeBlock($code); } diff --git a/cake/tests/cases/libs/view/helpers/ajax.test.php b/cake/tests/cases/libs/view/helpers/ajax.test.php index 20cd15bc8..d06bf4a71 100644 --- a/cake/tests/cases/libs/view/helpers/ajax.test.php +++ b/cake/tests/cases/libs/view/helpers/ajax.test.php @@ -566,49 +566,49 @@ class AjaxHelperTest extends CakeTestCase { $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'frequency' => 25)); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'complete' => 'complete();')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, onComplete:function(request, json) {complete();}})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'complete' => 'complete();', 'create' => 'create();')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, onComplete:function(request, json) {complete();}, onCreate:function(request, xhr) {create();}})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'exception' => 'alert(exception);')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, onException:function(request, exception) {alert(exception);}})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'contentType' => 'application/x-www-form-urlencoded')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, contentType:\'application/x-www-form-urlencoded\'})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'method' => 'get', 'encoding' => 'utf-8')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, method:\'get\', encoding:\'utf-8\'})')) . '/', $result); $result = $this->Ajax->remoteTimer(array('url' => 'http://www.cakephp.org', 'postBody' => 'var1=value1')); $this->assertPattern('/^]+type="text\/javascript"[^<>]*>.+<\/script>$/s', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); - $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); + $this->assertPattern('/^]+>\s*' . str_replace('/', '\\/', preg_quote('//')) . '\s*<\/script>$/', $result); $this->assertPattern('/' . str_replace('/', '\\/', preg_quote('new Ajax.Request(\'http://www.cakephp.org\', {asynchronous:true, evalScripts:true, postBody:\'var1=value1\'})')) . '/', $result); } /** From e0420937a7883914ea79ee0519c90938109ecfe2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 11 Feb 2011 22:30:51 -0500 Subject: [PATCH 313/668] Fixing notice error that could occur if csrfTokens ended up being null/not an array. --- cake/libs/controller/components/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index daf0bc8bb..0391a10b3 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -689,7 +689,7 @@ class SecurityComponent extends Component { $tokenData = array(); if ($this->Session->check('_Token')) { $tokenData = $this->Session->read('_Token'); - if (!empty($tokenData['csrfTokens'])) { + if (!empty($tokenData['csrfTokens']) && is_array($tokenData['csrfTokens'])) { $token['csrfTokens'] = $this->_expireTokens($tokenData['csrfTokens']); } } From 26c5f78a140076b9d993d73b276194430a4b584f Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 11 Feb 2011 22:37:56 -0500 Subject: [PATCH 314/668] Fixing notice error caused when looking for info on tables that don't exist. --- cake/libs/model/datasources/dbo/dbo_mysql.php | 5 ++++- .../libs/model/datasources/dbo/dbo_mysql.test.php | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 749b9d0a6..19d030b83 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -298,6 +298,9 @@ class DboMysql extends DboSource { } $fields = false; $cols = $this->_execute('SHOW FULL COLUMNS FROM ' . $this->fullTableName($model)); + if (!$cols) { + throw new CakeException(__('Could not describe table for %s', $model->name)); + } foreach ($cols as $column) { $fields[$column->Field] = array( @@ -609,7 +612,7 @@ class DboMysql extends DboSource { } } $result->closeCursor(); - if (is_string($name)) { + if (is_string($name) && isset($tables[$name])) { return $tables[$name]; } return $tables; diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index ff462f86e..f9f05dc6b 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -795,6 +795,21 @@ class DboMysqlTest extends CakeTestCase { $this->assertEqual($tables, array('cake_table', 'another_table')); } +/** + * test that listDetailedSources with a named table that doesn't exist. + * + * @return void + */ + function testListDetailedSourcesNamed() { + $this->loadFixtures('Apple'); + + $result = $this->Dbo->listDetailedSources('imaginary'); + $this->assertEquals(array(), $result, 'Should be empty when table does not exist.'); + + $result = $this->Dbo->listDetailedSources(); + $this->assertTrue(isset($result['apples']), 'Key should exist'); + } + /** * Tests that getVersion method sends the correct query for getting the mysql version * @return void From 08509cc6d3a5dd71c0e1abd748f090fe1c6ad0a9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 11 Feb 2011 22:39:09 -0500 Subject: [PATCH 315/668] Fixing issue where static variable would be shared inconsistently across multiple instances. Fixes #1504 --- cake/libs/model/model.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index b7899582a..4e64c20ce 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -360,6 +360,14 @@ class Model extends Object { */ private $__affectedRows = null; +/** + * Has the datasource been configured. + * + * @var boolean + * @see Model::getDataSource + */ + private $__sourceConfigured = false; + /** * List of valid finder method options, supplied as the first parameter to find(). * @@ -2888,14 +2896,12 @@ class Model extends Object { /** * Gets the DataSource to which this model is bound. - * Not safe for use with some versions of PHP4, because this class is overloaded. * * @return object A DataSource object */ public function getDataSource() { - static $configured = false; - if (!$configured && $this->useTable !== false) { - $configured = true; + if (!$this->__sourceConfigured && $this->useTable !== false) { + $this->__sourceConfigured = true; $this->setSource($this->useTable); } return ConnectionManager::getDataSource($this->useDbConfig); From d0c2b9c9d1d601188a5d1a4b87f0bdf2dd447adf Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 06:21:19 -0500 Subject: [PATCH 316/668] Fixing failing test caused by boolean type changes. --- cake/tests/cases/libs/model/model_delete.test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/model/model_delete.test.php b/cake/tests/cases/libs/model/model_delete.test.php index ae4045743..97535ad17 100644 --- a/cake/tests/cases/libs/model/model_delete.test.php +++ b/cake/tests/cases/libs/model/model_delete.test.php @@ -44,7 +44,7 @@ class ModelDeleteTest extends BaseModelTest { array( 'id' => 3, 'syfile_id' => 3, - 'published' => 0, + 'published' => false, 'name' => 'Item 3', 'ItemsPortfolio' => array( 'id' => 3, @@ -54,7 +54,7 @@ class ModelDeleteTest extends BaseModelTest { array( 'id' => 4, 'syfile_id' => 4, - 'published' => 0, + 'published' => false, 'name' => 'Item 4', 'ItemsPortfolio' => array( 'id' => 4, @@ -64,7 +64,7 @@ class ModelDeleteTest extends BaseModelTest { array( 'id' => 5, 'syfile_id' => 5, - 'published' => 0, + 'published' => false, 'name' => 'Item 5', 'ItemsPortfolio' => array( 'id' => 5, From e16d21eaa3dc32c245fe2a845b9372add49d286b Mon Sep 17 00:00:00 2001 From: mark Date: Wed, 13 Oct 2010 14:06:03 +0200 Subject: [PATCH 317/668] Add displayField and primaryKey to controller bake. Fixes #1192 Signed-off-by: mark_story --- cake/console/shells/tasks/controller.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cake/console/shells/tasks/controller.php b/cake/console/shells/tasks/controller.php index f1cac43eb..c3c4e2ea4 100644 --- a/cake/console/shells/tasks/controller.php +++ b/cake/console/shells/tasks/controller.php @@ -282,9 +282,13 @@ class ControllerTask extends BakeTask { $singularName = Inflector::variable($currentModelName); $singularHumanName = $this->_singularHumanName($controllerName); $pluralHumanName = $this->_pluralName($controllerName); + $displayField = $modelObj->displayField; + $primaryKey = $modelObj->primaryKey; - $this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName', 'singularHumanName', - 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName')); + $this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName', + 'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName', + 'displayField', 'primaryKey' + )); $actions = $this->Template->generate('actions', 'controller_actions'); return $actions; } From 681b9997b00482db19ac0bed15c63a886d2d0e2f Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 13 Feb 2011 02:24:39 +0530 Subject: [PATCH 318/668] Renamed Controller::view to Controller::viewClass and Controller::view, View::view can now be used to change the view rendered by default. Parameters of Controller::render() and View::render() changed to eliminate redundancy. Closes #1520 --- cake/libs/controller/controller.php | 38 +++++++++++-------- cake/libs/view/view.php | 38 +++++++++---------- .../cases/libs/controller/controller.test.php | 19 ++++++---- 3 files changed, 54 insertions(+), 41 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 3929d7ed9..1893e407a 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -31,12 +31,12 @@ App::import('View', 'View', false); * automatic model availability, redirection, callbacks, and more. * * Controllers should provide a number of 'action' methods. These are public methods on the controller - * that are not prefixed with a '_' and not part of Controller. Each action serves as an endpoint for + * that are not prefixed with a '_' and not part of Controller. Each action serves as an endpoint for * performing a specific action on a resource or collection of resources. For example adding or editing a new * object, or listing a set of objects. * * You can access request parameters, using `$this->request`. The request object contains all the POST, GET and FILES - * that were part of the request. + * that were part of the request. * * After performing the required actions, controllers are responsible for creating a response. This usually * takes the form of a generated View, or possibly a redirection to another controller action. In either case @@ -86,7 +86,7 @@ class Controller extends Object { /** * An instance of a CakeRequest object that contains information about the current request. * This object contains all the information about a request and several methods for reading - * additional information about the request. + * additional information about the request. * * @var CakeRequest */ @@ -134,6 +134,15 @@ class Controller extends Object { */ public $modelNames = array(); +/** + * The name of the view file to render. The name specified + * is the filename in /app/views/ without the .ctp extension. + * + * @var string + * @link http://book.cakephp.org/view/962/Page-related-Attributes-layout-and-pageTitle + */ + public $view = null; + /** * The name of the layout file to render the view inside of. The name specified * is the filename of the layout in /app/views/layouts without the .ctp @@ -182,7 +191,7 @@ class Controller extends Object { * * @var string */ - public $view = 'View'; + public $viewClass = 'View'; /** * Instance of the View created during rendering. Won't be set until after Controller::render() is called. @@ -431,7 +440,7 @@ class Controller extends Object { } $plugin = $pluginName . '.'; } - + if (is_subclass_of($this, $this->_mergeParent) || !empty($pluginController)) { $appVars = get_class_vars($this->_mergeParent); $uses = $appVars['uses']; @@ -447,7 +456,7 @@ class Controller extends Object { array_unshift($this->uses, $plugin . $this->modelClass); } } elseif ( - ($this->uses !== null || $this->uses !== false) && + ($this->uses !== null || $this->uses !== false) && is_array($this->uses) && !empty($appVars['uses']) ) { $this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses)); @@ -459,7 +468,7 @@ class Controller extends Object { $merge = array('components', 'helpers'); $appVars = get_class_vars($pluginController); if ( - ($this->uses !== null || $this->uses !== false) && + ($this->uses !== null || $this->uses !== false) && is_array($this->uses) && !empty($appVars['uses']) ) { $this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses)); @@ -636,7 +645,7 @@ class Controller extends Object { extract($status, EXTR_OVERWRITE); } $response = $this->Components->trigger( - 'beforeRedirect', + 'beforeRedirect', array(&$this, $url, $status, $exit), array('break' => true, 'breakOn' => false, 'collectReturn' => true) ); @@ -815,21 +824,20 @@ class Controller extends Object { /** * Instantiates the correct view class, hands it its data, and uses it to render the view output. * - * @param string $action Action name to render + * @param string $view View to use for rendering * @param string $layout Layout to use - * @param string $file File to use for rendering * @return string Full output string of view contents * @link http://book.cakephp.org/view/980/render */ - public function render($action = null, $layout = null, $file = null) { + public function render($view = null, $layout = null) { $this->beforeRender(); $this->Components->trigger('beforeRender', array(&$this)); - $viewClass = $this->view; - if ($this->view != 'View') { + $viewClass = $this->viewClass; + if ($this->viewClass != 'View') { list($plugin, $viewClass) = pluginSplit($viewClass); $viewClass = $viewClass . 'View'; - App::import('View', $this->view); + App::import('View', $this->viewClass); } $this->request->params['models'] = $this->modelNames; @@ -865,7 +873,7 @@ class Controller extends Object { $this->autoRender = false; $this->View = $View; - return $this->response->body($View->render($action, $layout, $file)); + return $this->response->body($View->render($view, $layout)); } /** diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 35a886fbc..7939aa910 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -28,9 +28,9 @@ App::import('View', 'Helper', false); * in from the controller to render the results of the controller action. Often this is HTML, * but can also take the form of JSON, XML, PDF's or streaming files. * - * CakePHP uses a two-step-view pattern. This means that the view content is rendered first, + * CakePHP uses a two-step-view pattern. This means that the view content is rendered first, * and then inserted into the selected layout. A special `$content_for_layout` variable is available - * in the layout, and it contains the rendered view. This also means you can pass data from the view to the + * in the layout, and it contains the rendered view. This also means you can pass data from the view to the * layout using `$this->set()` * * @package cake.libs.view @@ -87,6 +87,13 @@ class View extends Object { */ public $viewVars = array(); +/** + * Name of view to use with this View. + * + * @var string + */ + public $view = null; + /** * Name of layout to use with this View. * @@ -123,7 +130,7 @@ class View extends Object { * @var string */ public $subDir = null; - + /** * Theme name. If you are using themes, you should remember to use ThemeView as well. * @@ -212,7 +219,7 @@ class View extends Object { /** * An instance of a CakeRequest object that contains information about the current request. * This object contains all the information about a request and several methods for reading - * additional information about the request. + * additional information about the request. * * @var CakeRequest */ @@ -234,7 +241,7 @@ class View extends Object { * @var array */ private $__passedVars = array( - 'viewVars', 'autoLayout', 'ext', 'helpers', 'layout', 'name', + 'viewVars', 'autoLayout', 'ext', 'helpers', 'view', 'layout', 'name', 'layoutPath', 'viewPath', 'request', 'plugin', 'passedArgs', 'cacheAction' ); @@ -279,7 +286,7 @@ class View extends Object { /** * Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string. * - * This realizes the concept of Elements, (or "partial layouts") and the $params array is used to send + * This realizes the concept of Elements, (or "partial layouts") and the $params array is used to send * data to be used in the element. Elements can be cached improving performance by using the `cache` option. * * ### Special params @@ -353,8 +360,7 @@ class View extends Object { } /** - * Renders view for given action and layout. If $file is given, that is used - * for a view filename (e.g. customFunkyView.ctp). + * Renders view for given view file and layout. * * Render triggers helper callbacks, which are fired before and after the view are rendered, * as well as before and after the layout. The helper callbacks are called @@ -366,14 +372,12 @@ class View extends Object { * * If View::$autoRender is false and no `$layout` is provided, the view will be returned bare. * - * @param string $action Name of action to render for, this will be used as the filename to render, unless - * $file is give as well. + * @param string $view Name of view file to use * @param string $layout Layout to use. - * @param string $file Custom filename for view. Providing this will render a specific file for the given action. * @return string Rendered Element * @throws CakeException if there is an error in the view. */ - public function render($action = null, $layout = null, $file = null) { + public function render($view = null, $layout = null) { if ($this->hasRendered) { return true; } @@ -382,11 +386,7 @@ class View extends Object { } $this->output = null; - if ($file != null) { - $action = $file; - } - - if ($action !== false && $viewFileName = $this->_getViewFileName($action)) { + if ($view !== false && $viewFileName = $this->_getViewFileName($view)) { $this->Helpers->trigger('beforeRender', array($viewFileName)); $this->output = $this->_render($viewFileName); $this->Helpers->trigger('afterRender', array($viewFileName)); @@ -447,7 +447,7 @@ class View extends Object { } /** - * Render cached view. Works in concert with CacheHelper and Dispatcher to + * Render cached view. Works in concert with CacheHelper and Dispatcher to * render cached view files. * * @param string $filename the cache file to include @@ -699,7 +699,7 @@ class View extends Object { } } $paths = $this->_paths($this->plugin); - + $exts = $this->_getExtensions(); foreach ($exts as $ext) { foreach ($paths as $path) { diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 5ab0ccebb..5ff4b833e 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -134,7 +134,7 @@ class ControllerCommentsController extends ControllerTestAppController { * @access public */ public $name = 'ControllerComments'; - + protected $_mergeParent = 'ControllerTestAppController'; } @@ -277,7 +277,7 @@ class TestController extends ControllerTestAppController { * @access public */ public $uses = array('ControllerComment', 'ControllerAlias'); - + protected $_mergeParent = 'ControllerTestAppController'; /** @@ -343,7 +343,7 @@ class TestComponent extends Object { */ function beforeRender($controller) { if ($this->viewclass) { - $controller->view = $this->viewclass; + $controller->viewClass = $this->viewclass; } } } @@ -368,7 +368,7 @@ class AnotherTestController extends ControllerTestAppController { * @access public */ public $uses = null; - + protected $_mergeParent = 'ControllerTestAppController'; } @@ -627,7 +627,7 @@ class ControllerTest extends CakeTestCase { $Controller->set(array(1 => 'one', 2 => 'two')); $expected = array(3 => 'three', 4 => 'four', 1 => 'one', 2 => 'two'); $this->assertEqual($Controller->viewVars, $expected); - + } /** @@ -641,7 +641,7 @@ class ControllerTest extends CakeTestCase { 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) ), true); $request = new CakeRequest('controller_posts/index'); - + $request->params['action'] = 'index'; $Controller = new Controller($request, $this->getMock('CakeResponse')); $Controller->viewPath = 'posts'; @@ -649,8 +649,13 @@ class ControllerTest extends CakeTestCase { $result = $Controller->render('index'); $this->assertPattern('/posts index/', $result); + $Controller->view = 'index'; + $result = $Controller->render(); + $this->assertPattern('/posts index/', $result); + $result = $Controller->render('/elements/test_element'); $this->assertPattern('/this is the test element/', $result); + $Controller->view = null; $Controller = new TestController($request); $Controller->helpers = array('Html'); @@ -986,7 +991,7 @@ class ControllerTest extends CakeTestCase { $this->assertEqual($result, '/posts/index'); $request = $this->getMock('CakeRequest'); - + $request->expects($this->any())->method('referer') ->with(false) ->will($this->returnValue('http://localhost/posts/index')); From 63caf566fb82df7b4f9ddd2019773e92827637ec Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 12:22:29 -0500 Subject: [PATCH 319/668] Adding some tests around invalidFields() and fieldList options. Closes #1534 --- cake/tests/cases/libs/model/model_validation.test.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cake/tests/cases/libs/model/model_validation.test.php b/cake/tests/cases/libs/model/model_validation.test.php index bbf00996e..d0b3fb648 100644 --- a/cake/tests/cases/libs/model/model_validation.test.php +++ b/cake/tests/cases/libs/model/model_validation.test.php @@ -131,13 +131,14 @@ class ModelValidationTest extends BaseModelTest { $TestModel =& new ValidationTest1(); $TestModel->validate = $validate = array( 'title' => array( - 'rule' => 'customValidator', + 'rule' => 'alphaNumeric', 'required' => true ), 'name' => array( - 'rule' => 'allowEmpty', + 'rule' => 'alphaNumeric', 'required' => true )); + $TestModel->set(array('title' => '$$', 'name' => '##')); $TestModel->invalidFields(array('fieldList' => array('title'))); $expected = array( 'title' => 'This field cannot be left blank' @@ -175,9 +176,9 @@ class ModelValidationTest extends BaseModelTest { */ function testInvalidFieldsWhitelist() { $TestModel =& new ValidationTest1(); - $TestModel->validate = $validate = array( + $TestModel->validate = array( 'title' => array( - 'rule' => 'customValidator', + 'rule' => 'alphaNumeric', 'required' => true ), 'name' => array( @@ -186,7 +187,7 @@ class ModelValidationTest extends BaseModelTest { )); $TestModel->whitelist = array('name'); - $TestModel->save(array('name' => '#$$#')); + $TestModel->save(array('name' => '#$$#', 'title' => '$$$$')); $expected = array('name' => 'This field cannot be left blank'); $this->assertEqual($TestModel->validationErrors, $expected); From 60590de6bcd8be662b3cc59f1abbdfc8a5cb34cb Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 15:51:00 -0500 Subject: [PATCH 320/668] Starting to banish TestManager, and replace it with a more normal PHPUnit test loader. --- cake/console/shells/testsuite.php | 9 ++-- cake/tests/lib/cake_test_loader.php | 80 +++++++++++++++++++++++++++++ cake/tests/lib/test_manager.php | 1 + cake/tests/lib/test_runner.php | 18 +++++-- 4 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 cake/tests/lib/cake_test_loader.php diff --git a/cake/console/shells/testsuite.php b/cake/console/shells/testsuite.php index b8eb079b8..f74c53e36 100644 --- a/cake/console/shells/testsuite.php +++ b/cake/console/shells/testsuite.php @@ -165,7 +165,6 @@ class TestSuiteShell extends Shell { $this->_dispatcher = new CakeTestSuiteDispatcher(); $this->_dispatcher->loadTestFramework(); - require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php'; } /** @@ -178,6 +177,7 @@ class TestSuiteShell extends Shell { return; } $params = array( + 'core' => false, 'app' => false, 'plugin' => null, 'output' => 'text', @@ -185,7 +185,9 @@ class TestSuiteShell extends Shell { $category = $this->args[0]; - if ($category == 'app') { + if ($category == 'core') { + $params['core'] = true; + } elseif ($category == 'app') { $params['app'] = true; } elseif ($category != 'core') { $params['plugin'] = $category; @@ -252,11 +254,12 @@ class TestSuiteShell extends Shell { */ protected function run($runnerArgs, $options = array()) { require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_runner.php'; + require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_loader.php'; restore_error_handler(); restore_error_handler(); - $testCli = new TestRunner($runnerArgs); + $testCli = new TestRunner('CakeTestLoader', $runnerArgs); $testCli->run($options); } diff --git a/cake/tests/lib/cake_test_loader.php b/cake/tests/lib/cake_test_loader.php new file mode 100644 index 000000000..c388a410e --- /dev/null +++ b/cake/tests/lib/cake_test_loader.php @@ -0,0 +1,80 @@ +_resolveTestFile($filePath, $params); + + PHPUnit_Util_Class::collectStart(); + PHPUnit_Util_Fileloader::checkAndLoad($file, false); + $loadedClasses = PHPUnit_Util_Class::collectEnd(); + + if (!empty($loadedClasses)) { + $testCaseClass = 'PHPUnit_Framework_TestCase'; + + foreach ($loadedClasses as $loadedClass) { + $class = new ReflectionClass($loadedClass); + $classFile = $class->getFileName(); + + if ($class->isSubclassOf($testCaseClass) && + !$class->isAbstract()) { + $suiteClassName = $loadedClass; + $testCaseClass = $loadedClass; + + if ($classFile == realpath($file)) { + break; + } + } + + if ($class->hasMethod('suite')) { + $method = $class->getMethod('suite'); + + if (!$method->isAbstract() && + $method->isPublic() && + $method->isStatic()) { + $suiteClassName = $loadedClass; + + if ($classFile == realpath($file)) { + break; + } + } + } + } + } + + if (class_exists($suiteClassName, FALSE)) { + $class = new ReflectionClass($suiteClassName); + + if ($class->getFileName() == realpath($file)) { + return $class; + } + } + } + + public function reload(ReflectionClass $aClass) { + return $aClass; + } + +/** + * Convert path fragments used by Cake's test runner to absolute paths that can be fed to PHPUnit. + * + * @return void + */ + protected function _resolveTestFile($filePath, $params) { + $basePath = $this->_basePath($params); + return $basePath . DS . $filePath . '.test.php'; + } + + protected function _basePath($params) { + $result = null; + if (!empty($params['core'])) { + $result = CORE_TEST_CASES; + } elseif (!empty($params['app'])) { + $result = APP_TEST_CASES; + } else if (!empty($params['plugin'])) { + $pluginPath = App::pluginPath($params['plugin']); + $result = $pluginPath . 'tests' . DS . 'cases'; + } + return $result; + } +} diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 7cb6a3fdd..ea7c6f5eb 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -16,6 +16,7 @@ * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +var_dump(debug_backtrace()); define('CORE_TEST_CASES', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases'); define('CORE_TEST_GROUPS', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'groups'); define('APP_TEST_CASES', TESTS . 'cases'); diff --git a/cake/tests/lib/test_runner.php b/cake/tests/lib/test_runner.php index 22def2a23..ec99cf93a 100644 --- a/cake/tests/lib/test_runner.php +++ b/cake/tests/lib/test_runner.php @@ -16,10 +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 'test_manager.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'); + PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); @@ -35,7 +40,10 @@ class TestRunner extends PHPUnit_TextUI_Command { * * @param array $params list of options to be used for this run */ - public function __construct($params = array()) { + public function __construct($loader, $params = array()) { + $this->arguments['loader'] = $loader; + $this->arguments['test'] = $params['case']; + $this->arguments['testFile'] = $params; $this->_params = $params; } @@ -46,12 +54,12 @@ class TestRunner extends PHPUnit_TextUI_Command { * @return void */ protected function handleCustomTestSuite() { - $manager = new TestManager($this->_params); + /*$manager = new TestManager($this->_params); if (!empty($this->_params['case'])) { $this->arguments['test'] = $manager->getTestSuite(); $this->arguments['test']->setFixtureManager($manager->getFixtureManager()); $manager->loadCase($this->_params['case'] . '.test.php', $this->arguments['test']); - } + }*/ } } \ No newline at end of file From 5a631a6c74b6aba084adbfc5b7e67b17f5124cb1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 16:08:48 -0500 Subject: [PATCH 321/668] Renaming the runner. Making the runner extend PHPUnit_TextUi_TestRunner so we can customize the TestSuite classes it uses. Adding CakeTestSuiteCommand so we can customize the TextUI_Command output. --- cake/console/shells/testsuite.php | 5 +- .../{test_runner.php => cake_test_runner.php} | 31 +--- cake/tests/lib/cake_test_suite_command.php | 139 ++++++++++++++++++ 3 files changed, 144 insertions(+), 31 deletions(-) rename cake/tests/lib/{test_runner.php => cake_test_runner.php} (50%) create mode 100644 cake/tests/lib/cake_test_suite_command.php diff --git a/cake/console/shells/testsuite.php b/cake/console/shells/testsuite.php index f74c53e36..b0c31831f 100644 --- a/cake/console/shells/testsuite.php +++ b/cake/console/shells/testsuite.php @@ -253,13 +253,12 @@ class TestSuiteShell extends Shell { * @return void */ protected function run($runnerArgs, $options = array()) { - require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_runner.php'; - require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_loader.php'; + require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php'; restore_error_handler(); restore_error_handler(); - $testCli = new TestRunner('CakeTestLoader', $runnerArgs); + $testCli = new CakeTestSuiteCommand('CakeTestLoader', $runnerArgs); $testCli->run($options); } diff --git a/cake/tests/lib/test_runner.php b/cake/tests/lib/cake_test_runner.php similarity index 50% rename from cake/tests/lib/test_runner.php rename to cake/tests/lib/cake_test_runner.php index ec99cf93a..632f88fcb 100644 --- a/cake/tests/lib/test_runner.php +++ b/cake/tests/lib/cake_test_runner.php @@ -16,15 +16,7 @@ * @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_suite.php'; -require_once(CAKE_TESTS_LIB . 'cake_test_case.php'); -require_once(CAKE_TESTS_LIB . 'controller_test_case.php'); - +require 'PHPUnit/TextUI/TestRunner.php'; PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); @@ -33,19 +25,8 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); * * @package cake.tests.lib */ -class TestRunner extends PHPUnit_TextUI_Command { +class CakeTestRunner extends PHPUnit_TextUI_TestRunner { -/** - * Construct method - * - * @param array $params list of options to be used for this run - */ - public function __construct($loader, $params = array()) { - $this->arguments['loader'] = $loader; - $this->arguments['test'] = $params['case']; - $this->arguments['testFile'] = $params; - $this->_params = $params; - } /** * Sets the proper test suite to use and loads the test file in it. @@ -54,12 +35,6 @@ class TestRunner extends PHPUnit_TextUI_Command { * @return void */ protected function handleCustomTestSuite() { - /*$manager = new TestManager($this->_params); - - if (!empty($this->_params['case'])) { - $this->arguments['test'] = $manager->getTestSuite(); - $this->arguments['test']->setFixtureManager($manager->getFixtureManager()); - $manager->loadCase($this->_params['case'] . '.test.php', $this->arguments['test']); - }*/ + } } \ No newline at end of file diff --git a/cake/tests/lib/cake_test_suite_command.php b/cake/tests/lib/cake_test_suite_command.php new file mode 100644 index 000000000..779edad22 --- /dev/null +++ b/cake/tests/lib/cake_test_suite_command.php @@ -0,0 +1,139 @@ +addFileToBlacklist(__FILE__, 'DEFAULT'); + +/** + * Class to customize loading of test suites from CLI + * + * @package cake.tests.lib + */ +class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { + +/** + * Construct method + * + * @param array $params list of options to be used for this run + */ + public function __construct($loader, $params = array()) { + $this->arguments['loader'] = $loader; + $this->arguments['test'] = $params['case']; + $this->arguments['testFile'] = $params; + $this->_params = $params; + } + + /** + * @param array $argv + * @param boolean $exit + */ + public function run(array $argv, $exit = TRUE) + { + $this->handleArguments($argv); + + $runner = new CakeTestRunner($this->arguments['loader']); + + if (is_object($this->arguments['test']) && + $this->arguments['test'] instanceof PHPUnit_Framework_Test) { + $suite = $this->arguments['test']; + } else { + $suite = $runner->getTest( + $this->arguments['test'], + $this->arguments['testFile'], + $this->arguments['syntaxCheck'] + ); + } + + if (count($suite) == 0) { + $skeleton = new PHPUnit_Util_Skeleton_Test( + $suite->getName(), + $this->arguments['testFile'] + ); + + $result = $skeleton->generate(TRUE); + + if (!$result['incomplete']) { + eval(str_replace(array(''), '', $result['code'])); + $suite = new PHPUnit_Framework_TestSuite( + $this->arguments['test'] . 'Test' + ); + } + } + + if ($this->arguments['listGroups']) { + PHPUnit_TextUI_TestRunner::printVersionString(); + + print "Available test group(s):\n"; + + $groups = $suite->getGroups(); + sort($groups); + + foreach ($groups as $group) { + print " - $group\n"; + } + + exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); + } + + unset($this->arguments['test']); + unset($this->arguments['testFile']); + + try { + $result = $runner->doRun($suite, $this->arguments); + } + + catch (PHPUnit_Framework_Exception $e) { + print $e->getMessage() . "\n"; + } + + if ($exit) { + if (isset($result) && $result->wasSuccessful()) { + exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); + } + + else if (!isset($result) || $result->errorCount() > 0) { + exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); + } + + else { + exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); + } + } + } + +/** + * Sets the proper test suite to use and loads the test file in it. + * this method gets called as a callback from the parent class + * + * @return void + */ + protected function handleCustomTestSuite() { + + } +} \ No newline at end of file From f586ed03942a943949ae995ead12e0f23c3f8827 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 16:45:26 -0500 Subject: [PATCH 322/668] Initial ugly re-factor of where fixtures are done. --- cake/tests/lib/cake_test_runner.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/cake/tests/lib/cake_test_runner.php b/cake/tests/lib/cake_test_runner.php index 632f88fcb..2cd81897c 100644 --- a/cake/tests/lib/cake_test_runner.php +++ b/cake/tests/lib/cake_test_runner.php @@ -27,14 +27,16 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); */ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { - -/** - * Sets the proper test suite to use and loads the test file in it. - * this method gets called as a callback from the parent class - * - * @return void - */ - protected function handleCustomTestSuite() { - + public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) { + $fixture = new CakeFixtureManager; + foreach ($suite->getIterator() as $test) { + if ($test instanceof CakeTestCase) { + $fixture->fixturize($test); + $test->fixtureManager = $fixture; + } + } + $r = parent::doRun($suite, $arguments); + $fixture->shutdown(); + return $r; } } \ No newline at end of file From 0a2822335c44857a58cb15128650cecee81c607f Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 16:58:10 -0500 Subject: [PATCH 323/668] Removing a bunch of code not needed any more. --- cake/tests/lib/cake_test_suite.php | 51 +--------------------- cake/tests/lib/cake_test_suite_command.php | 9 ---- 2 files changed, 2 insertions(+), 58 deletions(-) diff --git a/cake/tests/lib/cake_test_suite.php b/cake/tests/lib/cake_test_suite.php index 2cde50059..7c5f49193 100644 --- a/cake/tests/lib/cake_test_suite.php +++ b/cake/tests/lib/cake_test_suite.php @@ -16,25 +16,10 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); + class CakeTestSuite extends PHPUnit_Framework_TestSuite { -/** - * Instance of a fixture manager - * @var CakeFixtureManager - */ - protected $_fixtureManager = null; - -/** - * Sets the intances for the fixture manager that will be used by this class. - * - * @param CakeFixtureManager $manager the instance of the manager class - * @return void - * @access public - */ - public function setFixtureManager(CakeFixtureManager $manager) { - $this->_fixtureManager = $manager; - } - /** * Adds all the files in a directory to the test suite. Does not recurse through directories. * @@ -71,36 +56,4 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite { } } -/** - * Method that is called before the tests of this test suite are run. - * It will load fixtures accordingly for each test. - * - * @return void - * @access protected - */ - protected function setUp() { - parent::setUp(); - if (!$this->_fixtureManager) { - return; - } - foreach ($this->getIterator() as $test) { - if ($test instanceof CakeTestCase) { - $this->_fixtureManager->fixturize($test); - $test->fixtureManager = $this->_fixtureManager; - } - } - } - -/** - * Method that is called after all the tests of this test suite are run. - * - * @return void - * @access protected - */ - protected function tearDown() { - parent::tearDown(); - if ($this->_fixtureManager) { - $this->_fixtureManager->shutDown(); - } - } } \ No newline at end of file diff --git a/cake/tests/lib/cake_test_suite_command.php b/cake/tests/lib/cake_test_suite_command.php index 779edad22..ab786d74f 100644 --- a/cake/tests/lib/cake_test_suite_command.php +++ b/cake/tests/lib/cake_test_suite_command.php @@ -127,13 +127,4 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { } } -/** - * Sets the proper test suite to use and loads the test file in it. - * this method gets called as a callback from the parent class - * - * @return void - */ - protected function handleCustomTestSuite() { - - } } \ No newline at end of file From 8c2e0815ece293406620c6c2ea8a689fd8078af4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 17:36:00 -0500 Subject: [PATCH 324/668] Adding Fixture manager overriding. Refs #1511 --- cake/console/shells/testsuite.php | 2 ++ cake/tests/lib/cake_test_runner.php | 29 +++++++++++++++++++--- cake/tests/lib/cake_test_suite_command.php | 11 ++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/cake/console/shells/testsuite.php b/cake/console/shells/testsuite.php index b0c31831f..5a9202454 100644 --- a/cake/console/shells/testsuite.php +++ b/cake/console/shells/testsuite.php @@ -143,6 +143,8 @@ class TestSuiteShell extends Shell { ))->addOption('directive', array( 'help' => __('key[=value] Sets a php.ini value.'), 'default' => false + ))->addOption('fixture', array( + 'help' => __('Choose a custom fixture manager.'), )); return $parser; diff --git a/cake/tests/lib/cake_test_runner.php b/cake/tests/lib/cake_test_runner.php index 2cd81897c..99c228332 100644 --- a/cake/tests/lib/cake_test_runner.php +++ b/cake/tests/lib/cake_test_runner.php @@ -27,16 +27,39 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); */ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { +/** + * Actually run a suite of tests. Cake initializes fixtures here using the chosen fixture manager + * + * @param PHPUnit_Framework_Test $suite + * @param array $arguments + * @return void + */ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) { - $fixture = new CakeFixtureManager; + $fixture = $this->_getFixtureManager($arguments); foreach ($suite->getIterator() as $test) { if ($test instanceof CakeTestCase) { $fixture->fixturize($test); $test->fixtureManager = $fixture; } } - $r = parent::doRun($suite, $arguments); + $return = parent::doRun($suite, $arguments); $fixture->shutdown(); - return $r; + return $return; + } + +/** + * Get the fixture manager class specified or use the default one. + * + * @return instance of a fixture manager. + */ + protected function _getFixtureManager($arguments) { + if (!isset($arguments['fixtureManager'])) { + return new CakeFixtureManager(); + } + App::import('Lib', 'test_suite/' . Inflector::underscore($arguments['fixtureManagerΩ'])); + if (class_exists($arguments['fixtureManager'])) { + return new $arguments['fixtureManager']; + } + throw new Exception('No fixture manager found.'); } } \ No newline at end of file diff --git a/cake/tests/lib/cake_test_suite_command.php b/cake/tests/lib/cake_test_suite_command.php index ab786d74f..a86a38d31 100644 --- a/cake/tests/lib/cake_test_suite_command.php +++ b/cake/tests/lib/cake_test_suite_command.php @@ -47,6 +47,8 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { $this->arguments['test'] = $params['case']; $this->arguments['testFile'] = $params; $this->_params = $params; + + $this->longOptions['fixture='] = 'handleFixture'; } /** @@ -127,4 +129,13 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { } } +/** + * Handler for customizing the FixtureManager class/ + * + * @param string $class Name of the class that will be the fixture manager + * @return void + */ + function handleFixture($class) { + $this->arguments['fixtureManager'] = $class; + } } \ No newline at end of file From 8ebbccbd760696439b1e7839594a136866d0a4a9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 17:39:42 -0500 Subject: [PATCH 325/668] Fixing tab/spaces. --- cake/tests/lib/cake_test_suite_command.php | 122 +++++++++++---------- 1 file changed, 62 insertions(+), 60 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_command.php b/cake/tests/lib/cake_test_suite_command.php index a86a38d31..dd2546e80 100644 --- a/cake/tests/lib/cake_test_suite_command.php +++ b/cake/tests/lib/cake_test_suite_command.php @@ -52,82 +52,84 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { } /** - * @param array $argv - * @param boolean $exit - */ - public function run(array $argv, $exit = TRUE) - { - $this->handleArguments($argv); + * Ugly hack to get around PHPUnit having a hard coded classname for the Runner. :( + * + * @param array $argv + * @param boolean $exit + */ + public function run(array $argv, $exit = TRUE) + { + $this->handleArguments($argv); - $runner = new CakeTestRunner($this->arguments['loader']); + $runner = new CakeTestRunner($this->arguments['loader']); - if (is_object($this->arguments['test']) && - $this->arguments['test'] instanceof PHPUnit_Framework_Test) { - $suite = $this->arguments['test']; - } else { - $suite = $runner->getTest( - $this->arguments['test'], - $this->arguments['testFile'], - $this->arguments['syntaxCheck'] - ); - } + if (is_object($this->arguments['test']) && + $this->arguments['test'] instanceof PHPUnit_Framework_Test) { + $suite = $this->arguments['test']; + } else { + $suite = $runner->getTest( + $this->arguments['test'], + $this->arguments['testFile'], + $this->arguments['syntaxCheck'] + ); + } - if (count($suite) == 0) { - $skeleton = new PHPUnit_Util_Skeleton_Test( - $suite->getName(), - $this->arguments['testFile'] - ); + if (count($suite) == 0) { + $skeleton = new PHPUnit_Util_Skeleton_Test( + $suite->getName(), + $this->arguments['testFile'] + ); - $result = $skeleton->generate(TRUE); + $result = $skeleton->generate(TRUE); - if (!$result['incomplete']) { - eval(str_replace(array(''), '', $result['code'])); - $suite = new PHPUnit_Framework_TestSuite( - $this->arguments['test'] . 'Test' - ); - } - } + if (!$result['incomplete']) { + eval(str_replace(array(''), '', $result['code'])); + $suite = new PHPUnit_Framework_TestSuite( + $this->arguments['test'] . 'Test' + ); + } + } - if ($this->arguments['listGroups']) { - PHPUnit_TextUI_TestRunner::printVersionString(); + if ($this->arguments['listGroups']) { + PHPUnit_TextUI_TestRunner::printVersionString(); - print "Available test group(s):\n"; + print "Available test group(s):\n"; - $groups = $suite->getGroups(); - sort($groups); + $groups = $suite->getGroups(); + sort($groups); - foreach ($groups as $group) { - print " - $group\n"; - } + foreach ($groups as $group) { + print " - $group\n"; + } - exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); - } + exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); + } - unset($this->arguments['test']); - unset($this->arguments['testFile']); + unset($this->arguments['test']); + unset($this->arguments['testFile']); - try { - $result = $runner->doRun($suite, $this->arguments); - } + try { + $result = $runner->doRun($suite, $this->arguments); + } - catch (PHPUnit_Framework_Exception $e) { - print $e->getMessage() . "\n"; - } + catch (PHPUnit_Framework_Exception $e) { + print $e->getMessage() . "\n"; + } - if ($exit) { - if (isset($result) && $result->wasSuccessful()) { - exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); - } + if ($exit) { + if (isset($result) && $result->wasSuccessful()) { + exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT); + } - else if (!isset($result) || $result->errorCount() > 0) { - exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); - } + else if (!isset($result) || $result->errorCount() > 0) { + exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT); + } - else { - exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); - } - } - } + else { + exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); + } + } + } /** * Handler for customizing the FixtureManager class/ From 16481d7b7ef80f77b1c35424935308e48e8e865f Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 18:39:25 -0500 Subject: [PATCH 326/668] Running individual tests from the web runner now works. Adding some more hooks, so webrunner can swap out result printers like it did before. --- cake/tests/lib/cake_test_runner.php | 5 +++ cake/tests/lib/cake_test_suite_command.php | 23 +++++++++++++ cake/tests/lib/cake_test_suite_dispatcher.php | 34 +++++++++++++------ .../tests/lib/reporter/cake_base_reporter.php | 7 +++- .../tests/lib/reporter/cake_html_reporter.php | 1 + 5 files changed, 59 insertions(+), 11 deletions(-) diff --git a/cake/tests/lib/cake_test_runner.php b/cake/tests/lib/cake_test_runner.php index 99c228332..8d245e790 100644 --- a/cake/tests/lib/cake_test_runner.php +++ b/cake/tests/lib/cake_test_runner.php @@ -35,6 +35,10 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { * @return void */ public function doRun(PHPUnit_Framework_Test $suite, array $arguments = array()) { + if (isset($arguments['printer'])) { + self::$versionStringPrinted = true; + } + $fixture = $this->_getFixtureManager($arguments); foreach ($suite->getIterator() as $test) { if ($test instanceof CakeTestCase) { @@ -42,6 +46,7 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { $test->fixtureManager = $fixture; } } + $return = parent::doRun($suite, $arguments); $fixture->shutdown(); return $return; diff --git a/cake/tests/lib/cake_test_suite_command.php b/cake/tests/lib/cake_test_suite_command.php index dd2546e80..010095fa3 100644 --- a/cake/tests/lib/cake_test_suite_command.php +++ b/cake/tests/lib/cake_test_suite_command.php @@ -49,6 +49,7 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { $this->_params = $params; $this->longOptions['fixture='] = 'handleFixture'; + $this->longOptions['output='] = 'handleReporter'; } /** @@ -140,4 +141,26 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { function handleFixture($class) { $this->arguments['fixtureManager'] = $class; } + +/** + * Handles output flag used to change printing on webrunner. + * + * @return void + */ + public function handleReporter($reporter) { + $object = null; + + $type = strtolower($reporter); + $coreClass = 'Cake' . ucwords($reporter) . 'Reporter'; + $coreFile = CAKE_TESTS_LIB . 'reporter/cake_' . $type . '_reporter.php'; + + $appClass = $reporter . 'Reporter'; + $appFile = APPLIBS . 'test_suite/reporter/' . $type . '_reporter.php'; + if (include_once $coreFile) { + $object = new $coreClass(null, $this->_params); + } elseif (include_once $appFile) { + $object = new $appClass(null, $this->_params); + } + $this->arguments['printer'] = $object; + } } \ No newline at end of file diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 36937ed2c..07c7cd32e 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -39,13 +39,6 @@ class CakeTestSuiteDispatcher { 'filter' => false ); -/** - * The classname for the TestManager being used - * - * @var string - */ - protected $_managerClass = 'TestManager'; - /** * The Instance of the Manager being used. * @@ -260,9 +253,11 @@ class CakeTestSuiteDispatcher { $this->_checkXdebug(); } } + if (empty($this->params['plugin']) && empty($this->params['app'])) { + $this->params['core'] = true; + } $this->params['baseUrl'] = $this->_baseUrl; $this->params['baseDir'] = $this->_baseDir; - $this->getManager(); } /** @@ -271,9 +266,28 @@ class CakeTestSuiteDispatcher { * @return void */ function _runTestCase() { + require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php'; + + $Reporter = CakeTestSuiteDispatcher::getReporter(); + + $commandArgs = array( + 'case' => $this->params['case'], + 'core' =>$this->params['core'], + 'app' => $this->params['app'], + 'plugin' => $this->params['plugin'], + 'codeCoverage' => $this->params['codeCoverage'], + 'baseUrl' => $this->_baseUrl, + 'baseDir' => $this->_baseDir, + ); + + $options = array( + '--filter', $this->params['filter'], + '--output', $this->params['output'] + ); + try { - $Reporter = CakeTestSuiteDispatcher::getReporter(); - return $this->Manager->runTestCase($this->params['case'], $Reporter, $this->params['codeCoverage']); + $command = new CakeTestSuiteCommand('CakeTestLoader', $commandArgs); + $result = $command->run($options); } catch (MissingConnectionException $exception) { ob_end_clean(); $baseDir = $this->_baseDir; diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index 9f4b3d3ec..e1dc5ddb7 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -16,6 +16,7 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +require_once 'PHPUnit/TextUi/ResultPrinter.php'; PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); @@ -25,7 +26,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); * @package cake * @package cake.tests.lib */ -class CakeBaseReporter implements PHPUnit_Framework_TestListener { +class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { /** * Time the test runs started. @@ -146,6 +147,10 @@ class CakeBaseReporter implements PHPUnit_Framework_TestListener { return ''; } + public function printResult(PHPUnit_Framework_TestResult $result) { + $this->paintFooter($result); + } + public function paintResult(PHPUnit_Framework_TestResult $result) { $this->paintFooter($result); } diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 73d6eb8f1..012063e42 100755 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -340,6 +340,7 @@ class CakeHtmlReporter extends CakeBaseReporter { * @param PHPUnit_Framework_TestSuite $suite */ public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { + echo $this->paintHeader(); echo '

    ' . __('Running %s', $suite->getName()) . '

    '; } } From 08fba9b2802b60f6f8b75a3d63282739219ea057 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 19:01:38 -0500 Subject: [PATCH 327/668] Making coverage reports work from the webrunner. --- cake/tests/lib/cake_test_runner.php | 24 ++++++++++++++++++- cake/tests/lib/cake_test_suite_command.php | 2 +- cake/tests/lib/cake_test_suite_dispatcher.php | 24 ------------------- cake/tests/lib/test_manager.php | 1 - 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/cake/tests/lib/cake_test_runner.php b/cake/tests/lib/cake_test_runner.php index 8d245e790..460a2edd2 100644 --- a/cake/tests/lib/cake_test_runner.php +++ b/cake/tests/lib/cake_test_runner.php @@ -21,11 +21,20 @@ require 'PHPUnit/TextUI/TestRunner.php'; PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); /** - * Class to customize loading of test suites from CLI + * A custom test runner for Cake's use of PHPUnit. * * @package cake.tests.lib */ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { +/** + * Lets us pass in some options needed for cake's webrunner. + * + * @return void + */ + public function __construct($loader, $params) { + parent::__construct($loader); + $this->_params = $params; + } /** * Actually run a suite of tests. Cake initializes fixtures here using the chosen fixture manager @@ -52,6 +61,19 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { return $return; } +/** + * Create the test result and splice on our code coverage reports. + * + * @return PHPUnit_Framework_TestResult + */ + protected function createTestResult() { + $result = new PHPUnit_Framework_TestResult; + if (isset($this->_params['codeCoverage'])) { + $result->collectCodeCoverageInformation(true); + } + return $result; + } + /** * Get the fixture manager class specified or use the default one. * diff --git a/cake/tests/lib/cake_test_suite_command.php b/cake/tests/lib/cake_test_suite_command.php index 010095fa3..0d9d62200 100644 --- a/cake/tests/lib/cake_test_suite_command.php +++ b/cake/tests/lib/cake_test_suite_command.php @@ -62,7 +62,7 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { { $this->handleArguments($argv); - $runner = new CakeTestRunner($this->arguments['loader']); + $runner = new CakeTestRunner($this->arguments['loader'], $this->_params); if (is_object($this->arguments['test']) && $this->arguments['test'] instanceof PHPUnit_Framework_Test) { diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 07c7cd32e..e61564d68 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -38,14 +38,6 @@ class CakeTestSuiteDispatcher { 'show_passes' => false, 'filter' => false ); - -/** - * The Instance of the Manager being used. - * - * @var TestManager subclass - */ - public $Manager; - /** * Baseurl for the request * @@ -185,20 +177,6 @@ class CakeTestSuiteDispatcher { $Reporter->paintDocumentEnd(); } -/** - * Sets the Manager to use for the request. - * - * @return string The manager class name - * @static - */ - function &getManager() { - if (empty($this->Manager)) { - require_once CAKE_TESTS_LIB . 'test_manager.php'; - $this->Manager = new $this->_managerClass($this->params); - } - return $this->Manager; - } - /** * Gets the reporter based on the request parameters * @@ -268,8 +246,6 @@ class CakeTestSuiteDispatcher { function _runTestCase() { require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php'; - $Reporter = CakeTestSuiteDispatcher::getReporter(); - $commandArgs = array( 'case' => $this->params['case'], 'core' =>$this->params['core'], diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index ea7c6f5eb..7cb6a3fdd 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -16,7 +16,6 @@ * @since CakePHP(tm) v 1.2.0.4433 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -var_dump(debug_backtrace()); define('CORE_TEST_CASES', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases'); define('CORE_TEST_GROUPS', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'groups'); define('APP_TEST_CASES', TESTS . 'cases'); From f84046c8027c88f7f753144e1e1f52c65ddcce67 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 19:11:47 -0500 Subject: [PATCH 328/668] Moving a require. Adding some doc blocks, and making the loader not double append test case suffixes. --- cake/tests/lib/cake_test_loader.php | 29 ++++++++++++++++--- cake/tests/lib/cake_test_suite_dispatcher.php | 4 +-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/cake/tests/lib/cake_test_loader.php b/cake/tests/lib/cake_test_loader.php index c388a410e..cbc767f01 100644 --- a/cake/tests/lib/cake_test_loader.php +++ b/cake/tests/lib/cake_test_loader.php @@ -2,6 +2,13 @@ class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader { +/** + * Load a file and find the first test case / suite in that file. + * + * @param string $filePath + * @param string $params + * @return ReflectionClass + */ public function load($filePath, $params = '') { $file = $this->_resolveTestFile($filePath, $params); @@ -50,7 +57,13 @@ class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader { } } } - + +/** + * Reload method. + * + * @param ReflectionClass $aClass + * @return void + */ public function reload(ReflectionClass $aClass) { return $aClass; } @@ -61,10 +74,17 @@ class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader { * @return void */ protected function _resolveTestFile($filePath, $params) { - $basePath = $this->_basePath($params); - return $basePath . DS . $filePath . '.test.php'; + $basePath = $this->_basePath($params) . DS . $filePath; + $ending = '.test.php'; + return (strpos($basePath, $ending) === (strlen($basePath) - strlen($ending))) ? $basePath : $basePath . $ending; } - + +/** + * Generates the base path to a set of tests based on the parameters. + * + * @param array $params + * @return string The base path. + */ protected function _basePath($params) { $result = null; if (!empty($params['core'])) { @@ -77,4 +97,5 @@ class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader { } return $result; } + } diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index e61564d68..e78d43001 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -86,6 +86,8 @@ 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 { @@ -244,8 +246,6 @@ class CakeTestSuiteDispatcher { * @return void */ function _runTestCase() { - require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php'; - $commandArgs = array( 'case' => $this->params['case'], 'core' =>$this->params['core'], From 00c56facddf5d95f59f5f9c89f780f59bd36e016 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 19:12:19 -0500 Subject: [PATCH 329/668] Removing CakeWebTestCase it doesn't work anymore. --- cake/tests/lib/cake_web_test_case.php | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 cake/tests/lib/cake_web_test_case.php diff --git a/cake/tests/lib/cake_web_test_case.php b/cake/tests/lib/cake_web_test_case.php deleted file mode 100644 index 256e75933..000000000 --- a/cake/tests/lib/cake_web_test_case.php +++ /dev/null @@ -1,26 +0,0 @@ - - * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) - * - * Licensed under The MIT License - * Redistributions of files must retain the above copyright notice - * - * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) - * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake.tests.lib - * @since CakePHP(tm) v 1.2.0.4433 - * @license MIT License (http://www.opensource.org/licenses/mit-license.php) - */ - -/** - * Simple wrapper for the WebTestCase provided by SimpleTest - * - * @package cake.tests.lib - */ -class CakeWebTestCase extends WebTestCase { -} From 846a0587fc6ad3893ac54d433178a354ec186873 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 19:12:55 -0500 Subject: [PATCH 330/668] Getting rid of TestManager. --- cake/tests/cases/libs/test_manager.test.php | 110 ------- .../tests/lib/reporter/cake_base_reporter.php | 117 ++++++- cake/tests/lib/test_manager.php | 299 ------------------ 3 files changed, 116 insertions(+), 410 deletions(-) delete mode 100644 cake/tests/cases/libs/test_manager.test.php delete mode 100644 cake/tests/lib/test_manager.php diff --git a/cake/tests/cases/libs/test_manager.test.php b/cake/tests/cases/libs/test_manager.test.php deleted file mode 100644 index 524e77fc3..000000000 --- a/cake/tests/cases/libs/test_manager.test.php +++ /dev/null @@ -1,110 +0,0 @@ - - * Copyright 2005-2010, Cake Software Foundation, Inc. - * 1785 E. Sahara Avenue, Suite 490-204 - * Las Vegas, Nevada 89104 - * - * Licensed under The MIT License - * Redistributions of files must retain the above copyright notice - * - * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) - * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake.tests.cases.libs - * @since CakePHP(tm) v 1.2.0.4206 - * @license MIT License (http://www.opensource.org/licenses/mit-license.php) - */ - -class TestTestManager extends TestManager { - - public function setTestSuite($testSuite) { - $this->_testSuite = $testSuite; - } -} - -/** - * TestManagerTest class - * - * @package cake.tests.cases.libs - */ -class TestManagerTest extends CakeTestCase { - -/** - * Number of times the funcion PHPUnit_Framework_TestSuite::addTestFile() has been called - * - * @var integer - */ - protected $_countFiles = 0; - -/** - * setUp method - * - * @return void - */ - public function setUp() { - parent::setUp(); - $this->_countFiles = 0; - $this->TestManager = new TestTestManager(); - $this->testSuiteStub = $this->getMock('CakeTestSuite'); - - $this->testSuiteStub - ->expects($this->any()) - ->method('addTestFile') - ->will($this->returnCallback(array(&$this, '_countIncludedTestFiles'))); - - $this->testSuiteStub - ->expects($this->any()) - ->method('addTestSuite') - ->will($this->returnCallback(array(&$this, '_countIncludedTestFiles'))); - - $this->TestManager->setTestSuite($this->testSuiteStub); - $this->Reporter = $this->getMock('CakeHtmlReporter'); - } - -/** - * Helper method to count the number of times the - * function PHPUnit_Framework_TestSuite::addTestFile() has been called - * @return void - */ - public function _countIncludedTestFiles() { - $this->_countFiles++; - } - - protected function _getAllTestFiles($directory = CORE_TEST_CASES, $type = 'test') { - $folder = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); - $extension = str_replace('.', '\.', $this->TestManager->getExtension($type)); - $out = new RegexIterator($folder, '#^.+'.$extension.'$#i', RecursiveRegexIterator::GET_MATCH); - - $files = array(); - foreach ($out as $testFile) { - $files[] = $testFile[0]; - } - return $files; - } - -/** -* Tests that trying to run an unexistent file throws an exception -* @expectedException InvalidArgumentException -*/ - public function testRunUnexistentCase() { - $file = md5(time()); - $result = $this->TestManager->runTestCase($file, $this->Reporter); - } - -/** - * testRunTestCase method - * - * @return void - */ - public function testRunTestCase() { - $file = 'libs/test_manager.test.php'; - $result = $this->TestManager->runTestCase($file, $this->Reporter, true); - $this->assertEquals(1, $this->_countFiles); - $this->assertInstanceOf('PHPUnit_Framework_TestResult', $result); - } - -} diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index e1dc5ddb7..99a53d062 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -101,10 +101,125 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { * @return mixed */ public function testCaseList() { - $testList = TestManager::getTestCaseList($this->params); + $testList = $this->_generateTestList($this->params); return $testList; } +/** + * Get the list of files for the test listing. + * + * @return void + */ + protected function _generateTestList($params) { + $directory = self::_getTestsPath($params); + $fileList = self::_getTestFileList($directory); + + $testCases = array(); + foreach ($fileList as $testCaseFile) { + $testCases[$testCaseFile] = str_replace($directory . DS, '', $testCaseFile); + } + return $testCases; + } + +/** + * Returns a list of test files from a given directory + * + * @param string $directory Directory to get test case files from. + * @static + */ + protected static function &_getTestFileList($directory = '.') { + $return = self::_getRecursiveFileList($directory, array('self', '_isTestCaseFile')); + return $return; + } + +/** + * Gets a recursive list of files from a given directory and matches then against + * a given fileTestFunction, like isTestCaseFile() + * + * @param string $directory The directory to scan for files. + * @param mixed $fileTestFunction + * @static + */ + protected static function &_getRecursiveFileList($directory = '.', $fileTestFunction) { + $fileList = array(); + if (!is_dir($directory)) { + return $fileList; + } + + $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); + + foreach ($files as $file) { + if (!$file->isFile()) { + continue; + } + $file = $file->getRealPath(); + + if (call_user_func_array($fileTestFunction, array($file))) { + $fileList[] = $file; + } + } + return $fileList; + } +/** + * Extension suffix for test case files. + * + * @var string + */ + protected static $_testExtension = '.test.php'; +/** + * Tests if a file has the correct test case extension + * + * @param string $file + * @return boolean Whether $file is a test case. + * @static + */ + protected static function _isTestCaseFile($file) { + return self::_hasExpectedExtension($file, self::$_testExtension); + } + +/** + * Check if a file has a specific extension + * + * @param string $file + * @param string $extension + * @return void + * @static + */ + protected static function _hasExpectedExtension($file, $extension) { + return $extension == strtolower(substr($file, (0 - strlen($extension)))); + } + +/** + * Returns the given path to the test files depending on a given type of tests (core, app, plugin) + * + * @param array $params Array of parameters for getting test paths. + * Can contain app, type, and plugin params. + * @return string The path tests are located on + * @static + */ + protected static function _getTestsPath($params) { + $result = null; + if (!empty($params['app'])) { + $result = APP_TEST_CASES; + } else if (!empty($params['plugin'])) { + $pluginPath = App::pluginPath($params['plugin']); + $result = $pluginPath . 'tests' . DS . 'cases'; + } else { + $result = CORE_TEST_CASES; + } + return $result; + } + +/** + * Get the extension for either 'group' or 'test' types. + * + * @param string $type Type of test to get, either 'test' or 'group' + * @return string Extension suffix for test. + */ + public static function getExtension($type = 'test') { + return self::$_testExtension; + } + /** * Paints the start of the response from the test suite. * Used to paint things like head elements in an html page. diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php deleted file mode 100644 index 7cb6a3fdd..000000000 --- a/cake/tests/lib/test_manager.php +++ /dev/null @@ -1,299 +0,0 @@ - - * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) - * - * Licensed under The MIT License - * Redistributions of files must retain the above copyright notice - * - * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) - * @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests - * @package cake.tests.lib - * @since CakePHP(tm) v 1.2.0.4433 - * @license MIT License (http://www.opensource.org/licenses/mit-license.php) - */ -define('CORE_TEST_CASES', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases'); -define('CORE_TEST_GROUPS', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'groups'); -define('APP_TEST_CASES', TESTS . 'cases'); -define('APP_TEST_GROUPS', TESTS . 'groups'); - -PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); -require_once CAKE_TESTS_LIB . 'cake_test_suite.php'; - -/** - * TestManager is the base class that handles loading and initiating the running - * of TestCase and TestSuite classes that the user has selected. - * - * @package cake.tests.lib - */ -class TestManager { -/** - * Extension suffix for test case files. - * - * @var string - */ - protected static $_testExtension = '.test.php'; - -/** - * Is this test an AppTest? - * - * @var boolean - */ - public $appTest = false; - -/** - * Is this test a plugin test? - * - * @var mixed boolean false or string name of the plugin being used. - */ - public $pluginTest = false; - -/** - * String to filter test case method names by. - * - * @var string - */ - public $filter = false; - -/** - * TestSuite container for single or grouped test files - * - * @var PHPUnit_Framework_TestSuite - */ - protected $_testSuite = null; - -/** - * Object instance responsible for managing the test fixtures - * - * @var CakeFixtureManager - */ - protected $_fixtureManager = null; - -/** - * Params to configure test runner - * - * @var CakeFixtureManager - */ - public $params = array(); - -/** - * Constructor for the TestManager class - * - * @return void - */ - public function __construct($params = array()) { - require_once(CAKE_TESTS_LIB . 'cake_test_case.php'); - require_once(CAKE_TESTS_LIB . 'controller_test_case.php'); - - $this->params = $params; - if (isset($params['app'])) { - $this->appTest = true; - } - if (isset($params['plugin'])) { - $this->pluginTest = htmlentities($params['plugin']); - } - if ( - isset($params['filter']) && - $params['filter'] !== false && - preg_match('/^[a-zA-Z0-9_]/', $params['filter']) - ) { - $this->filter = '/' . $params['filter'] . '/'; - } - } - -/** - * Runs a specific test case file - * - * @param string $testCaseFile Filename of the test to be run. - * @param PHPUnit_Framework_TestListener $reporter Reporter instance to attach to the test case. - * @throws InvalidArgumentException if the supplied $testCaseFile does not exists - * @return mixed Result of test case being run. - */ - public function runTestCase($testCaseFile, PHPUnit_Framework_TestListener $reporter, $codeCoverage = false) { - $this->loadCase($testCaseFile); - return $this->run($reporter, $codeCoverage); - } - -/** - * Runs the main testSuite and attaches to it a reporter - * - * @param PHPUnit_Framework_TestListener $reporter Reporter instance to use with the group test being run. - * @return PHPUnit_Framework_TestResult Result object of the test run. - */ - protected function run($reporter, $codeCoverage = false) { - restore_error_handler(); - restore_error_handler(); - - $result = new PHPUnit_Framework_TestResult; - $result->collectCodeCoverageInformation($codeCoverage); - $result->addListener($reporter); - $reporter->paintHeader(); - $testSuite = $this->getTestSuite(); - $testSuite->setFixtureManager($this->getFixtureManager()); - $testSuite->run($result, $this->filter); - $reporter->paintResult($result); - return $result; - } - -/** - * Loads a test case in a test suite, if the test suite is null it will create it - * - * @param string Test file path - * @param PHPUnit_Framework_TestSuite $suite the test suite to load the case in - * @throws InvalidArgumentException if test case file is not found - * @return PHPUnit_Framework_TestSuite the suite with the test case loaded - */ - public function loadCase($testCaseFile, PHPUnit_Framework_TestSuite $suite = null) { - $testCaseFileWithPath = $this->_getTestsPath($this->params) . DS . $testCaseFile; - - if (!file_exists($testCaseFileWithPath) || strpos($testCaseFileWithPath, '..')) { - throw new InvalidArgumentException(__('Unable to load test file %s', htmlentities($testCaseFile))); - } - if (!$suite) { - $suite = $this->getTestSuite(__('Individual test case: %s', $testCaseFile)); - } - $suite->addTestFile($testCaseFileWithPath); - - return $suite; - } - -/** - * Returns a list of test cases found in the current valid test case path - * - * @access public - * @static - */ - public static function getTestCaseList($params) { - $directory = self::_getTestsPath($params); - $fileList = self::_getTestFileList($directory); - - $testCases = array(); - foreach ($fileList as $testCaseFile) { - $testCases[$testCaseFile] = str_replace($directory . DS, '', $testCaseFile); - } - return $testCases; - } - -/** - * Returns a list of test files from a given directory - * - * @param string $directory Directory to get test case files from. - * @static - */ - protected static function &_getTestFileList($directory = '.') { - $return = self::_getRecursiveFileList($directory, array('self', '_isTestCaseFile')); - return $return; - } - -/** - * Gets a recursive list of files from a given directory and matches then against - * a given fileTestFunction, like isTestCaseFile() - * - * @param string $directory The directory to scan for files. - * @param mixed $fileTestFunction - * @static - */ - protected static function &_getRecursiveFileList($directory = '.', $fileTestFunction) { - $fileList = array(); - if (!is_dir($directory)) { - return $fileList; - } - - $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); - - foreach ($files as $file) { - if (!$file->isFile()) { - continue; - } - $file = $file->getRealPath(); - - if (call_user_func_array($fileTestFunction, array($file))) { - $fileList[] = $file; - } - } - return $fileList; - } - -/** - * Tests if a file has the correct test case extension - * - * @param string $file - * @return boolean Whether $file is a test case. - * @static - */ - protected static function _isTestCaseFile($file) { - return self::_hasExpectedExtension($file, self::$_testExtension); - } - -/** - * Check if a file has a specific extension - * - * @param string $file - * @param string $extension - * @return void - * @static - */ - protected static function _hasExpectedExtension($file, $extension) { - return $extension == strtolower(substr($file, (0 - strlen($extension)))); - } - -/** - * Returns the given path to the test files depending on a given type of tests (core, app, plugin) - * - * @param array $params Array of parameters for getting test paths. - * Can contain app, type, and plugin params. - * @return string The path tests are located on - * @static - */ - protected static function _getTestsPath($params) { - $result = null; - if (!empty($params['app'])) { - $result = APP_TEST_CASES; - } else if (!empty($params['plugin'])) { - $pluginPath = App::pluginPath($params['plugin']); - $result = $pluginPath . 'tests' . DS . 'cases'; - } else { - $result = CORE_TEST_CASES; - } - return $result; - } - -/** - * Get the extension for either 'group' or 'test' types. - * - * @param string $type Type of test to get, either 'test' or 'group' - * @return string Extension suffix for test. - */ - public static function getExtension($type = 'test') { - return self::$_testExtension; - } - -/** - * Get the container testSuite instance for this runner or creates a new one - * - * @param string $name The name for the container test suite - * @return PHPUnit_Framework_TestSuite container test suite - */ - public function getTestSuite($name = '') { - if (!empty($this->_testSuite)) { - return $this->_testSuite; - } - return $this->_testSuite = new CakeTestSuite($name); - } - -/** - * Get an instance of a Fixture manager to be used by the test cases - * - * @return CakeFixtureManager fixture manager - */ - public function getFixtureManager() { - if (!empty($this->_fixtureManager)) { - return $this->_fixtureManager; - } - return $this->_fixtureManager = new CakeFixtureManager; - } -} From 4f65d0dbed5ddc3363138520603b0a8ed4809f49 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 22:31:51 -0500 Subject: [PATCH 331/668] Fixing issue where document start would be sent multiple times. --- cake/tests/lib/reporter/cake_html_reporter.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 012063e42..f0752b947 100755 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -29,6 +29,8 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); */ class CakeHtmlReporter extends CakeBaseReporter { + protected $_headerSent = false; + /** * Paints the top of the web page setting the * title to the name of the starting test. @@ -36,6 +38,7 @@ class CakeHtmlReporter extends CakeBaseReporter { * @return void */ public function paintHeader() { + $this->_headerSent = true; $this->sendNoCacheHeaders(); $this->paintDocumentStart(); $this->paintTestMenu(); @@ -340,7 +343,9 @@ class CakeHtmlReporter extends CakeBaseReporter { * @param PHPUnit_Framework_TestSuite $suite */ public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { - echo $this->paintHeader(); + if (!$this->_headerSent) { + echo $this->paintHeader(); + } echo '

    ' . __('Running %s', $suite->getName()) . '

    '; } } From 0c09d085856f952b2b00e7c3aa10e9add23ae6e0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 22:32:16 -0500 Subject: [PATCH 332/668] Removing duplicate methods. --- cake/tests/lib/cake_test_suite_command.php | 2 +- cake/tests/lib/cake_test_suite_dispatcher.php | 26 ++----------------- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_command.php b/cake/tests/lib/cake_test_suite_command.php index 0d9d62200..d7c5fa835 100644 --- a/cake/tests/lib/cake_test_suite_command.php +++ b/cake/tests/lib/cake_test_suite_command.php @@ -161,6 +161,6 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { } elseif (include_once $appFile) { $object = new $appClass(null, $this->_params); } - $this->arguments['printer'] = $object; + return $this->arguments['printer'] = $object; } } \ No newline at end of file diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index e78d43001..57ab21c94 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -172,36 +172,14 @@ class CakeTestSuiteDispatcher { * @return void */ function _testCaseList() { - $Reporter =& $this->getReporter(); + $command = new CakeTestSuiteCommand('', $this->params); + $Reporter = $command->handleReporter($this->params['output']); $Reporter->paintDocumentStart(); $Reporter->paintTestMenu(); $Reporter->testCaseList(); $Reporter->paintDocumentEnd(); } -/** - * Gets the reporter based on the request parameters - * - * @return void - * @static - */ - function &getReporter() { - if (!self::$_Reporter) { - $type = strtolower($this->params['output']); - $coreClass = 'Cake' . ucwords($this->params['output']) . 'Reporter'; - $coreFile = CAKE_TESTS_LIB . 'reporter/cake_' . $type . '_reporter.php'; - - $appClass = $this->params['output'] . 'Reporter'; - $appFile = APPLIBS . 'test_suite/reporter/' . $type . '_reporter.php'; - if (include_once $coreFile) { - self::$_Reporter = new $coreClass(null, $this->params); - } elseif (include_once $appFile) { - self::$_Reporter = new $appClass(null, $this->params); - } - } - return self::$_Reporter; - } - /** * Sets the params, calling this will bypass the auto parameter parsing. * From e5c898a4d2f0ec2b240ee09370c2c9820286f6ba Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 22:49:15 -0500 Subject: [PATCH 333/668] Moving methods into the loader class. Getting rid of lame functions and using Spl more effectively. --- cake/tests/lib/cake_test_loader.php | 42 ++++++- .../tests/lib/reporter/cake_base_reporter.php | 117 +----------------- 2 files changed, 42 insertions(+), 117 deletions(-) diff --git a/cake/tests/lib/cake_test_loader.php b/cake/tests/lib/cake_test_loader.php index cbc767f01..bc23615b7 100644 --- a/cake/tests/lib/cake_test_loader.php +++ b/cake/tests/lib/cake_test_loader.php @@ -85,7 +85,7 @@ class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader { * @param array $params * @return string The base path. */ - protected function _basePath($params) { + protected static function _basePath($params) { $result = null; if (!empty($params['core'])) { $result = CORE_TEST_CASES; @@ -98,4 +98,44 @@ class CakeTestLoader implements PHPUnit_Runner_TestSuiteLoader { return $result; } +/** + * Get the list of files for the test listing. + * + * @return void + */ + public static function generateTestList($params) { + $directory = self::_basePath($params); + $fileList = self::_getRecursiveFileList($directory); + + $testCases = array(); + foreach ($fileList as $testCaseFile) { + $testCases[$testCaseFile] = str_replace($directory . DS, '', $testCaseFile); + } + return $testCases; + } + +/** + * Gets a recursive list of files from a given directory and matches then against + * a given fileTestFunction, like isTestCaseFile() + * + * @param string $directory The directory to scan for files. + * @param mixed $fileTestFunction + */ + protected static function _getRecursiveFileList($directory = '.') { + $fileList = array(); + if (!is_dir($directory)) { + return $fileList; + } + + $files = new RegexIterator( + new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)), + '/.*\.test.php$/' + ); + + foreach ($files as $file) { + $fileList[] = $file->getPathname(); + } + return $fileList; + } + } diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index 99a53d062..4232e7451 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -101,125 +101,10 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { * @return mixed */ public function testCaseList() { - $testList = $this->_generateTestList($this->params); + $testList = CakeTestLoader::generateTestList($this->params); return $testList; } -/** - * Get the list of files for the test listing. - * - * @return void - */ - protected function _generateTestList($params) { - $directory = self::_getTestsPath($params); - $fileList = self::_getTestFileList($directory); - - $testCases = array(); - foreach ($fileList as $testCaseFile) { - $testCases[$testCaseFile] = str_replace($directory . DS, '', $testCaseFile); - } - return $testCases; - } - -/** - * Returns a list of test files from a given directory - * - * @param string $directory Directory to get test case files from. - * @static - */ - protected static function &_getTestFileList($directory = '.') { - $return = self::_getRecursiveFileList($directory, array('self', '_isTestCaseFile')); - return $return; - } - -/** - * Gets a recursive list of files from a given directory and matches then against - * a given fileTestFunction, like isTestCaseFile() - * - * @param string $directory The directory to scan for files. - * @param mixed $fileTestFunction - * @static - */ - protected static function &_getRecursiveFileList($directory = '.', $fileTestFunction) { - $fileList = array(); - if (!is_dir($directory)) { - return $fileList; - } - - $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)); - - foreach ($files as $file) { - if (!$file->isFile()) { - continue; - } - $file = $file->getRealPath(); - - if (call_user_func_array($fileTestFunction, array($file))) { - $fileList[] = $file; - } - } - return $fileList; - } -/** - * Extension suffix for test case files. - * - * @var string - */ - protected static $_testExtension = '.test.php'; -/** - * Tests if a file has the correct test case extension - * - * @param string $file - * @return boolean Whether $file is a test case. - * @static - */ - protected static function _isTestCaseFile($file) { - return self::_hasExpectedExtension($file, self::$_testExtension); - } - -/** - * Check if a file has a specific extension - * - * @param string $file - * @param string $extension - * @return void - * @static - */ - protected static function _hasExpectedExtension($file, $extension) { - return $extension == strtolower(substr($file, (0 - strlen($extension)))); - } - -/** - * Returns the given path to the test files depending on a given type of tests (core, app, plugin) - * - * @param array $params Array of parameters for getting test paths. - * Can contain app, type, and plugin params. - * @return string The path tests are located on - * @static - */ - protected static function _getTestsPath($params) { - $result = null; - if (!empty($params['app'])) { - $result = APP_TEST_CASES; - } else if (!empty($params['plugin'])) { - $pluginPath = App::pluginPath($params['plugin']); - $result = $pluginPath . 'tests' . DS . 'cases'; - } else { - $result = CORE_TEST_CASES; - } - return $result; - } - -/** - * Get the extension for either 'group' or 'test' types. - * - * @param string $type Type of test to get, either 'test' or 'group' - * @return string Extension suffix for test. - */ - public static function getExtension($type = 'test') { - return self::$_testExtension; - } - /** * Paints the start of the response from the test suite. * Used to paint things like head elements in an html page. From 39e05bce4a32fba542ce8106b499ffe4bcd18998 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 23:07:39 -0500 Subject: [PATCH 334/668] Using PHPUnit internals for more things. Removing code that is also present in PHPUnit. Updating testsuite shell to use loader class. --- cake/console/shells/testsuite.php | 4 +-- .../tests/lib/reporter/cake_base_reporter.php | 28 ++++--------------- .../tests/lib/reporter/cake_html_reporter.php | 7 +---- .../tests/lib/reporter/cake_text_reporter.php | 13 ++++----- 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/cake/console/shells/testsuite.php b/cake/console/shells/testsuite.php index 5a9202454..b7b588e06 100644 --- a/cake/console/shells/testsuite.php +++ b/cake/console/shells/testsuite.php @@ -167,6 +167,7 @@ class TestSuiteShell extends Shell { $this->_dispatcher = new CakeTestSuiteDispatcher(); $this->_dispatcher->loadTestFramework(); + require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php'; } /** @@ -255,7 +256,6 @@ class TestSuiteShell extends Shell { * @return void */ protected function run($runnerArgs, $options = array()) { - require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php'; restore_error_handler(); restore_error_handler(); @@ -271,7 +271,7 @@ class TestSuiteShell extends Shell { */ public function available() { $params = $this->parseArgs(); - $testCases = TestManager::getTestCaseList($params); + $testCases = CakeTestLoader::generateTestList($params); $app = $params['app']; $plugin = $params['plugin']; diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index 4232e7451..dc0ff3d58 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -28,29 +28,7 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); */ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { -/** - * Time the test runs started. - * - * @var integer - * @access protected - */ - protected $_timeStart = 0; - -/** - * Time the test runs ended - * - * @var integer - * @access protected - */ - protected $_timeEnd = 0; - -/** - * Duration of all test methods. - * - * @var integer - * @access protected - */ - protected $_timeDuration = 0; + protected $_headerSent = false; /** * Array of request parameters. Usually parsed GET params. @@ -71,6 +49,7 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { * The number of assertions done for a test suite */ protected $numAssertions = 0; + /** * Does nothing yet. The first output will * be sent on the first test start. @@ -205,6 +184,9 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { * @param PHPUnit_Framework_TestSuite $suite */ public function startTestSuite(PHPUnit_Framework_TestSuite $suite) { + if (!$this->_headerSent) { + echo $this->paintHeader(); + } echo __('Running %s', $suite->getName()) . "\n"; } diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index f0752b947..671c4000a 100755 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -29,8 +29,6 @@ PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); */ class CakeHtmlReporter extends CakeBaseReporter { - protected $_headerSent = false; - /** * Paints the top of the web page setting the * title to the name of the starting test. @@ -142,10 +140,7 @@ class CakeHtmlReporter extends CakeBaseReporter { echo "" . $result->errorCount() . " exceptions."; echo "\n"; echo '
    '; - echo '

    Time taken by tests (in seconds): ' . $result->time() . '

    '; - if (function_exists('memory_get_peak_usage')) { - echo '

    Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . '

    '; - } + echo '

    ' . PHP_Timer::resourceUsage() . ''; echo $this->_paintLinks(); echo '

    '; if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) { diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index cf4cea447..ec85e50f4 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -35,9 +35,9 @@ class CakeTextReporter extends CakeBaseReporter { * @return void */ public function paintDocumentStart() { - if (!headers_sent()) { + // if (!headers_sent()) { header('Content-type: text/plain'); - } + // } } /** @@ -87,10 +87,8 @@ class CakeTextReporter extends CakeBaseReporter { ', Failures: ' . $result->failureCount() . ', Exceptions: ' . $result->errorCount() . "\n"; - echo 'Time taken by tests (in seconds): ' . $result->time() . "\n"; - if (function_exists('memory_get_peak_usage')) { - echo 'Peak memory use: (in bytes): ' . number_format(memory_get_peak_usage()) . "\n"; - } + echo PHP_Timer::resourceUsage(); + if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) { $coverage = $result->getCodeCoverageInformation(); echo $this->paintCoverage($coverage); @@ -129,8 +127,7 @@ class CakeTextReporter extends CakeBaseReporter { * @return void */ public function paintSkip($message) { - parent::paintSkip($message); - echo "Skip: $message\n"; + printf("Skip: %s\n", $message->getMessage()); } /** From 9f4597effd9b5e4965a2d0f46caf4bc8123218ff Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Feb 2011 23:09:47 -0500 Subject: [PATCH 335/668] reformatting code. --- cake/tests/lib/cake_test_suite_command.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_command.php b/cake/tests/lib/cake_test_suite_command.php index d7c5fa835..1a3a52e58 100644 --- a/cake/tests/lib/cake_test_suite_command.php +++ b/cake/tests/lib/cake_test_suite_command.php @@ -52,14 +52,13 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { $this->longOptions['output='] = 'handleReporter'; } - /** - * Ugly hack to get around PHPUnit having a hard coded classname for the Runner. :( - * - * @param array $argv - * @param boolean $exit - */ - public function run(array $argv, $exit = TRUE) - { +/** + * Ugly hack to get around PHPUnit having a hard coded classname for the Runner. :( + * + * @param array $argv + * @param boolean $exit + */ + public function run(array $argv, $exit = true) { $this->handleArguments($argv); $runner = new CakeTestRunner($this->arguments['loader'], $this->_params); @@ -81,7 +80,7 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { $this->arguments['testFile'] ); - $result = $skeleton->generate(TRUE); + $result = $skeleton->generate(true); if (!$result['incomplete']) { eval(str_replace(array(''), '', $result['code'])); From 78dd89027d219dfbf7a436fe13d1a3d9419e6b1a Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 12:06:51 -0500 Subject: [PATCH 336/668] Removing comments left in on previous commit. --- cake/tests/lib/reporter/cake_text_reporter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index ec85e50f4..c82b7829f 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -35,9 +35,9 @@ class CakeTextReporter extends CakeBaseReporter { * @return void */ public function paintDocumentStart() { - // if (!headers_sent()) { + if (!headers_sent()) { header('Content-type: text/plain'); - // } + } } /** From 1c9808fdcad5468685a6aa47da19d081f7fdd4e7 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 12:10:27 -0500 Subject: [PATCH 337/668] Creating a factory method for the runner creation. --- cake/tests/lib/cake_test_suite_command.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/cake_test_suite_command.php b/cake/tests/lib/cake_test_suite_command.php index 1a3a52e58..2ed6eab0f 100644 --- a/cake/tests/lib/cake_test_suite_command.php +++ b/cake/tests/lib/cake_test_suite_command.php @@ -61,7 +61,7 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { public function run(array $argv, $exit = true) { $this->handleArguments($argv); - $runner = new CakeTestRunner($this->arguments['loader'], $this->_params); + $runner = $this->getRunner($this->arguments['loader']); if (is_object($this->arguments['test']) && $this->arguments['test'] instanceof PHPUnit_Framework_Test) { @@ -131,13 +131,23 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command { } } +/** + * Create a runner for the command. + * + * @param $loader The loader to be used for the test run. + * @return CakeTestRunner + */ + public function getRunner($loader) { + return new CakeTestRunner($loader, $this->_params); + } + /** * Handler for customizing the FixtureManager class/ * * @param string $class Name of the class that will be the fixture manager * @return void */ - function handleFixture($class) { + public function handleFixture($class) { $this->arguments['fixtureManager'] = $class; } From f6e9b5b2544f9bbcd0cf661bbe71fe69f45bab99 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 13:08:43 -0500 Subject: [PATCH 338/668] Removing TestManager from the group tests. Fixing a failing case on the testsuite shell. Fixing Debugger from stealing the error handler from PHPUnit. --- cake/tests/cases/console/shells/testsuite.test.php | 2 +- cake/tests/cases/libs/all_test_suite.test.php | 1 - cake/tests/lib/cake_test_suite_dispatcher.php | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/tests/cases/console/shells/testsuite.test.php b/cake/tests/cases/console/shells/testsuite.test.php index c57d1573b..30ad6f8e9 100644 --- a/cake/tests/cases/console/shells/testsuite.test.php +++ b/cake/tests/cases/console/shells/testsuite.test.php @@ -100,7 +100,7 @@ class TestSuiteShellTest extends CakeTestCase { $this->Shell->expects($this->once())->method('run') ->with( - array('app' => false, 'plugin' => null, 'output' => 'text', 'case' => 'basics'), + array('app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'basics'), array('--filter', 'myFilter', '--colors', '--verbose') ); $this->Shell->main(); diff --git a/cake/tests/cases/libs/all_test_suite.test.php b/cake/tests/cases/libs/all_test_suite.test.php index b85ea0a19..6740003b7 100644 --- a/cake/tests/cases/libs/all_test_suite.test.php +++ b/cake/tests/cases/libs/all_test_suite.test.php @@ -34,7 +34,6 @@ class AllTestSuiteTest extends PHPUnit_Framework_TestSuite { public static function suite() { $suite = new PHPUnit_Framework_TestSuite('All Test Suite classes tests'); - $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'test_manager.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_test_case.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'cake_test_fixture.test.php'); $suite->addTestFile(CORE_TEST_CASES . DS . 'libs' . DS . 'html_coverage_report.test.php'); diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 57ab21c94..978471e0b 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -238,6 +238,7 @@ class CakeTestSuiteDispatcher { '--filter', $this->params['filter'], '--output', $this->params['output'] ); + restore_error_handler(); try { $command = new CakeTestSuiteCommand('CakeTestLoader', $commandArgs); From 912927db18229f2c3b2dca9edb2c8b0f5e259100 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 14:23:12 -0500 Subject: [PATCH 339/668] Removing duplicate tag. --- cake/tests/lib/cake_test_runner.php | 1 - 1 file changed, 1 deletion(-) diff --git a/cake/tests/lib/cake_test_runner.php b/cake/tests/lib/cake_test_runner.php index 460a2edd2..191d4aacf 100644 --- a/cake/tests/lib/cake_test_runner.php +++ b/cake/tests/lib/cake_test_runner.php @@ -12,7 +12,6 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.tests.libs * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ From 451b3fd18d9a9e4da0ed33a126afd6a11b98af01 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 15:01:00 -0500 Subject: [PATCH 340/668] Going back to using the old time and memory calculations/output. --- cake/tests/lib/reporter/cake_html_reporter.php | 3 ++- cake/tests/lib/reporter/cake_text_reporter.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 671c4000a..6af5c6029 100755 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -140,7 +140,8 @@ class CakeHtmlReporter extends CakeBaseReporter { echo "" . $result->errorCount() . " exceptions."; echo "\n"; echo '
    '; - echo '

    ' . PHP_Timer::resourceUsage() . ''; + echo '

    Time: ' . $result->time() . ' seconds

    '; + echo '

    Peak memory: ' . number_format(memory_get_peak_usage()) . ' bytes

    '; echo $this->_paintLinks(); echo '
    '; if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) { diff --git a/cake/tests/lib/reporter/cake_text_reporter.php b/cake/tests/lib/reporter/cake_text_reporter.php index c82b7829f..17d9ee5d2 100644 --- a/cake/tests/lib/reporter/cake_text_reporter.php +++ b/cake/tests/lib/reporter/cake_text_reporter.php @@ -87,7 +87,8 @@ class CakeTextReporter extends CakeBaseReporter { ', Failures: ' . $result->failureCount() . ', Exceptions: ' . $result->errorCount() . "\n"; - echo PHP_Timer::resourceUsage(); + echo 'Time: ' . $result->time() . " seconds\n"; + echo 'Peak memory: ' . number_format(memory_get_peak_usage()) . " bytes\n"; if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) { $coverage = $result->getCodeCoverageInformation(); From 844c6315c18acc495aad02ac01b9acd4448a2c25 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 15:13:52 -0500 Subject: [PATCH 341/668] Fixing issue where a non CakeException would break things. Test added. --- cake/libs/error/exception_renderer.php | 3 +++ .../cases/libs/error/exception_renderer.test.php | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/cake/libs/error/exception_renderer.php b/cake/libs/error/exception_renderer.php index 5745564df..f62b75833 100644 --- a/cake/libs/error/exception_renderer.php +++ b/cake/libs/error/exception_renderer.php @@ -100,6 +100,9 @@ class ExceptionRenderer { if ($exception instanceof CakeException && !$methodExists) { $method = '_cakeError'; + if (empty($template)) { + $template = 'error500'; + } if ($template == 'internalError') { $template = 'error500'; } diff --git a/cake/tests/cases/libs/error/exception_renderer.test.php b/cake/tests/cases/libs/error/exception_renderer.test.php index 1bc7e8bf0..1f0c0a150 100644 --- a/cake/tests/cases/libs/error/exception_renderer.test.php +++ b/cake/tests/cases/libs/error/exception_renderer.test.php @@ -556,8 +556,21 @@ class ExceptionRendererTest extends CakeTestCase { '/(\/|\\\)sidebox.php/' ), 500 + ), + array( + new Exception('boom'), + array( + '/Internal Error/' + ), + 500 + ), + array( + new RuntimeException('another boom'), + array( + '/Internal Error/' + ), + 500 ) - ); } From 7f8c98d9ded9fb86a37be261463a8e110877490c Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 15:15:01 -0500 Subject: [PATCH 342/668] Fixing typo and exposing fixture manager parameter to webrunner. --- cake/tests/lib/cake_test_runner.php | 4 ++-- cake/tests/lib/cake_test_suite_dispatcher.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cake/tests/lib/cake_test_runner.php b/cake/tests/lib/cake_test_runner.php index 191d4aacf..0b0eaa07e 100644 --- a/cake/tests/lib/cake_test_runner.php +++ b/cake/tests/lib/cake_test_runner.php @@ -82,10 +82,10 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { if (!isset($arguments['fixtureManager'])) { return new CakeFixtureManager(); } - App::import('Lib', 'test_suite/' . Inflector::underscore($arguments['fixtureManagerΩ'])); + App::import('Lib', 'test_suite/' . Inflector::underscore($arguments['fixtureManager'])); if (class_exists($arguments['fixtureManager'])) { return new $arguments['fixtureManager']; } - throw new Exception('No fixture manager found.'); + throw new RuntimeException('No fixture manager found.'); } } \ No newline at end of file diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index 978471e0b..cd52a1678 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -36,7 +36,8 @@ class CakeTestSuiteDispatcher { 'output' => 'html', 'show' => 'groups', 'show_passes' => false, - 'filter' => false + 'filter' => false, + 'fixture' => null ); /** * Baseurl for the request @@ -236,7 +237,8 @@ class CakeTestSuiteDispatcher { $options = array( '--filter', $this->params['filter'], - '--output', $this->params['output'] + '--output', $this->params['output'], + '--fixture', $this->params['fixture'] ); restore_error_handler(); From d20f68c44ee6d0b8f7fe3e17cf28e7874a30d5bb Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 18:42:04 -0500 Subject: [PATCH 343/668] Making Model::setSource() eager again to fix issues where joined models would not have the table prefixes correctly configured. Fixes #1507 --- cake/libs/model/model.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 4e64c20ce..9b537a95c 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -465,16 +465,14 @@ class Model extends Object { $this->Behaviors = new BehaviorCollection(); if ($this->useTable !== false) { - if ($this->useTable === null) { $this->useTable = Inflector::tableize($this->name); } + $this->setSource($this->useTable); if ($this->displayField == null) { unset($this->displayField); } - $this->table = $this->useTable; - $this->tableToModel[$this->table] = $this->alias; } elseif ($this->table === false) { $this->table = Inflector::tableize($this->name); } From 51dcb18742a35ed0a9d6c23d0c32eb6424a79603 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 19:01:53 -0500 Subject: [PATCH 344/668] Adding support for AppFixtureManager as well as option flag selection. --- cake/tests/lib/cake_test_runner.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cake/tests/lib/cake_test_runner.php b/cake/tests/lib/cake_test_runner.php index 0b0eaa07e..f1d2c9eda 100644 --- a/cake/tests/lib/cake_test_runner.php +++ b/cake/tests/lib/cake_test_runner.php @@ -79,13 +79,15 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { * @return instance of a fixture manager. */ protected function _getFixtureManager($arguments) { - if (!isset($arguments['fixtureManager'])) { - return new CakeFixtureManager(); + if (isset($arguments['fixtureManager'])) { + if (App::import('Lib', 'test_suite/' . Inflector::underscore($arguments['fixtureManager']))) { + return new $arguments['fixtureManager']; + } + throw new RuntimeException(__('Could not find fixture manager %s.', $arguments['fixtureManager'])); } - App::import('Lib', 'test_suite/' . Inflector::underscore($arguments['fixtureManager'])); - if (class_exists($arguments['fixtureManager'])) { - return new $arguments['fixtureManager']; + if (App::import('Lib', 'test_suite/AppFixtureManager')) { + return new AppFixtureManager(); } - throw new RuntimeException('No fixture manager found.'); + return new CakeFixtureManager(); } } \ No newline at end of file From e60376bef99feff1a3abbd9cd0898916c0dd9497 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 13 Feb 2011 22:19:49 -0500 Subject: [PATCH 345/668] Removing a bunch of code that can be reached through inheritance. Adding a doc block. --- cake/tests/lib/cake_test_loader.php | 77 ++++++++--------------------- 1 file changed, 20 insertions(+), 57 deletions(-) diff --git a/cake/tests/lib/cake_test_loader.php b/cake/tests/lib/cake_test_loader.php index bc23615b7..94ed036f9 100644 --- a/cake/tests/lib/cake_test_loader.php +++ b/cake/tests/lib/cake_test_loader.php @@ -1,6 +1,23 @@ _resolveTestFile($filePath, $params); - - PHPUnit_Util_Class::collectStart(); - PHPUnit_Util_Fileloader::checkAndLoad($file, false); - $loadedClasses = PHPUnit_Util_Class::collectEnd(); - - if (!empty($loadedClasses)) { - $testCaseClass = 'PHPUnit_Framework_TestCase'; - - foreach ($loadedClasses as $loadedClass) { - $class = new ReflectionClass($loadedClass); - $classFile = $class->getFileName(); - - if ($class->isSubclassOf($testCaseClass) && - !$class->isAbstract()) { - $suiteClassName = $loadedClass; - $testCaseClass = $loadedClass; - - if ($classFile == realpath($file)) { - break; - } - } - - if ($class->hasMethod('suite')) { - $method = $class->getMethod('suite'); - - if (!$method->isAbstract() && - $method->isPublic() && - $method->isStatic()) { - $suiteClassName = $loadedClass; - - if ($classFile == realpath($file)) { - break; - } - } - } - } - } - - if (class_exists($suiteClassName, FALSE)) { - $class = new ReflectionClass($suiteClassName); - - if ($class->getFileName() == realpath($file)) { - return $class; - } - } - } - -/** - * Reload method. - * - * @param ReflectionClass $aClass - * @return void - */ - public function reload(ReflectionClass $aClass) { - return $aClass; + return parent::load('', $file); } /** From c1e81a20cdbc389855c8533b69b4c8769d285509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 13 Feb 2011 23:20:49 -0430 Subject: [PATCH 346/668] Moving more files to the new folder --- .../cake_test_loader.php => lib/Cake/TestSuite/CakeTestLoader.php | 0 .../cake_test_runner.php => lib/Cake/TestSuite/CakeTestRunner.php | 0 .../Cake/TestSuite/CakeTestSuiteCommand.php | 0 .../Cake/TestSuite/ControllerTestCase.php | 0 .../view => lib/Cake/View}/errors/missing_datasource_config.ctp | 0 .../view => lib/Cake/View}/errors/missing_datasource_file.ctp | 0 .../tests/cases/libs/controller/components/paginator.test.php | 0 {cake => lib/Cake}/tests/cases/libs/controller_test_case.test.php | 0 .../Cake}/tests/cases/libs/http/basic_authentication.test.php | 0 .../Cake}/tests/cases/libs/http/digest_authentication.test.php | 0 {cake => lib/Cake}/tests/cases/libs/http_response.test.php | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename cake/tests/lib/cake_test_loader.php => lib/Cake/TestSuite/CakeTestLoader.php (100%) rename cake/tests/lib/cake_test_runner.php => lib/Cake/TestSuite/CakeTestRunner.php (100%) rename cake/tests/lib/cake_test_suite_command.php => lib/Cake/TestSuite/CakeTestSuiteCommand.php (100%) rename cake/tests/lib/controller_test_case.php => lib/Cake/TestSuite/ControllerTestCase.php (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_datasource_config.ctp (100%) rename {cake/libs/view => lib/Cake/View}/errors/missing_datasource_file.ctp (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/paginator.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller_test_case.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/http/basic_authentication.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/http/digest_authentication.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/http_response.test.php (100%) 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 100% rename from cake/tests/lib/cake_test_runner.php rename to lib/Cake/TestSuite/CakeTestRunner.php diff --git a/cake/tests/lib/cake_test_suite_command.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php similarity index 100% rename from cake/tests/lib/cake_test_suite_command.php rename to lib/Cake/TestSuite/CakeTestSuiteCommand.php diff --git a/cake/tests/lib/controller_test_case.php b/lib/Cake/TestSuite/ControllerTestCase.php similarity index 100% rename from cake/tests/lib/controller_test_case.php rename to lib/Cake/TestSuite/ControllerTestCase.php 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/tests/cases/libs/controller/components/paginator.test.php b/lib/Cake/tests/cases/libs/controller/components/paginator.test.php similarity index 100% rename from cake/tests/cases/libs/controller/components/paginator.test.php rename to lib/Cake/tests/cases/libs/controller/components/paginator.test.php 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 100% rename from cake/tests/cases/libs/controller_test_case.test.php rename to lib/Cake/tests/cases/libs/controller_test_case.test.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 100% rename from cake/tests/cases/libs/http/basic_authentication.test.php rename to lib/Cake/tests/cases/libs/http/basic_authentication.test.php 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 100% rename from cake/tests/cases/libs/http/digest_authentication.test.php rename to lib/Cake/tests/cases/libs/http/digest_authentication.test.php diff --git a/cake/tests/cases/libs/http_response.test.php b/lib/Cake/tests/cases/libs/http_response.test.php similarity index 100% rename from cake/tests/cases/libs/http_response.test.php rename to lib/Cake/tests/cases/libs/http_response.test.php From 1b38d7c851003dd0e7282fdc8d3d25eeb3c20ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 13 Feb 2011 23:42:41 -0430 Subject: [PATCH 347/668] Resolving conflict left out in previous commit --- lib/Cake/Console/TaskCollection.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/Cake/Console/TaskCollection.php b/lib/Cake/Console/TaskCollection.php index d9b8a1325..4a8513890 100644 --- a/lib/Cake/Console/TaskCollection.php +++ b/lib/Cake/Console/TaskCollection.php @@ -15,11 +15,9 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -<<<<<<< HEAD:lib/Cake/Console/TaskCollection.php + App::uses('ObjectCollection', 'Utility'); -======= ->>>>>>> origin/2.0:cake/console/libs/task_collection.php class TaskCollection extends ObjectCollection { /** * Shell to use to set params to tasks. From f8b51bfd929ce191f52985f71f7883c558a426e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Sun, 13 Feb 2011 23:56:41 -0430 Subject: [PATCH 348/668] Making the test suite load again --- lib/Cake/Console/Command/TestSuiteShell.php | 5 ++-- lib/Cake/Error/exceptions.php | 9 +++++++ lib/Cake/TestSuite/CakeTestCase.php | 2 +- lib/Cake/TestSuite/CakeTestSuiteCommand.php | 25 ++++++++++--------- .../TestSuite/CakeTestSuiteDispatcher.php | 7 ++++-- lib/Cake/TestSuite/ControllerTestCase.php | 9 ++++--- 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/lib/Cake/Console/Command/TestSuiteShell.php b/lib/Cake/Console/Command/TestSuiteShell.php index 2515fdbb0..c61f58a9f 100644 --- a/lib/Cake/Console/Command/TestSuiteShell.php +++ b/lib/Cake/Console/Command/TestSuiteShell.php @@ -20,8 +20,8 @@ */ App::uses('CakeTestSuiteDispatcher', 'TestSuite'); -App::uses('TestRunner', 'TestSuite'); -App::uses('TestManager', 'TestSuite'); +App::uses('CakeTestSuiteCommand', 'TestSuite'); +App::uses('CakeTestLoader', 'TestSuite'); class TestSuiteShell extends Shell { @@ -163,7 +163,6 @@ class TestSuiteShell extends Shell { public function initialize() { $this->_dispatcher = new CakeTestSuiteDispatcher(); $this->_dispatcher->loadTestFramework(); - require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_suite_command.php'; } /** diff --git a/lib/Cake/Error/exceptions.php b/lib/Cake/Error/exceptions.php index 7baa957c1..d1a941594 100644 --- a/lib/Cake/Error/exceptions.php +++ b/lib/Cake/Error/exceptions.php @@ -406,6 +406,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 diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index ba7d6fc95..318a42458 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -30,7 +30,7 @@ App::uses('CakeTestFixture', 'TestSuite/Fixture'); 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/lib/Cake/TestSuite/CakeTestSuiteCommand.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php index 2ed6eab0f..edb275199 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteCommand.php +++ b/lib/Cake/TestSuite/CakeTestSuiteCommand.php @@ -16,17 +16,14 @@ * @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'); PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); @@ -43,6 +40,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 (!class_exists($loader)) { + throw new MissingTestLoaderException; + } $this->arguments['loader'] = $loader; $this->arguments['test'] = $params['case']; $this->arguments['testFile'] = $params; @@ -161,13 +161,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/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php b/lib/Cake/TestSuite/CakeTestSuiteDispatcher.php index cd52a1678..c96afa8c4 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteDispatcher.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. * @@ -87,8 +92,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/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index 150bf12a5..ebf2af08c 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.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 From 396fbeec91cdf63ff64871dc835cf70bc0861193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 14 Feb 2011 00:18:10 -0430 Subject: [PATCH 349/668] Fixing the HtmlHelper tests --- lib/Cake/View/Helper/HtmlHelper.php | 3 ++- lib/Cake/tests/cases/libs/view/helpers/html.test.php | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 8d90cbd3e..1f098864f 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -944,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/lib/Cake/tests/cases/libs/view/helpers/html.test.php b/lib/Cake/tests/cases/libs/view/helpers/html.test.php index cb44894d7..bae4d5043 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/html.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/html.test.php @@ -16,7 +16,6 @@ * @since CakePHP(tm) v 1.2.0.4206 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::import('Core', array('Helper', 'AppHelper', 'ClassRegistry', 'Controller')); App::uses('Helper', 'View'); App::uses('AppHelper', 'View/Helper'); @@ -1384,7 +1383,7 @@ class HtmlHelperTest extends CakeTestCase { */ public function testLoadConfig() { - $path = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS; + $path = LIBS . 'tests' . DS . 'test_app' . DS . 'config'. DS; $result = $this->Html->loadConfig('htmlhelper_tags', $path); $expected = array( @@ -1424,7 +1423,7 @@ class HtmlHelperTest extends CakeTestCase { * @expectedException ConfigureException */ public function testLoadConfigWrongReader() { - $path = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config'. DS; + $path = LIBS . 'tests' . DS . 'test_app' . DS . 'config'. DS; $result = $this->Html->loadConfig(array('htmlhelper_tags', 'wrong_reader'), $path); } From 4938ac27495dde0f4c3f2b5825ca732dbed1e2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 14 Feb 2011 00:18:28 -0430 Subject: [PATCH 350/668] Moving the declaration of the CakeTestModel package location so it can be easily loaded --- lib/Cake/TestSuite/CakeTestSuiteCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/TestSuite/CakeTestSuiteCommand.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php index edb275199..0672835fc 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteCommand.php +++ b/lib/Cake/TestSuite/CakeTestSuiteCommand.php @@ -24,6 +24,7 @@ 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'); From 227ed6ef27214d2e1a3ca4ccaf4540011e62d60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 14 Feb 2011 00:19:06 -0430 Subject: [PATCH 351/668] Fixing the Js engine helpers --- lib/Cake/View/Helper/JsBaseEngineHelper.php | 2 +- lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php | 1 + .../tests/cases/libs/view/helpers/prototype_engine.test.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Cake/View/Helper/JsBaseEngineHelper.php b/lib/Cake/View/Helper/JsBaseEngineHelper.php index 771b43a98..ade4ca558 100644 --- a/lib/Cake/View/Helper/JsBaseEngineHelper.php +++ b/lib/Cake/View/Helper/JsBaseEngineHelper.php @@ -74,7 +74,7 @@ abstract class JsBaseEngineHelper extends AppHelper { * Constructor. * */ - function __construct() { + function __construct($View, $settings = array()) { parent::__construct($View, $settings); $this->useNative = function_exists('json_encode'); } diff --git a/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php index 1f65343b6..d3cf5ac35 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/mootools_engine.test.php @@ -21,6 +21,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('View', 'View'); App::uses('HtmlHelper', 'View/Helper'); App::uses('JsHelper', 'View/Helper'); App::uses('MootoolsEngineHelper', 'View/Helper'); diff --git a/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php b/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php index 93d7d9e19..49f9c0e4a 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/prototype_engine.test.php @@ -19,6 +19,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('View', 'View'); App::uses('HtmlHelper', 'View/Helper'); App::uses('JsHelper', 'View/Helper'); App::uses('PrototypeEngineHelper', 'View/Helper'); From a95d4acf09d7bd96aa986837b386f3a1ecc7b829 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 16 Feb 2011 21:14:32 -0500 Subject: [PATCH 352/668] Removing unused code, and adding a realpath() to document_root, so symlinks work a bit better. --- cake/dispatcher.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 729bb7a44..bc4b5a711 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -359,8 +359,7 @@ class Dispatcher extends Object { } $this->webroot = $base . '/'; - $docRoot = env('DOCUMENT_ROOT'); - $script = realpath(env('SCRIPT_FILENAME')); + $docRoot = realpath(env('DOCUMENT_ROOT')); $docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot); if (!empty($base) || !$docRootContainsWebroot) { From ca3e606ec8829fdbbeca4cf2bd04cee02d9cacdf Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 16 Feb 2011 22:08:20 -0500 Subject: [PATCH 353/668] Fixing failing tests caused by me forgetting to run tests in [703272965106532764817b661ef08791d29464ac] --- cake/tests/cases/dispatcher.test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 0255829b5..942e1f757 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1173,7 +1173,7 @@ class DispatcherTest extends CakeTestCase { $result = $Dispatcher->baseUrl(); $expected = '/index.php'; $this->assertEqual($expected, $result); - $expectedWebroot = '/'; + $expectedWebroot = '/app/webroot/'; $this->assertEqual($expectedWebroot, $Dispatcher->webroot); Configure::write('App.baseUrl', '/CakeBB/app/webroot/index.php'); @@ -1287,7 +1287,7 @@ class DispatcherTest extends CakeTestCase { $controller = $Dispatcher->dispatch($url, array('return' => 1)); $expected = array('missingController', array(array( 'className' => 'SomeControllerController', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => 'some_controller/home/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1310,7 +1310,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('privateAction', array(array( 'className' => 'SomePagesController', 'action' => '_protected', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => 'some_pages/_protected/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1333,7 +1333,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('missingAction', array(array( 'className' => 'SomePagesController', 'action' => 'home', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => '/index.php/some_pages/home/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1348,7 +1348,7 @@ class DispatcherTest extends CakeTestCase { $expected = array('missingAction', array(array( 'className' => 'SomePagesController', 'action' => 'redirect', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => '/index.php/some_pages/redirect/param:value/param2:value2', 'base' => '/index.php' ))); @@ -1455,7 +1455,7 @@ class DispatcherTest extends CakeTestCase { $result = $Dispatcher->dispatch($url); $expected = array('missingController', array(array( 'className' => 'Controller', - 'webroot' => '/', + 'webroot' => '/app/webroot/', 'url' => 'http://google.com', 'base' => '/index.php' ))); From 0e7f2efdb161db0b907ea0cdfc547ca8f348271e Mon Sep 17 00:00:00 2001 From: 0x20h Date: Tue, 15 Feb 2011 21:21:39 +0100 Subject: [PATCH 354/668] Fixing notice errors caused by accessing headers in po files that don't exist. Fixes #1515 Signed-off-by: mark_story --- cake/libs/i18n.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cake/libs/i18n.php b/cake/libs/i18n.php index f1234d46a..3fb94f336 100644 --- a/cake/libs/i18n.php +++ b/cake/libs/i18n.php @@ -321,8 +321,10 @@ class I18n extends Object { $this->__domains[$domain][$this->__lang][$this->category] = array(); return $domain; } - - if ($head = $this->__domains[$domain][$this->__lang][$this->category][""]) { + + if (isset($this->__domains[$domain][$this->__lang][$this->category][""])) { + $head = $this->__domains[$domain][$this->__lang][$this->category][""]; + foreach (explode("\n", $head) as $line) { $header = strtok($line,":"); $line = trim(strtok("\n")); From 5c4854b897e4ebcb844b200d53a1ffe733998f20 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 17 Feb 2011 07:44:41 -0500 Subject: [PATCH 355/668] Adding omitted return that would prevent users from reaching the login page after being redirected to it. Tests added. Fixes #1542 --- cake/libs/controller/components/auth.php | 2 +- .../libs/controller/components/auth.test.php | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 41b3c5146..6aa6a9aeb 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -311,6 +311,7 @@ class AuthComponent extends Component { $this->Session->write('Auth.redirect', $controller->referer(null, true)); } } + return true; } else { if (!$this->_getUser()) { if (!$request->is('ajax')) { @@ -328,7 +329,6 @@ class AuthComponent extends Component { } } } - if (empty($this->authorize) || $this->isAuthorized()) { return true; } diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index e7c689ae0..840065181 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -866,6 +866,27 @@ class AuthTest extends CakeTestCase { $this->Auth->Session->delete('Auth'); } +/** + * test that no redirects or authoization tests occur on the loginAction + * + * @return void + */ + function testNoRedirectOnLoginAction() { + $controller = $this->getMock('Controller'); + $controller->methods = array('login'); + + $url = '/AuthTest/login'; + $this->Auth->request = $controller->request = new CakeRequest($url); + $this->Auth->request->addParams(Router::parse($url)); + $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->authorize = array('Controller'); + + $controller->expects($this->never()) + ->method('redirect'); + + $this->Auth->startup($controller); + } + /** * Ensure that no redirect is performed when a 404 is reached * And the user doesn't have a session. From 0cb5394d0b540a7dfd6ed434bdbef735c5ba46b2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 17 Feb 2011 22:15:16 -0500 Subject: [PATCH 356/668] Adding static variable to allow changing which get param cake uses. Refs #1483 --- cake/libs/cake_request.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 1f2cfd037..4f06504d9 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -79,6 +79,13 @@ class CakeRequest implements ArrayAccess { */ public $here = null; +/** + * The key to look for inside $_GET + * + * @var string + */ + public static $urlKey = 'url'; + /** * The built in detectors used with `is()` can be modified with `addDetector()`. * @@ -231,7 +238,7 @@ class CakeRequest implements ArrayAccess { * @return string URL */ protected function _url() { - if (empty($_GET['url'])) { + if (empty($_GET[self::$urlKey])) { $uri = $this->_uri(); $base = $this->base; @@ -256,7 +263,7 @@ class CakeRequest implements ArrayAccess { } } } else { - $url = $_GET['url']; + $url = $_GET[self::$urlKey]; } return $url; } @@ -306,7 +313,6 @@ class CakeRequest implements ArrayAccess { $this->webroot = $base . '/'; $docRoot = env('DOCUMENT_ROOT'); - $script = realpath(env('SCRIPT_FILENAME')); $docRootContainsWebroot = strpos($docRoot, $dir . '/' . $webroot); if (!empty($base) || !$docRootContainsWebroot) { From 63f07d3f0febdbf6e8796fdbce423cd4ce4564d9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 17 Feb 2011 23:17:07 -0500 Subject: [PATCH 357/668] Making Authorize and Authenticate objects have constructors like other components. Adding ComponentCollection as a argument for the constructor, this unifies the two types of objects and makes them consistent with other components. It also allows authenticate/authorize objects to access other components, thanks to hiromichan for the idea. Tests updated. --- cake/libs/controller/components/auth.php | 4 ++-- .../components/auth/actions_authorize.php | 2 +- .../components/auth/base_authenticate.php | 11 ++++++++++- .../components/auth/base_authorize.php | 17 +++++++++++++---- .../components/auth/basic_authenticate.php | 6 +++--- .../components/auth/controller_authorize.php | 2 +- .../components/auth/crud_authorize.php | 8 ++++---- .../components/auth/digest_authenticate.php | 6 +++--- .../components/auth/actions_authorize.test.php | 6 +++--- .../components/auth/basic_authenticate.test.php | 5 +++-- .../auth/controller_authorize.test.php | 7 ++++++- .../components/auth/crud_authorize.test.php | 12 ++++++------ .../auth/digest_authenticate.test.php | 5 +++-- .../components/auth/form_authenticate.test.php | 6 ++++-- 14 files changed, 62 insertions(+), 35 deletions(-) diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 6aa6a9aeb..a9384cb49 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -413,7 +413,7 @@ class AuthComponent extends Component { throw new CakeException(__('Authorization objects must implement an authorize method.')); } $settings = array_merge($global, (array)$settings); - $this->_authorizeObjects[] = new $className($this->_Collection->getController(), $settings); + $this->_authorizeObjects[] = new $className($this->_Collection, $settings); } return $this->_authorizeObjects; } @@ -651,7 +651,7 @@ class AuthComponent extends Component { throw new CakeException(__('Authentication objects must implement an authenticate method.')); } $settings = array_merge($global, (array)$settings); - $this->_authenticateObjects[] = new $className($settings); + $this->_authenticateObjects[] = new $className($this->_Collection, $settings); } return $this->_authenticateObjects; } diff --git a/cake/libs/controller/components/auth/actions_authorize.php b/cake/libs/controller/components/auth/actions_authorize.php index 7f4f722d7..c2f1f35d2 100644 --- a/cake/libs/controller/components/auth/actions_authorize.php +++ b/cake/libs/controller/components/auth/actions_authorize.php @@ -33,7 +33,7 @@ class ActionsAuthorize extends BaseAuthorize { * @return boolean */ public function authorize($user, CakeRequest $request) { - $Acl = $this->_controller->Components->load('Acl'); + $Acl = $this->_Collection->load('Acl'); return $Acl->check($user, $this->action($request)); } } \ No newline at end of file diff --git a/cake/libs/controller/components/auth/base_authenticate.php b/cake/libs/controller/components/auth/base_authenticate.php index 575b7544e..1cfcc8896 100644 --- a/cake/libs/controller/components/auth/base_authenticate.php +++ b/cake/libs/controller/components/auth/base_authenticate.php @@ -40,12 +40,21 @@ abstract class BaseAuthenticate { 'scope' => array() ); +/** + * A Component collection, used to get more components. + * + * @var ComponentCollection + */ + protected $_Collection; + /** * Constructor * + * @param ComponentCollection $collection The Component collection used on this request. * @param array $settings Array of settings to use. */ - public function __construct($settings) { + public function __construct(ComponentCollection $collection, $settings) { + $this->_Collection = $collection; $this->settings = Set::merge($this->settings, $settings); } diff --git a/cake/libs/controller/components/auth/base_authorize.php b/cake/libs/controller/components/auth/base_authorize.php index e04f4e2de..911bbdb24 100644 --- a/cake/libs/controller/components/auth/base_authorize.php +++ b/cake/libs/controller/components/auth/base_authorize.php @@ -26,8 +26,15 @@ abstract class BaseAuthorize { * * @var Controller */ - protected $_controller = null; + protected $_Controller = null; +/** + * Component collection instance for getting more components. + * + * @var ComponentCollection + */ + protected $_Collection; + /** * Settings for authorize objects. * @@ -55,7 +62,9 @@ abstract class BaseAuthorize { * @param Controller $controller The controller for this request. * @param string $settings An array of settings. This class does not use any settings. */ - public function __construct(Controller $controller, $settings = array()) { + public function __construct(ComponentCollection $collection, $settings = array()) { + $this->_Collection = $collection; + $controller = $collection->getController(); $this->controller($controller); $this->settings = Set::merge($this->settings, $settings); } @@ -80,10 +89,10 @@ abstract class BaseAuthorize { if (!$controller instanceof Controller) { throw new CakeException(__('$controller needs to be an instance of Controller')); } - $this->_controller = $controller; + $this->_Controller = $controller; return true; } - return $this->_controller; + return $this->_Controller; } /** diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/cake/libs/controller/components/auth/basic_authenticate.php index 55bf48c40..2ba467e98 100644 --- a/cake/libs/controller/components/auth/basic_authenticate.php +++ b/cake/libs/controller/components/auth/basic_authenticate.php @@ -64,11 +64,11 @@ class BasicAuthenticate extends BaseAuthenticate { /** * Constructor, completes configuration for basic authentication. * + * @param ComponentCollection $collection The Component collection used on this request. * @param array $settings An array of settings. - * @return void */ - public function __construct($settings) { - parent::__construct($settings); + public function __construct(ComponentCollection $collection, $settings) { + parent::__construct($collection, $settings); if (empty($this->settings['realm'])) { $this->settings['realm'] = env('SERVER_NAME'); } diff --git a/cake/libs/controller/components/auth/controller_authorize.php b/cake/libs/controller/components/auth/controller_authorize.php index 720242e0b..8fd66b10d 100644 --- a/cake/libs/controller/components/auth/controller_authorize.php +++ b/cake/libs/controller/components/auth/controller_authorize.php @@ -59,7 +59,7 @@ class ControllerAuthorize extends BaseAuthorize { * @return boolean */ public function authorize($user, CakeRequest $request) { - return (bool) $this->_controller->isAuthorized($user); + return (bool) $this->_Controller->isAuthorized($user); } } \ No newline at end of file diff --git a/cake/libs/controller/components/auth/crud_authorize.php b/cake/libs/controller/components/auth/crud_authorize.php index 40844f4b1..be127f43a 100644 --- a/cake/libs/controller/components/auth/crud_authorize.php +++ b/cake/libs/controller/components/auth/crud_authorize.php @@ -34,11 +34,11 @@ class CrudAuthorize extends BaseAuthorize { /** * Sets up additional actionMap values that match the configured `Routing.prefixes`. * - * @param Controller $controller The controller for this request. + * @param ComponentCollection $collection The component collection from the controller. * @param string $settings An array of settings. This class does not use any settings. */ - public function __construct(Controller $controller, $settings = array()) { - parent::__construct($controller, $settings); + public function __construct(ComponentCollection $collection, $settings = array()) { + parent::__construct($collection, $settings); $this->_setPrefixMappings(); } @@ -88,7 +88,7 @@ class CrudAuthorize extends BaseAuthorize { ); return false; } - $Acl = $this->_controller->Components->load('Acl'); + $Acl = $this->_Collection->load('Acl'); return $Acl->check( $user, $this->action($request, ':controller'), diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/cake/libs/controller/components/auth/digest_authenticate.php index cde347110..c27f293c0 100644 --- a/cake/libs/controller/components/auth/digest_authenticate.php +++ b/cake/libs/controller/components/auth/digest_authenticate.php @@ -84,11 +84,11 @@ class DigestAuthenticate extends BaseAuthenticate { /** * Constructor, completes configuration for digest authentication. * + * @param ComponentCollection $collection The Component collection used on this request. * @param array $settings An array of settings. - * @return void */ - public function __construct($settings) { - parent::__construct($settings); + public function __construct(ComponentCollection $collection, $settings) { + parent::__construct($collection, $settings); if (empty($this->settings['realm'])) { $this->settings['realm'] = env('SERVER_NAME'); } diff --git a/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php index 69d0feb9f..242606416 100644 --- a/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php +++ b/cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php @@ -30,9 +30,9 @@ class ActionsAuthorizeTest extends CakeTestCase { parent::setUp(); $this->controller = $this->getMock('Controller', array(), array(), '', false); $this->Acl = $this->getMock('AclComponent', array(), array(), '', false); - $this->controller->Components = $this->getMock('ComponentCollection'); + $this->Collection = $this->getMock('ComponentCollection'); - $this->auth = new ActionsAuthorize($this->controller); + $this->auth = new ActionsAuthorize($this->Collection); $this->auth->settings['actionPath'] = '/controllers'; } @@ -42,7 +42,7 @@ class ActionsAuthorizeTest extends CakeTestCase { * @return void */ protected function _mockAcl() { - $this->controller->Components->expects($this->any()) + $this->Collection->expects($this->any()) ->method('load') ->with('Acl') ->will($this->returnValue($this->Acl)); diff --git a/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php index b1b2fc2e4..f310faac5 100644 --- a/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php @@ -39,7 +39,8 @@ class BasicAuthenticateTest extends CakeTestCase { */ function setUp() { parent::setUp(); - $this->auth = new BasicAuthenticate(array( + $this->Collection = $this->getMock('ComponentCollection'); + $this->auth = new BasicAuthenticate($this->Collection, array( 'fields' => array('username' => 'user', 'password' => 'password'), 'userModel' => 'User', 'realm' => 'localhost', @@ -67,7 +68,7 @@ class BasicAuthenticateTest extends CakeTestCase { * @return void */ function testConstructor() { - $object = new BasicAuthenticate(array( + $object = new BasicAuthenticate($this->Collection, array( 'userModel' => 'AuthUser', 'fields' => array('username' => 'user', 'password' => 'password') )); diff --git a/cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php index fff8a2a9f..a3f687f0d 100644 --- a/cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php +++ b/cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php @@ -27,7 +27,12 @@ class ControllerAuthorizeTest extends CakeTestCase { function setUp() { parent::setUp(); $this->controller = $this->getMock('Controller', array('isAuthorized'), array(), '', false); - $this->auth = new ControllerAuthorize($this->controller); + $this->components = $this->getMock('ComponentCollection'); + $this->components->expects($this->any()) + ->method('getController') + ->will($this->returnValue($this->controller)); + + $this->auth = new ControllerAuthorize($this->components); } /** diff --git a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php index beee53fb9..d9c28b873 100644 --- a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php +++ b/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php @@ -28,11 +28,11 @@ class CrudAuthorizeTest extends CakeTestCase { */ function setUp() { parent::setUp(); - $this->controller = $this->getMock('Controller', array(), array(), '', false); - $this->Acl = $this->getMock('AclComponent', array(), array(), '', false); - $this->controller->Components = $this->getMock('ComponentCollection'); - $this->auth = new CrudAuthorize($this->controller); + $this->Acl = $this->getMock('AclComponent', array(), array(), '', false); + $this->Components = $this->getMock('ComponentCollection'); + + $this->auth = new CrudAuthorize($this->Components); } /** @@ -41,7 +41,7 @@ class CrudAuthorizeTest extends CakeTestCase { * @return void */ protected function _mockAcl() { - $this->controller->Components->expects($this->any()) + $this->Components->expects($this->any()) ->method('load') ->with('Acl') ->will($this->returnValue($this->Acl)); @@ -174,7 +174,7 @@ class CrudAuthorizeTest extends CakeTestCase { Configure::write('Routing.prefixes', array('admin', 'manager')); Router::reload(); - $auth = new CrudAuthorize($this->controller); + $auth = new CrudAuthorize($this->Components); $this->assertTrue(isset($auth->settings['actionMap']['admin_index'])); } diff --git a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php index 16b175890..5d81c0bf1 100644 --- a/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php @@ -38,8 +38,9 @@ class DigestAuthenticateTest extends CakeTestCase { */ function setUp() { parent::setUp(); + $this->Collection = $this->getMock('ComponentCollection'); $this->server = $_SERVER; - $this->auth = new DigestAuthenticate(array( + $this->auth = new DigestAuthenticate($this->Collection, array( 'fields' => array('username' => 'user', 'password' => 'password'), 'userModel' => 'User', 'realm' => 'localhost', @@ -70,7 +71,7 @@ class DigestAuthenticateTest extends CakeTestCase { * @return void */ function testConstructor() { - $object = new DigestAuthenticate(array( + $object = new DigestAuthenticate($this->Collection, array( 'userModel' => 'AuthUser', 'fields' => array('username' => 'user', 'password' => 'password'), 'nonce' => 123456 diff --git a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php index e6b5a4aa7..7e99b3b7b 100644 --- a/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php +++ b/cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php @@ -14,6 +14,7 @@ * @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'); @@ -37,7 +38,8 @@ class FormAuthenticateTest extends CakeTestCase { */ function setUp() { parent::setUp(); - $this->auth = new FormAuthenticate(array( + $this->Collection = $this->getMock('ComponentCollection'); + $this->auth = new FormAuthenticate($this->Collection, array( 'fields' => array('username' => 'user', 'password' => 'password'), 'userModel' => 'User' )); @@ -52,7 +54,7 @@ class FormAuthenticateTest extends CakeTestCase { * @return void */ function testConstructor() { - $object = new FormAuthenticate(array( + $object = new FormAuthenticate($this->Collection, array( 'userModel' => 'AuthUser', 'fields' => array('username' => 'user', 'password' => 'password') )); From c15d0132f315e8cc3ff1198104455827f0ed4e51 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 10:00:34 -0500 Subject: [PATCH 358/668] Adding more environment detection tests. --- cake/tests/cases/libs/cake_request.test.php | 138 +++++++++----------- 1 file changed, 65 insertions(+), 73 deletions(-) diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index df018ad0b..1c103d5f8 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -31,6 +31,9 @@ class CakeRequestTestCase extends CakeTestCase { $this->_get = $_GET; $this->_post = $_POST; $this->_files = $_FILES; + $this->_app = Configure::read('App'); + + Configure::write('App.baseUrl', false); } /** @@ -44,6 +47,7 @@ class CakeRequestTestCase extends CakeTestCase { $_GET = $this->_get; $_POST = $this->_post; $_FILES = $this->_files; + Configure::write('App', $this->_app); } /** @@ -1003,13 +1007,6 @@ class CakeRequestTestCase extends CakeTestCase { 'SCRIPT_NAME' => '/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', - 'REMOTE_ADDR' => '127.0.0.1', - 'REMOTE_HOST' => '127.0.0.1', - 'REQUEST_METHOD' => 'GET', - 'SERVER_NAME' => 'localhost', - 'SERVER_PORT' => '80', - 'SERVER_PROTOCOL' => 'HTTP/1.1', - 'SERVER_SOFTWARE' => 'Microsoft-IIS/5.1', 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', @@ -1124,7 +1121,7 @@ class CakeRequestTestCase extends CakeTestCase { ) ), 'Apache' => array( - 'No rewrite base path' => array( + 'No rewrite, document root set to webroot, requesting path' => array( 'App' => array( 'base' => false, 'baseUrl' => '/index.php', @@ -1133,106 +1130,102 @@ class CakeRequestTestCase extends CakeTestCase { ), 'SERVER' => array( 'SERVER_NAME' => 'localhost', - 'SERVER_ADDR' => '::1', - 'SERVER_PORT' => '80', - 'REMOTE_ADDR' => '::1', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', - 'REQUEST_METHOD' => 'GET', 'QUERY_STRING' => '', - 'REQUEST_URI' => '/', - 'SCRIPT_NAME' => '/index.php', - 'PHP_SELF' => '/index.php', - 'argv' => array(), - 'argc' => 0 + 'REQUEST_URI' => '/index.php/posts/index', + 'SCRIPT_NAME' => '/index.php', + 'PATH_INFO' => '/posts/index', + 'PHP_SELF' => '/index.php/posts/index', ), 'reload' => true, - 'url' => '', + 'url' => 'posts/index', 'base' => '/index.php', 'webroot' => '/' ), - 'No rewrite with path' => array( + 'No rewrite, document root set to webroot, requesting root' => array( 'SERVER' => array( 'HTTP_HOST' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'QUERY_STRING' => '', - 'REQUEST_URI' => '/index.php/posts/add', + 'REQUEST_URI' => '/index.php', 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/posts/add', - 'PHP_SELF' => '/index.php/posts/add', + 'PATH_INFO' => '', + 'PHP_SELF' => '/index.php', 'argv' => array(), 'argc' => 0 ), 'reload' => false, - 'url' => 'posts/add', + 'url' => '', 'base' => '/index.php', 'webroot' => '/' ), - 'GET Request at base domain' => array( + 'No rewrite, document root set above top level cake dir, requesting path' => array( 'App' => array( 'base' => false, - 'baseUrl' => null, + 'baseUrl' => '/site/index.php', 'dir' => 'app', 'webroot' => 'webroot' ), 'SERVER' => array( - 'HTTP_HOST' => 'cake.1.2', - 'SERVER_NAME' => 'cake.1.2', - 'SERVER_ADDR' => '127.0.0.1', - 'SERVER_PORT' => '80', - 'REMOTE_ADDR' => '127.0.0.1', - 'DOCUMENT_ROOT' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot', - 'SERVER_ADMIN' => 'you@example.com', - 'SCRIPT_FILENAME' => '/Volumes/Home/htdocs/cake/repo/branches/1.2.x.x/app/webroot/index.php', - 'REMOTE_PORT' => '53550', - 'GATEWAY_INTERFACE' => 'CGI/1.1', - 'SERVER_PROTOCOL' => 'HTTP/1.1', - 'REQUEST_METHOD' => 'GET', - 'QUERY_STRING' => 'a=b', - 'REQUEST_URI' => '/?a=b', - 'SCRIPT_NAME' => '/index.php', - 'PHP_SELF' => '/index.php' + 'SERVER_NAME' => 'localhost', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', + 'REQUEST_URI' => '/site/index.php/posts/index', + 'SCRIPT_NAME' => '/site/index.php', + 'PATH_INFO' => '/posts/index', + 'PHP_SELF' => '/site/index.php/posts/index', + ), + 'reload' => true, + 'url' => 'posts/index', + 'base' => '/site/index.php', + 'webroot' => '/site/app/webroot/', + ), + 'No rewrite, document root set above top level cake dir, requesting root' => array( + 'App' => array( + 'base' => false, + 'baseUrl' => '/site/index.php', + 'dir' => 'app', + 'webroot' => 'webroot' + ), + 'SERVER' => array( + 'SERVER_NAME' => 'localhost', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', + 'REQUEST_URI' => '/site/index.php/', + 'SCRIPT_NAME' => '/site/index.php', + 'PATH_INFO' => '', + 'PHP_SELF' => '/site/index.php/', ), - 'GET' => array('a' => 'b'), - 'POST' => array(), 'reload' => true, 'url' => '', - 'base' => '', - 'webroot' => '/', - 'urlParams' => array('a' => 'b'), - 'environment' => array('CGI_MODE' => false) + 'base' => '/site/index.php', + 'webroot' => '/site/app/webroot/', ), - 'New CGI no mod_rewrite' => array( + 'No rewrite, document root set above top level cake dir, request path, with GET' => array( 'App' => array( 'base' => false, - 'baseUrl' => '/limesurvey20/index.php', + 'baseUrl' => '/site/index.php', 'dir' => 'app', 'webroot' => 'webroot' ), 'SERVER' => array( - 'DOCUMENT_ROOT' => '/home/.sites/110/site313/web', - 'PATH_INFO' => '/installations', - 'PATH_TRANSLATED' => '/home/.sites/110/site313/web/limesurvey20/index.php', - 'PHPRC' => '/home/.sites/110/site313', - 'QUERY_STRING' => '', - 'REQUEST_METHOD' => 'GET', - 'REQUEST_URI' => '/limesurvey20/index.php/installations', - 'SCRIPT_FILENAME' => '/home/.sites/110/site313/web/limesurvey20/index.php', - 'SCRIPT_NAME' => '/limesurvey20/index.php', - 'SCRIPT_URI' => 'http://www.gisdat-umfragen.at/limesurvey20/index.php/installations', - 'PHP_SELF' => '/limesurvey20/index.php/installations', - 'CGI_MODE' => true + 'SERVER_NAME' => 'localhost', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', + 'REQUEST_URI' => '/site/index.php/posts/index?a=b&c=d', + 'SCRIPT_NAME' => '/site/index.php', + 'PATH_INFO' => '/posts/index', + 'PHP_SELF' => '/site/index.php/posts/index', + 'QUERY_STRING' => 'a=b&c=d' ), - 'GET' => array(), - 'POST' => array(), + 'urlParams' => array('a' => 'b', 'c' => 'd'), 'reload' => true, - 'webroot' => '/limesurvey20/app/webroot/', - 'base' => '/limesurvey20/index.php', - 'url' => 'installations', - 'urlParams' => array(), - 'environment' => array('CGI_MODE' => true) - ) + 'url' => 'posts/index', + 'base' => '/site/index.php', + 'webroot' => '/site/app/webroot/', + ), ) ); $backup = $this->__backupEnvironment(); @@ -1245,9 +1238,9 @@ class CakeRequestTestCase extends CakeTestCase { $this->__loadEnvironment($settings); $request = new CakeRequest(); - $this->assertEqual($request->url, $settings['url'], "%s url on env: {$name} on setting {$descrip}"); - $this->assertEqual($request->base, $settings['base'], "%s base on env: {$name} on setting {$descrip}"); - $this->assertEqual($request->webroot, $settings['webroot'], "%s webroot on env: {$name} on setting {$descrip}"); + $this->assertEquals($settings['url'], $request->url, "url on env: {$name} on setting {$descrip}"); + $this->assertEquals($settings['base'], $request->base, "base on env: {$name} on setting {$descrip}"); + $this->assertEquals($settings['webroot'],$request->webroot, "webroot on env: {$name} on setting {$descrip}"); if (isset($settings['urlParams'])) { @@ -1271,7 +1264,6 @@ class CakeRequestTestCase extends CakeTestCase { * @return void */ function testBasePathInjection() { - $self = $_SERVER['PHP_SELF']; $_SERVER['PHP_SELF'] = urldecode( "/index.php/%22%3E%3Ch1%20onclick=%22alert('xss');%22%3Eheya%3C/h1%3E" ); From 1ee6c1ee453887ca838fba000b84876114600757 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 11:30:09 -0500 Subject: [PATCH 359/668] Removing some no longer required method calls. --- cake/tests/cases/libs/cake_request.test.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index 1c103d5f8..1b6f5f460 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -1228,13 +1228,9 @@ class CakeRequestTestCase extends CakeTestCase { ), ) ); - $backup = $this->__backupEnvironment(); foreach ($environments as $name => $env) { foreach ($env as $descrip => $settings) { - if ($settings['reload']) { - $this->__reloadEnvironment(); - } $this->__loadEnvironment($settings); $request = new CakeRequest(); @@ -1255,7 +1251,6 @@ class CakeRequestTestCase extends CakeTestCase { } } } - $this->__loadEnvironment(array_merge(array('reload' => true), $backup)); } /** From 79ec16364ac2cd76f8e11ab2321f030e857c101b Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 12:36:27 -0500 Subject: [PATCH 360/668] Refactoring tests to use a generator. --- cake/tests/cases/libs/cake_request.test.php | 219 ++++++++------------ 1 file changed, 89 insertions(+), 130 deletions(-) diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index 1b6f5f460..3517d5c7c 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -987,27 +987,25 @@ class CakeRequestTestCase extends CakeTestCase { } /** - * testEnvironmentDetection method + * generator for environment configurations * * @return void */ - public function testEnvironmentDetection() { - $environments = array( - 'IIS' => array( - 'No rewrite base path' => array( + public static function environmentGenerator() { + return array( + array( + 'IIS - No rewrite base path', + array( 'App' => array( 'base' => false, 'baseUrl' => '/index.php?', - 'server' => 'IIS', 'dir' => 'app', 'webroot' => 'webroot' ), 'SERVER' => array( - 'HTTPS' => 'off', 'SCRIPT_NAME' => '/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', - 'APPL_PHYSICAL_PATH' => 'C:\\Inetpub\\wwwroot\\', 'REQUEST_URI' => '/index.php', 'URL' => '/index.php', 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', @@ -1016,16 +1014,23 @@ class CakeRequestTestCase extends CakeTestCase { 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', - 'HTTP_HOST' => 'localhost', - 'argv' => array(), - 'argc' => 0 ), - 'reload' => true, + ), + array( 'base' => '/index.php?', 'webroot' => '/app/webroot/', 'url' => '' ), - 'No rewrite with path' => array( + ), + array( + 'IIS - No rewrite with path', + array( + 'App' => array( + 'base' => false, + 'baseUrl' => '/index.php?', + 'dir' => 'app', + 'webroot' => 'webroot' + ), 'SERVER' => array( 'QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/index.php?/posts/add', @@ -1033,56 +1038,22 @@ class CakeRequestTestCase extends CakeTestCase { 'argv' => array('/posts/add'), 'argc' => 1 ), - 'reload' => false, + ), + array( 'url' => 'posts/add', 'base' => '/index.php?', 'webroot' => '/app/webroot/' - ), - 'No rewrite sub dir 1' => array( - 'GET' => array(), - 'SERVER' => array( - 'QUERY_STRING' => '', - 'REQUEST_URI' => '/index.php', - 'URL' => '/index.php', - 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', - 'ORIG_PATH_INFO' => '/index.php', - 'PATH_INFO' => '', - 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', - 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', - 'PHP_SELF' => '/index.php', - 'argv' => array(), - 'argc' => 0 - ), - 'reload' => false, - 'url' => '', - 'base' => '/index.php?', - 'webroot' => '/app/webroot/' - ), - 'No rewrite sub dir 1 with path' => array( - 'GET' => array('/posts/add' => ''), - 'SERVER' => array( - 'QUERY_STRING' => '/posts/add', - 'REQUEST_URI' => '/index.php?/posts/add', - 'URL' => '/index.php?/posts/add', - 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\index.php', - 'argv' => array('/posts/add'), - 'argc' => 1 - ), - 'reload' => false, - 'url' => 'posts/add', - 'base' => '/index.php?', - 'webroot' => '/app/webroot/' - ), - 'No rewrite sub dir 2' => array( + ) + ), + array( + 'IIS - No rewrite sub dir 2', + array( 'App' => array( 'base' => false, 'baseUrl' => '/site/index.php?', 'dir' => 'app', 'webroot' => 'webroot', - 'server' => 'IIS' ), - 'GET' => array(), - 'POST' => array(), 'SERVER' => array( 'SCRIPT_NAME' => '/site/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', @@ -1095,12 +1066,22 @@ class CakeRequestTestCase extends CakeTestCase { 'argv' => array(), 'argc' => 0 ), - 'reload' => false, + ), + array( 'url' => '', 'base' => '/site/index.php?', 'webroot' => '/site/app/webroot/' ), - 'No rewrite sub dir 2 with path' => array( + ), + array( + 'IIS - No rewrite sub dir 2 with path', + array( + 'App' => array( + 'base' => false, + 'baseUrl' => '/site/index.php?', + 'dir' => 'app', + 'webroot' => 'webroot' + ), 'GET' => array('/posts/add' => ''), 'SERVER' => array( 'SCRIPT_NAME' => '/site/index.php', @@ -1114,14 +1095,16 @@ class CakeRequestTestCase extends CakeTestCase { 'argv' => array('/posts/add'), 'argc' => 1 ), - 'reload' => false, + ), + array( 'url' => 'posts/add', 'base' => '/site/index.php?', 'webroot' => '/site/app/webroot/' ) ), - 'Apache' => array( - 'No rewrite, document root set to webroot, requesting path' => array( + array( + 'Apache - No rewrite, document root set to webroot, requesting path', + array( 'App' => array( 'base' => false, 'baseUrl' => '/index.php', @@ -1129,7 +1112,6 @@ class CakeRequestTestCase extends CakeTestCase { 'webroot' => 'webroot' ), 'SERVER' => array( - 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'QUERY_STRING' => '', @@ -1138,14 +1120,23 @@ class CakeRequestTestCase extends CakeTestCase { 'PATH_INFO' => '/posts/index', 'PHP_SELF' => '/index.php/posts/index', ), - 'reload' => true, + ), + array( 'url' => 'posts/index', 'base' => '/index.php', 'webroot' => '/' ), - 'No rewrite, document root set to webroot, requesting root' => array( + ), + array( + 'Apache - No rewrite, document root set to webroot, requesting root', + array( + 'App' => array( + 'base' => false, + 'baseUrl' => '/index.php', + 'dir' => 'app', + 'webroot' => 'webroot' + ), 'SERVER' => array( - 'HTTP_HOST' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'QUERY_STRING' => '', @@ -1153,15 +1144,17 @@ class CakeRequestTestCase extends CakeTestCase { 'SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '', 'PHP_SELF' => '/index.php', - 'argv' => array(), - 'argc' => 0 ), - 'reload' => false, + ), + array( 'url' => '', 'base' => '/index.php', 'webroot' => '/' ), - 'No rewrite, document root set above top level cake dir, requesting path' => array( + ), + array( + 'Apache - No rewrite, document root set above top level cake dir, requesting path', + array( 'App' => array( 'base' => false, 'baseUrl' => '/site/index.php', @@ -1177,12 +1170,16 @@ class CakeRequestTestCase extends CakeTestCase { 'PATH_INFO' => '/posts/index', 'PHP_SELF' => '/site/index.php/posts/index', ), - 'reload' => true, + ), + array( 'url' => 'posts/index', 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/', ), - 'No rewrite, document root set above top level cake dir, requesting root' => array( + ), + array( + 'Apache - No rewrite, document root set above top level cake dir, requesting root', + array( 'App' => array( 'base' => false, 'baseUrl' => '/site/index.php', @@ -1198,12 +1195,16 @@ class CakeRequestTestCase extends CakeTestCase { 'PATH_INFO' => '', 'PHP_SELF' => '/site/index.php/', ), - 'reload' => true, + ), + array( 'url' => '', 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/', ), - 'No rewrite, document root set above top level cake dir, request path, with GET' => array( + ), + array( + 'Apache - No rewrite, document root set above top level cake dir, request path, with GET', + array( 'App' => array( 'base' => false, 'baseUrl' => '/site/index.php', @@ -1220,36 +1221,32 @@ class CakeRequestTestCase extends CakeTestCase { 'PHP_SELF' => '/site/index.php/posts/index', 'QUERY_STRING' => 'a=b&c=d' ), + ), + array( 'urlParams' => array('a' => 'b', 'c' => 'd'), - 'reload' => true, 'url' => 'posts/index', 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/', ), ) ); + } - foreach ($environments as $name => $env) { - foreach ($env as $descrip => $settings) { - $this->__loadEnvironment($settings); - - $request = new CakeRequest(); - $this->assertEquals($settings['url'], $request->url, "url on env: {$name} on setting {$descrip}"); - $this->assertEquals($settings['base'], $request->base, "base on env: {$name} on setting {$descrip}"); - $this->assertEquals($settings['webroot'],$request->webroot, "webroot on env: {$name} on setting {$descrip}"); - - - if (isset($settings['urlParams'])) { - $this->assertEqual($_GET, $settings['urlParams'], "%s on environment: {$name}, on setting: {$descrip}"); - } - +/** + * testEnvironmentDetection method + * + * @dataProvider environmentGenerator + * @return void + */ + public function testEnvironmentDetection($name, $env, $expected) { + $this->__loadEnvironment($env); - if (isset($settings['environment'])) { - foreach ($settings['environment'] as $key => $val) { - $this->assertEqual(env($key), $val, "%s on key {$key} on environment: {$name}, on setting: {$descrip}"); - } - } - } + $request = new CakeRequest(); + $this->assertEquals($expected['url'], $request->url, "url error"); + $this->assertEquals($expected['base'], $request->base, "base error"); + $this->assertEquals($expected['webroot'],$request->webroot, "webroot error"); + if (isset($expected['urlParams'])) { + $this->assertEqual($_GET, $expected['urlParams'], "GET param mismatch"); } } @@ -1351,40 +1348,6 @@ class CakeRequestTestCase extends CakeTestCase { $this->assertFalse($result); } -/** - * backupEnvironment method - * - * @return void - * @access private - */ - function __backupEnvironment() { - return array( - 'App' => Configure::read('App'), - 'GET' => $_GET, - 'POST' => $_POST, - 'SERVER' => $_SERVER - ); - } - -/** - * reloadEnvironment method - * - * @return void - * @access private - */ - function __reloadEnvironment() { - foreach ($_GET as $key => $val) { - unset($_GET[$key]); - } - foreach ($_POST as $key => $val) { - unset($_POST[$key]); - } - foreach ($_SERVER as $key => $val) { - unset($_SERVER[$key]); - } - Configure::write('App', array()); - } - /** * loadEnvironment method * @@ -1393,10 +1356,6 @@ class CakeRequestTestCase extends CakeTestCase { * @access private */ function __loadEnvironment($env) { - if ($env['reload']) { - $this->__reloadEnvironment(); - } - if (isset($env['App'])) { Configure::write('App', $env['App']); } From 52467a7e18889c27f67f92db422400869dce51c2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 13:17:05 -0500 Subject: [PATCH 361/668] Moving assignment of base into _base(). --- cake/libs/cake_request.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 4f06504d9..1f66452da 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -119,7 +119,7 @@ class CakeRequest implements ArrayAccess { * @return void */ public function __construct($url = null, $parseEnvironment = true) { - $this->base = $this->_base(); + $this->_base(); if (empty($url)) { $url = $this->_url(); } @@ -301,7 +301,7 @@ class CakeRequest implements ArrayAccess { } $this->webroot = $base .'/'; - return $base; + return $this->base = $base; } $file = '/' . basename($baseUrl); @@ -323,7 +323,7 @@ class CakeRequest implements ArrayAccess { $this->webroot .= $webroot . '/'; } } - return $base . $file; + return $this->base = $base . $file; } /** From db00915dea16661fd86b47f5bafaee70db9efeb4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 18:20:54 -0500 Subject: [PATCH 362/668] Removing complicated logic that does a reasonable amount of unnecessary work. Favouring $_SERVER['PATH_INFO'] over more complicated, logic. This may cause issues with IIS 5.x, but its a very old release now. Updating tests to match values that come out of IIS7. --- cake/libs/cake_request.php | 70 ++++++--------------- cake/tests/cases/libs/cake_request.test.php | 22 ++++--- 2 files changed, 30 insertions(+), 62 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 1f66452da..45e7e7b83 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -187,49 +187,37 @@ class CakeRequest implements ArrayAccess { } /** - * Returns the REQUEST_URI from the server environment, or, failing that, - * constructs a new one, using the PHP_SELF constant and other variables. + * Get the request uri. Looks in PATH_INFO first, as this is the exact value we need prepared + * by PHP. Following that, REQUEST_URI, PHP_SELF, HTTP_X_REWRITE_URL and argv are checked in that order. + * Each of these server variables have the base path, and query strings stripped off * - * @return string URI + * @return string URI The CakePHP request path that is being accessed. */ protected function _uri() { - foreach (array('HTTP_X_REWRITE_URL', 'REQUEST_URI', 'argv') as $var) { + $pathInfo = env('PATH_INFO'); + if (!empty($pathInfo)) { + return $pathInfo; + } + foreach (array('PHP_SELF', 'REQUEST_URI', 'HTTP_X_REWRITE_URL', 'argv') as $var) { if ($uri = env($var)) { if ($var == 'argv') { - $uri = $uri[0]; + $uri = $url[0]; } break; } } + $base = $this->base; - $base = trim(Configure::read('App.baseUrl'), '/'); - - if ($base) { - $uri = preg_replace('/^(?:\/)?(?:' . preg_quote($base, '/') . ')?(?:url=)?/', '', $uri); + if (strpos($uri, $base) === 0) { + $uri = substr($uri, strlen($base)); } - if (PHP_SAPI == 'isapi') { - $uri = preg_replace('/^(?:\/)?(?:\/)?(?:\?)?(?:url=)?/', '', $uri); - } - if (!empty($uri)) { - if (key($_GET) && strpos(key($_GET), '?') !== false) { - unset($_GET[key($_GET)]); - } - $uri = explode('?', $uri, 2); - - if (isset($uri[1])) { - parse_str($uri[1], $_GET); - } - $uri = $uri[0]; - } else { - $uri = env('QUERY_STRING'); - } - if (is_string($uri) && strpos($uri, 'index.php') !== false) { - list(, $uri) = explode('index.php', $uri, 2); + if (strpos($uri, '?') !== false) { + $uri = parse_url($uri, PHP_URL_PATH); } if (empty($uri) || $uri == '/' || $uri == '//') { - return ''; + return '/'; } - return str_replace('//', '/', '/' . $uri); + return $uri; } /** @@ -239,29 +227,7 @@ class CakeRequest implements ArrayAccess { */ protected function _url() { if (empty($_GET[self::$urlKey])) { - $uri = $this->_uri(); - $base = $this->base; - - $url = null; - $tmpUri = preg_replace('/^(?:\?)?(?:\/)?/', '', $uri); - $baseDir = trim(dirname($base) . '/', '/'); - - if ($tmpUri === '/' || $tmpUri == $baseDir || $tmpUri == $base) { - $url = '/'; - } else { - $elements = array(); - if ($base && strpos($uri, $base) !== false) { - $elements = explode($base, $uri); - } elseif (preg_match('/^[\/\?\/|\/\?|\?\/]/', $uri)) { - $elements = array(1 => preg_replace('/^[\/\?\/|\/\?|\?\/]/', '', $uri)); - } - - if (!empty($elements[1])) { - $url = $elements[1]; - } else { - $url = '/'; - } - } + $url = $this->_uri(); } else { $url = $_GET[self::$urlKey]; } diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index 3517d5c7c..9086310eb 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -998,7 +998,7 @@ class CakeRequestTestCase extends CakeTestCase { array( 'App' => array( 'base' => false, - 'baseUrl' => '/index.php?', + 'baseUrl' => '/index.php', 'dir' => 'app', 'webroot' => 'webroot' ), @@ -1017,13 +1017,13 @@ class CakeRequestTestCase extends CakeTestCase { ), ), array( - 'base' => '/index.php?', + 'base' => '/index.php', 'webroot' => '/app/webroot/', 'url' => '' ), ), array( - 'IIS - No rewrite with path', + 'IIS - No rewrite with path, no PHP_SELF', array( 'App' => array( 'base' => false, @@ -1034,6 +1034,7 @@ class CakeRequestTestCase extends CakeTestCase { 'SERVER' => array( 'QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/index.php?/posts/add', + 'PHP_SELF' => '', 'URL' => '/index.php?/posts/add', 'argv' => array('/posts/add'), 'argc' => 1 @@ -1050,7 +1051,7 @@ class CakeRequestTestCase extends CakeTestCase { array( 'App' => array( 'base' => false, - 'baseUrl' => '/site/index.php?', + 'baseUrl' => '/site/index.php', 'dir' => 'app', 'webroot' => 'webroot', ), @@ -1069,7 +1070,7 @@ class CakeRequestTestCase extends CakeTestCase { ), array( 'url' => '', - 'base' => '/site/index.php?', + 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/' ), ), @@ -1078,7 +1079,7 @@ class CakeRequestTestCase extends CakeTestCase { array( 'App' => array( 'base' => false, - 'baseUrl' => '/site/index.php?', + 'baseUrl' => '/site/index.php', 'dir' => 'app', 'webroot' => 'webroot' ), @@ -1087,18 +1088,18 @@ class CakeRequestTestCase extends CakeTestCase { 'SCRIPT_NAME' => '/site/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '/posts/add', - 'REQUEST_URI' => '/site/index.php?/posts/add', - 'URL' => '/site/index.php?/posts/add', + 'REQUEST_URI' => '/site/index.php/posts/add', + 'URL' => '/site/index.php/posts/add', 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', - 'PHP_SELF' => '/site/index.php', + 'PHP_SELF' => '/site/index.php/posts/add', 'argv' => array('/posts/add'), 'argc' => 1 ), ), array( 'url' => 'posts/add', - 'base' => '/site/index.php?', + 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/' ) ), @@ -1211,6 +1212,7 @@ class CakeRequestTestCase extends CakeTestCase { 'dir' => 'app', 'webroot' => 'webroot' ), + 'GET' => array('a' => 'b', 'c' => 'd'), 'SERVER' => array( 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', From 24369cf04a0ab86b51d7b077bb131abf42e9c982 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 22:20:55 -0500 Subject: [PATCH 363/668] Removing GET param, and making CakeRequest use PATH_INFO and SCRIPT_NAME to determine base paths and request urls. Updated tests. Removed test for base path injection, as PHP_SELF is no longer used to compute the base path, and users cannot influence SCRIPT_NAME. --- cake/libs/cake_request.php | 9 +--- cake/tests/cases/libs/cake_request.test.php | 47 ++++++--------------- 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 45e7e7b83..d49900365 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -226,11 +226,7 @@ class CakeRequest implements ArrayAccess { * @return string URL */ protected function _url() { - if (empty($_GET[self::$urlKey])) { - $url = $this->_uri(); - } else { - $url = $_GET[self::$urlKey]; - } + $url = $this->_uri(); return $url; } @@ -252,8 +248,7 @@ class CakeRequest implements ArrayAccess { return $this->base = $base; } if (!$baseUrl) { - $replace = array('<', '>', '*', '\'', '"'); - $base = str_replace($replace, '', dirname(env('PHP_SELF'))); + $base = dirname(env('SCRIPT_NAME')); if ($webroot === 'webroot' && $webroot === basename($base)) { $base = dirname($base); diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index 9086310eb..41cf77f21 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -794,9 +794,8 @@ class CakeRequestTestCase extends CakeTestCase { Configure::write('App.baseUrl', false); $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches'; - $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php'; - $_SERVER['PHP_SELF'] = '/1.2.x.x/app/webroot/index.php'; - $_GET['url'] = 'posts/view/1'; + $_SERVER['SCRIPT_NAME'] = '/1.2.x.x/app/webroot/index.php'; + $_SERVER['PATH_INFO'] = '/posts/view/1'; $request = new CakeRequest(); $this->assertEqual($request->base, '/1.2.x.x'); @@ -805,9 +804,8 @@ class CakeRequestTestCase extends CakeTestCase { $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/app/webroot'; - $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/app/webroot/index.php'; - $_SERVER['PHP_SELF'] = '/index.php'; - $_GET['url'] = 'posts/add'; + $_SERVER['SCRIPT_NAME'] = '/index.php'; + $_SERVER['PATH_INFO'] = '/posts/add'; $request = new CakeRequest(); $this->assertEqual($request->base, ''); @@ -815,8 +813,7 @@ class CakeRequestTestCase extends CakeTestCase { $this->assertEqual($request->url, 'posts/add'); $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches/1.2.x.x/test/'; - $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/1.2.x.x/test/webroot/index.php'; - $_SERVER['PHP_SELF'] = '/webroot/index.php'; + $_SERVER['SCRIPT_NAME'] = '/webroot/index.php'; $request = new CakeRequest(); $this->assertEqual('', $request->base); @@ -824,18 +821,16 @@ class CakeRequestTestCase extends CakeTestCase { $_SERVER['DOCUMENT_ROOT'] = '/some/apps/where'; - $_SERVER['SCRIPT_FILENAME'] = '/some/apps/where/app/webroot/index.php'; - $_SERVER['PHP_SELF'] = '/some/apps/where/app/webroot/index.php'; + $_SERVER['SCRIPT_NAME'] = '/app/webroot/index.php'; $request = new CakeRequest(); - $this->assertEqual($request->base, '/some/apps/where'); - $this->assertEqual($request->webroot, '/some/apps/where/'); + $this->assertEqual($request->base, ''); + $this->assertEqual($request->webroot, '/'); Configure::write('App.dir', 'auth'); $_SERVER['DOCUMENT_ROOT'] = '/cake/repo/branches'; - $_SERVER['SCRIPT_FILENAME'] = '/cake/repo/branches/demos/auth/webroot/index.php'; - $_SERVER['PHP_SELF'] = '/demos/auth/webroot/index.php'; + $_SERVER['SCRIPT_NAME'] = '/demos/auth/webroot/index.php'; $request = new CakeRequest(); @@ -845,8 +840,7 @@ class CakeRequestTestCase extends CakeTestCase { Configure::write('App.dir', 'code'); $_SERVER['DOCUMENT_ROOT'] = '/Library/WebServer/Documents'; - $_SERVER['SCRIPT_FILENAME'] = '/Library/WebServer/Documents/clients/PewterReport/code/webroot/index.php'; - $_SERVER['PHP_SELF'] = '/clients/PewterReport/code/webroot/index.php'; + $_SERVER['SCRIPT_NAME'] = '/clients/PewterReport/code/webroot/index.php'; $request = new CakeRequest(); $this->assertEqual($request->base, '/clients/PewterReport/code'); @@ -860,8 +854,7 @@ class CakeRequestTestCase extends CakeTestCase { */ public function testBaseUrlwithModRewriteAlias() { $_SERVER['DOCUMENT_ROOT'] = '/home/aplusnur/public_html'; - $_SERVER['SCRIPT_FILENAME'] = '/home/aplusnur/cake2/app/webroot/index.php'; - $_SERVER['PHP_SELF'] = '/control/index.php'; + $_SERVER['SCRIPT_NAME'] = '/control/index.php'; Configure::write('App.base', '/control'); @@ -875,8 +868,7 @@ class CakeRequestTestCase extends CakeTestCase { Configure::write('App.webroot', 'newaffiliate'); $_SERVER['DOCUMENT_ROOT'] = '/var/www/abtravaff/html'; - $_SERVER['SCRIPT_FILENAME'] = '/var/www/abtravaff/html/newaffiliate/index.php'; - $_SERVER['PHP_SELF'] = '/newaffiliate/index.php'; + $_SERVER['SCRIPT_NAME'] = '/newaffiliate/index.php'; $request = new CakeRequest(); $this->assertEqual($request->base, '/newaffiliate'); @@ -1252,21 +1244,6 @@ class CakeRequestTestCase extends CakeTestCase { } } -/** - * test that XSS can't be performed against the base path. - * - * @return void - */ - function testBasePathInjection() { - $_SERVER['PHP_SELF'] = urldecode( - "/index.php/%22%3E%3Ch1%20onclick=%22alert('xss');%22%3Eheya%3C/h1%3E" - ); - - $request = new CakeRequest(); - $expected = '/index.php/h1 onclick=alert(xss);heya'; - $this->assertEqual($request->base, $expected); - } - /** * test the data() method reading * From 633fcba4e830b526545443538ee9320f9e36fef8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 22:21:06 -0500 Subject: [PATCH 364/668] Fixing viewClass name on Scaffold. --- cake/libs/controller/scaffold.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 97a2533d7..ab66e137a 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -143,8 +143,8 @@ class Scaffold { 'singularHumanName', 'pluralHumanName', 'scaffoldFields', 'associations' )); - if ($this->controller->view) { - $this->controller->view = 'Scaffold'; + if ($this->controller->viewClass) { + $this->controller->viewClass = 'Scaffold'; } $this->_validSession = ( isset($this->controller->Session) && $this->controller->Session->valid() != false From 8cbd9fc36190a3ac2f37940e92fa076347194e80 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 22:21:06 -0500 Subject: [PATCH 365/668] Fixing viewClass name on Scaffold. --- cake/libs/controller/scaffold.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/controller/scaffold.php b/cake/libs/controller/scaffold.php index 97a2533d7..ab66e137a 100644 --- a/cake/libs/controller/scaffold.php +++ b/cake/libs/controller/scaffold.php @@ -143,8 +143,8 @@ class Scaffold { 'singularHumanName', 'pluralHumanName', 'scaffoldFields', 'associations' )); - if ($this->controller->view) { - $this->controller->view = 'Scaffold'; + if ($this->controller->viewClass) { + $this->controller->viewClass = 'Scaffold'; } $this->_validSession = ( isset($this->controller->Session) && $this->controller->Session->valid() != false From 897e50b09f58cb320723fe30f5f2e4f373124550 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 22:23:17 -0500 Subject: [PATCH 366/668] Updating htaccess file to use PATH_INFO instead of GET parameters for handling cake request strings. This fixes issues where cake's usage of url could conflict with other uses. Using PATH_INFO makes for a more consistent and simple implementation as well. Fixes #1483 --- app/webroot/.htaccess | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/webroot/.htaccess b/app/webroot/.htaccess index f9d8b938b..8e7f16397 100644 --- a/app/webroot/.htaccess +++ b/app/webroot/.htaccess @@ -2,5 +2,5 @@ RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] + RewriteRule ^(.*)$ index.php/$1 [QSA,L] \ No newline at end of file From 630d0a988760982a0c60402a95ed51cdead9a9d3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 22:26:12 -0500 Subject: [PATCH 367/668] Removing redundant method. --- cake/libs/cake_request.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index d49900365..4e6ba423d 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -193,7 +193,7 @@ class CakeRequest implements ArrayAccess { * * @return string URI The CakePHP request path that is being accessed. */ - protected function _uri() { + protected function _url() { $pathInfo = env('PATH_INFO'); if (!empty($pathInfo)) { return $pathInfo; @@ -220,16 +220,6 @@ class CakeRequest implements ArrayAccess { return $uri; } -/** - * Returns and sets the $_GET[url] derived from the REQUEST_URI - * - * @return string URL - */ - protected function _url() { - $url = $this->_uri(); - return $url; - } - /** * Returns a base URL and sets the proper webroot * From ea52f880fd93019b9fca8431dbd20960ea1c4ef4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 22:26:44 -0500 Subject: [PATCH 368/668] Removing useless property. --- cake/libs/cake_request.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 4e6ba423d..0ff573bd8 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -79,13 +79,6 @@ class CakeRequest implements ArrayAccess { */ public $here = null; -/** - * The key to look for inside $_GET - * - * @var string - */ - public static $urlKey = 'url'; - /** * The built in detectors used with `is()` can be modified with `addDetector()`. * From 24935afff472752cca48a64d3c7cc3d1535f0cfa Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 19 Feb 2011 22:27:38 -0500 Subject: [PATCH 369/668] Removing remaining references to $_GET['url']. --- app/webroot/index.php | 2 +- cake/console/templates/skel/webroot/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/webroot/index.php b/app/webroot/index.php index 5955688f6..f7dfcc14c 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -75,5 +75,5 @@ } else { require LIBS . 'dispatcher.php'; $Dispatcher = new Dispatcher(); - $Dispatcher->dispatch(new CakeRequest(isset($_GET['url']) ? $_GET['url'] : null)); + $Dispatcher->dispatch(new CakeRequest()); } diff --git a/cake/console/templates/skel/webroot/index.php b/cake/console/templates/skel/webroot/index.php index 5955688f6..f7dfcc14c 100644 --- a/cake/console/templates/skel/webroot/index.php +++ b/cake/console/templates/skel/webroot/index.php @@ -75,5 +75,5 @@ } else { require LIBS . 'dispatcher.php'; $Dispatcher = new Dispatcher(); - $Dispatcher->dispatch(new CakeRequest(isset($_GET['url']) ? $_GET['url'] : null)); + $Dispatcher->dispatch(new CakeRequest()); } From 8991095045f54c3ced4165ff4bf6ce2fa7ba6aa5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 20 Feb 2011 13:12:04 -0500 Subject: [PATCH 370/668] Removing references to GET['url'] & favicon, as there is no more GET[url]. --- app/webroot/index.php | 11 ++++------- cake/console/templates/skel/webroot/index.php | 11 ++++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/app/webroot/index.php b/app/webroot/index.php index f7dfcc14c..41ab05c3a 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -70,10 +70,7 @@ 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); } - if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { - return; - } else { - require LIBS . 'dispatcher.php'; - $Dispatcher = new Dispatcher(); - $Dispatcher->dispatch(new CakeRequest()); - } + + require LIBS . 'dispatcher.php'; + $Dispatcher = new Dispatcher(); + $Dispatcher->dispatch(new CakeRequest()); diff --git a/cake/console/templates/skel/webroot/index.php b/cake/console/templates/skel/webroot/index.php index f7dfcc14c..41ab05c3a 100644 --- a/cake/console/templates/skel/webroot/index.php +++ b/cake/console/templates/skel/webroot/index.php @@ -70,10 +70,7 @@ 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); } - if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') { - return; - } else { - require LIBS . 'dispatcher.php'; - $Dispatcher = new Dispatcher(); - $Dispatcher->dispatch(new CakeRequest()); - } + + require LIBS . 'dispatcher.php'; + $Dispatcher = new Dispatcher(); + $Dispatcher->dispatch(new CakeRequest()); From 23bacfc0c71e5bf428f6683893b9ca2755f1506c Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 20 Feb 2011 13:29:19 -0500 Subject: [PATCH 371/668] Adding new checks, so missing favicons don't flood the error logs. --- app/webroot/index.php | 4 ++++ cake/console/templates/skel/webroot/index.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/webroot/index.php b/app/webroot/index.php index 41ab05c3a..f1ff8d197 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -71,6 +71,10 @@ 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); } + if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] == '/favicon.ico') { + return; + } + require LIBS . 'dispatcher.php'; $Dispatcher = new Dispatcher(); $Dispatcher->dispatch(new CakeRequest()); diff --git a/cake/console/templates/skel/webroot/index.php b/cake/console/templates/skel/webroot/index.php index 41ab05c3a..f1ff8d197 100644 --- a/cake/console/templates/skel/webroot/index.php +++ b/cake/console/templates/skel/webroot/index.php @@ -71,6 +71,10 @@ 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); } + if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] == '/favicon.ico') { + return; + } + require LIBS . 'dispatcher.php'; $Dispatcher = new Dispatcher(); $Dispatcher->dispatch(new CakeRequest()); From 21905967643ec0492cf241243e84f999f84f16cf Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 20 Feb 2011 13:57:38 -0500 Subject: [PATCH 372/668] Fixing htaccess file to not use GET params anymore. --- cake/console/templates/skel/webroot/.htaccess | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/console/templates/skel/webroot/.htaccess b/cake/console/templates/skel/webroot/.htaccess index f9d8b938b..8e7f16397 100644 --- a/cake/console/templates/skel/webroot/.htaccess +++ b/cake/console/templates/skel/webroot/.htaccess @@ -2,5 +2,5 @@ RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] + RewriteRule ^(.*)$ index.php/$1 [QSA,L] \ No newline at end of file From d1821b3f9da5fea18e06b4f771bc80bd773eba24 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 20 Feb 2011 21:52:20 -0500 Subject: [PATCH 373/668] Removing $request->query[url]. This simulated value is also available at $request->url, and having it in the query array confuses things, as GET[url] no longer exists. Fixing failing tests elsewhere in the framework. --- cake/libs/cake_request.php | 4 +-- cake/libs/controller/components/auth.php | 4 +-- cake/tests/cases/console/shells/api.test.php | 27 +++++++++---------- cake/tests/cases/libs/cake_request.test.php | 7 ++--- .../libs/controller/components/auth.test.php | 18 ++++++------- .../components/auth/crud_authorize.test.php | 2 ++ .../cases/libs/controller/controller.test.php | 14 ---------- .../cases/libs/controller/scaffold.test.php | 4 +-- .../cases/libs/controller_test_case.test.php | 2 -- cake/tests/cases/libs/debugger.test.php | 1 + cake/tests/cases/libs/dispatcher.test.php | 13 ++------- 11 files changed, 37 insertions(+), 59 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 0ff573bd8..7a80b43a5 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -167,15 +167,15 @@ class CakeRequest implements ArrayAccess { } else { $query = $_GET; } + if (strpos($this->url, '?') !== false) { list(, $querystr) = explode('?', $this->url); parse_str($querystr, $queryArgs); - $query += $queryArgs; + $query += $queryArgs; } if (isset($this->params['url'])) { $query = array_merge($this->params['url'], $query); } - $query['url'] = $this->url; $this->query = $query; } diff --git a/cake/libs/controller/components/auth.php b/cake/libs/controller/components/auth.php index 6aa6a9aeb..5a2eebce3 100644 --- a/cake/libs/controller/components/auth.php +++ b/cake/libs/controller/components/auth.php @@ -289,8 +289,8 @@ class AuthComponent extends Component { $url = ''; - if (isset($request->query['url'])) { - $url = $request->query['url']; + if (isset($request->url)) { + $url = $request->url; } $url = Router::normalize($url); $loginAction = Router::normalize($this->loginAction); diff --git a/cake/tests/cases/console/shells/api.test.php b/cake/tests/cases/console/shells/api.test.php index 79deea551..99e5abf33 100644 --- a/cake/tests/cases/console/shells/api.test.php +++ b/cake/tests/cases/console/shells/api.test.php @@ -66,20 +66,19 @@ class ApiShellTest extends CakeTestCase { '8. getResponse()', '9. header($status)', '10. httpCodes($code = NULL)', - '11. isAuthorized()', - '12. loadModel($modelClass = NULL, $id = NULL)', - '13. paginate($object = NULL, $scope = array (), $whitelist = array ())', - '14. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)', - '15. redirect($url, $status = NULL, $exit = true)', - '16. referer($default = NULL, $local = false)', - '17. render($action = NULL, $layout = NULL, $file = NULL)', - '18. set($one, $two = NULL)', - '19. setAction($action)', - '20. setRequest($request)', - '21. shutdownProcess()', - '22. startupProcess()', - '23. validate()', - '24. validateErrors()' + '11. loadModel($modelClass = NULL, $id = NULL)', + '12. paginate($object = NULL, $scope = array (), $whitelist = array ())', + '13. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)', + '14. redirect($url, $status = NULL, $exit = true)', + '15. referer($default = NULL, $local = false)', + '16. render($view = NULL, $layout = NULL)', + '17. set($one, $two = NULL)', + '18. setAction($action)', + '19. setRequest($request)', + '20. shutdownProcess()', + '21. startupProcess()', + '22. validate()', + '23. validateErrors()' ); $this->Shell->expects($this->at(2))->method('out')->with($expected); diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index 41cf77f21..0a1381e9d 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -74,12 +74,11 @@ class CakeRequestTestCase extends CakeTestCase { 'two' => 'banana' ); $request = new CakeRequest('some/path'); - $this->assertEqual($request->query, $_GET + array('url' => 'some/path')); + $this->assertEqual($request->query, $_GET); $_GET = array( 'one' => 'param', 'two' => 'banana', - 'url' => 'some/path' ); $request = new CakeRequest('some/path'); $this->assertEqual($request->query, $_GET); @@ -94,8 +93,10 @@ class CakeRequestTestCase extends CakeTestCase { function testQueryStringParsingFromInputUrl() { $_GET = array(); $request = new CakeRequest('some/path?one=something&two=else'); - $expected = array('one' => 'something', 'two' => 'else', 'url' => 'some/path?one=something&two=else'); + $expected = array('one' => 'something', 'two' => 'else'); $this->assertEqual($request->query, $expected); + $this->assertEquals('some/path?one=something&two=else', $request->url); + } /** diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 840065181..2c6701e93 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -443,7 +443,7 @@ class AuthTest extends CakeTestCase { $this->Controller->data = array(); $this->Controller->request->addParams(Router::parse('auth_test/login')); - $this->Controller->request->query['url'] = 'auth_test/login'; + $this->Controller->request->url = 'auth_test/login'; $this->Auth->Session->delete('Auth'); $this->Auth->loginRedirect = '/users/dashboard'; @@ -730,7 +730,7 @@ class AuthTest extends CakeTestCase { )); $this->Auth->request->addParams(Router::parse('users/login')); - $this->Auth->request->query['url'] = 'users/login'; + $this->Auth->request->url = 'users/login'; $this->Auth->initialize($this->Controller); $this->Auth->loginRedirect = array( @@ -771,7 +771,7 @@ class AuthTest extends CakeTestCase { 'AuthUser' => array('id'=>'1', 'username' => 'nate') )); $this->Auth->request->params['action'] = 'login'; - $this->Auth->request->query['url'] = 'auth_test/login'; + $this->Auth->request->url = 'auth_test/login'; $this->Auth->initialize($this->Controller); $this->Auth->loginAction = 'auth_test/login'; $this->Auth->loginRedirect = false; @@ -784,7 +784,7 @@ class AuthTest extends CakeTestCase { $this->Auth->Session->delete('Auth'); $url = '/posts/index/year:2008/month:feb'; $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->request->query['url'] = Router::normalize($url); + $this->Auth->request->url = Router::normalize($url); $this->Auth->initialize($this->Controller); $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->startup($this->Controller); @@ -795,7 +795,7 @@ class AuthTest extends CakeTestCase { $this->Auth->Session->delete('Auth'); $url = '/posts/view/1'; $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->request->query['url'] = Router::normalize($url); + $this->Auth->request->url = Router::normalize($url); $this->Auth->initialize($this->Controller); $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->startup($this->Controller); @@ -843,7 +843,7 @@ class AuthTest extends CakeTestCase { $url = '/posts/edit/1'; $this->Auth->request = $this->Controller->request = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->request->query = array('url' => Router::normalize($url)); + $this->Auth->request->url = Router::normalize($url); $this->Auth->initialize($this->Controller); $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->startup($this->Controller); @@ -856,7 +856,7 @@ class AuthTest extends CakeTestCase { $url = '/AuthTest/login'; $this->Auth->request = $this->Controller->request = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->request->query['url'] = Router::normalize($url); + $this->Auth->request->url = Router::normalize($url); $this->Auth->initialize($this->Controller); $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); $this->Auth->startup($this->Controller); @@ -965,11 +965,11 @@ class AuthTest extends CakeTestCase { $url = '/admin/auth_test/login'; $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->request->query['url'] = ltrim($url, '/'); + $this->Auth->request->url = ltrim($url, '/'); Router::setRequestInfo(array( array( 'pass' => array(), 'action' => 'admin_login', 'plugin' => null, 'controller' => 'auth_test', - 'admin' => true, 'url' => array('url' => $this->Auth->request->query['url']), + 'admin' => true, ), array( 'base' => null, 'here' => $url, diff --git a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php b/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php index beee53fb9..92020b428 100644 --- a/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php +++ b/cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php @@ -27,6 +27,8 @@ class CrudAuthorizeTest extends CakeTestCase { * @return void */ function setUp() { + Configure::write('Routing.prefixes', array()); + parent::setUp(); $this->controller = $this->getMock('Controller', array(), array(), '', false); $this->Acl = $this->getMock('AclComponent', array(), array(), '', false); diff --git a/cake/tests/cases/libs/controller/controller.test.php b/cake/tests/cases/libs/controller/controller.test.php index 5ff4b833e..dd637e622 100644 --- a/cake/tests/cases/libs/controller/controller.test.php +++ b/cake/tests/cases/libs/controller/controller.test.php @@ -1020,20 +1020,6 @@ class ControllerTest extends CakeTestCase { $this->assertidentical($TestController->data, $expected); } -/** - * testUnimplementedIsAuthorized method - * - * @expectedException PHPUnit_Framework_Error - * @access public - * @return void - */ - function testUnimplementedIsAuthorized() { - $request = new CakeRequest('controller_posts/index'); - - $TestController = new TestController($request); - $TestController->isAuthorized(); - } - /** * testValidateErrors method * diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index 031d8a0c5..54a67beff 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -771,11 +771,11 @@ class ScaffoldTest extends CakeTestCase { function testScaffoldChangingViewProperty() { $this->Controller->action = 'edit'; $this->Controller->theme = 'test_theme'; - $this->Controller->view = 'Theme'; + $this->Controller->viewClass = 'Theme'; $this->Controller->constructClasses(); $Scaffold = new TestScaffoldMock($this->Controller, $this->Controller->request); - $this->assertEqual($this->Controller->view, 'Scaffold'); + $this->assertEqual($this->Controller->viewClass, 'Scaffold'); } /** diff --git a/cake/tests/cases/libs/controller_test_case.test.php b/cake/tests/cases/libs/controller_test_case.test.php index 1ffb518c6..9e4feb4b7 100644 --- a/cake/tests/cases/libs/controller_test_case.test.php +++ b/cake/tests/cases/libs/controller_test_case.test.php @@ -388,7 +388,6 @@ class ControllerTestCaseTest extends CakeTestCase { 'return' => 'vars', 'method' => 'get', )); - $this->assertTrue(isset($result['params']['url']['url'])); $this->assertEqual(array_keys($result['params']['named']), array('var1', 'var2')); $result = $this->Case->testAction('/tests_apps_posts/url_var/gogo/val2', array( @@ -407,7 +406,6 @@ class ControllerTestCaseTest extends CakeTestCase { )); $this->assertTrue(isset($result['params']['url']['red'])); $this->assertTrue(isset($result['params']['url']['blue'])); - $this->assertTrue(isset($result['params']['url']['url'])); } /** diff --git a/cake/tests/cases/libs/debugger.test.php b/cake/tests/cases/libs/debugger.test.php index a76945566..e728fb5ea 100644 --- a/cake/tests/cases/libs/debugger.test.php +++ b/cake/tests/cases/libs/debugger.test.php @@ -227,6 +227,7 @@ class DebuggerTest extends CakeTestCase { View::$helpers = array View::$viewPath = "" View::$viewVars = array + View::$view = NULL View::$layout = "default" View::$layoutPath = NULL View::$autoLayout = true diff --git a/cake/tests/cases/libs/dispatcher.test.php b/cake/tests/cases/libs/dispatcher.test.php index 20fab006b..0f9a6bbbb 100644 --- a/cake/tests/cases/libs/dispatcher.test.php +++ b/cake/tests/cases/libs/dispatcher.test.php @@ -862,7 +862,6 @@ class DispatcherTest extends CakeTestCase { */ public function testPluginDispatch() { $_POST = array(); - $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; Router::reload(); $Dispatcher = new TestDispatcher(); @@ -879,7 +878,6 @@ class DispatcherTest extends CakeTestCase { 'pass' => array('home'), 'named' => array('param'=> 'value', 'param2'=> 'value2'), 'plugin'=> 'my_plugin', 'controller'=> 'some_pages', 'action'=> 'display', 'form'=> array(), - 'url'=> array('url'=> 'my_plugin/some_pages/home/param:value/param2:value2'), ); foreach ($expected as $key => $value) { $this->assertEqual($result[$key], $value, 'Value mismatch ' . $key . ' %'); @@ -889,12 +887,6 @@ class DispatcherTest extends CakeTestCase { $this->assertIdentical($controller->name, 'SomePages'); $this->assertIdentical($controller->params['controller'], 'some_pages'); $this->assertIdentical($controller->passedArgs, array('0' => 'home', 'param'=>'value', 'param2'=>'value2')); - - $expected = '/cake/repo/branches/1.2.x.x/my_plugin/some_pages/home/param:value/param2:value2'; - $this->assertIdentical($expected, $controller->here); - - $expected = '/cake/repo/branches/1.2.x.x'; - $this->assertIdentical($expected, $controller->base); } /** @@ -904,7 +896,7 @@ class DispatcherTest extends CakeTestCase { */ public function testAutomaticPluginDispatch() { $_POST = array(); - $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; + $_SERVER['SCRIPT_NAME'] = '/cake/repo/branches/1.2.x.x/index.php'; Router::reload(); $Dispatcher = new TestDispatcher(); @@ -1018,11 +1010,10 @@ class DispatcherTest extends CakeTestCase { 'prefix' => 'admin', 'admin' => true, 'form' => array(), - 'url' => array('url' => 'admin/articles_test'), 'return' => 1 ); foreach ($expected as $key => $value) { - $this->assertEqual($controller->params[$key], $expected[$key], 'Value mismatch ' . $key . ' %s'); + $this->assertEqual($controller->request[$key], $expected[$key], 'Value mismatch ' . $key . ' %s'); } } From 440a89051d675aa5fd4a6d6365d469a3bd67b343 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 20 Feb 2011 22:33:10 -0500 Subject: [PATCH 374/668] Fixing test that didn't fail as expected. --- cake/tests/cases/libs/cake_socket.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/cake_socket.test.php b/cake/tests/cases/libs/cake_socket.test.php index ac12b4553..0fc6f826a 100644 --- a/cake/tests/cases/libs/cake_socket.test.php +++ b/cake/tests/cases/libs/cake_socket.test.php @@ -108,7 +108,7 @@ class CakeSocketTest extends CakeTestCase { */ public static function invalidConnections() { return array( - array(array('host' => 'invalid.host', 'timeout' => 1)), + array(array('host' => 'invalid.host', 'port' => 9999, 'timeout' => 1)), array(array('host' => '127.0.0.1', 'port' => '70000', 'timeout' => 1)) ); } From d0b7d3355d72fbb5046dca83a0f6efae0e7db3c2 Mon Sep 17 00:00:00 2001 From: Victor Widell Date: Mon, 21 Feb 2011 04:38:07 -0800 Subject: [PATCH 375/668] $this->data[$habtmKey] could be a string, meaning $this->data[$habtmKey][$habtmKey] would be the first character of that string. Probably not what you want. Fixes #1549 Signed-off-by: mark_story --- cake/libs/view/helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/view/helper.php b/cake/libs/view/helper.php index ecd731b90..b8bc471fe 100644 --- a/cake/libs/view/helper.php +++ b/cake/libs/view/helper.php @@ -708,7 +708,7 @@ class Helper extends Overloadable { } $habtmKey = $this->field(); - if (empty($result) && isset($this->data[$habtmKey][$habtmKey])) { + if (empty($result) && isset($this->data[$habtmKey][$habtmKey]) && is_array($this->data[$habtmKey])) { $result = $this->data[$habtmKey][$habtmKey]; } elseif (empty($result) && isset($this->data[$habtmKey]) && is_array($this->data[$habtmKey])) { if (ClassRegistry::isKeySet($habtmKey)) { From 1f9bbbce53a15f3471bf3814da7b835a19274078 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 21 Feb 2011 10:48:34 -0500 Subject: [PATCH 376/668] Pulling windows specific tests into a separate test method. --- .../cases/libs/view/helpers/time.test.php | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index cbe42d2a1..5501750cf 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -731,14 +731,6 @@ class TimeHelperTest extends CakeTestCase { $expected = 4; $this->assertEqual($result, $expected); - $result = $this->Time->convertSpecifiers('%e', $time); - $expected = '14'; - $this->assertEqual($result, $expected); - - $result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01')); - $expected = ' 1'; - $this->assertEqual($result, $expected); - $result = $this->Time->convertSpecifiers('%x', $time); $expected = '%d/%m/%y'; $this->assertEqual($result, $expected); @@ -748,6 +740,25 @@ class TimeHelperTest extends CakeTestCase { $this->assertEqual($result, $expected); } +/** + * test convert %e on windows. + * + * @return void + */ + function testConvertPercentE() { + if ($this->skipIf(DS !== '\\', 'Cannot run windows tests on non-windows OS')) { + return; + } + $time = strtotime('Thu Jan 14 11:43:39 2010'); + $result = $this->Time->convertSpecifiers('%e', $time); + $expected = '14'; + $this->assertEqual($result, $expected); + + $result = $this->Time->convertSpecifiers('%e', strtotime('2011-01-01')); + $expected = ' 1'; + $this->assertEqual($result, $expected); + } + /** * test formatting dates taking in account preferred i18n locale file * From e1b3703c204b88896d5b4823a0ef8f10a899a18a Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 21 Feb 2011 15:45:46 -0300 Subject: [PATCH 377/668] Adding a protection to cake console be executed in driver root (windows). Fixes #1408. --- app/console/cake.bat | 2 +- cake/console/cake.bat | 2 +- cake/console/shell_dispatcher.php | 3 +++ cake/console/templates/skel/console/cake.bat | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/console/cake.bat b/app/console/cake.bat index ed04546c9..7d0c1247d 100644 --- a/app/console/cake.bat +++ b/app/console/cake.bat @@ -25,7 +25,7 @@ SET app=%0 SET lib=%~dp0 -php -q "%lib%cake.php" -working "%CD%" %* +php -q "%lib%cake.php" -working "%CD% " %* echo. diff --git a/cake/console/cake.bat b/cake/console/cake.bat index 40a271425..a22cfcacd 100644 --- a/cake/console/cake.bat +++ b/cake/console/cake.bat @@ -25,7 +25,7 @@ SET app=%0 SET lib=%~dp0 -php -q "%lib%cake.php" -working "%CD%" %* +php -q "%lib%cake.php" -working "%CD% " %* echo. diff --git a/cake/console/shell_dispatcher.php b/cake/console/shell_dispatcher.php index 1b520500b..0a625f8cd 100644 --- a/cake/console/shell_dispatcher.php +++ b/cake/console/shell_dispatcher.php @@ -244,6 +244,9 @@ class ShellDispatcher { } $params = str_replace('\\', '/', $params); + if (isset($params['working'])) { + $params['working'] = trim($params['working']); + } if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) { if (empty($this->params['app']) && $params['working'] != $params['root']) { $params['root'] = dirname($params['working']); diff --git a/cake/console/templates/skel/console/cake.bat b/cake/console/templates/skel/console/cake.bat index ed04546c9..7d0c1247d 100644 --- a/cake/console/templates/skel/console/cake.bat +++ b/cake/console/templates/skel/console/cake.bat @@ -25,7 +25,7 @@ SET app=%0 SET lib=%~dp0 -php -q "%lib%cake.php" -working "%CD%" %* +php -q "%lib%cake.php" -working "%CD% " %* echo. From c64dd9d3529459c7a073bd9cd614da8262b2ffe3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 21 Feb 2011 14:07:33 -0500 Subject: [PATCH 378/668] Adding the ability to pass additional information into the rendering of flash messages. Allows you to keep keep code DRY by moving repeated settings into the view. Added tests. Fixes #792 --- cake/libs/view/helpers/session.php | 50 +++++++++++++++---- .../cases/libs/view/helpers/session.test.php | 33 ++++++++++-- 2 files changed, 71 insertions(+), 12 deletions(-) diff --git a/cake/libs/view/helpers/session.php b/cake/libs/view/helpers/session.php index fb26c91c7..6dcf90294 100644 --- a/cake/libs/view/helpers/session.php +++ b/cake/libs/view/helpers/session.php @@ -32,7 +32,7 @@ class SessionHelper extends AppHelper { /** * Used to read a session values set in a controller for a key or return values for all keys. * - * In your view: `$session->read('Controller.sessKey');` + * In your view: `$this->Session->read('Controller.sessKey');` * Calling the method without a param will return all session vars * * @param string $name the name of the session key you want to read @@ -46,7 +46,7 @@ class SessionHelper extends AppHelper { /** * Used to check is a session key has been set * - * In your view: `$session->check('Controller.sessKey');` + * In your view: `$this->Session->check('Controller.sessKey');` * * @param string $name * @return boolean @@ -59,7 +59,7 @@ class SessionHelper extends AppHelper { /** * Returns last error encountered in a session * - * In your view: `$session->error();` + * In your view: `$this->Session->error();` * * @return string last error * @link http://book.cakephp.org/view/1466/Methods @@ -71,32 +71,64 @@ class SessionHelper extends AppHelper { /** * Used to render the message set in Controller::Session::setFlash() * - * In your view: $session->flash('somekey'); + * In your view: $this->Session->flash('somekey'); * Will default to flash if no param is passed * + * You can pass additional information into the flash message generation. This allows you + * to consolidate all the parameters for a given type of flash message into the view. + * + * {{{ + * echo $this->Session->flash('flash', array('params' => array('class' => 'new-flash'))); + * }}} + * + * The above would generate a flash message with a custom class name. Using $attrs['params'] you + * can pass additional data into the element rendering that will be made available as local variables + * when the element is rendered: + * + * {{{ + * echo $this->Session->flash('flash', array('params' => array('name' => $user['User']['name']))); + * }}} + * + * This would pass the current user's name into the flash message, so you could create peronsonalized + * messages without the controller needing access to that data. + * + * Lastly you can choose the element that is rendered when creating the flash message. Using + * custom elements allows you to fully customize how flash messages are generated. + * + * {{{ + * echo $this->Session->flash('flash', array('element' => 'my_custom_element')); + * }}} + * * @param string $key The [Message.]key you are rendering in the view. - * @return boolean|string Will return the value if $key is set, or false if not set. + * @return array $attrs Additional attributes to use for the creation of this flash message. + * Supports the 'params', and 'element' keys that are used in the helper. * @access public * @link http://book.cakephp.org/view/1466/Methods * @link http://book.cakephp.org/view/1467/flash */ - public function flash($key = 'flash') { + public function flash($key = 'flash', $attrs = array()) { $out = false; if (CakeSession::check('Message.' . $key)) { $flash = CakeSession::read('Message.' . $key); + $message = $flash['message']; + unset($flash['message']); + + if (!empty($attrs)) { + $flash = array_merge($flash, $attrs); + } if ($flash['element'] == 'default') { $class = 'message'; if (!empty($flash['params']['class'])) { $class = $flash['params']['class']; } - $out = '
    ' . $flash['message'] . '
    '; + $out = '
    ' . $message . '
    '; } elseif ($flash['element'] == '' || $flash['element'] == null) { - $out = $flash['message']; + $out = $message; } else { $tmpVars = $flash['params']; - $tmpVars['message'] = $flash['message']; + $tmpVars['message'] = $message; $out = $this->_View->element($flash['element'], $tmpVars); } CakeSession::delete('Message.' . $key); diff --git a/cake/tests/cases/libs/view/helpers/session.test.php b/cake/tests/cases/libs/view/helpers/session.test.php index df957580a..a282d0a5c 100644 --- a/cake/tests/cases/libs/view/helpers/session.test.php +++ b/cake/tests/cases/libs/view/helpers/session.test.php @@ -119,19 +119,19 @@ class SessionHelperTest extends CakeTestCase { * @return void */ function testFlash() { - $result = $this->Session->flash('flash', true); + $result = $this->Session->flash('flash'); $expected = '
    This is a calling
    '; $this->assertEqual($result, $expected); $this->assertFalse($this->Session->check('Message.flash')); $expected = '
    Recorded
    '; - $result = $this->Session->flash('classy', true); + $result = $this->Session->flash('classy'); $this->assertEqual($result, $expected); App::build(array( 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); - $result = $this->Session->flash('notification', true); + $result = $this->Session->flash('notification'); $result = str_replace("\r\n", "\n", $result); $expected = "
    \n\t

    Alert!

    \n\t

    Notice!

    \n\t

    This is a test of the emergency broadcasting system

    \n
    "; $this->assertEqual($result, $expected); @@ -143,4 +143,31 @@ class SessionHelperTest extends CakeTestCase { $this->assertFalse($this->Session->check('Message.bare')); } +/** + * test flash() with the attributes. + * + * @return void + */ + function testFlashAttributes() { + $result = $this->Session->flash('flash', array('params' => array('class' => 'test-message'))); + $expected = '
    This is a calling
    '; + $this->assertEqual($result, $expected); + $this->assertFalse($this->Session->check('Message.flash')); + } + +/** + * test setting the element from the attrs. + * + * @return void + */ + function testFlashElementInAttrs() { + App::build(array( + 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) + )); + $result = $this->Session->flash('flash', array( + 'element' => 'session_helper', + 'params' => array('title' => 'Notice!', 'name' => 'Alert!') + )); + $expected = "
    \n\t

    Alert!

    \n\t

    Notice!

    \n\t

    This is a calling

    \n
    "; + } } From 0b75906649f45f104d40b8085334ad8d52961080 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 21 Feb 2011 14:08:01 -0500 Subject: [PATCH 379/668] Adding docs about the ability to set settings in the helper as well. --- cake/libs/controller/components/session.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cake/libs/controller/components/session.php b/cake/libs/controller/components/session.php index 09a9f6da6..fefa7dbf7 100644 --- a/cake/libs/controller/components/session.php +++ b/cake/libs/controller/components/session.php @@ -113,7 +113,9 @@ class SessionComponent extends Component { * * In your controller: $this->Session->setFlash('This has been saved'); * - * Additional params below can be passed to customize the output, or the Message.[key] + * Additional params below can be passed to customize the output, or the Message.[key]. + * You can also set additional parameters when rendering flash messages. See SessionHelper::flash() + * for more information on how to do that. * * @param string $message Message to be flashed * @param string $element Element to wrap flash message in. From 709ed7675b7cc200d22d2066a6a04dc6ab0fb105 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 22 Feb 2011 01:21:26 +0530 Subject: [PATCH 380/668] Fixing typo in PHPUnit include file path --- cake/tests/lib/reporter/cake_base_reporter.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cake/tests/lib/reporter/cake_base_reporter.php b/cake/tests/lib/reporter/cake_base_reporter.php index dc0ff3d58..8e48065c2 100644 --- a/cake/tests/lib/reporter/cake_base_reporter.php +++ b/cake/tests/lib/reporter/cake_base_reporter.php @@ -16,7 +16,7 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once 'PHPUnit/TextUi/ResultPrinter.php'; +require_once 'PHPUnit/TextUI/ResultPrinter.php'; PHP_CodeCoverage_Filter::getInstance()->addFileToBlacklist(__FILE__, 'DEFAULT'); @@ -61,7 +61,7 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { * - app - App test being run. * - case - The case being run * - codeCoverage - Whether the case/group being run is being code covered. - * + * * @param string $charset The character set to output with. Defaults to UTF-8 * @param array $params Array of request parameters the reporter should use. See above. */ @@ -101,7 +101,7 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { * @return void */ public function paintDocumentEnd() { - + } /** @@ -111,7 +111,7 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { * @return void */ public function paintTestMenu() { - + } /** From 1f2afd8d3ffeeb4a81f575bbcc4b67255437a754 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 22 Feb 2011 01:24:21 +0530 Subject: [PATCH 381/668] Removing deprecated function TimeHelper::relativeTime() which was simply an alias for TimeHelper::timeAgoInWords() --- cake/libs/view/helpers/time.php | 24 ++++--------------- .../cases/libs/view/helpers/time.test.php | 19 +++++---------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index 6e1df2fe7..2540e32bc 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -56,7 +56,7 @@ class TimeHelper extends AppHelper { * Converts a string representing the format for the function strftime and returns a * windows safe and i18n aware format. * - * @param string $format Format with specifiers for strftime function. + * @param string $format Format with specifiers for strftime function. * Accepts the special specifier %S which mimics th modifier S for date() * @param string UNIX timestamp * @return string windows safe and date() function compatible format for strftime @@ -77,7 +77,7 @@ class TimeHelper extends AppHelper { * @return string converted element * @access private */ - function __translateSpecifier($specifier) { + private function __translateSpecifier($specifier) { switch ($specifier[1]) { case 'a': $abday = __c('abday', 5); @@ -361,7 +361,7 @@ class TimeHelper extends AppHelper { * @return boolean True if datetime string was yesterday * @access public * @link http://book.cakephp.org/view/1472/Testing-Time - * + * */ public function wasYesterday($dateString, $userOffset = null) { $date = $this->fromString($dateString, $userOffset); @@ -643,26 +643,10 @@ class TimeHelper extends AppHelper { return $relativeDate; } -/** - * Alias for timeAgoInWords - * - * @param mixed $dateTime Datetime string (strtotime-compatible) or Unix timestamp - * @param mixed $options Default format string, if timestamp is used in $dateTime, or an array of options to be passed - * on to timeAgoInWords(). - * @return string Relative time string. - * @see TimeHelper::timeAgoInWords - * @access public - * @deprecated This method alias will be removed in future versions. - * @link http://book.cakephp.org/view/1471/Formatting - */ - function relativeTime($dateTime, $options = array()) { - return $this->timeAgoInWords($dateTime, $options); - } - /** * Returns true if specified datetime was within the interval specified, else false. * - * @param mixed $timeInterval the numeric value with space then time type. + * @param mixed $timeInterval the numeric value with space then time type. * Example of valid types: 6 hours, 2 days, 1 minute. * @param mixed $dateString the datestring or unix timestamp to compare * @param int $userOffset User's offset from GMT (in hours) diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index 60f61fed2..aa2310bdf 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -84,6 +84,12 @@ class TimeHelperTest extends CakeTestCase { * @return void */ function testTimeAgoInWords() { + $result = $this->Time->timeAgoInWords('-1 week'); + $this->assertEqual($result, '1 week ago'); + + $result = $this->Time->timeAgoInWords('+1 week'); + $this->assertEqual($result, '1 week'); + $result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +3 days'), array('end' => '8 years'), true); $this->assertEqual($result, '4 months, 2 weeks, 3 days'); @@ -290,19 +296,6 @@ class TimeHelperTest extends CakeTestCase { $this->assertEqual($expected, $result); } -/** - * testRelative method - * - * @access public - * @return void - */ - function testRelative() { - $result = $this->Time->relativeTime('-1 week'); - $this->assertEqual($result, '1 week ago'); - $result = $this->Time->relativeTime('+1 week'); - $this->assertEqual($result, '1 week'); - } - /** * testNice method * From c5f291958b013bfee47b2da8f19ff4e53bb328b8 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 21 Feb 2011 17:36:02 -0300 Subject: [PATCH 382/668] Adding extra protection to cake console be executed in driver root (windows). --- cake/console/shell_dispatcher.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cake/console/shell_dispatcher.php b/cake/console/shell_dispatcher.php index 0a625f8cd..45152b6cb 100644 --- a/cake/console/shell_dispatcher.php +++ b/cake/console/shell_dispatcher.php @@ -263,7 +263,10 @@ class ShellDispatcher { } $params['app'] = basename($params['app']); - $params['working'] = rtrim($params['root'], '/') . '/' . $params['app']; + $params['working'] = rtrim($params['root'], '/'); + if (!$isWin || !preg_match('/^[A-Z]:$/i', $params['app'])) { + $params['working'] .= '/' . $params['app']; + } if (!empty($matches[0]) || !empty($isWin)) { $params = str_replace('/', '\\', $params); From 21a9904a71b24e753049a31a47b6dab26fde6743 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Mon, 21 Feb 2011 17:55:15 -0300 Subject: [PATCH 383/668] Adding a protection to cake console be executed in driver root (windows). Fixes #1408. --- cake/console/cake.bat | 2 +- cake/console/cake.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cake/console/cake.bat b/cake/console/cake.bat index 7e35cfcb9..87ee1c7d9 100644 --- a/cake/console/cake.bat +++ b/cake/console/cake.bat @@ -26,7 +26,7 @@ SET app=%0 SET lib=%~dp0 -php -q "%lib%cake.php" -working "%CD%" %* +php -q "%lib%cake.php" -working "%CD% " %* echo. diff --git a/cake/console/cake.php b/cake/console/cake.php index a4c89b520..f5cf287e4 100644 --- a/cake/console/cake.php +++ b/cake/console/cake.php @@ -501,6 +501,9 @@ class ShellDispatcher { } $params = str_replace('\\', '/', $params); + if (isset($params['working'])) { + $params['working'] = trim($params['working']); + } if (!empty($params['working']) && (!isset($this->args[0]) || isset($this->args[0]) && $this->args[0]{0} !== '.')) { if (empty($this->params['app']) && $params['working'] != $params['root']) { $params['root'] = dirname($params['working']); @@ -516,8 +519,10 @@ class ShellDispatcher { $params['root'] .= '/' . dirname($params['app']); } - $params['app'] = basename($params['app']); - $params['working'] = rtrim($params['root'], '/') . '/' . $params['app']; + $params['working'] = rtrim($params['root'], '/'); + if (!$isWin || !preg_match('/^[A-Z]:$/i', $params['app'])) { + $params['working'] .= '/' . $params['app']; + } if (!empty($matches[0]) || !empty($isWin)) { $params = str_replace('/', '\\', $params); From 6e60216c1378873a50f97c3f4c76fd73ddc578f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 21 Feb 2011 22:43:49 -0430 Subject: [PATCH 384/668] Fixing error in testLoader class checking --- lib/Cake/TestSuite/CakeTestSuiteCommand.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/CakeTestSuiteCommand.php b/lib/Cake/TestSuite/CakeTestSuiteCommand.php index 0672835fc..29dfd8f1d 100644 --- a/lib/Cake/TestSuite/CakeTestSuiteCommand.php +++ b/lib/Cake/TestSuite/CakeTestSuiteCommand.php @@ -41,8 +41,8 @@ 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 (!class_exists($loader)) { - throw new MissingTestLoaderException; + if ($loader && !class_exists($loader)) { + throw new MissingTestLoaderException(array('class' => $loader)); } $this->arguments['loader'] = $loader; $this->arguments['test'] = $params['case']; From c105899cbcbb93ed4e5095a74a7a4dd0d07f2f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 21 Feb 2011 22:48:22 -0430 Subject: [PATCH 385/668] Removing use of old constant --- lib/Cake/tests/cases/libs/view/helpers/session.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/libs/view/helpers/session.test.php b/lib/Cake/tests/cases/libs/view/helpers/session.test.php index ef2da35d8..60efe7622 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/session.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/session.test.php @@ -165,7 +165,7 @@ class SessionHelperTest extends CakeTestCase { */ function testFlashElementInAttrs() { 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) )); $result = $this->Session->flash('flash', array( 'element' => 'session_helper', From 6426b7ec04e7a3f9d56de1a5d14aa167da694b29 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 21 Feb 2011 22:30:01 -0500 Subject: [PATCH 386/668] Fixing issues with / routes, as PATH_INFO doesn't exist. Changing foreach loop for if elseif blocks, and removing use of env(). The values we want will never be anywhere else by _SERVER, so don't incur extra overhead looking places it won't be. Added tests. --- cake/libs/cake_request.php | 22 ++++---- cake/tests/cases/libs/cake_request.test.php | 58 +++++++++++++++++++-- 2 files changed, 64 insertions(+), 16 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 7a80b43a5..53340bf7f 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -187,18 +187,18 @@ class CakeRequest implements ArrayAccess { * @return string URI The CakePHP request path that is being accessed. */ protected function _url() { - $pathInfo = env('PATH_INFO'); - if (!empty($pathInfo)) { - return $pathInfo; - } - foreach (array('PHP_SELF', 'REQUEST_URI', 'HTTP_X_REWRITE_URL', 'argv') as $var) { - if ($uri = env($var)) { - if ($var == 'argv') { - $uri = $url[0]; - } - break; - } + if (!empty($_SERVER['PATH_INFO'])) { + return $_SERVER['PATH_INFO']; + } elseif (isset($_SERVER['REQUEST_URI'])) { + $uri = $_SERVER['REQUEST_URI']; + } elseif (isset($_SERVER['PHP_SELF']) && isset($_SERVER['SCRIPT_NAME'])) { + $uri = str_replace($_SERVER['SCRIPT_NAME'], '', $_SERVER['PHP_SELF']); + } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { + $uri = $_SERVER['HTTP_X_REWRITE_URL']; + } elseif ($var = env('argv')) { + $uri = $var[0]; } + $base = $this->base; if (strpos($uri, $base) === 0) { diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index 0a1381e9d..f4fa2916d 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -1172,7 +1172,7 @@ class CakeRequestTestCase extends CakeTestCase { ), ), array( - 'Apache - No rewrite, document root set above top level cake dir, requesting root', + 'Apache - No rewrite, document root set above top level cake dir, reques root, no PATH_INFO', array( 'App' => array( 'base' => false, @@ -1184,9 +1184,8 @@ class CakeRequestTestCase extends CakeTestCase { 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', - 'REQUEST_URI' => '/site/index.php/', + 'REQUEST_URI' => '/site/index.php/', 'SCRIPT_NAME' => '/site/index.php', - 'PATH_INFO' => '', 'PHP_SELF' => '/site/index.php/', ), ), @@ -1223,7 +1222,56 @@ class CakeRequestTestCase extends CakeTestCase { 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/', ), - ) + ), + array( + 'Apache - w/rewrite, document root set above top level cake dir, request root, no PATH_INFO', + array( + 'App' => array( + 'base' => false, + 'baseUrl' => false, + 'dir' => 'app', + 'webroot' => 'webroot' + ), + 'SERVER' => array( + 'SERVER_NAME' => 'localhost', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', + 'REQUEST_URI' => '/site/', + 'SCRIPT_NAME' => '/site/app/webroot/index.php', + 'PHP_SELF' => '/site/app/webroot/index.php', + ), + ), + array( + 'url' => '', + 'base' => '/site', + 'webroot' => '/site/', + ), + ), + array( + 'Apache - w/rewrite, document root above top level cake dir, request root, no PATH_INFO/REQUEST_URI', + array( + 'App' => array( + 'base' => false, + 'baseUrl' => false, + 'dir' => 'app', + 'webroot' => 'webroot' + ), + 'SERVER' => array( + 'SERVER_NAME' => 'localhost', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', + 'SCRIPT_NAME' => '/site/app/webroot/index.php', + 'PHP_SELF' => '/site/app/webroot/index.php', + 'PATH_INFO' => null, + 'REQUEST_URI' => null, + ), + ), + array( + 'url' => '', + 'base' => '/site', + 'webroot' => '/site/', + ), + ), ); } @@ -1239,7 +1287,7 @@ class CakeRequestTestCase extends CakeTestCase { $request = new CakeRequest(); $this->assertEquals($expected['url'], $request->url, "url error"); $this->assertEquals($expected['base'], $request->base, "base error"); - $this->assertEquals($expected['webroot'],$request->webroot, "webroot error"); + $this->assertEquals($expected['webroot'], $request->webroot, "webroot error"); if (isset($expected['urlParams'])) { $this->assertEqual($_GET, $expected['urlParams'], "GET param mismatch"); } From b314149efdb5650827e365ee87ef3fce0f906745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 21 Feb 2011 23:28:00 -0430 Subject: [PATCH 387/668] Checkin that PluginAppModel is not in the list of modles to be used for CakeSchema --- lib/Cake/Model/CakeSchema.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Cake/Model/CakeSchema.php b/lib/Cake/Model/CakeSchema.php index 93b3ecc76..d6e138159 100644 --- a/lib/Cake/Model/CakeSchema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -230,13 +230,18 @@ class CakeSchema extends Object { $importModel = $model; $plugin = null; if (isset($this->plugin)) { + if ($model == $this->plugin . 'AppModel') { + continue; + } $importModel = $model; $plugin = $this->plugin . '.'; } + App::uses($importModel, $plugin . 'Model'); if (!class_exists($importModel)) { continue; } + $vars = get_class_vars($model); if (empty($vars['useDbConfig']) || $vars['useDbConfig'] != $connection) { continue; From 0cb08a09dc3e131d092183fb66f72a4267b60647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Mon, 21 Feb 2011 23:58:46 -0430 Subject: [PATCH 388/668] Fixing class loading for authentication clasess in HttpSocket, also allowing the use of plugin authentication classes --- lib/Cake/Network/Http/HttpSocket.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index e8f675c14..1d5d1400d 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -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')) { From dbff3b8c58fb6b5e8be672cd9a28d51f0f7ee5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 00:02:35 -0430 Subject: [PATCH 389/668] Correctly importing HttpResponse in test --- lib/Cake/tests/cases/libs/http_response.test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/libs/http_response.test.php b/lib/Cake/tests/cases/libs/http_response.test.php index 9155bb8a3..53afc8ed9 100644 --- a/lib/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 From 3e7b85dc3468eccf753d60bda9df4cd01051aa43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 00:04:21 -0430 Subject: [PATCH 390/668] Correctly importing classes in DigetAuthentication test --- lib/Cake/tests/cases/libs/http/digest_authentication.test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/tests/cases/libs/http/digest_authentication.test.php b/lib/Cake/tests/cases/libs/http/digest_authentication.test.php index 17832ce45..0b9b6daea 100644 --- a/lib/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 { From b1e007f231bb46062e2f033905afd511fe24e806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 00:06:11 -0430 Subject: [PATCH 391/668] Correctly importing classes in BasicAuthentication test --- lib/Cake/tests/cases/libs/http/basic_authentication.test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/tests/cases/libs/http/basic_authentication.test.php b/lib/Cake/tests/cases/libs/http/basic_authentication.test.php index 990ed0750..3989b6f37 100644 --- a/lib/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 From a9d2078d2517649a9d6bc7310d8b11c8dffdd066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 00:13:35 -0430 Subject: [PATCH 392/668] Revert "Refactoring Dispatcher::_isPrivate to directly check for controller methods, doing in in the controller could be unnecessary" This reverts commit c431ddd22c973c1b797df8edf5e98de2e59578cd. Conflicts: lib/Cake/Routing/Dispatcher.php --- lib/Cake/Controller/Controller.php | 7 +++++-- lib/Cake/Routing/Dispatcher.php | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 039d7ae09..c34a3bc81 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -319,12 +319,15 @@ class Controller extends Object { } if (empty($this->uses)) { $this->modelClass = Inflector::singularize($this->name); - } else { - $this->modelClass = current($this->uses); } $this->modelKey = Inflector::underscore($this->modelClass); $this->Components = new ComponentCollection(); + $childMethods = get_class_methods($this); + $parentMethods = get_class_methods('Controller'); + + $this->methods = array_diff($childMethods, $parentMethods); + if ($request instanceof CakeRequest) { $this->setRequest($request); } diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index 6fceec3d7..2cc41f173 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -142,7 +142,7 @@ class Dispatcher { } } - return $privateAction || in_array($request->params['action'], get_class_methods('Controller')); + return $privateAction; } /** @@ -159,7 +159,7 @@ class Dispatcher { $controller->constructClasses(); $controller->startupProcess(); - $methods = array_flip(get_class_methods($controller)); + $methods = array_flip($controller->methods); if (!isset($methods[$request->params['action']])) { if ($controller->scaffold !== false) { From deae38546b4a17f7fe381767d488661d059185aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 00:44:33 -0430 Subject: [PATCH 393/668] Fixing App::objects() and App::setObjects() so all dispatcher tests pass --- lib/Cake/Core/App.php | 26 ++++++++++++------- lib/Cake/Routing/Dispatcher.php | 1 + lib/Cake/tests/cases/libs/dispatcher.test.php | 2 +- .../test_plugin_app_controller.php | 0 4 files changed, 18 insertions(+), 11 deletions(-) rename lib/Cake/tests/test_app/plugins/test_plugin/{ => controllers}/test_plugin_app_controller.php (100%) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 66272e35d..36cdd31fc 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -19,7 +19,7 @@ /** * App is responsible for path managment, class location and class loading. * - * ### Adding paths + * ### Adding paths * * You can add paths to the search indexes App uses to find classes using `App::build()`. Adding * additional controller paths for example would alter where CakePHP looks for controllers. @@ -33,7 +33,7 @@ * ### Locating plugins and themes * * Plugins and Themes can be located with App as well. Using App::pluginPath('DebugKit') for example, will - * give you the full path to the DebugKit plugin. App::themePath('purple'), would give the full path to the + * give you the full path to the DebugKit plugin. App::themePath('purple'), would give the full path to the * `purple` theme. * * ### Inspecting known objects @@ -212,7 +212,7 @@ class App { private static $__packages = array(); /** - * + * * */ private static $__packageFormat = array(); @@ -299,7 +299,7 @@ class App { 'View/Helper' => array('%s' . 'views' . DS . 'helpers' . DS), 'Console' => array( '%s' . 'console' . DS . 'shells' . DS, - '%s' . 'vendors' . DS . 'shells' . DS, + '%s' . 'vendors' . DS . 'shells' . DS, VENDORS . 'shells' . DS ), 'libs' => array('%s' . 'libs' . DS), @@ -413,7 +413,7 @@ class App { * * You can also search only within a plugin's objects by using the plugin dot * syntax. - * + * * `App::objects('MyPlugin.model');` returns `array('Post', 'Comment');` * * @param string $type Type of object, i.e. 'model', 'controller', 'helper', or 'plugin' @@ -468,8 +468,12 @@ class App { if ($dir != APP && is_dir($dir)) { $files = new RegexIterator(new DirectoryIterator($dir), $extension); foreach ($files as $file) { - if (!$file->isDot() && (!$file->isDir() || $includeDirectories)) { - $objects[] = substr(basename($file), 0, -4); + if (!$file->isDot()) { + if ($file->isDir() && $includeDirectories) { + $objects[] = basename($file); + } elseif (!$includeDirectories) { + $objects[] = substr(basename($file), 0, -4); + } } } } @@ -496,14 +500,16 @@ class App { /** * Allows you to modify the object listings that App maintains inside of it - * Useful for testing + * 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; + list($plugin, $type) = pluginSplit($type); + $cacheLocation = empty($plugin) ? 'app' : $plugin; + self::$__objects[$cacheLocation][$type] = $values; } public static function uses($className, $location) { @@ -523,7 +529,7 @@ class App { if (empty($plugin)) { $appLibs = empty(self::$__packages['libs']) ? APPLIBS : current(self::$__packages['libs']); $paths[] = $appLibs . self::$__classMap[$className] . DS; - $paths[] = LIBS . self::$__classMap[$className] . DS; + $paths[] = LIBS . self::$__classMap[$className] . DS; } foreach ($paths as $path) { diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index 2cc41f173..02e8aed2f 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -243,6 +243,7 @@ class Dispatcher { if ($pluginPath . $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; diff --git a/lib/Cake/tests/cases/libs/dispatcher.test.php b/lib/Cake/tests/cases/libs/dispatcher.test.php index 7689c9961..c9d21c9d4 100644 --- a/lib/Cake/tests/cases/libs/dispatcher.test.php +++ b/lib/Cake/tests/cases/libs/dispatcher.test.php @@ -1216,7 +1216,7 @@ class DispatcherTest extends CakeTestCase { App::build(array( 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'vendors' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'vendors'. DS), - 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) + 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $Dispatcher = new TestDispatcher(); diff --git a/lib/Cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php b/lib/Cake/tests/test_app/plugins/test_plugin/controllers/test_plugin_app_controller.php similarity index 100% rename from lib/Cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php rename to lib/Cake/tests/test_app/plugins/test_plugin/controllers/test_plugin_app_controller.php From d4cdc118d264830b51840d524cedb421c01ebdf7 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 22 Feb 2011 08:41:36 -0500 Subject: [PATCH 394/668] Fixing notice error that happens when you run tests for plugins. --- cake/tests/lib/cake_test_suite_dispatcher.php | 1 + 1 file changed, 1 insertion(+) diff --git a/cake/tests/lib/cake_test_suite_dispatcher.php b/cake/tests/lib/cake_test_suite_dispatcher.php index cd52a1678..05fd8411e 100644 --- a/cake/tests/lib/cake_test_suite_dispatcher.php +++ b/cake/tests/lib/cake_test_suite_dispatcher.php @@ -31,6 +31,7 @@ class CakeTestSuiteDispatcher { public $params = array( 'codeCoverage' => false, 'case' => null, + 'core' => false, 'app' => false, 'plugin' => null, 'output' => 'html', From 52163b4b05c3febc9643bc5e81366af7800314a6 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 22 Feb 2011 21:23:15 -0300 Subject: [PATCH 395/668] Allowing strings in cc and bcc. Fixes #1553. --- cake/libs/controller/components/email.php | 10 +++------- .../cases/libs/controller/components/email.test.php | 4 ++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index fd4ed3479..43ee594b7 100755 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -561,11 +561,7 @@ class EmailComponent extends Object{ $headers = array(); if ($this->delivery == 'smtp') { - if (is_array($this->to)) { - $headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), $this->to)); - } else { - $headers['To'] = $this->_formatAddress($this->to); - } + $headers['To'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->to)); } $headers['From'] = $this->_formatAddress($this->from); @@ -580,11 +576,11 @@ class EmailComponent extends Object{ } if (!empty($this->cc)) { - $headers['cc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->cc)); + $headers['Cc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->cc)); } if (!empty($this->bcc) && $this->delivery != 'smtp') { - $headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), $this->bcc)); + $headers['Bcc'] = implode(', ', array_map(array($this, '_formatAddress'), (array)$this->bcc)); } if ($this->delivery == 'smtp') { $headers['Subject'] = $this->_encode($this->subject); diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 541ed4f2a..78fb7b45c 100755 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -740,6 +740,8 @@ HTMLBLOC; function testSendDebug() { $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; + $this->Controller->EmailTest->cc = 'cc@example.com'; + $this->Controller->EmailTest->bcc = 'bcc@example.com'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; $this->Controller->EmailTest->replyTo = 'noreply@example.com'; $this->Controller->EmailTest->template = null; @@ -752,6 +754,8 @@ HTMLBLOC; $this->assertPattern('/Subject: Cake Debug Test\n/', $result); $this->assertPattern('/Reply-To: noreply@example.com\n/', $result); $this->assertPattern('/From: noreply@example.com\n/', $result); + $this->assertPattern('/Cc: cc@example.com\n/', $result); + $this->assertPattern('/Bcc: bcc@example.com\n/', $result); $this->assertPattern('/Date: ' . preg_quote(date(DATE_RFC2822)) . '\n/', $result); $this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result); $this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result); From 4e1fcbed61413bdb79ca64af105c82b4fd95b1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 22:47:07 -0430 Subject: [PATCH 396/668] Fixing ScaffoldView test --- lib/Cake/View/ScaffoldView.php | 2 +- .../cases/libs/controller/scaffold.test.php | 24 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/Cake/View/ScaffoldView.php b/lib/Cake/View/ScaffoldView.php index 35b968eb0..746e84eea 100644 --- a/lib/Cake/View/ScaffoldView.php +++ b/lib/Cake/View/ScaffoldView.php @@ -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/lib/Cake/tests/cases/libs/controller/scaffold.test.php b/lib/Cake/tests/cases/libs/controller/scaffold.test.php index 6bca35855..64c68d343 100644 --- a/lib/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::uses('Scaffold', 'Controller'); + App::uses('Controller', 'Controller'); +App::uses('Scaffold', 'Controller'); +App::uses('ScaffoldView', 'View'); /** * ScaffoldMockController class @@ -277,7 +279,7 @@ class ScaffoldViewTest extends CakeTestCase { $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); App::build(array( - 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . 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 = LIBS . '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 = LIBS . '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 = LIBS . '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 = LIBS . '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 = LIBS . '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 = LIBS . '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 = LIBS . '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 = LIBS . '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); From ffacbd7d273073f02f813a65c4a4122101dea7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 22:49:33 -0430 Subject: [PATCH 397/668] Fixing pages controller test --- lib/Cake/tests/cases/libs/controller/pages_controller.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/libs/controller/pages_controller.test.php b/lib/Cake/tests/cases/libs/controller/pages_controller.test.php index d03a14d97..de1dd5b11 100644 --- a/lib/Cake/tests/cases/libs/controller/pages_controller.test.php +++ b/lib/Cake/tests/cases/libs/controller/pages_controller.test.php @@ -44,7 +44,7 @@ class PagesControllerTest extends CakeTestCase { */ function testDisplay() { App::build(array( - 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS, LIBS . '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)); From ff1942d271bc966f492f1303f69460ec6b471999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 23:03:04 -0430 Subject: [PATCH 398/668] Automatically adding the declaration of the PluginAppModel class in ClassRegistry::init(), making more controller tests pass --- lib/Cake/Utility/ClassRegistry.php | 1 + lib/Cake/tests/cases/libs/controller/controller.test.php | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Utility/ClassRegistry.php b/lib/Cake/Utility/ClassRegistry.php index 8a6f83bb3..c0d4e6685 100644 --- a/lib/Cake/Utility/ClassRegistry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -134,6 +134,7 @@ class ClassRegistry { 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); diff --git a/lib/Cake/tests/cases/libs/controller/controller.test.php b/lib/Cake/tests/cases/libs/controller/controller.test.php index 5fbe858a0..4e743ef57 100644 --- a/lib/Cake/tests/cases/libs/controller/controller.test.php +++ b/lib/Cake/tests/cases/libs/controller/controller.test.php @@ -17,6 +17,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ App::uses('Controller', 'Controller'); +App::uses('Router', 'Routing'); App::uses('CakeRequest', 'Network'); App::uses('CakeResponse', 'Network'); App::uses('SecurityComponent', 'Controller/Component'); @@ -438,9 +439,10 @@ class ControllerTest extends CakeTestCase { function testLoadModelInPlugins() { App::build(array( 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), - 'controllers' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS), - 'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS) + 'Controller' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS), + 'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS) )); + App::uses('TestPluginAppController', 'TestPlugin.Controller'); App::uses('TestPluginController', 'TestPlugin.Controller'); $Controller = new TestPluginController(); From 2371ed9f15070c773036d2206b5df7c0823143a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 23:36:53 -0430 Subject: [PATCH 399/668] Reverting change made in model constructor to lazily initialize the modelClass variable, making remaining controller tests pass --- lib/Cake/Controller/Controller.php | 7 +++---- lib/Cake/tests/cases/libs/controller/controller.test.php | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index c34a3bc81..3a6f1180e 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -317,9 +317,8 @@ class Controller extends Object { if ($this->viewPath == null) { $this->viewPath = Inflector::underscore($this->name); } - if (empty($this->uses)) { - $this->modelClass = Inflector::singularize($this->name); - } + + $this->modelClass = Inflector::singularize($this->name); $this->modelKey = Inflector::underscore($this->modelClass); $this->Components = new ComponentCollection(); @@ -336,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 */ diff --git a/lib/Cake/tests/cases/libs/controller/controller.test.php b/lib/Cake/tests/cases/libs/controller/controller.test.php index 4e743ef57..ec7345ca2 100644 --- a/lib/Cake/tests/cases/libs/controller/controller.test.php +++ b/lib/Cake/tests/cases/libs/controller/controller.test.php @@ -578,7 +578,7 @@ class ControllerTest extends CakeTestCase { $this->assertEqual($result, $expected); App::build(array( - 'views' => array(LIBS . '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')); From b62c8d8ee236452a70dcf276a19cad10e2886c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 23:42:14 -0430 Subject: [PATCH 400/668] Fixing bug in RequestHandler that was preventing the helper related to content type to be loaded correctly --- lib/Cake/Controller/Component/RequestHandlerComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index 41b6bd928..56cf6c448 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -541,7 +541,7 @@ class RequestHandlerComponent extends Component { ); if (!$isAdded) { - App::uses($helper . 'Helper', 'Helper'); + App::uses($helper . 'Helper', 'View/Helper'); if (class_exists($helper . 'Helper')) { $controller->helpers[] = $helper; } From a79877d11a911265731cac77297c36541902f62e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Tue, 22 Feb 2011 23:49:02 -0430 Subject: [PATCH 401/668] Revert "Making Model::setSource() eager again to fix issues where joined models" This reverts commit d20f68c44ee6d0b8f7fe3e17cf28e7874a30d5bb. --- cake/libs/model/model.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 9b537a95c..4e64c20ce 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -465,14 +465,16 @@ class Model extends Object { $this->Behaviors = new BehaviorCollection(); if ($this->useTable !== false) { + if ($this->useTable === null) { $this->useTable = Inflector::tableize($this->name); } - $this->setSource($this->useTable); if ($this->displayField == null) { unset($this->displayField); } + $this->table = $this->useTable; + $this->tableToModel[$this->table] = $this->alias; } elseif ($this->table === false) { $this->table = Inflector::tableize($this->name); } From fc060b5e9cb56bd2d32866dc41d533628f580e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 23 Feb 2011 00:43:56 -0430 Subject: [PATCH 402/668] Starting to lazy load database conenctions again, model read tests fixed --- cake/libs/model/datasources/dbo_source.php | 1 + .../cases/libs/model/model_read.test.php | 29 +++++++------------ 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index c57124a5a..3544804bd 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -944,6 +944,7 @@ class DboSource extends DataSource { $linkModel = $model->{$assoc}; $external = isset($assocData['external']); + $linkModel->getDataSource(); if ($model->useDbConfig == $linkModel->useDbConfig) { if (true === $this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null)) { $linkedModels[$type . '/' . $assoc] = true; diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php index 8788b04af..1a87f0ac4 100755 --- a/cake/tests/cases/libs/model/model_read.test.php +++ b/cake/tests/cases/libs/model/model_read.test.php @@ -3496,19 +3496,16 @@ class ModelReadTest extends BaseModelTest { * @return void */ public function testFindNeighbors() { - $this->loadFixtures('User', 'Article'); + $this->loadFixtures('User', 'Article', 'Comment', 'Tag', 'ArticlesTag', 'Attachment'); $TestModel = new Article(); $TestModel->id = 1; $result = $TestModel->find('neighbors', array('fields' => array('id'))); - $expected = array( - 'prev' => null, - 'next' => array( - 'Article' => array('id' => 2), - 'Comment' => array(), - 'Tag' => array() - )); - $this->assertEqual($result, $expected); + + $this->assertNull($result['prev']); + $this->assertEqual($result['next']['Article'], array('id' => 2)); + $this->assertEqual(count($result['next']['Comment']), 2); + $this->assertEqual(count($result['next']['Tag']), 2); $TestModel->id = 2; $TestModel->recursive = 0; @@ -3530,15 +3527,11 @@ class ModelReadTest extends BaseModelTest { $TestModel->id = 3; $TestModel->recursive = 1; $result = $TestModel->find('neighbors', array('fields' => array('id'))); - $expected = array( - 'prev' => array( - 'Article' => array('id' => 2), - 'Comment' => array(), - 'Tag' => array() - ), - 'next' => null - ); - $this->assertEqual($result, $expected); + + $this->assertNull($result['next']); + $this->assertEqual($result['prev']['Article'], array('id' => 2)); + $this->assertEqual(count($result['prev']['Comment']), 2); + $this->assertEqual(count($result['prev']['Tag']), 2); $TestModel->id = 1; $result = $TestModel->find('neighbors', array('recursive' => -1)); From 8f62d01701049fa099c4c70f0bde79a8d54a09b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 23 Feb 2011 00:49:37 -0430 Subject: [PATCH 403/668] Fixing lazy loading of database conenction when using prefixes and performing delete operations --- cake/libs/model/datasources/dbo_source.php | 2 +- cake/libs/model/model.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 3544804bd..307fe0b7a 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1852,7 +1852,7 @@ class DboSource extends DataSource { $joins = array_merge($model->getAssociated('hasOne'), $model->getAssociated('belongsTo')); foreach ($joins as $assoc) { - if (isset($model->{$assoc}) && $model->useDbConfig == $model->{$assoc}->useDbConfig) { + if (isset($model->{$assoc}) && $model->useDbConfig == $model->{$assoc}->useDbConfig && $model->{$assoc}->getDataSource()) { $assocData = $model->getAssociated($assoc); $join[] = $this->buildJoinStatement(array( 'table' => $this->fullTableName($model->{$assoc}), diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 4e64c20ce..fd9802b65 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -1882,7 +1882,7 @@ class Model extends Object { if (!$filters || !$this->exists()) { return false; } - $db = ConnectionManager::getDataSource($this->useDbConfig); + $db = $this->getDataSource(); $this->_deleteDependent($id, $cascade); $this->_deleteLinks($id); From 00f3aaf61572a1ad334f66053136c5a68247af28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 23 Feb 2011 01:22:23 -0430 Subject: [PATCH 404/668] Fixing some issues in ACL related classes when using database prefixes --- cake/libs/model/db_acl.php | 2 +- cake/tests/cases/libs/model/db_acl.test.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/db_acl.php b/cake/libs/model/db_acl.php index 4782cfc91..b0cd5d8fc 100644 --- a/cake/libs/model/db_acl.php +++ b/cake/libs/model/db_acl.php @@ -67,7 +67,7 @@ class AclNode extends AppModel { * @return array Node found in database */ public function node($ref = null) { - $db =& ConnectionManager::getDataSource($this->useDbConfig); + $db = $this->getDataSource(); $type = $this->alias; $result = null; diff --git a/cake/tests/cases/libs/model/db_acl.test.php b/cake/tests/cases/libs/model/db_acl.test.php index 5b046717a..07cff6748 100644 --- a/cake/tests/cases/libs/model/db_acl.test.php +++ b/cake/tests/cases/libs/model/db_acl.test.php @@ -363,8 +363,8 @@ class AclNodeTest extends CakeTestCase { * @return void */ function testNodeAliasParenting() { - $Aco = new DbAcoTest(); - $db = ConnectionManager::getDataSource('test'); + $Aco = ClassRegistry::init('DbAcoTest'); + $db = $Aco->getDataSource(); $db->truncate($Aco); $Aco->create(array('model' => null, 'foreign_key' => null, 'parent_id' => null, 'alias' => 'Application')); From 30c7b954ec12d91574c91a22811d7f673d9c0e92 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 23 Feb 2011 11:26:43 -0500 Subject: [PATCH 405/668] Fixing greedy regexp in project task. --- cake/console/shells/tasks/project.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/console/shells/tasks/project.php b/cake/console/shells/tasks/project.php index 433ce9616..eb59cc7c2 100644 --- a/cake/console/shells/tasks/project.php +++ b/cake/console/shells/tasks/project.php @@ -316,8 +316,8 @@ class ProjectTask extends Shell { $path = (empty($this->configPath)) ? CONFIGS : $this->configPath; $File = new File($path . 'core.php'); $contents = $File->read(); - if (preg_match('%([/\s]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%', $contents, $match)) { - $result = str_replace($match[0], "\t" . 'Configure::write(\'Routing.prefixes\', array(\''.$name.'\'));', $contents); + if (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%', $contents, $match)) { + $result = str_replace($match[0], "\n" . 'Configure::write(\'Routing.prefixes\', array(\''.$name.'\'));', $contents); if ($File->write($result)) { Configure::write('Routing.prefixes', array($name)); return true; From 98df3e331f8f1e3b5928bfb1518fd222a8438c3a Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 23 Feb 2011 11:36:41 -0500 Subject: [PATCH 406/668] Fixing DboMysql not quoting database names in listSources. Updated tests. Fixes #1552 --- cake/libs/model/datasources/dbo/dbo_mysql.php | 2 +- .../cases/libs/model/datasources/dbo/dbo_mysql.test.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 19d030b83..3b00a49a6 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -182,7 +182,7 @@ class DboMysql extends DboSource { if ($cache != null) { return $cache; } - $result = $this->_execute('SHOW TABLES FROM ' . $this->config['database']); + $result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database'])); if (!$result) { $result->closeCursor(); diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index f9f05dc6b..b31f4e5d6 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -779,7 +779,7 @@ class DboMysqlTest extends CakeTestCase { $queryResult = $this->getMock('PDOStatement'); $db->expects($this->once()) ->method('_execute') - ->with('SHOW TABLES FROM cake') + ->with('SHOW TABLES FROM `cake`') ->will($this->returnValue($queryResult)); $queryResult->expects($this->at(0)) ->method('fetch') @@ -2869,7 +2869,7 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testVirtualFields() { - $this->loadFixtures('Article', 'Comment'); + $this->loadFixtures('Article', 'Comment', 'Tag'); $this->Dbo->virtualFieldSeparator = '__'; $Article = ClassRegistry::init('Article'); $Article->virtualFields = array( @@ -2939,7 +2939,7 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testVirtualFieldsInConditions() { - $Article = ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article', 'Comment', 'Tag'); $Article->virtualFields = array( 'this_moment' => 'NOW()', 'two' => '1 + 1', @@ -2973,7 +2973,7 @@ class DboMysqlTest extends CakeTestCase { * @return void */ function testConditionsWithComplexVirtualFields() { - $Article = ClassRegistry::init('Article'); + $Article = ClassRegistry::init('Article', 'Comment', 'Tag'); $Article->virtualFields = array( 'distance' => 'ACOS(SIN(20 * PI() / 180) * SIN(Article.latitude * PI() / 180) From 139d6b3133bfe1068a1fbee50fd1605d28dbe561 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 23 Feb 2011 21:15:39 -0500 Subject: [PATCH 407/668] Changing the checks surrounding dataExpression to use empty() instead of isset() so unexpected things don't happen if you ever use dataExpression = false. Fixes #1521 --- cake/libs/view/helpers/jquery_engine.php | 2 +- cake/libs/view/helpers/mootools_engine.php | 2 +- cake/libs/view/helpers/prototype_engine.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/view/helpers/jquery_engine.php b/cake/libs/view/helpers/jquery_engine.php index 16668d08b..54e9a7589 100644 --- a/cake/libs/view/helpers/jquery_engine.php +++ b/cake/libs/view/helpers/jquery_engine.php @@ -269,7 +269,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper { unset($options['update']); } $callbacks = array('success', 'error', 'beforeSend', 'complete'); - if (isset($options['dataExpression'])) { + if (!empty($options['dataExpression'])) { $callbacks[] = 'data'; unset($options['dataExpression']); } diff --git a/cake/libs/view/helpers/mootools_engine.php b/cake/libs/view/helpers/mootools_engine.php index 2ade6069c..693d84597 100644 --- a/cake/libs/view/helpers/mootools_engine.php +++ b/cake/libs/view/helpers/mootools_engine.php @@ -252,7 +252,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper { } $options['url'] = $url; $options = $this->_prepareCallbacks('request', $options); - if (isset($options['dataExpression'])) { + if (!empty($options['dataExpression'])) { $callbacks[] = 'data'; unset($options['dataExpression']); } elseif (!empty($data)) { diff --git a/cake/libs/view/helpers/prototype_engine.php b/cake/libs/view/helpers/prototype_engine.php index 848b676a2..7d49ae07e 100644 --- a/cake/libs/view/helpers/prototype_engine.php +++ b/cake/libs/view/helpers/prototype_engine.php @@ -244,7 +244,7 @@ class PrototypeEngineHelper extends JsBaseEngineHelper { } $safe = array_keys($this->_callbackArguments['request']); $options = $this->_prepareCallbacks('request', $options, $safe); - if (isset($options['dataExpression'])) { + if (!empty($options['dataExpression'])) { $safe[] = 'parameters'; unset($options['dataExpression']); } From ea7f0bf900c70ee68610f2b9180236561a53036d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Wed, 23 Feb 2011 23:44:48 -0430 Subject: [PATCH 408/668] Fixing some tests to make them run with table prefixes --- .../model/datasources/dbo/dbo_mysql.test.php | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php index f9f05dc6b..43971ddef 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php @@ -457,6 +457,7 @@ class DboMysqlTest extends CakeTestCase { function testAlterSchemaIndexes() { App::import('Model', 'CakeSchema'); $this->Dbo->cacheSources = $this->Dbo->testing = false; + $table = $this->Dbo->fullTableName('altertest'); $schema1 = new CakeSchema(array( 'name' => 'AlterTest1', @@ -493,7 +494,7 @@ class DboMysqlTest extends CakeTestCase { ))); $result = $this->Dbo->alterSchema($schema2->compare($schema1)); - $this->assertContains('ALTER TABLE `altertest`', $result); + $this->assertContains("ALTER TABLE $table", $result); $this->assertContains('ADD KEY name_idx (`name`),', $result); $this->assertContains('ADD KEY group_idx (`group1`),', $result); $this->assertContains('ADD KEY compound_idx (`group1`, `group2`),', $result); @@ -520,7 +521,7 @@ class DboMysqlTest extends CakeTestCase { ))); $result = $this->Dbo->alterSchema($schema3->compare($schema2)); - $this->assertContains('ALTER TABLE `altertest`', $result); + $this->assertContains("ALTER TABLE $table", $result); $this->assertContains('DROP PRIMARY KEY,', $result); $this->assertContains('DROP KEY name_idx,', $result); $this->assertContains('DROP KEY group_idx,', $result); @@ -539,7 +540,7 @@ class DboMysqlTest extends CakeTestCase { // Drop the indexes $result = $this->Dbo->alterSchema($schema1->compare($schema3)); - $this->assertContains('ALTER TABLE `altertest`', $result); + $this->assertContains("ALTER TABLE $table", $result); $this->assertContains('DROP KEY name_idx,', $result); $this->assertContains('DROP KEY group_idx,', $result); $this->assertContains('DROP KEY compound_idx,', $result); @@ -611,11 +612,11 @@ class DboMysqlTest extends CakeTestCase { $this->assertContains('COLLATE=utf8_general_ci', $result); $this->Dbo->rawQuery($result); - $result = $this->Dbo->listDetailedSources('altertest'); + $result = $this->Dbo->listDetailedSources($this->Dbo->fullTableName('altertest', false)); $this->assertEqual($result['Collation'], 'utf8_general_ci'); $this->assertEqual($result['Engine'], 'InnoDB'); $this->assertEqual($result['charset'], 'utf8'); - + $this->Dbo->rawQuery($this->Dbo->dropSchema($schema1)); } @@ -662,18 +663,20 @@ class DboMysqlTest extends CakeTestCase { function testReadTableParameters() { $this->Dbo->cacheSources = $this->Dbo->testing = false; $tableName = 'tinyint_' . uniqid(); - $this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'); - $result = $this->Dbo->readTableParameters($tableName); - $this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName)); + $table = $this->Dbo->fullTableName($tableName); + $this->Dbo->rawQuery('CREATE TABLE ' . $table . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'); + $result = $this->Dbo->readTableParameters($this->Dbo->fullTableName($tableName, false)); + $this->Dbo->rawQuery('DROP TABLE ' . $table); $expected = array( 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci', 'engine' => 'InnoDB'); $this->assertEqual($result, $expected); - $this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;'); - $result = $this->Dbo->readTableParameters($tableName); - $this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName)); + $table = $this->Dbo->fullTableName($tableName); + $this->Dbo->rawQuery('CREATE TABLE ' . $table . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;'); + $result = $this->Dbo->readTableParameters($this->Dbo->fullTableName($tableName, false)); + $this->Dbo->rawQuery('DROP TABLE ' . $table); $expected = array( 'charset' => 'cp1250', 'collate' => 'cp1250_general_ci', @@ -762,7 +765,7 @@ class DboMysqlTest extends CakeTestCase { $this->Dbo->execute($this->Dbo->createSchema($schema)); $model = new CakeTestModel(array('table' => 'testdescribes', 'name' => 'Testdescribes')); - $result = $this->Dbo->describe($model); + $result = $model->getDataSource()->describe($model); $this->Dbo->execute($this->Dbo->dropSchema($schema)); $this->assertEqual($result['stringy']['collate'], 'cp1250_general_ci'); @@ -807,7 +810,8 @@ class DboMysqlTest extends CakeTestCase { $this->assertEquals(array(), $result, 'Should be empty when table does not exist.'); $result = $this->Dbo->listDetailedSources(); - $this->assertTrue(isset($result['apples']), 'Key should exist'); + $tableName = $this->Dbo->fullTableName('apples', false); + $this->assertTrue(isset($result[$tableName]), 'Key should exist'); } /** @@ -1633,8 +1637,9 @@ class DboMysqlTest extends CakeTestCase { $params = $this->_prepareAssociationQuery($this->Model, $queryData, $binding); $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet); + $assocTable = $this->Dbo->fullTableName($this->Model->TestModel4TestModel7, false); $this->assertPattern('/^SELECT\s+`TestModel7`\.`id`, `TestModel7`\.`name`, `TestModel7`\.`created`, `TestModel7`\.`updated`, `TestModel4TestModel7`\.`test_model4_id`, `TestModel4TestModel7`\.`test_model7_id`\s+/', $result); - $this->assertPattern('/\s+FROM\s+`test_model7` AS `TestModel7`\s+JOIN\s+`' . $this->Dbo->fullTableName('test_model4_test_model7', false) . '`/', $result); + $this->assertPattern('/\s+FROM\s+`test_model7` AS `TestModel7`\s+JOIN\s+`' . $assocTable . '`/', $result); $this->assertPattern('/\s+ON\s+\(`TestModel4TestModel7`\.`test_model4_id`\s+=\s+{\$__cakeID__\$}\s+AND/', $result); $this->assertPattern('/\s+AND\s+`TestModel4TestModel7`\.`test_model7_id`\s+=\s+`TestModel7`\.`id`\)/', $result); $this->assertPattern('/WHERE\s+(?:\()?1 = 1(?:\))?\s*$/', $result); @@ -2872,11 +2877,12 @@ class DboMysqlTest extends CakeTestCase { $this->loadFixtures('Article', 'Comment'); $this->Dbo->virtualFieldSeparator = '__'; $Article = ClassRegistry::init('Article'); + $commentsTable = $this->Dbo->fullTableName('comments', false); $Article->virtualFields = array( 'this_moment' => 'NOW()', 'two' => '1 + 1', - 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->Dbo->fullTableName('comments') . - ' WHERE Article.id = ' . $this->Dbo->fullTableName('comments') . '.article_id' + 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentsTable . + ' WHERE Article.id = ' . $commentsTable . '.article_id' ); $result = $this->Dbo->fields($Article); $expected = array( @@ -2889,8 +2895,9 @@ class DboMysqlTest extends CakeTestCase { '`Article`.`updated`', '(NOW()) AS `Article__this_moment`', '(1 + 1) AS `Article__two`', - '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`' + "(SELECT COUNT(*) FROM $commentsTable WHERE `Article`.`id` = `$commentsTable`.`article_id`) AS `Article__comment_count`" ); + $this->assertEqual($expected, $result); $result = $this->Dbo->fields($Article, null, array('this_moment', 'title')); @@ -2919,7 +2926,7 @@ class DboMysqlTest extends CakeTestCase { '`Article`.*', '(NOW()) AS `Article__this_moment`', '(1 + 1) AS `Article__two`', - '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`' + "(SELECT COUNT(*) FROM $commentsTable WHERE `Article`.`id` = `$commentsTable`.`article_id`) AS `Article__comment_count`" ); $this->assertEqual($expected, $result); @@ -2928,7 +2935,7 @@ class DboMysqlTest extends CakeTestCase { '*', '(NOW()) AS `Article__this_moment`', '(1 + 1) AS `Article__two`', - '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `Article__comment_count`' + "(SELECT COUNT(*) FROM $commentsTable WHERE `Article`.`id` = `$commentsTable`.`article_id`) AS `Article__comment_count`" ); $this->assertEqual($expected, $result); } @@ -2940,11 +2947,12 @@ class DboMysqlTest extends CakeTestCase { */ function testVirtualFieldsInConditions() { $Article = ClassRegistry::init('Article'); + $commentsTable = $this->Dbo->fullTableName('comments', false); $Article->virtualFields = array( 'this_moment' => 'NOW()', 'two' => '1 + 1', - 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->Dbo->fullTableName('comments') . - ' WHERE Article.id = ' . $this->Dbo->fullTableName('comments') . '.article_id' + 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentsTable . + ' WHERE Article.id = ' . $commentsTable . '.article_id' ); $conditions = array('two' => 2); $result = $this->Dbo->conditions($conditions, true, false, $Article); @@ -2957,7 +2965,7 @@ class DboMysqlTest extends CakeTestCase { $this->assertEqual($expected, $result); $conditions = array('comment_count >' => 5); - $expected = '(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) > 5'; + $expected = "(SELECT COUNT(*) FROM $commentsTable WHERE `Article`.`id` = `$commentsTable`.`article_id`) > 5"; $result = $this->Dbo->conditions($conditions, true, false, $Article); $this->assertEqual($expected, $result); @@ -2997,11 +3005,12 @@ class DboMysqlTest extends CakeTestCase { */ function testVirtualFieldsInCalculate() { $Article = ClassRegistry::init('Article'); + $commentsTable = $this->Dbo->fullTableName('comments', false); $Article->virtualFields = array( 'this_moment' => 'NOW()', 'two' => '1 + 1', - 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->Dbo->fullTableName('comments') . - ' WHERE Article.id = ' . $this->Dbo->fullTableName('comments'). '.article_id' + 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentsTable . + ' WHERE Article.id = ' . $commentsTable . '.article_id' ); $result = $this->Dbo->calculate($Article, 'count', array('this_moment')); @@ -3009,7 +3018,7 @@ class DboMysqlTest extends CakeTestCase { $this->assertEqual($expected, $result); $result = $this->Dbo->calculate($Article, 'max', array('comment_count')); - $expected = 'MAX(SELECT COUNT(*) FROM comments WHERE `Article`.`id` = `comments`.`article_id`) AS `comment_count`'; + $expected = "MAX(SELECT COUNT(*) FROM $commentsTable WHERE `Article`.`id` = `$commentsTable`.`article_id`) AS `comment_count`"; $this->assertEqual($expected, $result); } From 69b70249da0228489d336a2a676ad18ea6214a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=CC=81=20Lorenzo=20Rodri=CC=81guez?= Date: Thu, 24 Feb 2011 01:31:03 -0430 Subject: [PATCH 409/668] Fixing more issues with database prefixes --- cake/libs/model/behaviors/translate.php | 12 ++++--- cake/libs/model/cake_schema.php | 4 +-- .../cases/libs/model/cake_schema.test.php | 36 +++++++++++++------ 3 files changed, 35 insertions(+), 17 deletions(-) diff --git a/cake/libs/model/behaviors/translate.php b/cake/libs/model/behaviors/translate.php index 3f0c462d5..ff7c9bdc5 100644 --- a/cake/libs/model/behaviors/translate.php +++ b/cake/libs/model/behaviors/translate.php @@ -90,7 +90,7 @@ class TranslateBehavior extends ModelBehavior { if (empty($locale)) { return $query; } - $db = ConnectionManager::getDataSource($model->useDbConfig); + $db = $model->getDataSource(); $RuntimeModel = $this->translateModel($model); if (!empty($RuntimeModel->tablePrefix)) { $tablePrefix = $RuntimeModel->tablePrefix; @@ -98,12 +98,16 @@ class TranslateBehavior extends ModelBehavior { $tablePrefix = $db->config['prefix']; } + if ($tablePrefix == $db->config['prefix']) { + $tablePrefix = null; + } + if (is_string($query['fields']) && 'COUNT(*) AS '.$db->name('count') == $query['fields']) { $query['fields'] = 'COUNT(DISTINCT('.$db->name($model->alias . '.' . $model->primaryKey) . ')) ' . $db->alias . 'count'; $query['joins'][] = array( 'type' => 'INNER', 'alias' => $RuntimeModel->alias, - 'table' => $db->name($tablePrefix . $RuntimeModel->useTable), + 'table' => $db->fullTableName($tablePrefix . $RuntimeModel->useTable), 'conditions' => array( $model->alias . '.' . $model->primaryKey => $db->identifier($RuntimeModel->alias.'.foreign_key'), $RuntimeModel->alias.'.model' => $model->name, @@ -149,7 +153,7 @@ class TranslateBehavior extends ModelBehavior { $query['joins'][] = array( 'type' => 'LEFT', 'alias' => 'I18n__'.$field.'__'.$_locale, - 'table' => $db->name($tablePrefix . $RuntimeModel->useTable), + 'table' => $db->fullTableName($tablePrefix . $RuntimeModel->useTable), 'conditions' => array( $model->alias . '.' . $model->primaryKey => $db->identifier("I18n__{$field}__{$_locale}.foreign_key"), 'I18n__'.$field.'__'.$_locale.'.model' => $model->name, @@ -166,7 +170,7 @@ class TranslateBehavior extends ModelBehavior { $query['joins'][] = array( 'type' => 'LEFT', 'alias' => 'I18n__'.$field, - 'table' => $db->name($tablePrefix . $RuntimeModel->useTable), + 'table' => $db->fullTableName($tablePrefix . $RuntimeModel->useTable), 'conditions' => array( $model->alias . '.' . $model->primaryKey => $db->identifier("I18n__{$field}.foreign_key"), 'I18n__'.$field.'.model' => $model->name, diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index 3542a6300..5579540b0 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -240,7 +240,7 @@ class CakeSchema extends Object { } $Object = ClassRegistry::init(array('class' => $model, 'ds' => $connection)); - + $db = $Object->getDataSource(); if (is_object($Object) && $Object->useTable !== false) { $fulltable = $table = $db->fullTableName($Object, false); if ($prefix && strpos($table, $prefix) !== 0) { @@ -575,7 +575,7 @@ class CakeSchema extends Object { * @return array Formatted columns */ public function __columns(&$Obj) { - $db = ConnectionManager::getDataSource($Obj->useDbConfig); + $db = $Obj->getDataSource(); $fields = $Obj->schema(true); $columns = $props = array(); diff --git a/cake/tests/cases/libs/model/cake_schema.test.php b/cake/tests/cases/libs/model/cake_schema.test.php index 69fb920d2..78890fbf7 100644 --- a/cake/tests/cases/libs/model/cake_schema.test.php +++ b/cake/tests/cases/libs/model/cake_schema.test.php @@ -589,22 +589,33 @@ class CakeSchemaTest extends CakeTestCase { $read = $this->Schema->read(array('connection' => 'schema_prefix', 'models' => false)); $this->assertTrue(empty($read['tables'])); - $SchemaPost = ClassRegistry::init('SchemaPost'); - $SchemaPost->table = 'sts'; - $SchemaPost->tablePrefix = 'po'; - $read = $this->Schema->read(array( - 'connection' => 'test', - 'name' => 'TestApp', - 'models' => array('SchemaPost') - )); - $this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix %s'); - $read = $this->Schema->read(array( 'connection' => 'test', 'name' => 'TestApp', 'models' => array('SchemaComment', 'SchemaTag', 'SchemaPost') )); - $this->assertFalse(isset($read['tables']['missing']['posts_tags']), 'Join table marked as missing %s'); + $this->assertFalse(isset($read['tables']['missing']['posts_tags']), 'Join table marked as missing'); + } + +/** + * testSchemaReadWithOddTablePrefix method + * + * @access public + * @return void + */ + function testSchemaReadWithOddTablePrefix() { + $config = ConnectionManager::getDataSource('test')->config; + $this->skipIf(!empty($config['prefix']), 'This test can not be executed with datasource prefix set'); + $SchemaPost = ClassRegistry::init('SchemaPost'); + $SchemaPost->tablePrefix = 'po'; + $SchemaPost->useTable = 'sts'; + $read = $this->Schema->read(array( + 'connection' => 'test', + 'name' => 'TestApp', + 'models' => array('SchemaPost') + )); + + $this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix'); } /** @@ -613,6 +624,9 @@ class CakeSchemaTest extends CakeTestCase { * @return void */ function testSchemaReadWithTablePrefix() { + $config = ConnectionManager::getDataSource('test')->config; + $this->skipIf(!empty($config['prefix']), 'This test can not be executed with datasource prefix set'); + $model = new SchemaPrefixAuthUser(); $Schema = new CakeSchema(); From e05c6cd83fb35ac2f25234147309776f39fb2556 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 24 Feb 2011 16:43:13 -0500 Subject: [PATCH 410/668] Fixing issue where actions starting with a prefix but not followed by an _ would get mangled when going through router::url(). Fixes #1556 --- cake/libs/router.php | 2 +- cake/tests/cases/libs/router.test.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 622dae829..86e77daae 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -822,7 +822,7 @@ class Router { } elseif (isset($url[$prefix]) && !$url[$prefix]) { unset($url[$prefix]); } - if (isset($url[$prefix]) && strpos($url['action'], $prefix) === 0) { + if (isset($url[$prefix]) && strpos($url['action'], $prefix . '_') === 0) { $url['action'] = substr($url['action'], strlen($prefix) + 1); } } diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 8346dfec8..0d199655d 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1513,6 +1513,10 @@ class RouterTest extends CakeTestCase { $result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true)); $expected = '/protected/images/edit/1'; $this->assertEqual($result, $expected); + + $result = Router::url(array('action' => 'protectededit', 1, 'protected' => true)); + $expected = '/protected/images/protectededit/1'; + $this->assertEqual($result, $expected); $result = Router::url(array('action' => 'edit', 1, 'protected' => true)); $expected = '/protected/images/edit/1'; From 31679c3efacaada2b8a5af00b7d1a01e4680f318 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 22 Feb 2011 23:42:15 -0300 Subject: [PATCH 411/668] Changed the scope of methods in Model. --- cake/libs/model/model.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index fd9802b65..d2fdf4a3e 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -2123,10 +2123,9 @@ class Model extends Object { * @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") * @param integer $recursive The number of levels deep to fetch associated records * @return array Array of records - * @access public * @link http://book.cakephp.org/view/1018/find */ - function find($conditions = null, $fields = array(), $order = null, $recursive = null) { + public function find($conditions = null, $fields = array(), $order = null, $recursive = null) { if (!is_string($conditions) || (is_string($conditions) && !array_key_exists($conditions, $this->_findMethods))) { $type = 'first'; $query = array_merge(compact('conditions', 'fields', 'order', 'recursive'), array('limit' => 1)); @@ -2212,10 +2211,9 @@ class Model extends Object { * @param array $query * @param array $data * @return array - * @access protected * @see Model::find() */ - function _findFirst($state, $query, $results = array()) { + protected function _findFirst($state, $query, $results = array()) { if ($state == 'before') { $query['limit'] = 1; return $query; @@ -2234,10 +2232,9 @@ class Model extends Object { * @param array $query * @param array $data * @return int The number of records found, or false - * @access protected * @see Model::find() */ - function _findCount($state, $query, $results = array()) { + protected function _findCount($state, $query, $results = array()) { if ($state == 'before') { $db = $this->getDataSource(); if (empty($query['fields'])) { @@ -2266,10 +2263,9 @@ class Model extends Object { * @param array $query * @param array $data * @return array Key/value pairs of primary keys/display field values of all records found - * @access protected * @see Model::find() */ - function _findList($state, $query, $results = array()) { + protected function _findList($state, $query, $results = array()) { if ($state == 'before') { if (empty($query['fields'])) { $query['fields'] = array("{$this->alias}.{$this->primaryKey}", "{$this->alias}.{$this->displayField}"); @@ -2427,9 +2423,8 @@ class Model extends Object { * @param array Results to filter * @param boolean $primary If this is the primary model results (results from model where the find operation was performed) * @return array Set of filtered results - * @access private */ - function __filterResults($results, $primary = true) { + private function __filterResults($results, $primary = true) { $return = $this->Behaviors->trigger( 'afterFind', array(&$this, $results, $primary), From 5bfa0867ef006d2b9f8456d5e559a20dc35bbaa0 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 22 Feb 2011 23:45:27 -0300 Subject: [PATCH 412/668] Removed the support to notation of 1.2. --- cake/libs/model/model.php | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index d2fdf4a3e..f6b667738 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -2073,7 +2073,7 @@ class Model extends Object { /** * Queries the datasource and returns a result set array. * - * Also used to perform new-notation finds, where the first argument is type of find operation to perform + * Also used to perform notation finds, where the first argument is type of find operation to perform * (all / first / count / neighbors / list / threaded ), * second parameter options for finding ( indexed array, including: 'conditions', 'limit', * 'recursive', 'page', 'fields', 'offset', 'order') @@ -2109,30 +2109,19 @@ class Model extends Object { * * Behaviors and find types can also define custom finder keys which are passed into find(). * - * Specifying 'fields' for new-notation 'list': + * Specifying 'fields' for notation 'list': * * - If no fields are specified, then 'id' is used for key and 'model->displayField' is used for value. * - If a single field is specified, 'id' is used for key and specified field is used for value. * - If three fields are specified, they are used (in order) for key, value and group. * - Otherwise, first and second fields are used for key and value. * - * @param array $conditions SQL conditions array, or type of find operation (all / first / count / - * neighbors / list / threaded) - * @param mixed $fields Either a single string of a field name, or an array of field names, or - * options for matching - * @param string $order SQL ORDER BY conditions (e.g. "price DESC" or "name ASC") - * @param integer $recursive The number of levels deep to fetch associated records + * @param string $type Type of find operation (all / first / count / neighbors / list / threaded) + * @param array $query Option fields (conditions / fields / joins / limit / offset / order / page / group / callbacks) * @return array Array of records * @link http://book.cakephp.org/view/1018/find */ - public function find($conditions = null, $fields = array(), $order = null, $recursive = null) { - if (!is_string($conditions) || (is_string($conditions) && !array_key_exists($conditions, $this->_findMethods))) { - $type = 'first'; - $query = array_merge(compact('conditions', 'fields', 'order', 'recursive'), array('limit' => 1)); - } else { - list($type, $query) = array($conditions, $fields); - } - + public function find($type = 'first', $query = array()) { $this->findQueryType = $type; $this->id = $this->getID(); From f15544018f7f613c6e7494746d6f46c7e6d63c3b Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Tue, 22 Feb 2011 23:47:27 -0300 Subject: [PATCH 413/668] Minor optimizations in find. --- cake/libs/model/model.php | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index f6b667738..307e648bd 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -2128,12 +2128,12 @@ class Model extends Object { $query = array_merge( array( 'conditions' => null, 'fields' => null, 'joins' => array(), 'limit' => null, - 'offset' => null, 'order' => null, 'page' => null, 'group' => null, 'callbacks' => true + 'offset' => null, 'order' => null, 'page' => 1, 'group' => null, 'callbacks' => true ), (array)$query ); - if ($type != 'all') { + if ($type !== 'all') { if ($this->_findMethods[$type] === true) { $query = $this->{'_find' . ucfirst($type)}('before', $query); } @@ -2171,10 +2171,7 @@ class Model extends Object { } } - if (!$db = $this->getDataSource()) { - return false; - } - + $db = $this->getDataSource(); $results = $db->read($this, $query); $this->resetAssociations(); @@ -2203,10 +2200,10 @@ class Model extends Object { * @see Model::find() */ protected function _findFirst($state, $query, $results = array()) { - if ($state == 'before') { + if ($state === 'before') { $query['limit'] = 1; return $query; - } elseif ($state == 'after') { + } elseif ($state === 'after') { if (empty($results[0])) { return false; } @@ -2224,7 +2221,7 @@ class Model extends Object { * @see Model::find() */ protected function _findCount($state, $query, $results = array()) { - if ($state == 'before') { + if ($state === 'before') { $db = $this->getDataSource(); if (empty($query['fields'])) { $query['fields'] = $db->calculate($this, 'count'); @@ -2235,7 +2232,7 @@ class Model extends Object { } $query['order'] = false; return $query; - } elseif ($state == 'after') { + } elseif ($state === 'after') { if (isset($results[0][0]['count'])) { return intval($results[0][0]['count']); } elseif (isset($results[0][$this->alias]['count'])) { @@ -2255,7 +2252,7 @@ class Model extends Object { * @see Model::find() */ protected function _findList($state, $query, $results = array()) { - if ($state == 'before') { + if ($state === 'before') { if (empty($query['fields'])) { $query['fields'] = array("{$this->alias}.{$this->primaryKey}", "{$this->alias}.{$this->displayField}"); $list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null); @@ -2264,14 +2261,14 @@ class Model extends Object { $query['fields'] = String::tokenize($query['fields']); } - if (count($query['fields']) == 1) { + if (count($query['fields']) === 1) { if (strpos($query['fields'][0], '.') === false) { $query['fields'][0] = $this->alias . '.' . $query['fields'][0]; } $list = array("{n}.{$this->alias}.{$this->primaryKey}", '{n}.' . $query['fields'][0], null); $query['fields'] = array("{$this->alias}.{$this->primaryKey}", $query['fields'][0]); - } elseif (count($query['fields']) == 3) { + } elseif (count($query['fields']) === 3) { for ($i = 0; $i < 3; $i++) { if (strpos($query['fields'][$i], '.') === false) { $query['fields'][$i] = $this->alias . '.' . $query['fields'][$i]; @@ -2294,7 +2291,7 @@ class Model extends Object { } list($query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']) = $list; return $query; - } elseif ($state == 'after') { + } elseif ($state === 'after') { if (empty($results)) { return array(); } @@ -2313,7 +2310,7 @@ class Model extends Object { * @return array */ protected function _findNeighbors($state, $query, $results = array()) { - if ($state == 'before') { + if ($state === 'before') { extract($query); $conditions = (array)$conditions; if (isset($field) && isset($value)) { @@ -2330,7 +2327,7 @@ class Model extends Object { $query['field'] = $field; $query['value'] = $value; return $query; - } elseif ($state == 'after') { + } elseif ($state === 'after') { extract($query); unset($query['conditions'][$field . ' <']); $return = array(); @@ -2349,9 +2346,9 @@ class Model extends Object { if (!array_key_exists('prev', $return)) { $return['prev'] = $return2[0]; } - if (count($return2) == 2) { + if (count($return2) === 2) { $return['next'] = $return2[1]; - } elseif (count($return2) == 1 && !$return['prev']) { + } elseif (count($return2) === 1 && !$return['prev']) { $return['next'] = $return2[0]; } else { $return['next'] = null; @@ -2370,9 +2367,9 @@ class Model extends Object { * @return array Threaded results */ protected function _findThreaded($state, $query, $results = array()) { - if ($state == 'before') { + if ($state === 'before') { return $query; - } elseif ($state == 'after') { + } elseif ($state === 'after') { $return = $idMap = array(); $ids = Set::extract($results, '{n}.' . $this->alias . '.' . $this->primaryKey); From 6e14fa894933d8de48c6343aeaa032841cd766f3 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 24 Feb 2011 21:06:30 -0300 Subject: [PATCH 414/668] Moving attributes from Datasource to DboDataSource. --- cake/libs/model/datasources/datasource.php | 122 --------------------- cake/libs/model/datasources/dbo_source.php | 122 +++++++++++++++++++++ 2 files changed, 122 insertions(+), 122 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index a6ebd4d1f..6d7687408 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -32,112 +32,6 @@ class DataSource extends Object { */ public $connected = false; -/** - * Print full query debug info? - * - * @var boolean - * @access public - */ - public $fullDebug = false; - -/** - * Error description of last query - * - * @var unknown_type - * @access public - */ - public $error = null; - -/** - * String to hold how many rows were affected by the last SQL operation. - * - * @var string - * @access public - */ - public $affected = null; - -/** - * Number of rows in current resultset - * - * @var int - * @access public - */ - public $numRows = null; - -/** - * Time the last query took - * - * @var int - * @access public - */ - public $took = null; - -/** - * The starting character that this DataSource uses for quoted identifiers. - * - * @var string - * @access public - */ - public $startQuote = null; - -/** - * The ending character that this DataSource uses for quoted identifiers. - * - * @var string - * @access public - */ - public $endQuote = null; - -/** - * Result - * - * @var array - * @access protected - */ - protected $_result = null; - -/** - * Queries count. - * - * @var int - * @access protected - */ - protected $_queriesCnt = 0; - -/** - * Total duration of all queries. - * - * @var unknown_type - * @access protected - */ - protected $_queriesTime = null; - -/** - * Log of queries executed by this DataSource - * - * @var unknown_type - * @access protected - */ - protected $_queriesLog = array(); - -/** - * Maximum number of items in query log - * - * This is to prevent query log taking over too much memory. - * - * @var int Maximum number of queries in the queries log. - * @access protected - */ - protected $_queriesLogMax = 200; - -/** - * Caches serialzed results of executed queries - * - * @var array Maximum number of queries in the queries log. - * @access protected - */ - protected $_queryCache = array(); - /** * The default configuration of a specific DataSource * @@ -162,14 +56,6 @@ class DataSource extends Object { */ protected $_sources = null; -/** - * A reference to the physical connection of this DataSource - * - * @var array - * @access public - */ - public $connection = null; - /** * The DataSource configuration * @@ -178,14 +64,6 @@ class DataSource extends Object { */ public $config = array(); -/** - * The DataSource configuration key name - * - * @var string - * @access public - */ - public $configKeyName = null; - /** * Whether or not this DataSource is in the middle of a transaction * diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 307fe0b7a..a3304f41c 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -70,6 +70,128 @@ class DboSource extends DataSource { */ public $cacheMethods = true ; +/** + * Print full query debug info? + * + * @var boolean + * @access public + */ + public $fullDebug = false; + +/** + * Error description of last query + * + * @var unknown_type + * @access public + */ + public $error = null; + +/** + * String to hold how many rows were affected by the last SQL operation. + * + * @var string + * @access public + */ + public $affected = null; + +/** + * Number of rows in current resultset + * + * @var int + * @access public + */ + public $numRows = null; + +/** + * Time the last query took + * + * @var int + * @access public + */ + public $took = null; + +/** + * Result + * + * @var array + * @access protected + */ + protected $_result = null; + +/** + * Queries count. + * + * @var int + * @access protected + */ + protected $_queriesCnt = 0; + +/** + * Total duration of all queries. + * + * @var unknown_type + * @access protected + */ + protected $_queriesTime = null; + +/** + * Log of queries executed by this DataSource + * + * @var unknown_type + * @access protected + */ + protected $_queriesLog = array(); + +/** + * Maximum number of items in query log + * + * This is to prevent query log taking over too much memory. + * + * @var int Maximum number of queries in the queries log. + * @access protected + */ + protected $_queriesLogMax = 200; + +/** + * Caches serialzed results of executed queries + * + * @var array Maximum number of queries in the queries log. + * @access protected + */ + protected $_queryCache = array(); + +/** + * A reference to the physical connection of this DataSource + * + * @var array + * @access public + */ + public $connection = null; + +/** + * The DataSource configuration key name + * + * @var string + * @access public + */ + public $configKeyName = null; + +/** + * The starting character that this DataSource uses for quoted identifiers. + * + * @var string + * @access public + */ + public $startQuote = null; + +/** + * The ending character that this DataSource uses for quoted identifiers. + * + * @var string + * @access public + */ + public $endQuote = null; + /** * Bypass automatic adding of joined fields/associations. * From 5ab5197090d904ae8288e3362914c58f3fb439a9 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 24 Feb 2011 21:07:50 -0300 Subject: [PATCH 415/668] Less one var. --- cake/libs/model/model.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 307e648bd..12a6de9e1 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -2171,8 +2171,7 @@ class Model extends Object { } } - $db = $this->getDataSource(); - $results = $db->read($this, $query); + $results = $this->getDataSource()->read($this, $query); $this->resetAssociations(); if ($query['callbacks'] === true || $query['callbacks'] === 'after') { From 9e8fc96bf859013898e6b0b1d8c49c995940cf7d Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 24 Feb 2011 21:12:58 -0300 Subject: [PATCH 416/668] Trimming whitespaces. --- cake/libs/model/datasources/dbo_source.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index a3304f41c..b9e928cbf 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -68,7 +68,7 @@ class DboSource extends DataSource { * @var boolean. * @access public */ - public $cacheMethods = true ; + public $cacheMethods = true; /** * Print full query debug info? @@ -332,7 +332,7 @@ class DboSource extends DataSource { } } elseif (in_array($data, array('{$__cakeID__$}', '{$__cakeForeignKey__$}'), true)) { return $data; - } + } if ($data === null || (is_array($data) && empty($data))) { return 'NULL'; @@ -482,7 +482,7 @@ class DboSource extends DataSource { $this->error = $e->getMessage(); return false; } - + } /** From 7f58d2628fdd662992bc413400d6988487dd4331 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 24 Feb 2011 21:16:03 -0300 Subject: [PATCH 417/668] Removing return from constructor. --- cake/libs/model/datasources/dbo_source.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index b9e928cbf..e8aadeb80 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -264,12 +264,10 @@ class DboSource extends DataSource { parent::__construct($config); $this->fullDebug = Configure::read('debug') > 1; if (!$this->enabled()) { - return false; + return; } if ($autoConnect) { - return $this->connect(); - } else { - return true; + $this->connect(); } } From 6f5be8ff954a9c098afb59f1ed1302e48f0d3ff4 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 24 Feb 2011 21:41:27 -0300 Subject: [PATCH 418/668] Minor changes. --- cake/libs/model/datasources/datasource.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 6d7687408..494ace324 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -116,8 +116,7 @@ class DataSource extends Object { Cache::write($key, $data, '_cake_model_'); } - $this->_sources = $sources; - return $sources; + return $this->_sources = $sources; } /** @@ -139,7 +138,7 @@ class DataSource extends Object { * @param Model $model * @return array Array of Metadata for the $model */ - public function describe($model) { + public function describe(Model $model) { if ($this->cacheSources === false) { return null; } @@ -204,7 +203,7 @@ class DataSource extends Object { * @param array $values An Array of values to save. * @return boolean success */ - public function create($model, $fields = null, $values = null) { + public function create(Model $model, $fields = null, $values = null) { return false; } @@ -217,7 +216,7 @@ class DataSource extends Object { * @param array $queryData An array of query data used to find the data you want * @return mixed */ - public function read($model, $queryData = array()) { + public function read(Model $model, $queryData = array()) { return false; } @@ -231,7 +230,7 @@ class DataSource extends Object { * @param array $values Array of values to be update $fields to. * @return boolean Success */ - public function update($model, $fields = null, $values = null) { + public function update(Model $model, $fields = null, $values = null) { return false; } @@ -243,7 +242,7 @@ class DataSource extends Object { * @param Model $model The model class having record(s) deleted * @param mixed $id Primary key of the model */ - public function delete($model, $id = null) { + public function delete(Model $model, $id = null) { if ($id == null) { $id = $model->id; } @@ -357,7 +356,7 @@ class DataSource extends Object { * @access public * @todo Remove and refactor $assocData, ensure uses of the method have the param removed too. */ - function insertQueryData($query, $data, $association, $assocData, &$model, &$linkModel, $stack) { + function insertQueryData($query, $data, $association, $assocData, Model $model, Model $linkModel, $stack) { $keys = array('{$__cakeID__$}', '{$__cakeForeignKey__$}'); foreach ($keys as $key) { @@ -437,7 +436,7 @@ class DataSource extends Object { * @param string $key Key name to make * @return string Key name for model. */ - public function resolveKey($model, $key) { + public function resolveKey(Model $model, $key) { return $model->alias . $key; } @@ -448,8 +447,7 @@ class DataSource extends Object { */ public function __destruct() { if ($this->_transactionStarted) { - $null = null; - $this->rollback($null); + $this->rollback(); } if ($this->connected) { $this->close(); From 05fc10e717b45360b2c81ed699b8bf41c1ff882d Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 24 Feb 2011 22:42:15 -0300 Subject: [PATCH 419/668] Removed the Datasource::sources method that is used to PHP4. Changed the isInterfaceSupported to be case sensitive (PHP4 restriction). --- cake/libs/model/datasources/datasource.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index 494ace324..c2bdfc018 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -119,19 +119,6 @@ class DataSource extends Object { return $this->_sources = $sources; } -/** - * Convenience method for DboSource::listSources(). Returns source names in lowercase. - * - * @param boolean $reset Whether or not the source list should be reset. - * @return array Array of sources available in this datasource - */ - public function sources($reset = false) { - if ($reset === true) { - $this->_sources = null; - } - return array_map('strtolower', $this->listSources()); - } - /** * Returns a Model description (metadata) or null if none found. * @@ -298,9 +285,9 @@ class DataSource extends Object { public function isInterfaceSupported($interface) { static $methods = false; if ($methods === false) { - $methods = array_map('strtolower', get_class_methods($this)); + $methods = get_class_methods($this); } - return in_array(strtolower($interface), $methods); + return in_array($interface, $methods); } /** From a091302c92f76fc09a2e963f3230a3b2eda41791 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 24 Feb 2011 22:51:43 -0300 Subject: [PATCH 420/668] Removed the isInterfaceSupported method. It not make sense in PHP5. --- cake/libs/model/datasources/datasource.php | 14 -------------- cake/libs/model/datasources/dbo_source.php | 2 +- cake/libs/model/model.php | 4 ++-- cake/libs/view/elements/sql_dump.ctp | 2 +- cake/tests/cases/libs/model/model_write.test.php | 6 ------ 5 files changed, 4 insertions(+), 24 deletions(-) diff --git a/cake/libs/model/datasources/datasource.php b/cake/libs/model/datasources/datasource.php index c2bdfc018..8f89e37de 100644 --- a/cake/libs/model/datasources/datasource.php +++ b/cake/libs/model/datasources/datasource.php @@ -276,20 +276,6 @@ class DataSource extends Object { return true; } -/** - * Returns true if the DataSource supports the given interface (method) - * - * @param string $interface The name of the interface (method) - * @return boolean True on success - */ - public function isInterfaceSupported($interface) { - static $methods = false; - if ($methods === false) { - $methods = get_class_methods($this); - } - return in_array($interface, $methods); - } - /** * Sets the configuration for the DataSource. * Merges the $config information with the _baseConfig and the existing $config property. diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index e8aadeb80..f918b65d5 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -3065,7 +3065,7 @@ class DboSource extends DataSource { */ public function readTableParameters($name) { $parameters = array(); - if ($this->isInterfaceSupported('listDetailedSources')) { + if (method_exists($this, 'listDetailedSources')) { $currentTableDetails = $this->listDetailedSources($name); foreach ($this->tableParameters as $paramName => $parameter) { if (!empty($parameter['column']) && !empty($currentTableDetails[$parameter['column']])) { diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 12a6de9e1..3ef6c7a2b 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -798,7 +798,7 @@ class Model extends Object { $db = ConnectionManager::getDataSource($this->useDbConfig); $db->cacheSources = ($this->cacheSources && $db->cacheSources); - if ($db->isInterfaceSupported('listSources')) { + if (method_exists($db, 'listSources')) { $sources = $db->listSources(); if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) { throw new MissingTableException(array( @@ -981,7 +981,7 @@ class Model extends Object { if (!is_array($this->_schema) || $field === true) { $db = $this->getDataSource(); $db->cacheSources = ($this->cacheSources && $db->cacheSources); - if ($db->isInterfaceSupported('describe') && $this->useTable !== false) { + if (method_exists($db, 'describe') && $this->useTable !== false) { $this->_schema = $db->describe($this, $field); } elseif ($this->useTable === false) { $this->_schema = array(); diff --git a/cake/libs/view/elements/sql_dump.ctp b/cake/libs/view/elements/sql_dump.ctp index b770dfbaa..5bc41ea10 100644 --- a/cake/libs/view/elements/sql_dump.ctp +++ b/cake/libs/view/elements/sql_dump.ctp @@ -26,7 +26,7 @@ if ($noLogs): $logs = array(); foreach ($sources as $source): $db =& ConnectionManager::getDataSource($source); - if (!$db->isInterfaceSupported('getLog')): + if (!method_exists($db, 'getLog')): continue; endif; $logs[$source] = $db->getLog(); diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index 27e5fde37..c9aae1fb3 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -2987,10 +2987,6 @@ class ModelWriteTest extends BaseModelTest { $db = ConnectionManager::create('mock_transaction', array( 'datasource' => 'MockTransactionDbo', )); - $db->expects($this->at(2)) - ->method('isInterfaceSupported') - ->with('describe') - ->will($this->returnValue(true)); $db->expects($this->once()) ->method('describe') @@ -3026,8 +3022,6 @@ class ModelWriteTest extends BaseModelTest { $db->columns = $testDb->columns; $db->expects($this->once())->method('rollback'); - $db->expects($this->any())->method('isInterfaceSupported') - ->will($this->returnValue(true)); $db->expects($this->any())->method('describe') ->will($this->returnValue(array( 'id' => array('type' => 'integer'), From 765c094cf161d245f6b1be19883e44a41fe11508 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Thu, 24 Feb 2011 23:16:47 -0300 Subject: [PATCH 421/668] Extra protection. --- cake/libs/model/datasources/dbo_source.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index f918b65d5..37ccd0990 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -322,7 +322,7 @@ class DboSource extends DataSource { array(&$this, 'value'), $data, array_fill(0, count($data), $column) ); - } elseif (is_object($data) && isset($data->type)) { + } elseif (is_object($data) && isset($data->type, $data->type)) { if ($data->type == 'identifier') { return $this->name($data->value); } elseif ($data->type == 'expression') { From 9baeaf8338476fa914fa683c175cb859414fc111 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 25 Feb 2011 01:02:37 -0300 Subject: [PATCH 422/668] Some code optimizations. --- cake/libs/model/datasources/dbo/dbo_mysql.php | 5 +- cake/libs/model/datasources/dbo_source.php | 215 ++++++++---------- 2 files changed, 98 insertions(+), 122 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 3b00a49a6..055964dc4 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -243,10 +243,9 @@ class DboMysql extends DboSource { } } return $resultRow; - } else { - $this->_result->closeCursor(); - return false; } + $this->_result->closeCursor(); + return false; } /** diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 37ccd0990..a3ece4a69 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -296,7 +296,7 @@ class DboSource extends DataSource { } unset($this->_connection); $this->connected = false; - return !$this->connected; + return true; } /** @@ -308,7 +308,6 @@ class DboSource extends DataSource { return $this->_connection; } - /** * Returns a quoted and escaped string of $data for use in an SQL statement. * @@ -424,7 +423,7 @@ class DboSource extends DataSource { * @return mixed Resource or object representing the result set, or false on failure */ public function execute($sql, $options = array(), $params = array()) { - $options = $options + array('log' => $this->fullDebug); + $options += array('log' => $this->fullDebug); $this->error = null; $t = microtime(true); @@ -480,7 +479,6 @@ class DboSource extends DataSource { $this->error = $e->getMessage(); return false; } - } /** @@ -501,10 +499,9 @@ class DboSource extends DataSource { * Returns number of affected rows in previous database operation. If no previous operation exists, * this returns false. * - * @param string $source * @return integer Number of affected rows */ - function lastAffected($source = null) { + function lastAffected() { if ($this->hasResult()) { return $this->_result->rowCount(); } @@ -515,10 +512,9 @@ class DboSource extends DataSource { * Returns number of rows in previous resultset. If no previous resultset exists, * this returns false. * - * @param string $source * @return integer Number of rows in resultset */ - function lastNumRows($source = null) { + function lastNumRows() { return $this->lastAffected($source); } @@ -535,18 +531,17 @@ class DboSource extends DataSource { $page = null; $recursive = null; - if (count($args) == 1) { + if (count($args) === 1) { return $this->fetchAll($args[0]); - } elseif (count($args) > 1 && (strpos($args[0], 'findBy') === 0 || strpos($args[0], 'findAllBy') === 0)) { $params = $args[1]; - if (strpos($args[0], 'findBy') === 0) { + if (substr($args[0], 0, 6) === 'findBy') { $all = false; - $field = Inflector::underscore(preg_replace('/^findBy/i', '', $args[0])); + $field = Inflector::underscore(substr($args[0], 6)); } else { $all = true; - $field = Inflector::underscore(preg_replace('/^findAllBy/i', '', $args[0])); + $field = Inflector::underscore(substr($args[0], 9)); } $or = (strpos($field, '_or_') !== false); @@ -573,8 +568,7 @@ class DboSource extends DataSource { $conditions = array(); foreach ($field as $f) { - $conditions[$args[2]->alias . '.' . $f] = $params[$c]; - $c++; + $conditions[$args[2]->alias . '.' . $f] = $params[$c++]; } if ($or) { @@ -624,10 +618,8 @@ class DboSource extends DataSource { * @return array The fetched row as an array */ public function fetchRow($sql = null) { - if (!empty($sql) && is_string($sql) && strlen($sql) > 5) { - if (!$this->execute($sql)) { - return null; - } + if (is_string($sql) && strlen($sql) > 5 && !$this->execute($sql)) { + return null; } if ($this->hasResult()) { @@ -664,8 +656,7 @@ class DboSource extends DataSource { $options['cache'] = $params; $params = array(); } - $defaults = array('cache' => true); - $options = $options + $defaults; + $options += array('cache' => true); $cache = $options['cache']; if ($cache && ($cached = $this->getQueryCache($sql, $params)) !== false) { return $cached; @@ -673,13 +664,15 @@ class DboSource extends DataSource { if ($result = $this->execute($sql, array(), $params)) { $out = array(); - $first = $this->fetchRow(); - if ($first != null) { - $out[] = $first; - } - while ($this->hasResult() && $item = $this->fetchResult()) { - $this->fetchVirtualField($item); - $out[] = $item; + if ($this->hasResult()) { + $first = $this->fetchRow(); + if ($first != null) { + $out[] = $first; + } + while ($item = $this->fetchResult()) { + $this->fetchVirtualField($item); + $out[] = $item; + } } if (!is_bool($result) && $cache) { @@ -690,9 +683,17 @@ class DboSource extends DataSource { return $this->_result; } return $out; - } else { - return false; } + return false; + } + +/** + * Fetches the next row from the current result set + * + * @return boolean + */ + public function fetchResult() { + return false; } /** @@ -733,11 +734,10 @@ class DboSource extends DataSource { */ public function field($name, $sql) { $data = $this->fetchRow($sql); - if (!isset($data[$name]) || empty($data[$name])) { + if (empty($data[$name])) { return false; - } else { - return $data[$name]; } + return $data[$name]; } /** @@ -909,7 +909,7 @@ class DboSource extends DataSource { $this->_queriesCnt++; $this->_queriesTime += $this->took; $this->_queriesLog[] = array( - 'query' => $sql, + 'query' => $sql, 'error' => $this->error, 'affected' => $this->affected, 'numRows' => $this->numRows, @@ -1010,10 +1010,9 @@ class DboSource extends DataSource { $model->setInsertID($id); $model->id = $id; return true; - } else { - $model->onError(); - return false; } + $model->onError(); + return false; } /** @@ -1055,7 +1054,7 @@ class DboSource extends DataSource { if ($model->recursive == -1) { $_associations = array(); - } else if ($model->recursive == 0) { + } elseif ($model->recursive == 0) { unset($_associations[2], $_associations[3]); } @@ -1173,7 +1172,7 @@ class DboSource extends DataSource { */ public function queryAssociation($model, &$linkModel, $type, $association, $assocData, &$queryData, $external = false, &$resultSet, $recursive, $stack) { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { - if (!isset($resultSet) || !is_array($resultSet)) { + if (!is_array($resultSet)) { if (Configure::read('debug') > 0) { echo '
    ' . __('SQL Error in model %s:', $model->alias) . ' '; if (isset($this->error) && $this->error != null) { @@ -1231,7 +1230,7 @@ class DboSource extends DataSource { $query = str_replace('{$__cakeID__$}', '(' .implode(', ', $ins) .')', $query); $query = str_replace('= (', 'IN (', $query); } else { - $query = str_replace('{$__cakeID__$}',$ins[0], $query); + $query = str_replace('{$__cakeID__$}', $ins[0], $query); } $query = str_replace(' WHERE 1 = 1', '', $query); @@ -1243,7 +1242,7 @@ class DboSource extends DataSource { $habtmFieldsCount = count($habtmFields); $q = $this->insertQueryData($query, null, $association, $assocData, $model, $linkModel, $stack); - if ($q != false) { + if ($q !== false) { $fetch = $this->fetchAll($q, $model->cacheQueries); } else { $fetch = null; @@ -1255,7 +1254,7 @@ class DboSource extends DataSource { if ($type !== 'hasAndBelongsToMany') { $q = $this->insertQueryData($query, $resultSet[$i], $association, $assocData, $model, $linkModel, $stack); - if ($q != false) { + if ($q !== false) { $fetch = $this->fetchAll($q, $model->cacheQueries); } else { $fetch = null; @@ -1290,9 +1289,7 @@ class DboSource extends DataSource { $uniqueIds = $merge = array(); foreach ($fetch as $j => $data) { - if ( - (isset($data[$with]) && $data[$with][$foreignKey] === $row[$model->alias][$model->primaryKey]) - ) { + if (isset($data[$with]) && $data[$with][$foreignKey] === $row[$model->alias][$model->primaryKey]) { if ($habtmFieldsCount <= 2) { unset($data[$with]); } @@ -1440,11 +1437,11 @@ class DboSource extends DataSource { } } else { foreach ($merge as $i => $row) { - if (count($row) == 1) { + if (count($row) === 1) { if (empty($data[$association]) || (isset($data[$association]) && !in_array($row[$association], $data[$association]))) { $data[$association][] = $row[$association]; } - } else if (!empty($row)) { + } elseif (!empty($row)) { $tmp = array_merge($row[$association], $row); unset($tmp[$association]); $data[$association][] = $tmp; @@ -1633,34 +1630,28 @@ class DboSource extends DataSource { * @return array Conditions array defining the constraint between $model and $association */ public function getConstraint($type, $model, $linkModel, $alias, $assoc, $alias2 = null) { - $assoc = array_merge(array('external' => false, 'self' => false), $assoc); + $assoc += array('external' => false, 'self' => false); - if (array_key_exists('foreignKey', $assoc) && empty($assoc['foreignKey'])) { + if (empty($assoc['foreignKey'])) { return array(); } switch (true) { - case ($assoc['external'] && $type == 'hasOne'): + case ($assoc['external'] && $type === 'hasOne'): return array("{$alias}.{$assoc['foreignKey']}" => '{$__cakeID__$}'); - break; - case ($assoc['external'] && $type == 'belongsTo'): + case ($assoc['external'] && $type === 'belongsTo'): return array("{$alias}.{$linkModel->primaryKey}" => '{$__cakeForeignKey__$}'); - break; - case (!$assoc['external'] && $type == 'hasOne'): + case (!$assoc['external'] && $type === 'hasOne'): return array("{$alias}.{$assoc['foreignKey']}" => $this->identifier("{$model->alias}.{$model->primaryKey}")); - break; - case (!$assoc['external'] && $type == 'belongsTo'): + case (!$assoc['external'] && $type === 'belongsTo'): return array("{$model->alias}.{$assoc['foreignKey']}" => $this->identifier("{$alias}.{$linkModel->primaryKey}")); - break; - case ($type == 'hasMany'): + case ($type === 'hasMany'): return array("{$alias}.{$assoc['foreignKey']}" => array('{$__cakeID__$}')); - break; - case ($type == 'hasAndBelongsToMany'): + case ($type === 'hasAndBelongsToMany'): return array( array("{$alias}.{$assoc['foreignKey']}" => '{$__cakeID__$}'), array("{$alias}.{$assoc['associationForeignKey']}" => $this->identifier("{$alias2}.{$linkModel->primaryKey}")) ); - break; } return array(); } @@ -1747,22 +1738,18 @@ class DboSource extends DataSource { switch (strtolower($type)) { case 'select': return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$group} {$order} {$limit}"; - break; case 'create': return "INSERT INTO {$table} ({$fields}) VALUES ({$values})"; - break; case 'update': if (!empty($alias)) { $aliases = "{$this->alias}{$alias} {$joins} "; } return "UPDATE {$table} {$aliases}SET {$fields} {$conditions}"; - break; case 'delete': if (!empty($alias)) { $aliases = "{$this->alias}{$alias} {$joins} "; } return "DELETE {$alias} FROM {$table} {$aliases}{$conditions}"; - break; case 'schema': foreach (array('columns', 'indexes', 'tableParameters') as $var) { if (is_array(${$var})) { @@ -1771,23 +1758,23 @@ class DboSource extends DataSource { ${$var} = ''; } } - if (trim($indexes) != '') { + if (trim($indexes) !== '') { $columns .= ','; } return "CREATE TABLE {$table} (\n{$columns}{$indexes}){$tableParameters};"; - break; case 'alter': - break; + return; } } /** * Merges a mixed set of string/array conditions * + * @param mixed $query + * @param mixed $assoc * @return array - * @access private */ - function __mergeConditions($query, $assoc) { + private function __mergeConditions($query, $assoc) { if (empty($assoc)) { return $query; } @@ -2145,7 +2132,7 @@ class DboSource extends DataSource { if (empty($assoc)) { $assoc = $model->alias; } - if (!strpos('.', $key)) { + if (strpos('.', $key) !== false) { return $this->name($model->alias) . '.' . $this->name($key); } return $key; @@ -2272,8 +2259,7 @@ class DboSource extends DataSource { $fields[$i] = $this->name(($prefix ? $alias . '.' : '') . $fields[$i]); } else { $value = array(); - $comma = strpos($fields[$i], ','); - if ($comma === false) { + if (strpos($fields[$i], ',') === false) { $build = explode('.', $fields[$i]); if (!Set::numeric($build)) { $fields[$i] = $this->name(implode('.', $build)); @@ -2351,11 +2337,11 @@ class DboSource extends DataSource { } return $this->cacheMethod(__FUNCTION__, $cacheKey, $clause . implode(' AND ', $out)); } - if ($conditions === false || $conditions === true) { + if (is_bool($conditions)) { return $this->cacheMethod(__FUNCTION__, $cacheKey, $clause . (int)$conditions . ' = 1'); } - if (empty($conditions) || trim($conditions) == '') { + if (empty($conditions) || trim($conditions) === '') { return $this->cacheMethod(__FUNCTION__, $cacheKey, $clause . '1 = 1'); } $clauses = '/^WHERE\\x20|^GROUP\\x20BY\\x20|^HAVING\\x20|^ORDER\\x20BY\\x20/i'; @@ -2363,11 +2349,7 @@ class DboSource extends DataSource { if (preg_match($clauses, $conditions, $match)) { $clause = ''; } - if (trim($conditions) == '') { - $conditions = ' 1 = 1'; - } else { - $conditions = $this->__quoteFields($conditions); - } + $conditions = $this->__quoteFields($conditions); return $this->cacheMethod(__FUNCTION__, $cacheKey, $clause . $conditions); } @@ -2380,7 +2362,6 @@ class DboSource extends DataSource { * @return string SQL fragment */ public function conditionKeysToString($conditions, $quoteValues = true, $model = null) { - $c = 0; $out = array(); $data = $columnType = null; $bool = array('and', 'or', 'not', 'and not', 'or not', 'xor', '||', '&&'); @@ -2392,7 +2373,7 @@ class DboSource extends DataSource { if (is_array($value)) { $valueInsert = ( !empty($value) && - (substr_count($key, '?') == count($value) || substr_count($key, ':') == count($value)) + (substr_count($key, '?') === count($value) || substr_count($key, ':') === count($value)) ); } @@ -2409,7 +2390,7 @@ class DboSource extends DataSource { $value = $this->conditionKeysToString($value, $quoteValues, $model); if (strpos($join, 'NOT') !== false) { - if (strtoupper(trim($key)) == 'NOT') { + if (strtoupper(trim($key)) === 'NOT') { $key = 'AND ' . trim($key); } $not = 'NOT '; @@ -2424,12 +2405,11 @@ class DboSource extends DataSource { } else { $out[] = '(' . $not . '(' . implode(') ' . strtoupper($key) . ' (', $value) . '))'; } - } else { if (is_object($value) && isset($value->type)) { - if ($value->type == 'identifier') { + if ($value->type === 'identifier') { $data .= $this->name($key) . ' = ' . $this->name($value->value); - } elseif ($value->type == 'expression') { + } elseif ($value->type === 'expression') { if (is_numeric($key)) { $data .= $value->value; } else { @@ -2471,7 +2451,6 @@ class DboSource extends DataSource { $data = null; } } - $c++; } return $out; } @@ -2491,7 +2470,7 @@ class DboSource extends DataSource { $operatorMatch .= '\\x20)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is'; $bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false)); - if (!strpos($key, ' ')) { + if (strpos($key, ' ') === false) { $operator = '='; } else { list($key, $operator) = explode(' ', trim($key), 2); @@ -2510,9 +2489,8 @@ class DboSource extends DataSource { $virtual = true; } - $type = (is_object($model) ? $model->getColumnType($key) : null); - - $null = ($value === null || (is_array($value) && empty($value))); + $type = is_object($model) ? $model->getColumnType($key) : null; + $null = $value === null || (is_array($value) && empty($value)); if (strtolower($operator) === 'not') { $data = $this->conditionKeysToString( @@ -2529,7 +2507,7 @@ class DboSource extends DataSource { } if ($bound) { - return String::insert($key . ' ' . trim($operator), $value); + return String::insert($key . ' ' . trim($operator), $value); } if (!preg_match($operatorMatch, trim($operator))) { @@ -2575,7 +2553,7 @@ class DboSource extends DataSource { * @access private */ function __quoteFields($conditions) { - $start = $end = null; + $start = $end = null; $original = $conditions; if (!empty($this->startQuote)) { @@ -2617,7 +2595,7 @@ class DboSource extends DataSource { public function limit($limit, $offset = null) { if ($limit) { $rt = ''; - if (!strpos(strtolower($limit), 'limit') || strpos(strtolower($limit), 'limit') === 0) { + if (!strpos(strtolower($limit), 'limit')) { $rt = ' LIMIT'; } @@ -2654,7 +2632,7 @@ class DboSource extends DataSource { $dir = $direction; } - if (is_string($key) && strpos($key, ',') && !preg_match('/\(.+\,.+\)/', $key)) { + if (is_string($key) && strpos($key, ',') !== false && !preg_match('/\(.+\,.+\)/', $key)) { $key = array_map('trim', explode(',', $key)); } if (is_array($key)) { @@ -2687,7 +2665,7 @@ class DboSource extends DataSource { if (strpos($key, '.')) { $key = preg_replace_callback('/([a-zA-Z0-9_]{1,})\\.([a-zA-Z0-9_]{1,})/', array(&$this, '__quoteMatchedField'), $key); } - if (!preg_match('/\s/', $key) && !strpos($key, '.')) { + if (!preg_match('/\s/', $key) && strpos($key, '.') === false) { $key = $this->name($key); } $key .= ' ' . trim($dir); @@ -2883,7 +2861,7 @@ class DboSource extends DataSource { if (is_string($col)) { $col = array('type' => $col); } - if (isset($col['key']) && $col['key'] == 'primary') { + if (isset($col['key']) && $col['key'] === 'primary') { $primary = $name; } if ($name !== 'indexes' && $name !== 'tableParameters') { @@ -2892,9 +2870,9 @@ class DboSource extends DataSource { $col['type'] = 'string'; } $cols[] = $this->buildColumn($col); - } elseif ($name == 'indexes') { + } elseif ($name === 'indexes') { $indexes = array_merge($indexes, $this->buildIndex($col, $table)); - } elseif ($name == 'tableParameters') { + } elseif ($name === 'tableParameters') { $tableParameters = array_merge($tableParameters, $this->buildTableParameters($col, $table)); } } @@ -2962,29 +2940,29 @@ class DboSource extends DataSource { $real = $this->columns[$type]; $out = $this->name($name) . ' ' . $real['name']; - if (isset($real['limit']) || isset($real['length']) || isset($column['limit']) || isset($column['length'])) { - if (isset($column['length'])) { - $length = $column['length']; - } elseif (isset($column['limit'])) { - $length = $column['limit']; - } elseif (isset($real['length'])) { - $length = $real['length']; - } else { - $length = $real['limit']; - } + if (isset($column['length'])) { + $length = $column['length']; + } elseif (isset($column['limit'])) { + $length = $column['limit']; + } elseif (isset($real['length'])) { + $length = $real['length']; + } else { + $length = $real['limit']; + } + if (isset($length)) { $out .= '(' . $length . ')'; } - if (($column['type'] == 'integer' || $column['type'] == 'float' ) && isset($column['default']) && $column['default'] === '') { + if (($column['type'] === 'integer' || $column['type'] === 'float' ) && isset($column['default']) && $column['default'] === '') { $column['default'] = null; } $out = $this->_buildFieldParameters($out, $column, 'beforeDefault'); - if (isset($column['key']) && $column['key'] == 'primary' && $type == 'integer') { + if (isset($column['key']) && $column['key'] === 'primary' && $type === 'integer') { $out .= ' ' . $this->columns['primary_key']['name']; - } elseif (isset($column['key']) && $column['key'] == 'primary') { + } elseif (isset($column['key']) && $column['key'] === 'primary') { $out .= ' NOT NULL'; - } elseif (isset($column['default']) && isset($column['null']) && $column['null'] == false) { + } elseif (isset($column['default']) && isset($column['null']) && $column['null'] === false) { $out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL'; } elseif (isset($column['default'])) { $out .= ' DEFAULT ' . $this->value($column['default'], $type); @@ -2992,14 +2970,13 @@ class DboSource extends DataSource { $out .= ' DEFAULT NULL'; } elseif ($type === 'timestamp' && !empty($column['null'])) { $out .= ' NULL'; - } elseif (isset($column['null']) && $column['null'] == false) { + } elseif (isset($column['null']) && $column['null'] === false) { $out .= ' NOT NULL'; } - if ($type == 'timestamp' && isset($column['default']) && strtolower($column['default']) == 'current_timestamp') { + if ($type === 'timestamp' && isset($column['default']) && strtolower($column['default']) === 'current_timestamp') { $out = str_replace(array("'CURRENT_TIMESTAMP'", "'current_timestamp'"), 'CURRENT_TIMESTAMP', $out); } - $out = $this->_buildFieldParameters($out, $column, 'afterDefault'); - return $out; + return $this->_buildFieldParameters($out, $column, 'afterDefault'); } /** @@ -3037,7 +3014,7 @@ class DboSource extends DataSource { $join = array(); foreach ($indexes as $name => $value) { $out = ''; - if ($name == 'PRIMARY') { + if ($name === 'PRIMARY') { $out .= 'PRIMARY '; $name = null; } else { @@ -3104,7 +3081,7 @@ class DboSource extends DataSource { */ public function introspectType($value) { if (!is_array($value)) { - if ($value === true || $value === false) { + if (is_bool($value)) { return 'boolean'; } if (is_float($value) && floatval($value) === $value) { From 728d9b2a26f20a6afc34fe46f6d18d601a02cb53 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 25 Feb 2011 13:05:08 -0300 Subject: [PATCH 423/668] Removed the unused var. --- cake/libs/model/datasources/dbo_source.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index a3ece4a69..7128a1c72 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -515,7 +515,7 @@ class DboSource extends DataSource { * @return integer Number of rows in resultset */ function lastNumRows() { - return $this->lastAffected($source); + return $this->lastAffected(); } /** From 73b3b65a53587035b87561d53b5b931ab98dd6b8 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 25 Feb 2011 13:26:14 -0300 Subject: [PATCH 424/668] Changed to filterResults be protected instead of private. --- cake/libs/model/datasources/dbo_source.php | 9 ++++----- cake/libs/model/model.php | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 7128a1c72..3fac20ea8 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1081,7 +1081,7 @@ class DboSource extends DataSource { return false; } - $filtered = $this->__filterResults($resultSet, $model); + $filtered = $this->_filterResults($resultSet, $model); if ($model->recursive > -1) { foreach ($_associations as $type) { @@ -1109,7 +1109,7 @@ class DboSource extends DataSource { } } } - $this->__filterResults($resultSet, $model, $filtered); + $this->_filterResults($resultSet, $model, $filtered); } if (!is_null($recursive)) { @@ -1125,9 +1125,8 @@ class DboSource extends DataSource { * @param object $model Instance of model to operate against * @param array $filtered List of classes already filtered, to be skipped * @return array Array of results that have been filtered through $model->afterFind - * @access private */ - function __filterResults(&$results, &$model, $filtered = array()) { + protected function _filterResults(&$results, &$model, $filtered = array()) { $filtering = array(); $count = count($results); @@ -1215,7 +1214,7 @@ class DboSource extends DataSource { } } } - $this->__filterResults($fetch, $model); + $this->_filterResults($fetch, $model); return $this->__mergeHasMany($resultSet, $fetch, $association, $model, $linkModel, $recursive); } elseif ($type === 'hasAndBelongsToMany') { $ins = $fetch = array(); diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index 3ef6c7a2b..e5e0e4819 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -2175,7 +2175,7 @@ class Model extends Object { $this->resetAssociations(); if ($query['callbacks'] === true || $query['callbacks'] === 'after') { - $results = $this->__filterResults($results); + $results = $this->_filterResults($results); } $this->findQueryType = null; @@ -2409,7 +2409,7 @@ class Model extends Object { * @param boolean $primary If this is the primary model results (results from model where the find operation was performed) * @return array Set of filtered results */ - private function __filterResults($results, $primary = true) { + protected function _filterResults($results, $primary = true) { $return = $this->Behaviors->trigger( 'afterFind', array(&$this, $results, $primary), From fea2b5798ca4b8aeaf7958f74b2694518e4fe226 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 25 Feb 2011 17:22:15 -0300 Subject: [PATCH 425/668] Minor optimizations in DboMysql. --- cake/libs/model/datasources/dbo/dbo_mysql.php | 34 +++++++++---------- cake/libs/model/datasources/dbo_source.php | 8 ++--- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 055964dc4..0ac24e123 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -209,21 +209,19 @@ class DboMysql extends DboSource { $this->map = array(); $numFields = $results->columnCount(); $index = 0; - $j = 0; - while ($j < $numFields) { - $column = $results->getColumnMeta($j); - if (!empty($column['native_type'])) { - $type = $column['native_type']; - } else { + while ($numFields-- > 0) { + $column = $results->getColumnMeta($index); + if (empty($column['native_type'])) { $type = ($column['len'] == 1) ? 'boolean' : 'string'; + } else { + $type = $column['native_type']; } if (!empty($column['table']) && strpos($column['name'], $this->virtualFieldSeparator) === false) { $this->map[$index++] = array($column['table'], $column['name'], $type); } else { $this->map[$index++] = array(0, $column['name'], $type); } - $j++; } } @@ -238,7 +236,7 @@ class DboMysql extends DboSource { foreach ($this->map as $col => $meta) { list($table, $column, $type) = $meta; $resultRow[$table][$column] = $row[$col]; - if ($type == 'boolean' && !is_null($row[$col])) { + if ($type === 'boolean' && !is_null($row[$col])) { $resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]); } } @@ -304,7 +302,7 @@ class DboMysql extends DboSource { foreach ($cols as $column) { $fields[$column->Field] = array( 'type' => $this->column($column->Type), - 'null' => ($column->Null == 'YES' ? true : false), + 'null' => ($column->Null === 'YES' ? true : false), 'default' => $column->Default, 'length' => $this->length($column->Type), ); @@ -365,7 +363,7 @@ class DboMysql extends DboSource { return false; } - if (!$this->execute($this->renderStatement('update', compact('table', 'alias', 'joins', 'fields', 'conditions')))) { + if ($this->execute($this->renderStatement('update', compact('table', 'alias', 'joins', 'fields', 'conditions'))) === false) { $model->onError(); return false; } @@ -409,7 +407,7 @@ class DboMysql extends DboSource { * @param string $enc Database encoding */ function setEncoding($enc) { - return $this->_execute('SET NAMES ' . $enc) != false; + return $this->_execute('SET NAMES ' . $enc) !== false; } /** @@ -499,7 +497,7 @@ class DboMysql extends DboSource { } $colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes)); $colList = array_merge($colList, $this->_alterTableParameters($curTable, $tableParameters)); - $out .= "\t" . join(",\n\t", $colList) . ";\n\n"; + $out .= "\t" . implode(",\n\t", $colList) . ";\n\n"; } } return $out; @@ -516,7 +514,7 @@ class DboMysql extends DboSource { function dropSchema(CakeSchema $schema, $table = null) { $out = ''; foreach ($schema->tables as $curTable => $columns) { - if (!$table || $table == $curTable) { + if (!$table || $table === $curTable) { $out .= 'DROP TABLE IF EXISTS ' . $this->fullTableName($curTable) . ";\n"; } } @@ -583,7 +581,7 @@ class DboMysql extends DboSource { /** * Returns an detailed array of sources (tables) in the database. * - * @param string $name Table name to get parameters + * @param string $name Table name to get parameters * @return array Array of tablenames in the database */ function listDetailedSources($name = null) { @@ -628,7 +626,7 @@ class DboMysql extends DboSource { if (is_array($real)) { $col = $real['name']; if (isset($real['limit'])) { - $col .= '('.$real['limit'].')'; + $col .= '(' . $real['limit'] . ')'; } return $col; } @@ -642,19 +640,19 @@ class DboMysql extends DboSource { if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) { return $col; } - if (($col == 'tinyint' && $limit == 1) || $col == 'boolean') { + if (($col === 'tinyint' && $limit == 1) || $col === 'boolean') { return 'boolean'; } if (strpos($col, 'int') !== false) { return 'integer'; } - if (strpos($col, 'char') !== false || $col == 'tinytext') { + if (strpos($col, 'char') !== false || $col === 'tinytext') { return 'string'; } if (strpos($col, 'text') !== false) { return 'text'; } - if (strpos($col, 'blob') !== false || $col == 'binary') { + if (strpos($col, 'blob') !== false || $col === 'binary') { return 'binary'; } if (strpos($col, 'float') !== false || strpos($col, 'double') !== false || strpos($col, 'decimal') !== false) { diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 3fac20ea8..7fd298c8d 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -2744,7 +2744,7 @@ class DboSource extends DataSource { if (strpos($col, '(') !== false) { list($col, $limit) = explode('(', $col); } - if ($limit != null) { + if ($limit !== null) { return intval($limit); } return null; @@ -2762,10 +2762,10 @@ class DboSource extends DataSource { $isFloat = in_array($type, array('dec', 'decimal', 'float', 'numeric', 'double')); if ($isFloat && $offset) { - return $length.','.$offset; + return $length . ',' . $offset; } - if (($real[0] == $type) && (count($real) == 1)) { + if (($real[0] == $type) && (count($real) === 1)) { return null; } @@ -2777,7 +2777,7 @@ class DboSource extends DataSource { } elseif (in_array($type, array('enum', 'set'))) { $length = 0; foreach ($typeArr as $key => $enumValue) { - if ($key == 0) { + if ($key === 0) { continue; } $tmpLength = strlen($enumValue); From d095f5fe8dbbc910aa35168bf57f931f4b76982e Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 25 Feb 2011 19:06:45 -0300 Subject: [PATCH 426/668] Optimizations in filterResults. --- cake/libs/model/datasources/dbo_source.php | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 7fd298c8d..c0f3c68b8 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1126,33 +1126,30 @@ class DboSource extends DataSource { * @param array $filtered List of classes already filtered, to be skipped * @return array Array of results that have been filtered through $model->afterFind */ - protected function _filterResults(&$results, &$model, $filtered = array()) { + protected function _filterResults(&$results, Model $model, $filtered = array()) { $filtering = array(); - $count = count($results); + $_filtered = array_flip($filtered); - for ($i = 0; $i < $count; $i++) { - if (is_array($results[$i])) { - $classNames = array_keys($results[$i]); - $count2 = count($classNames); - - for ($j = 0; $j < $count2; $j++) { - $className = $classNames[$j]; - if ($model->alias != $className && !in_array($className, $filtered)) { - if (!in_array($className, $filtering)) { - $filtering[] = $className; - } + foreach ($results as &$result) { + if (is_array($result)) { + if (!isset($keys)) { + $keys = array_keys($result); + } + foreach ($keys as $className) { + if ($model->alias !== $className && !isset($_filtered[$className])) { + $filtering[] = $className; if (isset($model->{$className}) && is_object($model->{$className})) { - $data = $model->{$className}->afterFind(array(array($className => $results[$i][$className])), false); + $data = $model->{$className}->afterFind(array(array($className => $result[$className])), false); } if (isset($data[0][$className])) { - $results[$i][$className] = $data[0][$className]; + $result[$className] = $data[0][$className]; } } } } } - return $filtering; + return array_unique($filtering); } /** From 8c7b0f48d871eeb542635c16f8d7353d54d48639 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 25 Feb 2011 19:55:34 -0300 Subject: [PATCH 427/668] Checking if has item before fetch virtual fields, avoiding call a function with result (can be large). It save a good time. --- cake/libs/model/datasources/dbo_source.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index c0f3c68b8..0665412bc 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -625,7 +625,7 @@ class DboSource extends DataSource { if ($this->hasResult()) { $this->resultSet($this->_result); $resultRow = $this->fetchResult(); - if (!empty($resultRow)) { + if (isset($resultRow[0])) { $this->fetchVirtualField($resultRow); } return $resultRow; @@ -666,11 +666,13 @@ class DboSource extends DataSource { if ($this->hasResult()) { $first = $this->fetchRow(); - if ($first != null) { + if ($first !== null) { $out[] = $first; } while ($item = $this->fetchResult()) { - $this->fetchVirtualField($item); + if (isset($item[0])) { + $this->fetchVirtualField($item); + } $out[] = $item; } } From b80955c9fe1f03db93009cd920bf21c6d7285d77 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 25 Feb 2011 18:50:50 -0500 Subject: [PATCH 428/668] Adding newlines to the builtin email template. Fixes issues with long lines. Refs #857 --- cake/libs/view/elements/email/html/default.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/view/elements/email/html/default.ctp b/cake/libs/view/elements/email/html/default.ctp index 70e28b22e..61fb69bb0 100644 --- a/cake/libs/view/elements/email/html/default.ctp +++ b/cake/libs/view/elements/email/html/default.ctp @@ -21,6 +21,6 @@ $content = explode("\n", $content); foreach ($content as $line): - echo '

    ' . $line . '

    '; + echo '

    ' . $line . "

    \n"; endforeach; ?> \ No newline at end of file From 7efe15393d08b060769aafaec66f8fd98bb3fbf4 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 25 Feb 2011 20:18:12 -0300 Subject: [PATCH 429/668] Fixed error caused by code optimizations. --- cake/libs/model/datasources/dbo_source.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 0665412bc..20a205da9 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -666,7 +666,7 @@ class DboSource extends DataSource { if ($this->hasResult()) { $first = $this->fetchRow(); - if ($first !== null) { + if ($first != null) { $out[] = $first; } while ($item = $this->fetchResult()) { @@ -2944,7 +2944,7 @@ class DboSource extends DataSource { $length = $column['limit']; } elseif (isset($real['length'])) { $length = $real['length']; - } else { + } elseif (isset($real['limit'])) { $length = $real['limit']; } if (isset($length)) { From 4828e16762b0f3145252db5cbdd6f26362dc6b97 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 25 Feb 2011 21:26:35 -0300 Subject: [PATCH 430/668] Updating tests to use new find notation. --- .../cases/libs/model/behaviors/tree.test.php | 74 +++++++++---------- .../cases/libs/model/model_read.test.php | 12 +-- .../cases/libs/model/model_write.test.php | 26 +++---- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/cake/tests/cases/libs/model/behaviors/tree.test.php b/cake/tests/cases/libs/model/behaviors/tree.test.php index 96e4e174d..8e8323df6 100644 --- a/cake/tests/cases/libs/model/behaviors/tree.test.php +++ b/cake/tests/cases/libs/model/behaviors/tree.test.php @@ -288,7 +288,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree->initialize(2, 2); $this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null))); - $result = $this->Tree->find(null, array('name', $parentField), $modelClass . '.' . $leftField . ' desc'); + $result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc')); $expected = array($modelClass => array('name' => 'testAddOrphan', $parentField => null)); $this->assertEqual($result, $expected); @@ -307,7 +307,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data= $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $initialCount = $this->Tree->find('count'); $this->Tree->create(); @@ -367,7 +367,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree->initialize(2, 2); $this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null)); - $result = $this->Tree->find(null, array('name', $parentField), $modelClass . '.' . $leftField . ' desc'); + $result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc')); $expected = array($modelClass => array('name' => 'testAddNotIndexed', $parentField => null)); $this->assertEqual($result, $expected); @@ -387,10 +387,10 @@ class NumberTreeTest extends CakeTestCase { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find(array($modelClass . '.name' => '1. Root')); + $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parent_id = $parent[$modelClass]['id']; - $data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $this->Tree->id= $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parent_id); $direct = $this->Tree->children($parent_id, true, array('id', 'name', $parentField, $leftField, $rightField)); @@ -414,10 +414,10 @@ class NumberTreeTest extends CakeTestCase { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find(array($modelClass . '.name' => '1. Root')); + $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parent_id = $parent[$modelClass]['id']; - $data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->whitelist = array($parentField, 'name', 'description'); $this->Tree->saveField($parentField, $parent_id); @@ -461,10 +461,10 @@ class NumberTreeTest extends CakeTestCase { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find(array($modelClass . '.name' => '1.1')); + $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1'))); $parent_id = $parent[$modelClass]['id']; - $data= $this->Tree->find(array($modelClass . '.name' => '1.2'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parent_id); @@ -490,10 +490,10 @@ class NumberTreeTest extends CakeTestCase { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find(array($modelClass . '.name' => '1.2')); + $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2'))); $parent_id = $parent[$modelClass]['id']; - $data= $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id')); + $data= $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parent_id); @@ -519,10 +519,10 @@ class NumberTreeTest extends CakeTestCase { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find(array($modelClass . '.name' => '1. Root')); + $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parent_id = $parent[$modelClass]['id']; - $data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $expects = $this->Tree->find('all'); $before = $this->Tree->read(null, $data[$modelClass]['id']); @@ -606,7 +606,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find(array($modelClass . '.name' => '1.2'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2'))); $this->Tree->moveUp($data[$modelClass]['id']); $parent = $this->Tree->findByName('1. Root', array('id')); @@ -628,7 +628,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find(array($modelClass . '.name' => '1.1')); + $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1'))); $this->Tree->moveUp($data[$modelClass]['id']); @@ -651,7 +651,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); - $data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $this->Tree->moveUp($data[$modelClass]['id'], 2); $parent = $this->Tree->findByName('1. Root', array('id')); @@ -682,7 +682,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); - $data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $this->Tree->moveUp($data[$modelClass]['id'], true); $parent = $this->Tree->findByName('1. Root', array('id')); @@ -713,7 +713,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $this->Tree->moveDown($data[$modelClass]['id']); $parent = $this->Tree->findByName('1. Root', array('id')); @@ -735,7 +735,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find(array($modelClass . '.name' => '1.2')); + $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2'))); $this->Tree->moveDown($data[$modelClass]['id']); $parent = $this->Tree->findByName('1. Root', array('id')); @@ -757,7 +757,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); - $data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $this->Tree->moveDown($data[$modelClass]['id'], true); $parent = $this->Tree->findByName('1. Root', array('id')); @@ -788,7 +788,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); - $data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $this->Tree->moveDown($data[$modelClass]['id'], 2); $parent = $this->Tree->findByName('1. Root', array('id')); @@ -819,7 +819,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); - $data = $this->Tree->find(array($modelClass . '.name' => '1.5'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField('name', 'renamed'); $parent = $this->Tree->findByName('1. Root', array('id')); @@ -849,7 +849,7 @@ class NumberTreeTest extends CakeTestCase { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(1, 1); - $data = $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->save(array($parentField => null)); @@ -1077,7 +1077,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find(array($modelClass . '.name' => '1. Root')); + $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $this->Tree->id= $data[$modelClass]['id']; $direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField)); @@ -1108,7 +1108,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find(array($modelClass . '.name' => '1. Root')); + $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $this->Tree->id = $data[$modelClass]['id']; $direct = $this->Tree->childCount(null, true); @@ -1129,7 +1129,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find(array($modelClass . '.name' => '1.2.2')); + $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2'))); $this->Tree->id= $data[$modelClass]['id']; $result = $this->Tree->getParentNode(null, array('name')); @@ -1148,7 +1148,7 @@ class NumberTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find(array($modelClass . '.name' => '1.2.2')); + $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2'))); $this->Tree->id= $data[$modelClass]['id']; $result = $this->Tree->getPath(null, array('name')); @@ -1171,7 +1171,7 @@ class NumberTreeTest extends CakeTestCase { array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); $this->Tree->initialize(2, 2); - $data = $this->Tree->find(array($modelClass . '.name' => '1. Root')); + $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $this->Tree->id= $data[$modelClass]['id']; $direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField)); @@ -1203,13 +1203,13 @@ class NumberTreeTest extends CakeTestCase { $this->Tree->initialize(3, 3); $nodes = $this->Tree->find('list', array('order' => $leftField)); - $data = $this->Tree->find(array($modelClass . '.name' => '1.1'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); $this->Tree->moveDown($data[$modelClass]['id']); - $data = $this->Tree->find(array($modelClass . '.name' => '1.2.1'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2.1'))); $this->Tree->moveDown($data[$modelClass]['id']); - $data = $this->Tree->find(array($modelClass . '.name' => '1.3.2.2'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.3.2.2'))); $this->Tree->moveDown($data[$modelClass]['id']); $unsortedNodes = $this->Tree->find('list', array('order' => $leftField)); @@ -1676,10 +1676,10 @@ class UuidTreeTest extends CakeTestCase { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find(array($modelClass . '.name' => '1. Root')); + $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parent_id = $parent[$modelClass]['id']; - $data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $this->Tree->id= $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parent_id); $direct = $this->Tree->children($parent_id, true, array('name', $leftField, $rightField)); @@ -1702,10 +1702,10 @@ class UuidTreeTest extends CakeTestCase { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find(array($modelClass . '.name' => '1. Root')); + $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $parent_id = $parent[$modelClass]['id']; - $data = $this->Tree->find(array($modelClass . '.name' => '1.1.1'), array('id')); + $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->whitelist = array($parentField, 'name', 'description'); $this->Tree->saveField($parentField, $parent_id); @@ -1794,7 +1794,7 @@ class UuidTreeTest extends CakeTestCase { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find(array($modelClass . '.name' => '1. Root')); + $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $this->Tree->id = $data[$modelClass]['id']; $direct = $this->Tree->children(null, true, array('name', $leftField, $rightField)); @@ -1825,7 +1825,7 @@ class UuidTreeTest extends CakeTestCase { $this->Tree->bindModel(array('belongsTo' => array('Dummy' => array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); - $data = $this->Tree->find(array($modelClass . '.name' => '1. Root')); + $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); $this->Tree->id = $data[$modelClass]['id']; $direct = $this->Tree->children(null, true, array('name', $leftField, $rightField)); diff --git a/cake/tests/cases/libs/model/model_read.test.php b/cake/tests/cases/libs/model/model_read.test.php index 1a87f0ac4..b74ee5632 100755 --- a/cake/tests/cases/libs/model/model_read.test.php +++ b/cake/tests/cases/libs/model/model_read.test.php @@ -5087,7 +5087,7 @@ class ModelReadTest extends BaseModelTest { $this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio', 'Syfile', 'Image'); $Portfolio = new Portfolio(); - $result = $Portfolio->find(array('id' => 2), null, null, 3); + $result = $Portfolio->find('first', array('conditions' => array('id' => 2), 'recursive' => 3)); $expected = array( 'Portfolio' => array( 'id' => 2, @@ -5725,7 +5725,7 @@ class ModelReadTest extends BaseModelTest { $fullDebug = $this->db->fullDebug; $this->db->fullDebug = true; $TestModel->recursive = 6; - $result = $TestModel->find(array('CategoryThread.id' => 7)); + $result = $TestModel->find('first', array('conditions' => array('CategoryThread.id' => 7))); $expected = array( 'CategoryThread' => array( @@ -6007,12 +6007,12 @@ class ModelReadTest extends BaseModelTest { function testConditionalNumerics() { $this->loadFixtures('NumericArticle'); $NumericArticle = new NumericArticle(); - $data = array('title' => '12345abcde'); - $result = $NumericArticle->find($data); + $data = array('conditions' => array('title' => '12345abcde')); + $result = $NumericArticle->find('first', $data); $this->assertTrue(!empty($result)); - $data = array('title' => '12345'); - $result = $NumericArticle->find($data); + $data = array('conditions' => array('title' => '12345')); + $result = $NumericArticle->find('first', $data); $this->assertTrue(empty($result)); } diff --git a/cake/tests/cases/libs/model/model_write.test.php b/cake/tests/cases/libs/model/model_write.test.php index c9aae1fb3..5e301cbc8 100644 --- a/cake/tests/cases/libs/model/model_write.test.php +++ b/cake/tests/cases/libs/model/model_write.test.php @@ -105,7 +105,7 @@ class ModelWriteTest extends BaseModelTest { $result = $Article->save($data); $this->assertFalse(empty($result)); - $testResult = $Article->find(array('Article.title' => 'Test Title')); + $testResult = $Article->find('first', array('conditions' => array('Article.title' => 'Test Title'))); $this->assertEqual($testResult['Article']['title'], $data['Article']['title']); $this->assertEqual($testResult['Article']['created'], '2008-01-01 00:00:00'); @@ -1019,17 +1019,17 @@ class ModelWriteTest extends BaseModelTest { $Article = new Article(); $result = $Article->save(Xml::build('
    ')); $this->assertFalse(empty($result)); - $results = $Article->find(array('Article.title' => 'test xml')); + $results = $Article->find('first', array('conditions' => array('Article.title' => 'test xml'))); $this->assertFalse(empty($results)); $result = $Article->save(Xml::build('
    testing6
    ')); $this->assertFalse(empty($result)); - $results = $Article->find(array('Article.title' => 'testing')); + $results = $Article->find('first', array('conditions' => array('Article.title' => 'testing'))); $this->assertFalse(empty($results)); $result = $Article->save(Xml::build('
    testing with DOMDocument7
    ', array('return' => 'domdocument'))); $this->assertFalse(empty($result)); - $results = $Article->find(array('Article.title' => 'testing with DOMDocument')); + $results = $Article->find('first', array('conditions' => array('Article.title' => 'testing with DOMDocument'))); $this->assertFalse(empty($results)); } @@ -1111,7 +1111,7 @@ class ModelWriteTest extends BaseModelTest { $this->assertFalse(empty($result)); $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment'))); - $result = $TestModel->find(array('Article.id' => 2), array('id', 'user_id', 'title', 'body')); + $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); $expected = array( 'Article' => array( 'id' => '2', @@ -1145,7 +1145,7 @@ class ModelWriteTest extends BaseModelTest { 'belongsTo' => array('User'), 'hasMany' => array('Comment') )); - $result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); + $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); $expected = array( 'Article' => array( 'id' => '2', @@ -1180,7 +1180,7 @@ class ModelWriteTest extends BaseModelTest { 'belongsTo' => array('User'), 'hasMany' => array('Comment') )); - $result = $TestModel->find(array('Article.id' => 2), array('id', 'user_id', 'title', 'body')); + $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); $expected = array( 'Article' => array( 'id' => '2', @@ -1227,7 +1227,7 @@ class ModelWriteTest extends BaseModelTest { 'belongsTo' => array('User'), 'hasMany' => array('Comment') )); - $result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); + $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); $expected = array( 'Article' => array( 'id' => '2', @@ -1250,7 +1250,7 @@ class ModelWriteTest extends BaseModelTest { 'belongsTo' => array('User'), 'hasMany' => array('Comment') )); - $result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); + $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); $expected = array( 'Article' => array( 'id' => '2', @@ -1290,7 +1290,7 @@ class ModelWriteTest extends BaseModelTest { 'belongsTo' => array('User'), 'hasMany' => array('Comment') )); - $result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); + $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); $expected = array( 'Article' => array( 'id' => '2', @@ -1330,7 +1330,7 @@ class ModelWriteTest extends BaseModelTest { 'belongsTo' => array('User'), 'hasMany' => array('Comment') )); - $result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); + $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); $expected = array( 'Article' => array( 'id' => '2', @@ -1372,7 +1372,7 @@ class ModelWriteTest extends BaseModelTest { 'belongsTo' => array('User'), 'hasMany' => array('Comment') )); - $result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); + $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); $expected = array( 'Article' => array( 'id' => '2', @@ -1414,7 +1414,7 @@ class ModelWriteTest extends BaseModelTest { 'belongsTo' => array('User'), 'hasMany' => array('Comment') )); - $result = $TestModel->find(array('Article.id'=>2), array('id', 'user_id', 'title', 'body')); + $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); $expected = array( 'Article' => array( 'id' => '2', From 7fc3eead9ca71a9ed2c26594988eea1119264c13 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 25 Feb 2011 22:14:52 -0300 Subject: [PATCH 431/668] Fixed error in update statement. --- cake/libs/model/datasources/dbo/dbo_mysql.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 0ac24e123..29c98c4a0 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -363,7 +363,7 @@ class DboMysql extends DboSource { return false; } - if ($this->execute($this->renderStatement('update', compact('table', 'alias', 'joins', 'fields', 'conditions'))) === false) { + if (!$this->execute($this->renderStatement('update', compact('table', 'alias', 'joins', 'fields', 'conditions')))) { $model->onError(); return false; } From 164c2a59f3534b5428e31fd7f1978eb6a9cd36e4 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Fri, 25 Feb 2011 23:28:03 -0300 Subject: [PATCH 432/668] Optimizating scrubQueryData. --- cake/libs/model/datasources/dbo_source.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 20a205da9..a161e226c 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -2143,12 +2143,11 @@ class DboSource extends DataSource { * @return array */ public function __scrubQueryData($data) { - foreach (array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group') as $key) { - if (empty($data[$key])) { - $data[$key] = array(); - } + static $base = null; + if ($base === null) { + $base = array_fill_keys(array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'), array()); } - return $data; + return (array)$data + $base; } /** From ef6632a5edd30d16414dedd82ed830016105fd2f Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 26 Feb 2011 04:17:42 -0300 Subject: [PATCH 433/668] Optimizations in generateAssociationQuery and fullTableName. --- cake/libs/model/datasources/dbo_source.php | 57 ++++++++++------------ 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index a161e226c..a7a7bb217 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -963,7 +963,7 @@ class DboSource extends DataSource { $table = strval($model); } if ($quote) { - return $this->name($table); + return $this->startQuote . $table . $this->endQuote; } return $table; } @@ -1066,7 +1066,7 @@ class DboSource extends DataSource { $external = isset($assocData['external']); $linkModel->getDataSource(); - if ($model->useDbConfig == $linkModel->useDbConfig) { + if ($model->useDbConfig === $linkModel->useDbConfig) { if (true === $this->generateAssociationQuery($model, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null)) { $linkedModels[$type . '/' . $assoc] = true; } @@ -1074,7 +1074,7 @@ class DboSource extends DataSource { } } - $query = trim($this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null)); + $query = trim($this->generateAssociationQuery($model, null, null, null, null, $queryData, false, $null)); $resultSet = $this->fetchAll($query, $model->cacheQueries); @@ -1462,20 +1462,18 @@ class DboSource extends DataSource { * @param array $resultSet * @return mixed */ - public function generateAssociationQuery($model, &$linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) { + public function generateAssociationQuery($model, $linkModel, $type, $association = null, $assocData = array(), &$queryData, $external = false, &$resultSet) { $queryData = $this->__scrubQueryData($queryData); $assocData = $this->__scrubQueryData($assocData); + $modelAlias = $model->alias; if (empty($queryData['fields'])) { - $queryData['fields'] = $this->fields($model, $model->alias); + $queryData['fields'] = $this->fields($model, $modelAlias); } elseif (!empty($model->hasMany) && $model->recursive > -1) { - $assocFields = $this->fields($model, $model->alias, array("{$model->alias}.{$model->primaryKey}")); - $passedFields = $this->fields($model, $model->alias, $queryData['fields']); + $assocFields = $this->fields($model, $modelAlias, array("{$modelAlias}.{$model->primaryKey}")); + $passedFields = $this->fields($model, $modelAlias, $queryData['fields']); if (count($passedFields) === 1) { - $match = strpos($passedFields[0], $assocFields[0]); - $match1 = (bool)preg_match('/^[a-z]+\(/i', $passedFields[0]); - - if ($match === false && $match1 === false) { + if (strpos($passedFields[0], $assocFields[0]) === false && !preg_match('/^[a-z]+\(/i', $passedFields[0])) { $queryData['fields'] = array_merge($passedFields, $assocFields); } else { $queryData['fields'] = $passedFields; @@ -1486,12 +1484,12 @@ class DboSource extends DataSource { unset($assocFields, $passedFields); } - if ($linkModel == null) { + if ($linkModel === null) { return $this->buildStatement( array( 'fields' => array_unique($queryData['fields']), 'table' => $this->fullTableName($model), - 'alias' => $model->alias, + 'alias' => $modelAlias, 'limit' => $queryData['limit'], 'offset' => $queryData['offset'], 'joins' => $queryData['joins'], @@ -1506,12 +1504,11 @@ class DboSource extends DataSource { return $assocData['finderQuery']; } - $alias = $association; - $self = ($model->name == $linkModel->name); + $self = $model->name === $linkModel->name; $fields = array(); - if ((!$external && in_array($type, array('hasOne', 'belongsTo')) && $this->__bypass === false) || $external) { - $fields = $this->fields($linkModel, $alias, $assocData['fields']); + if ($external || (in_array($type, array('hasOne', 'belongsTo')) && $this->__bypass === false)) { + $fields = $this->fields($linkModel, $association, $assocData['fields']); } if (empty($assocData['offset']) && !empty($assocData['page'])) { $assocData['offset'] = ($assocData['page'] - 1) * $assocData['limit']; @@ -1523,12 +1520,12 @@ class DboSource extends DataSource { case 'belongsTo': $conditions = $this->__mergeConditions( $assocData['conditions'], - $this->getConstraint($type, $model, $linkModel, $alias, array_merge($assocData, compact('external', 'self'))) + $this->getConstraint($type, $model, $linkModel, $association, array_merge($assocData, compact('external', 'self'))) ); if (!$self && $external) { foreach ($conditions as $key => $condition) { - if (is_numeric($key) && strpos($condition, $model->alias . '.') !== false) { + if (is_numeric($key) && strpos($condition, $modelAlias . '.') !== false) { unset($conditions[$key]); } } @@ -1539,14 +1536,14 @@ class DboSource extends DataSource { 'conditions' => $conditions, 'table' => $this->fullTableName($linkModel), 'fields' => $fields, - 'alias' => $alias, + 'alias' => $association, 'group' => null )); - $query = array_merge(array('order' => $assocData['order'], 'limit' => $assocData['limit']), $query); + $query += array('order' => $assocData['order'], 'limit' => $assocData['limit']); } else { $join = array( 'table' => $this->fullTableName($linkModel), - 'alias' => $alias, + 'alias' => $association, 'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT', 'conditions' => trim($this->conditions($conditions, true, false, $model)) ); @@ -1562,15 +1559,15 @@ class DboSource extends DataSource { } break; case 'hasMany': - $assocData['fields'] = $this->fields($linkModel, $alias, $assocData['fields']); + $assocData['fields'] = $this->fields($linkModel, $association, $assocData['fields']); if (!empty($assocData['foreignKey'])) { - $assocData['fields'] = array_merge($assocData['fields'], $this->fields($linkModel, $alias, array("{$alias}.{$assocData['foreignKey']}"))); + $assocData['fields'] = array_merge($assocData['fields'], $this->fields($linkModel, $association, array("{$association}.{$assocData['foreignKey']}"))); } $query = array( - 'conditions' => $this->__mergeConditions($this->getConstraint('hasMany', $model, $linkModel, $alias, $assocData), $assocData['conditions']), + 'conditions' => $this->__mergeConditions($this->getConstraint('hasMany', $model, $linkModel, $association, $assocData), $assocData['conditions']), 'fields' => array_unique($assocData['fields']), 'table' => $this->fullTableName($linkModel), - 'alias' => $alias, + 'alias' => $association, 'order' => $assocData['order'], 'limit' => $assocData['limit'], 'group' => null @@ -1588,8 +1585,8 @@ class DboSource extends DataSource { $joinAlias = $joinTbl; if (is_array($joinFields) && !empty($joinFields)) { - $joinFields = $this->fields($model->{$with}, $model->{$with}->alias, $joinFields); $joinAssoc = $joinAlias = $model->{$with}->alias; + $joinFields = $this->fields($model->{$with}, $joinAlias, $joinFields); } else { $joinFields = array(); } @@ -1601,14 +1598,14 @@ class DboSource extends DataSource { 'conditions' => $assocData['conditions'], 'limit' => $assocData['limit'], 'table' => $this->fullTableName($linkModel), - 'alias' => $alias, - 'fields' => array_merge($this->fields($linkModel, $alias, $assocData['fields']), $joinFields), + 'alias' => $association, + 'fields' => array_merge($this->fields($linkModel, $association, $assocData['fields']), $joinFields), 'order' => $assocData['order'], 'group' => null, 'joins' => array(array( 'table' => $joinTbl, 'alias' => $joinAssoc, - 'conditions' => $this->getConstraint('hasAndBelongsToMany', $model, $linkModel, $joinAlias, $assocData, $alias) + 'conditions' => $this->getConstraint('hasAndBelongsToMany', $model, $linkModel, $joinAlias, $assocData, $association) )) ); break; From 34b4ff920486fac85f5222616c459704d95e0ef0 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 26 Feb 2011 04:31:13 -0300 Subject: [PATCH 434/668] More changes in read. --- cake/libs/model/datasources/dbo_source.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index a7a7bb217..264aef623 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1077,7 +1077,6 @@ class DboSource extends DataSource { $query = trim($this->generateAssociationQuery($model, null, null, null, null, $queryData, false, $null)); $resultSet = $this->fetchAll($query, $model->cacheQueries); - if ($resultSet === false) { $model->onError(); return false; @@ -1090,13 +1089,13 @@ class DboSource extends DataSource { foreach ($model->{$type} as $assoc => $assocData) { $linkModel = $model->{$assoc}; - if (empty($linkedModels[$type . '/' . $assoc])) { - if ($model->useDbConfig == $linkModel->useDbConfig) { + if (!isset($linkedModels[$type . '/' . $assoc])) { + if ($model->useDbConfig === $linkModel->useDbConfig) { $db = $this; } else { $db = ConnectionManager::getDataSource($linkModel->useDbConfig); } - } elseif ($model->recursive > 1 && ($type == 'belongsTo' || $type == 'hasOne')) { + } elseif ($model->recursive > 1 && ($type === 'belongsTo' || $type === 'hasOne')) { $db = $this; } @@ -1106,7 +1105,7 @@ class DboSource extends DataSource { unset($db); if ($type === 'hasMany') { - $filtered []= $assoc; + $filtered[] = $assoc; } } } From 63d700a9d6ae97d66955649f2cd9669cb2074506 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 26 Feb 2011 05:23:59 -0300 Subject: [PATCH 435/668] Refactored the filterResults again. Now this method not call the callback afterFind when model is Model. --- cake/libs/model/datasources/dbo_source.php | 45 +++++++++++++--------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 264aef623..38a172401 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1128,29 +1128,36 @@ class DboSource extends DataSource { * @return array Array of results that have been filtered through $model->afterFind */ protected function _filterResults(&$results, Model $model, $filtered = array()) { + static $haveCallback = array(); + + $current = current($results); + if (!is_array($current)) { + return array(); + } + $keys = array_diff(array_keys($current), $filtered, array($model->alias)); $filtering = array(); - $_filtered = array_flip($filtered); - - foreach ($results as &$result) { - if (is_array($result)) { - if (!isset($keys)) { - $keys = array_keys($result); - } - foreach ($keys as $className) { - if ($model->alias !== $className && !isset($_filtered[$className])) { - $filtering[] = $className; - - if (isset($model->{$className}) && is_object($model->{$className})) { - $data = $model->{$className}->afterFind(array(array($className => $result[$className])), false); - } - if (isset($data[0][$className])) { - $result[$className] = $data[0][$className]; - } - } + foreach ($keys as $className) { + if (!isset($model->{$className}) || !is_object($model->{$className})) { + continue; + } + $linkedModel = $model->{$className}; + $linkedClass = get_class($linkedModel); + if (!isset($haveCallback[$linkedClass])) { + $ref = new ReflectionClass($linkedModel); + $haveCallback[$linkedClass] = $ref->getMethod('afterFind')->class !== 'Model'; + } + if ($haveCallback[$linkedClass] !== true) { + continue; + } + $filtering[] = $className; + foreach ($results as &$result) { + $data = $linkedModel->afterFind(array(array($className => $result[$className])), false); + if (isset($data[0][$className])) { + $result[$className] = $data[0][$className]; } } } - return array_unique($filtering); + return $filtering; } /** From 731cc7bb0c4455bf83379f7ae71b058984899bee Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 26 Feb 2011 12:39:33 -0300 Subject: [PATCH 436/668] Reverted the change to quote the table name. --- cake/libs/model/datasources/dbo_source.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 38a172401..b1eb000f2 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -963,7 +963,7 @@ class DboSource extends DataSource { $table = strval($model); } if ($quote) { - return $this->startQuote . $table . $this->endQuote; + return $this->name($table); } return $table; } From cbe8d9ca76a0d671c156e974fa0f51bfea2c1996 Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 26 Feb 2011 13:45:06 -0300 Subject: [PATCH 437/668] Removed unused var. --- cake/libs/model/datasources/dbo_source.php | 1 - 1 file changed, 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index b1eb000f2..96397ac18 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1034,7 +1034,6 @@ class DboSource extends DataSource { $array = array(); $linkedModels = array(); $this->__bypass = false; - $this->__booleans = array(); if ($recursive === null && isset($queryData['recursive'])) { $recursive = $queryData['recursive']; From ef9dfe7f265b47f943b8bcfa373a545e010f5f6e Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 26 Feb 2011 14:03:17 -0300 Subject: [PATCH 438/668] Some optimizations in queryAssociation. --- cake/libs/model/datasources/dbo_source.php | 34 +++++++++------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 96397ac18..c391eed93 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1189,8 +1189,8 @@ class DboSource extends DataSource { if ($type === 'hasMany' && empty($assocData['limit']) && !empty($assocData['foreignKey'])) { $ins = $fetch = array(); - for ($i = 0; $i < $count; $i++) { - if ($in = $this->insertQueryData('{$__cakeID__$}', $resultSet[$i], $association, $assocData, $model, $linkModel, $stack)) { + foreach ($resultSet as &$result) { + if ($in = $this->insertQueryData('{$__cakeID__$}', $result, $association, $assocData, $model, $linkModel, $stack)) { $ins[] = $in; } } @@ -1222,8 +1222,8 @@ class DboSource extends DataSource { return $this->__mergeHasMany($resultSet, $fetch, $association, $model, $linkModel, $recursive); } elseif ($type === 'hasAndBelongsToMany') { $ins = $fetch = array(); - for ($i = 0; $i < $count; $i++) { - if ($in = $this->insertQueryData('{$__cakeID__$}', $resultSet[$i], $association, $assocData, $model, $linkModel, $stack)) { + foreach ($resultSet as &$result) { + if ($in = $this->insertQueryData('{$__cakeID__$}', $result, $association, $assocData, $model, $linkModel, $stack)) { $ins[] = $in; } } @@ -1252,22 +1252,16 @@ class DboSource extends DataSource { } } - for ($i = 0; $i < $count; $i++) { - $row =& $resultSet[$i]; - + foreach ($resultSet as &$row) { if ($type !== 'hasAndBelongsToMany') { - $q = $this->insertQueryData($query, $resultSet[$i], $association, $assocData, $model, $linkModel, $stack); + $q = $this->insertQueryData($query, $row, $association, $assocData, $model, $linkModel, $stack); if ($q !== false) { $fetch = $this->fetchAll($q, $model->cacheQueries); } else { $fetch = null; } } - $selfJoin = false; - - if ($linkModel->name === $model->name) { - $selfJoin = true; - } + $selfJoin = $linkModel->name === $model->name; if (!empty($fetch) && is_array($fetch)) { if ($recursive > 0) { @@ -1275,7 +1269,7 @@ class DboSource extends DataSource { foreach ($linkModel->{$type1} as $assoc1 => $assocData1) { $deepModel = $linkModel->{$assoc1}; - if (($type1 === 'belongsTo') || ($deepModel->alias === $model->alias && $type === 'belongsTo') || ($deepModel->alias != $model->alias)) { + if ($type1 === 'belongsTo' || ($deepModel->alias === $model->alias && $type === 'belongsTo') || ($deepModel->alias != $model->alias)) { $tmpStack = $stack; $tmpStack[] = $assoc1; if ($linkModel->useDbConfig == $deepModel->useDbConfig) { @@ -1288,7 +1282,7 @@ class DboSource extends DataSource { } } } - if ($type == 'hasAndBelongsToMany') { + if ($type === 'hasAndBelongsToMany') { $uniqueIds = $merge = array(); foreach ($fetch as $j => $data) { @@ -1302,17 +1296,17 @@ class DboSource extends DataSource { if (empty($merge) && !isset($row[$association])) { $row[$association] = $merge; } else { - $this->__mergeAssociation($resultSet[$i], $merge, $association, $type); + $this->__mergeAssociation($row, $merge, $association, $type); } } else { - $this->__mergeAssociation($resultSet[$i], $fetch, $association, $type, $selfJoin); + $this->__mergeAssociation($row, $fetch, $association, $type, $selfJoin); } - if (isset($resultSet[$i][$association])) { - $resultSet[$i][$association] = $linkModel->afterFind($resultSet[$i][$association], false); + if (isset($row[$association])) { + $row[$association] = $linkModel->afterFind($row[$association], false); } } else { $tempArray[0][$association] = false; - $this->__mergeAssociation($resultSet[$i], $tempArray, $association, $type, $selfJoin); + $this->__mergeAssociation($row, $tempArray, $association, $type, $selfJoin); } } } From f9b5d419cdc1bf182c2ce2afa884d74dfca9b21e Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 26 Feb 2011 14:06:50 -0300 Subject: [PATCH 439/668] Fixed wrong attribute name. --- cake/libs/model/datasources/dbo_source.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index c391eed93..7af467027 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -321,7 +321,7 @@ class DboSource extends DataSource { array(&$this, 'value'), $data, array_fill(0, count($data), $column) ); - } elseif (is_object($data) && isset($data->type, $data->type)) { + } elseif (is_object($data) && isset($data->type, $data->value)) { if ($data->type == 'identifier') { return $this->name($data->value); } elseif ($data->type == 'expression') { From 72245ebb0cee56052e2c8829dbe2a0ec5cf55fd2 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 23 Feb 2011 20:59:54 -0500 Subject: [PATCH 440/668] Making debug() not html escape in cli contexts. --- cake/basics.php | 2 +- cake/tests/cases/basics.test.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cake/basics.php b/cake/basics.php index 58ee67c41..ae14bb2cf 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -98,7 +98,7 @@ TEXT; if (php_sapi_name() == 'cli') { $template = $text; } - if ($showHtml === null) { + if ($showHtml === null && $template !== $text) { $showHtml = true; } $var = print_r($var, true); diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php index e3090938a..2c0282cb2 100644 --- a/cake/tests/cases/basics.test.php +++ b/cake/tests/cases/basics.test.php @@ -683,7 +683,7 @@ class BasicsTest extends CakeTestCase { $this->assertPattern($pattern, $result); ob_start(); - debug('
    this-is-a-test
    '); + debug('
    this-is-a-test
    ', true); $result = ob_get_clean(); $pattern = '/(.+?tests(\/|\\\)cases(\/|\\\)basics\.test\.php|'; $pattern .= preg_quote(substr(__FILE__, 1), '/') . ')'; @@ -761,7 +761,7 @@ class BasicsTest extends CakeTestCase { * @return void */ public function testStripslashesDeepSybase() { - $this->skipUnless(ini_get('magic_quotes_sybase') === '1', '%s magic_quotes_sybase is off'); + $this->skipUnless(ini_get('magic_quotes_sybase') === '1', 'magic_quotes_sybase is off'); $this->assertEqual(stripslashes_deep("tes\'t"), "tes\'t"); From a52756d550b1a9ad33ccb3b43353e849cbc5591b Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 26 Feb 2011 15:37:08 -0500 Subject: [PATCH 441/668] Fixing issue with empty delimeter notice error when installed at the webroot using url rewriting. --- cake/libs/cake_request.php | 2 +- cake/tests/cases/libs/cake_request.test.php | 25 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 53340bf7f..90d42826f 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -201,7 +201,7 @@ class CakeRequest implements ArrayAccess { $base = $this->base; - if (strpos($uri, $base) === 0) { + if (strlen($base) > 0 && strpos($uri, $base) === 0) { $uri = substr($uri, strlen($base)); } if (strpos($uri, '?') !== false) { diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index f4fa2916d..a28838a14 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -1272,6 +1272,31 @@ class CakeRequestTestCase extends CakeTestCase { 'webroot' => '/site/', ), ), + array( + 'Apache - w/rewrite, document root set to webroot, request root, no PATH_INFO/REQUEST_URI', + array( + 'App' => array( + 'base' => false, + 'baseUrl' => false, + 'dir' => 'app', + 'webroot' => 'webroot' + ), + 'SERVER' => array( + 'SERVER_NAME' => 'localhost', + 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', + 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', + 'SCRIPT_NAME' => '/index.php', + 'PHP_SELF' => '/index.php', + 'PATH_INFO' => null, + 'REQUEST_URI' => null, + ), + ), + array( + 'url' => '', + 'base' => '', + 'webroot' => '/', + ), + ), ); } From d7991aac2368ac3fe20d90eeb58daf0a80f821da Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 26 Feb 2011 16:19:50 -0300 Subject: [PATCH 442/668] Optimizations related with hasMany and HABTM assoc. --- cake/libs/model/datasources/dbo_source.php | 42 +++++++++++----------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 7af467027..2dbfc623d 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1185,7 +1185,6 @@ class DboSource extends DataSource { } return null; } - $count = count($resultSet); if ($type === 'hasMany' && empty($assocData['limit']) && !empty($assocData['foreignKey'])) { $ins = $fetch = array(); @@ -1219,7 +1218,7 @@ class DboSource extends DataSource { } } $this->_filterResults($fetch, $model); - return $this->__mergeHasMany($resultSet, $fetch, $association, $model, $linkModel, $recursive); + return $this->__mergeHasMany($resultSet, $fetch, $association, $model, $linkModel); } elseif ($type === 'hasAndBelongsToMany') { $ins = $fetch = array(); foreach ($resultSet as &$result) { @@ -1252,6 +1251,8 @@ class DboSource extends DataSource { } } + $modelAlias = $model->alias; + $modelPK = $model->primaryKey; foreach ($resultSet as &$row) { if ($type !== 'hasAndBelongsToMany') { $q = $this->insertQueryData($query, $row, $association, $assocData, $model, $linkModel, $stack); @@ -1269,7 +1270,7 @@ class DboSource extends DataSource { foreach ($linkModel->{$type1} as $assoc1 => $assocData1) { $deepModel = $linkModel->{$assoc1}; - if ($type1 === 'belongsTo' || ($deepModel->alias === $model->alias && $type === 'belongsTo') || ($deepModel->alias != $model->alias)) { + if ($type1 === 'belongsTo' || ($deepModel->alias === $modelAlias && $type === 'belongsTo') || ($deepModel->alias !== $modelAlias)) { $tmpStack = $stack; $tmpStack[] = $assoc1; if ($linkModel->useDbConfig == $deepModel->useDbConfig) { @@ -1286,7 +1287,7 @@ class DboSource extends DataSource { $uniqueIds = $merge = array(); foreach ($fetch as $j => $data) { - if (isset($data[$with]) && $data[$with][$foreignKey] === $row[$model->alias][$model->primaryKey]) { + if (isset($data[$with]) && $data[$with][$foreignKey] === $row[$modelAlias][$modelPK]) { if ($habtmFieldsCount <= 2) { unset($data[$with]); } @@ -1339,12 +1340,17 @@ class DboSource extends DataSource { * @param object $linkModel Model being merged * @return void */ - function __mergeHasMany(&$resultSet, $merge, $association, &$model, &$linkModel) { - foreach ($resultSet as $i => $value) { - $count = 0; - $merged[$association] = array(); - foreach ($merge as $j => $data) { - if (isset($value[$model->alias]) && $value[$model->alias][$model->primaryKey] === $data[$association][$model->hasMany[$association]['foreignKey']]) { + function __mergeHasMany(&$resultSet, $merge, $association, $model, $linkModel) { + $modelAlias = $model->alias; + $modelPK = $model->primaryKey; + $modelFK = $model->hasMany[$association]['foreignKey']; + foreach ($resultSet as &$result) { + if (!isset($result[$modelAlias])) { + continue; + } + $merged = array(); + foreach ($merge as $data) { + if ($result[$modelAlias][$modelPK] === $data[$association][$modelFK]) { if (count($data) > 1) { $data = array_merge($data[$association], $data); unset($data[$association]); @@ -1354,17 +1360,13 @@ class DboSource extends DataSource { unset($data[$key]); } } - $merged[$association][] = $data; + $merged[] = $data; } else { - $merged[$association][] = $data[$association]; + $merged[] = $data[$association]; } } - $count++; - } - if (isset($value[$model->alias])) { - $resultSet[$i] = Set::pushDiff($resultSet[$i], $merged); - unset($merged); } + $result = Set::pushDiff($result, array($association => $merged)); } } @@ -1378,18 +1380,18 @@ class DboSource extends DataSource { * @param boolean $selfJoin * @access private */ - function __mergeAssociation(&$data, $merge, $association, $type, $selfJoin = false) { + function __mergeAssociation(&$data, &$merge, $association, $type, $selfJoin = false) { if (isset($merge[0]) && !isset($merge[0][$association])) { $association = Inflector::pluralize($association); } - if ($type == 'belongsTo' || $type == 'hasOne') { + if ($type === 'belongsTo' || $type === 'hasOne') { if (isset($merge[$association])) { $data[$association] = $merge[$association][0]; } else { if (count($merge[0][$association]) > 1) { foreach ($merge[0] as $assoc => $data2) { - if ($assoc != $association) { + if ($assoc !== $association) { $merge[0][$association][$assoc] = $data2; } } From 0e30042f824a4c43adedf3744bfdd65dd0ff33ec Mon Sep 17 00:00:00 2001 From: Juan Basso Date: Sat, 26 Feb 2011 18:24:05 -0300 Subject: [PATCH 443/668] Removed the ReflectionClass when filtering results. The Reflection just help in big data. --- cake/libs/model/datasources/dbo_source.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cake/libs/model/datasources/dbo_source.php b/cake/libs/model/datasources/dbo_source.php index 2dbfc623d..1f85d0ac1 100755 --- a/cake/libs/model/datasources/dbo_source.php +++ b/cake/libs/model/datasources/dbo_source.php @@ -1127,8 +1127,6 @@ class DboSource extends DataSource { * @return array Array of results that have been filtered through $model->afterFind */ protected function _filterResults(&$results, Model $model, $filtered = array()) { - static $haveCallback = array(); - $current = current($results); if (!is_array($current)) { return array(); @@ -1140,14 +1138,6 @@ class DboSource extends DataSource { continue; } $linkedModel = $model->{$className}; - $linkedClass = get_class($linkedModel); - if (!isset($haveCallback[$linkedClass])) { - $ref = new ReflectionClass($linkedModel); - $haveCallback[$linkedClass] = $ref->getMethod('afterFind')->class !== 'Model'; - } - if ($haveCallback[$linkedClass] !== true) { - continue; - } $filtering[] = $className; foreach ($results as &$result) { $data = $linkedModel->afterFind(array(array($className => $result[$className])), false); From d999650d5ea724e25eca4870f57f3d3049a4f476 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sun, 27 Feb 2011 06:31:15 +0530 Subject: [PATCH 444/668] MediaView now forces download of unknown file types. Closes #140 --- cake/libs/view/media.php | 24 ++++----- cake/tests/cases/libs/view/media.test.php | 65 ++++++++++++++++++++--- 2 files changed, 70 insertions(+), 19 deletions(-) diff --git a/cake/libs/view/media.php b/cake/libs/view/media.php index 880383b30..34b047aef 100644 --- a/cake/libs/view/media.php +++ b/cake/libs/view/media.php @@ -89,13 +89,9 @@ class MediaView extends View { * @return mixed */ function render() { - $name = $download = $extension = $id = $modified = $path = $size = $cache = $mimeType = $compress = null; + $name = $download = $extension = $id = $modified = $path = $cache = $mimeType = $compress = null; extract($this->viewVars, EXTR_OVERWRITE); - if ($size) { - $id = $id . '_' . $size; - } - if (is_dir($path)) { $path = $path . $id; } else { @@ -109,15 +105,12 @@ class MediaView extends View { throw new NotFoundException('The requested file was not found'); } - if (is_null($name)) { - $name = $id; - } - if (is_array($mimeType)) { $this->response->type($mimeType); } - if (isset($extension) && $this->response->type($extension) && $this->_isActive()) { + if (isset($extension) && $this->_isActive()) { + $extension = strtolower($extension); $chunkSize = 8192; $buffer = ''; $fileSize = @filesize($path); @@ -131,6 +124,9 @@ class MediaView extends View { } else { $modified = time(); } + if ($this->response->type($extension) === false) { + $download = true; + } if ($cache) { $this->response->cache($modified, $cache); @@ -155,7 +151,10 @@ class MediaView extends View { if (!empty($contentType)) { $this->response->type($contentType); } - $this->response->download($name . '.' . $extension); + if (is_null($name)) { + $name = $id; + } + $this->response->download($name); $this->response->header(array('Accept-Ranges' => 'bytes')); $httpRange = env('HTTP_RANGE'); @@ -176,7 +175,6 @@ class MediaView extends View { $this->response->header('Content-Length', $fileSize); } } else { - $this->response->type($extension); $this->response->header(array( 'Content-Length' => $fileSize )); @@ -237,7 +235,7 @@ class MediaView extends View { /** * Flushes the contents of the output buffer - * + * * @return void */ protected function _flushBuffer() { diff --git a/cake/tests/cases/libs/view/media.test.php b/cake/tests/cases/libs/view/media.test.php index 115f74505..fac9b4beb 100644 --- a/cake/tests/cases/libs/view/media.test.php +++ b/cake/tests/cases/libs/view/media.test.php @@ -77,7 +77,7 @@ class MediaViewTest extends CakeTestCase { ->method('_isActive') ->will($this->returnValue(true)); - $this->MediaView->response->expects($this->exactly(2)) + $this->MediaView->response->expects($this->exactly(1)) ->method('type') ->with('css') ->will($this->returnArgument(0)); @@ -91,7 +91,7 @@ class MediaViewTest extends CakeTestCase { 'Pragma' => 'no-cache' )); - $this->MediaView->response->expects($this->at(3)) + $this->MediaView->response->expects($this->at(2)) ->method('header') ->with(array( 'Content-Length' => 31 @@ -107,6 +107,61 @@ class MediaViewTest extends CakeTestCase { $this->assertTrue($result !== false); } +/** + * testRenderWithUnknownFileType method + * + * @access public + * @return void + */ + function testRenderWithUnknownFileType() { + $this->MediaView->viewVars = array( + 'path' => TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS, + 'id' => 'no_section.ini', + 'extension' => 'ini', + ); + $this->MediaView->expects($this->exactly(2)) + ->method('_isActive') + ->will($this->returnValue(true)); + + $this->MediaView->response->expects($this->exactly(1)) + ->method('type') + ->with('ini') + ->will($this->returnValue(false)); + + $this->MediaView->response->expects($this->at(1)) + ->method('header') + ->with(array( + 'Date' => gmdate('D, d M Y H:i:s', time()) . ' GMT', + 'Expires' => '0', + 'Cache-Control' => 'private, must-revalidate, post-check=0, pre-check=0', + 'Pragma' => 'no-cache' + )); + + $this->MediaView->response->expects($this->once()) + ->method('download') + ->with('no_section.ini'); + + $this->MediaView->response->expects($this->at(3)) + ->method('header') + ->with(array( + 'Accept-Ranges' => 'bytes' + )); + + $this->MediaView->response->expects($this->at(4)) + ->method('header') + ->with('Content-Length', 35); + + $this->MediaView->response->expects($this->once())->method('send'); + $this->MediaView->expects($this->once())->method('_clearBuffer'); + $this->MediaView->expects($this->once())->method('_flushBuffer'); + + ob_start(); + $result = $this->MediaView->render(); + $output = ob_get_clean(); + $this->assertEqual("some_key = some_value\nbool_key = 1\n", $output); + $this->assertTrue($result !== false); + } + /** * testConnectionAborted method * @@ -124,10 +179,8 @@ class MediaViewTest extends CakeTestCase { ->method('_isActive') ->will($this->returnValue(false)); - $this->MediaView->response->expects($this->once()) - ->method('type') - ->with('css') - ->will($this->returnArgument(0)); + $this->MediaView->response->expects($this->never()) + ->method('type'); $result = $this->MediaView->render(); $this->assertFalse($result); From f1f586480c620939c6bba9a5bb2da572392bd5dc Mon Sep 17 00:00:00 2001 From: Ceeram Date: Sun, 27 Feb 2011 16:08:52 +0100 Subject: [PATCH 445/668] Implementing Aclbehavior to be set as both requester as controlled, tests updated, fixes #346 --- cake/libs/model/behaviors/acl.php | 82 ++++++++++++------- .../cases/libs/model/behaviors/acl.test.php | 69 +++++++++++++--- 2 files changed, 110 insertions(+), 41 deletions(-) diff --git a/cake/libs/model/behaviors/acl.php b/cake/libs/model/behaviors/acl.php index 63b85a6f0..08f66acce 100644 --- a/cake/libs/model/behaviors/acl.php +++ b/cake/libs/model/behaviors/acl.php @@ -35,7 +35,7 @@ class AclBehavior extends ModelBehavior { * @var array * @access protected */ - var $__typeMaps = array('requester' => 'Aro', 'controlled' => 'Aco'); + var $__typeMaps = array('requester' => 'Aro', 'controlled' => 'Aco', 'both' => array('Aro', 'Aco')); /** * Sets up the configuation for the model, and loads ACL models if they haven't been already @@ -48,17 +48,22 @@ class AclBehavior extends ModelBehavior { if (is_string($config)) { $config = array('type' => $config); } - $this->settings[$model->name] = array_merge(array('type' => 'requester'), (array)$config); - $this->settings[$model->name]['type'] = strtolower($this->settings[$model->name]['type']); + $this->settings[$model->alias] = array_merge(array('type' => 'controlled'), (array)$config); + $this->settings[$model->alias]['type'] = strtolower($this->settings[$model->alias]['type']); - $type = $this->__typeMaps[$this->settings[$model->name]['type']]; + $types = $this->__typeMaps[$this->settings[$model->alias]['type']]; if (!class_exists('AclNode')) { require LIBS . 'model' . DS . 'db_acl.php'; } - if (PHP5) { - $model->{$type} = ClassRegistry::init($type); - } else { - $model->{$type} =& ClassRegistry::init($type); + if (!is_array($types)) { + $types = array($types); + } + foreach($types as $type) { + if (PHP5) { + $model->{$type} = ClassRegistry::init($type); + } else { + $model->{$type} =& ClassRegistry::init($type); + } } if (!method_exists($model, 'parentNode')) { trigger_error(sprintf(__('Callback parentNode() not defined in %s', true), $model->alias), E_USER_WARNING); @@ -69,14 +74,21 @@ class AclBehavior extends ModelBehavior { * Retrieves the Aro/Aco node for this model * * @param mixed $ref + * @param string $type Only needed when Acl is set up as 'both', specify 'Aro' or 'Aco' to get the correct node * @return array * @access public * @link http://book.cakephp.org/view/1322/node */ - function node(&$model, $ref = null) { - $type = $this->__typeMaps[$this->settings[$model->name]['type']]; + function node(&$model, $ref = null, $type = null) { + if (empty($type)) { + $type = $this->__typeMaps[$this->settings[$model->alias]['type']]; + if (is_array($type)) { + trigger_error(__('AclBehavior is setup with more then one type, please specify type parameter for node()', true), E_USER_WARNING); + return null; + } + } if (empty($ref)) { - $ref = array('model' => $model->name, 'foreign_key' => $model->id); + $ref = array('model' => $model->alias, 'foreign_key' => $model->id); } return $model->{$type}->node($ref); } @@ -89,22 +101,27 @@ class AclBehavior extends ModelBehavior { * @access public */ function afterSave(&$model, $created) { - $type = $this->__typeMaps[$this->settings[$model->name]['type']]; - $parent = $model->parentNode(); - if (!empty($parent)) { - $parent = $this->node($model, $parent); + $types = $this->__typeMaps[$this->settings[$model->alias]['type']]; + if (!is_array($types)) { + $types = array($types); } - $data = array( - 'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null, - 'model' => $model->alias, - 'foreign_key' => $model->id - ); - if (!$created) { - $node = $this->node($model); - $data['id'] = isset($node[0][$type]['id']) ? $node[0][$type]['id'] : null; + foreach ($types as $type) { + $parent = $model->parentNode(); + if (!empty($parent)) { + $parent = $this->node($model, $parent, $type); + } + $data = array( + 'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null, + 'model' => $model->alias, + 'foreign_key' => $model->id + ); + if (!$created) { + $node = $this->node($model, null, $type); + $data['id'] = isset($node[0][$type]['id']) ? $node[0][$type]['id'] : null; + } + $model->{$type}->create(); + $model->{$type}->save($data); } - $model->{$type}->create(); - $model->{$type}->save($data); } /** @@ -114,10 +131,15 @@ class AclBehavior extends ModelBehavior { * @access public */ function afterDelete(&$model) { - $type = $this->__typeMaps[$this->settings[$model->name]['type']]; - $node = Set::extract($this->node($model), "0.{$type}.id"); - if (!empty($node)) { - $model->{$type}->delete($node); + $types = $this->__typeMaps[$this->settings[$model->alias]['type']]; + if (!is_array($types)) { + $types = array($types); + } + foreach ($types as $type) { + $node = Set::extract($this->node($model, null, $type), "0.{$type}.id"); + if (!empty($node)) { + $model->{$type}->delete($node); + } } } -} +} \ No newline at end of file diff --git a/cake/tests/cases/libs/model/behaviors/acl.test.php b/cake/tests/cases/libs/model/behaviors/acl.test.php index a2469b051..8f42e577c 100644 --- a/cake/tests/cases/libs/model/behaviors/acl.test.php +++ b/cake/tests/cases/libs/model/behaviors/acl.test.php @@ -52,7 +52,7 @@ class AclPerson extends CakeTestModel { * @var array * @access public */ - var $actsAs = array('Acl' => 'requester'); + var $actsAs = array('Acl' => 'both'); /** * belongsTo property @@ -133,7 +133,7 @@ class AclUser extends CakeTestModel { * @var array * @access public */ - var $actsAs = array('Acl'); + var $actsAs = array('Acl' => 'requester'); /** * parentNode @@ -261,6 +261,20 @@ class AclBehaviorTestCase extends CakeTestCase { $this->assertTrue(is_object($Post->Aco)); } +/** + * Test Setup of AclBehavior as both requester and controlled + * + * @return void + * @access public + */ + function testSetupMulti() { + $User =& new AclPerson(); + $this->assertTrue(isset($User->Behaviors->Acl->settings['AclPerson'])); + $this->assertEqual($User->Behaviors->Acl->settings['AclPerson']['type'], 'both'); + $this->assertTrue(is_object($User->Aro)); + $this->assertTrue(is_object($User->Aco)); + } + /** * test After Save * @@ -294,6 +308,15 @@ class AclBehaviorTestCase extends CakeTestCase { ); $this->Aro->save($aroData); + $acoData = array( + 'Aco' => array( + 'model' => 'AclPerson', + 'foreign_key' => 2, + 'parent_id' => null + ) + ); + $this->Aco->save($acoData); + $Person =& new AclPerson(); $data = array( 'AclPerson' => array( @@ -309,7 +332,7 @@ class AclBehaviorTestCase extends CakeTestCase { $this->assertTrue(is_array($result)); $this->assertEqual($result['Aro']['parent_id'], 5); - $node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8)); + $node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro'); $this->assertEqual(count($node), 2); $this->assertEqual($node[0]['Aro']['parent_id'], 5); $this->assertEqual($node[1]['Aro']['parent_id'], null); @@ -323,17 +346,24 @@ class AclBehaviorTestCase extends CakeTestCase { ); $this->Aro->create(); $this->Aro->save($aroData); - + $acoData = array( + 'Aco' => array( + 'model' => 'AclPerson', + 'foreign_key' => 1, + 'parent_id' => null + )); + $this->Aco->create(); + $this->Aco->save($acoData); $Person->read(null, 8); $Person->set('mother_id', 1); $Person->save(); $result = $this->Aro->find('first', array( 'conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id) )); - $this->assertTrue(is_array($result)); - $this->assertEqual($result['Aro']['parent_id'], 7); - - $node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8)); + $this->assertTrue(is_array($result)); + $this->assertEqual($result['Aro']['parent_id'], 7); + + $node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro'); $this->assertEqual(sizeof($node), 2); $this->assertEqual($node[0]['Aro']['parent_id'], 7); $this->assertEqual($node[1]['Aro']['parent_id'], null); @@ -354,6 +384,15 @@ class AclBehaviorTestCase extends CakeTestCase { ); $this->Aro->save($aroData); + $acoData = array( + 'Aco' => array( + 'model' => 'AclPerson', + 'foreign_key' => 2, + 'parent_id' => null + ) + ); + $this->Aco->save($acoData); + $Person =& new AclPerson(); $data = array( 'AclPerson' => array( @@ -391,6 +430,14 @@ class AclBehaviorTestCase extends CakeTestCase { ) ); $this->Aro->save($aroData); + $acoData = array( + 'Aco' => array( + 'model' => 'AclPerson', + 'foreign_key' => 2, + 'parent_id' => null + ) + ); + $this->Aco->save($acoData); $Person =& new AclPerson(); $data = array( 'AclPerson' => array( @@ -401,7 +448,7 @@ class AclBehaviorTestCase extends CakeTestCase { ); $Person->save($data); $id = $Person->id; - $node = $Person->node(); + $node = $Person->node(null, 'Aro'); $this->assertEqual(count($node), 2); $this->assertEqual($node[0]['Aro']['parent_id'], 5); $this->assertEqual($node[1]['Aro']['parent_id'], null); @@ -455,8 +502,8 @@ class AclBehaviorTestCase extends CakeTestCase { $this->Aro->save($aroData); $Person->id = 2; - $result = $Person->node(); + $result = $Person->node(null, 'Aro'); $this->assertTrue(is_array($result)); $this->assertEqual(count($result), 1); } -} +} \ No newline at end of file From dbd8199dad3a7ab86c8ab8d8586f2e36bab6b1de Mon Sep 17 00:00:00 2001 From: Ceeram Date: Sun, 27 Feb 2011 16:18:32 +0100 Subject: [PATCH 446/668] replaced use of model->alias by model->name, where these might cause issues, refers #346 --- cake/libs/model/behaviors/acl.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/libs/model/behaviors/acl.php b/cake/libs/model/behaviors/acl.php index 08f66acce..87c165563 100644 --- a/cake/libs/model/behaviors/acl.php +++ b/cake/libs/model/behaviors/acl.php @@ -48,10 +48,10 @@ class AclBehavior extends ModelBehavior { if (is_string($config)) { $config = array('type' => $config); } - $this->settings[$model->alias] = array_merge(array('type' => 'controlled'), (array)$config); - $this->settings[$model->alias]['type'] = strtolower($this->settings[$model->alias]['type']); + $this->settings[$model->name] = array_merge(array('type' => 'controlled'), (array)$config); + $this->settings[$model->name]['type'] = strtolower($this->settings[$model->name]['type']); - $types = $this->__typeMaps[$this->settings[$model->alias]['type']]; + $types = $this->__typeMaps[$this->settings[$model->name]['type']]; if (!class_exists('AclNode')) { require LIBS . 'model' . DS . 'db_acl.php'; } @@ -81,14 +81,14 @@ class AclBehavior extends ModelBehavior { */ function node(&$model, $ref = null, $type = null) { if (empty($type)) { - $type = $this->__typeMaps[$this->settings[$model->alias]['type']]; + $type = $this->__typeMaps[$this->settings[$model->name]['type']]; if (is_array($type)) { trigger_error(__('AclBehavior is setup with more then one type, please specify type parameter for node()', true), E_USER_WARNING); return null; } } if (empty($ref)) { - $ref = array('model' => $model->alias, 'foreign_key' => $model->id); + $ref = array('model' => $model->name, 'foreign_key' => $model->id); } return $model->{$type}->node($ref); } @@ -101,7 +101,7 @@ class AclBehavior extends ModelBehavior { * @access public */ function afterSave(&$model, $created) { - $types = $this->__typeMaps[$this->settings[$model->alias]['type']]; + $types = $this->__typeMaps[$this->settings[$model->name]['type']]; if (!is_array($types)) { $types = array($types); } @@ -131,7 +131,7 @@ class AclBehavior extends ModelBehavior { * @access public */ function afterDelete(&$model) { - $types = $this->__typeMaps[$this->settings[$model->alias]['type']]; + $types = $this->__typeMaps[$this->settings[$model->name]['type']]; if (!is_array($types)) { $types = array($types); } From 08bec291fd30d8e294ada66bc4579e8bafa95e86 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sun, 27 Feb 2011 22:50:25 -0430 Subject: [PATCH 447/668] Fixing class importing in paginator test --- .../cases/libs/controller/components/paginator.test.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Cake/tests/cases/libs/controller/components/paginator.test.php b/lib/Cake/tests/cases/libs/controller/components/paginator.test.php index cbaecb2b9..c286c0a67 100644 --- a/lib/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 From e9011badb59ffbfba75d90dcce53935785c6c8aa Mon Sep 17 00:00:00 2001 From: Ceeram Date: Mon, 28 Feb 2011 21:16:17 +0100 Subject: [PATCH 448/668] Ensure both node() and afterSave() use ->name Fixes #1564 --- cake/libs/model/behaviors/acl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/behaviors/acl.php b/cake/libs/model/behaviors/acl.php index 63b85a6f0..41cc50899 100644 --- a/cake/libs/model/behaviors/acl.php +++ b/cake/libs/model/behaviors/acl.php @@ -96,7 +96,7 @@ class AclBehavior extends ModelBehavior { } $data = array( 'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null, - 'model' => $model->alias, + 'model' => $model->name, 'foreign_key' => $model->id ); if (!$created) { From 2977448891aaaec7be1c23dd566fe19b75e6b15e Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 1 Mar 2011 17:14:15 -0800 Subject: [PATCH 449/668] Added more options to NumberHelper::currency() to allow for better flexibility in defining formats. Fixes #1267 --- cake/libs/view/helpers/number.php | 38 +++++++++++-------- .../cases/libs/view/helpers/number.test.php | 38 ++++++++++++++++++- 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/cake/libs/view/helpers/number.php b/cake/libs/view/helpers/number.php index c88cd8ff2..8c9a2e665 100644 --- a/cake/libs/view/helpers/number.php +++ b/cake/libs/view/helpers/number.php @@ -38,16 +38,16 @@ class NumberHelper extends AppHelper { */ protected $_currencies = array( 'USD' => array( - 'before' => '$', 'after' => 'c', 'zero' => 0, 'places' => 2, 'thousands' => ',', - 'decimals' => '.', 'negative' => '()', 'escape' => true + 'wholeSymbol' => '$', 'wholePosition' => 'before', 'fractionSymbol' => 'c', 'fractionPosition' => 'after', + 'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()', 'escape' => true ), 'GBP' => array( - 'before'=>'£', 'after' => 'p', 'zero' => 0, 'places' => 2, 'thousands' => ',', - 'decimals' => '.', 'negative' => '()','escape' => false + 'wholeSymbol'=>'£', 'wholePosition' => 'before', 'fractionSymbol' => 'p', 'fractionPosition' => 'after', + 'zero' => 0, 'places' => 2, 'thousands' => ',', 'decimals' => '.', 'negative' => '()','escape' => false ), 'EUR' => array( - 'before'=>'€', 'after' => false, 'zero' => 0, 'places' => 2, 'thousands' => '.', - 'decimals' => ',', 'negative' => '()', 'escape' => false + 'wholeSymbol'=>'€', 'wholePosition' => 'before', 'fractionSymbol' => false, 'fractionPosition' => 'after', + 'zero' => 0, 'places' => 2, 'thousands' => '.', 'decimals' => ',', 'negative' => '()', 'escape' => false ) ); @@ -58,8 +58,8 @@ class NumberHelper extends AppHelper { * @access protected */ protected $_currencyDefaults = array( - 'before'=>'', 'after' => '', 'zero' => '0', 'places' => 2, 'thousands' => ',', - 'decimals' => '.','negative' => '()', 'escape' => true + 'wholeSymbol'=>'', 'wholePosition' => 'before', 'fractionSymbol' => '', 'fractionPosition' => 'after', + 'zero' => '0', 'places' => 2, 'thousands' => ',', 'decimals' => '.','negative' => '()', 'escape' => true ); /** @@ -190,26 +190,32 @@ class NumberHelper extends AppHelper { $options = array_merge($default, $options); - $result = null; + if (isset($options['before']) && $options['before'] !== '') { + $options['wholeSymbol'] = $options['before']; + } + if (isset($options['after']) && !$options['after'] !== '') { + $options['fractionSymbol'] = $options['after']; + } + $result = $options['before'] = $options['after'] = null; + + $symbolKey = 'whole'; if ($number == 0 ) { if ($options['zero'] !== 0 ) { return $options['zero']; } - $options['after'] = null; } elseif ($number < 1 && $number > -1 ) { - if ($options['after'] !== false) { + if ($options['fractionSymbol'] !== false) { $multiply = intval('1' . str_pad('', $options['places'], '0')); $number = $number * $multiply; - $options['before'] = null; $options['places'] = null; + $symbolKey = 'fraction'; } - } elseif (empty($options['before'])) { - $options['before'] = null; - } else { - $options['after'] = null; } + $position = $options[$symbolKey.'Position'] != 'after' ? 'before' : 'after'; + $options[$position] = $options[$symbolKey.'Symbol']; + $abs = abs($number); $result = $this->format($abs, $options); diff --git a/cake/tests/cases/libs/view/helpers/number.test.php b/cake/tests/cases/libs/view/helpers/number.test.php index 99857df99..8bbd1eea6 100644 --- a/cake/tests/cases/libs/view/helpers/number.test.php +++ b/cake/tests/cases/libs/view/helpers/number.test.php @@ -114,7 +114,7 @@ class NumberHelperTest extends CakeTestCase { $expected = '£100,100,100.00'; $this->assertEqual($expected, $result); - $result = $this->Number->currency($value, '', array('thousands' =>' ', 'after' => '€', 'decimals' => ',', 'zero' => 'Gratuit')); + $result = $this->Number->currency($value, '', array('thousands' =>' ', 'wholeSymbol' => '€', 'wholePosition' => 'after', 'decimals' => ',', 'zero' => 'Gratuit')); $expected = '100 100 100,00€'; $this->assertEqual($expected, $result); @@ -129,6 +129,42 @@ class NumberHelperTest extends CakeTestCase { $result = $this->Number->currency(0.5, NULL, array('after'=>'øre')); $expected = '50øre'; $this->assertEqual($expected,$result); + + $result = $this->Number->currency(1, null, array('wholeSymbol' => '$ ')); + $expected = '$ 1.00'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(1, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after')); + $expected = '1.00 $'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(.2, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after', 'fractionSymbol' => 'cents')); + $expected = '20cents'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(.2, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after', 'fractionSymbol' => 'cents', 'fractionPosition' => 'before')); + $expected = 'cents20'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(311, 'USD', array('wholePosition' => 'after')); + $expected = '311.00$'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(.2, 'EUR'); + $expected = '€0,20'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(12, null, array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents', 'fractionPosition' => 'after')); + $expected = '12.00 dollars'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(.12, null, array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents', 'fractionPosition' => 'after')); + $expected = '12 cents'; + $this->assertEqual($result, $expected); + + $result = $this->Number->currency(.5, null, array('fractionSymbol' => false, 'fractionPosition' => 'before', 'wholeSymbol' => '$')); + $expected = '$0.50'; + $this->assertEqual($result, $expected); } /** From 06f9fc0fc9cb28a41fcfb8989596f4de0f349e05 Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 1 Mar 2011 17:31:02 -0800 Subject: [PATCH 450/668] Made form post to the current location by default. Fixes #1418 --- cake/libs/view/helpers/form.php | 8 +++-- .../cases/libs/view/helpers/form.test.php | 35 +++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 1eb2b315f..75b5ce62d 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -238,8 +238,12 @@ class FormHelper extends AppHelper { $options); $this->_inputDefaults = $options['inputDefaults']; unset($options['inputDefaults']); - - if (empty($options['url']) || is_array($options['url'])) { + if ($options['action'] === null && $options['url'] === null) { + $options['action'] = $this->request->here; + if (!isset($options['id'])) { + $options['id'] = $this->domId($this->request['action'] . 'Form'); + } + } elseif (empty($options['url']) || is_array($options['url'])) { if (empty($options['url']['controller'])) { if (!empty($model) && $model != $this->defaultModel) { $options['url']['controller'] = Inflector::underscore(Inflector::pluralize($model)); diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index bb389396a..5694d8959 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -670,6 +670,7 @@ class FormHelperTest extends CakeTestCase { $this->Form = new FormHelper($this->View); $this->Form->Html = new HtmlHelper($this->View); $this->Form->request = new CakeRequest(null, false); + $this->Form->request->here = '/contacts/add'; $this->Form->request['action'] = 'add'; $this->Form->request->webroot = ''; $this->Form->request->base = ''; @@ -5524,6 +5525,7 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); $this->Form->request->data['Contact']['id'] = 1; + $this->Form->request->here = '/contacts/edit/1'; $this->Form->request['action'] = 'edit'; $result = $this->Form->create('Contact'); $expected = array( @@ -5538,6 +5540,7 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); $this->Form->request->data['Contact']['id'] = 1; + $this->Form->request->here = '/contacts/edit/1'; $this->Form->request['action'] = 'edit'; $result = $this->Form->create('Contact', array('type' => 'file')); $expected = array( @@ -5552,7 +5555,7 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); $this->Form->request->data['ContactNonStandardPk']['pk'] = 1; - $result = $this->Form->create('ContactNonStandardPk'); + $result = $this->Form->create('ContactNonStandardPk', array('url' => array('action' => 'edit'))); $expected = array( 'form' => array( 'id' => 'ContactNonStandardPkEditForm', 'method' => 'post', @@ -5638,6 +5641,33 @@ class FormHelperTest extends CakeTestCase { '/div' ); $this->assertTags($result, $expected); + + $this->Form->request->here = '/contacts/add/Contact:1'; + $result = $this->Form->create(); + $expected = array( + 'form' => array( + 'id' => 'ContactAddForm', 'method' => 'post', 'action' => '/contacts/add/Contact:1', + 'accept-charset' => 'utf-8' + ), + 'div' => array('style' => 'display:none;'), + 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), + '/div' + ); + $this->assertTags($result, $expected); + + $this->Form->request['action'] = 'delete'; + $this->Form->request->here = '/contacts/delete/10/User:42'; + $result = $this->Form->create(); + $expected = array( + 'form' => array( + 'id' => 'ContactDeleteForm', 'method' => 'post', 'action' => '/contacts/delete/10/User:42', + 'accept-charset' => 'utf-8' + ), + 'div' => array('style' => 'display:none;'), + 'input' => array('type' => 'hidden', 'name' => '_method', 'value' => 'POST'), + '/div' + ); + $this->assertTags($result, $expected); } /** @@ -5809,7 +5839,8 @@ class FormHelperTest extends CakeTestCase { */ function testGetFormWithFalseModel() { $encoding = strtolower(Configure::read('App.encoding')); - $result = $this->Form->create(false, array('type' => 'get')); + $this->Form->request['controller'] = 'contact_test'; + $result = $this->Form->create(false, array('type' => 'get', 'url' => array('controller' => 'contact_test'))); $expected = array('form' => array( 'id' => 'addForm', 'method' => 'get', 'action' => '/contact_test/add', From 82834f2ec0aa6feb684b422f949d0d4a5a4dd218 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 1 Mar 2011 23:38:39 -0430 Subject: [PATCH 451/668] Moving Auth related classes to the new structure --- .../Cake/Controller/Component/Auth/ActionsAuthorize.php | 0 .../Cake/Controller/Component/Auth/BaseAuthenticate.php | 0 .../Cake/Controller/Component/Auth/BaseAuthorize.php | 0 .../Cake/Controller/Component/Auth/ControllerAuthorize.php | 0 .../Cake/Controller/Component/Auth/CrudAuthorize.php | 0 .../Cake/Controller/Component/Auth/DigestAuthenticate.php | 0 .../Cake/Controller/Component/Auth/FormAuthenticate.php | 0 .../Cake/Controller/Component/Auth}/basic_authenticate.php | 0 .../libs/controller/components/auth/actions_authorize.test.php | 0 .../libs/controller/components/auth/basic_authenticate.test.php | 0 .../libs/controller/components/auth/controller_authorize.test.php | 0 .../cases/libs/controller/components/auth/crud_authorize.test.php | 0 .../libs/controller/components/auth/digest_authenticate.test.php | 0 .../libs/controller/components/auth/form_authenticate.test.php | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename cake/libs/controller/components/auth/actions_authorize.php => lib/Cake/Controller/Component/Auth/ActionsAuthorize.php (100%) rename cake/libs/controller/components/auth/base_authenticate.php => lib/Cake/Controller/Component/Auth/BaseAuthenticate.php (100%) rename cake/libs/controller/components/auth/base_authorize.php => lib/Cake/Controller/Component/Auth/BaseAuthorize.php (100%) rename cake/libs/controller/components/auth/controller_authorize.php => lib/Cake/Controller/Component/Auth/ControllerAuthorize.php (100%) rename cake/libs/controller/components/auth/crud_authorize.php => lib/Cake/Controller/Component/Auth/CrudAuthorize.php (100%) rename cake/libs/controller/components/auth/digest_authenticate.php => lib/Cake/Controller/Component/Auth/DigestAuthenticate.php (100%) rename cake/libs/controller/components/auth/form_authenticate.php => lib/Cake/Controller/Component/Auth/FormAuthenticate.php (100%) rename {cake/libs/controller/components/auth => lib/Cake/Controller/Component/Auth}/basic_authenticate.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/auth/actions_authorize.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/auth/basic_authenticate.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/auth/controller_authorize.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/auth/crud_authorize.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/auth/digest_authenticate.test.php (100%) rename {cake => lib/Cake}/tests/cases/libs/controller/components/auth/form_authenticate.test.php (100%) diff --git a/cake/libs/controller/components/auth/actions_authorize.php b/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php similarity index 100% rename from cake/libs/controller/components/auth/actions_authorize.php rename to lib/Cake/Controller/Component/Auth/ActionsAuthorize.php diff --git a/cake/libs/controller/components/auth/base_authenticate.php b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php similarity index 100% rename from cake/libs/controller/components/auth/base_authenticate.php rename to lib/Cake/Controller/Component/Auth/BaseAuthenticate.php 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/controller_authorize.php b/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php similarity index 100% rename from cake/libs/controller/components/auth/controller_authorize.php rename to lib/Cake/Controller/Component/Auth/ControllerAuthorize.php diff --git a/cake/libs/controller/components/auth/crud_authorize.php b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php similarity index 100% rename from cake/libs/controller/components/auth/crud_authorize.php rename to lib/Cake/Controller/Component/Auth/CrudAuthorize.php diff --git a/cake/libs/controller/components/auth/digest_authenticate.php b/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php similarity index 100% rename from cake/libs/controller/components/auth/digest_authenticate.php rename to lib/Cake/Controller/Component/Auth/DigestAuthenticate.php diff --git a/cake/libs/controller/components/auth/form_authenticate.php b/lib/Cake/Controller/Component/Auth/FormAuthenticate.php similarity index 100% rename from cake/libs/controller/components/auth/form_authenticate.php rename to lib/Cake/Controller/Component/Auth/FormAuthenticate.php diff --git a/cake/libs/controller/components/auth/basic_authenticate.php b/lib/Cake/Controller/Component/Auth/basic_authenticate.php similarity index 100% rename from cake/libs/controller/components/auth/basic_authenticate.php rename to lib/Cake/Controller/Component/Auth/basic_authenticate.php 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 100% 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 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 100% 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 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 100% 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 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 100% 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 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 100% 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 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 100% 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 From 7891143cd959645569c278f3b1a8e7c9cabb14c8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Mar 2011 05:46:27 -0500 Subject: [PATCH 452/668] Removing repetitive strtoupper call. --- cake/libs/route/cake_route.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 798d26c92..ca96428ba 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -193,12 +193,13 @@ class CakeRoute { } else { $header = 'http_' . $header[1]; } + $header = strtoupper($header); $val = (array)$val; $h = false; foreach ($val as $v) { - if (env(strtoupper($header)) === $v) { + if (env($header) === $v) { $h = true; } } From 197c9bf912543b118094f531d96db00ac02ab7b3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Mar 2011 20:27:02 -0500 Subject: [PATCH 453/668] Making empty string create empty submit buttons. This applies to both Form->submit() and Form->end(). Tests added. Fixes #1569 --- cake/libs/view/helpers/form.php | 6 +---- .../cases/libs/view/helpers/form.test.php | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 7b6dd35a5..84bc7a2e2 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -363,10 +363,6 @@ class FormHelper extends AppHelper { unset($options['label']); } $submitOptions = $options; - - if (!$submit) { - $submit = __('Submit', true); - } } $out .= $this->submit($submit, $submitOptions); } @@ -1309,7 +1305,7 @@ class FormHelper extends AppHelper { * @link http://book.cakephp.org/view/1431/submit */ function submit($caption = null, $options = array()) { - if (!$caption) { + if (!is_string($caption) && empty($caption)) { $caption = __('Submit', true); } $out = null; diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 3aea5e665..8816fe816 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -5284,6 +5284,14 @@ class FormHelperTest extends CakeTestCase { * @return void */ function testSubmitButton() { + $result = $this->Form->submit(''); + $expected = array( + 'div' => array('class' => 'submit'), + 'input' => array('type' => 'submit', 'value' => ''), + '/div' + ); + $this->assertTags($result, $expected); + $result = $this->Form->submit('Test Submit'); $expected = array( 'div' => array('class' => 'submit'), @@ -6333,6 +6341,24 @@ class FormHelperTest extends CakeTestCase { function testFormEnd() { $this->assertEqual($this->Form->end(), ''); + $result = $this->Form->end(''); + $expected = array( + 'div' => array('class' => 'submit'), + 'input' => array('type' => 'submit', 'value' => ''), + '/div', + '/form' + ); + $this->assertTags($result, $expected); + + $result = $this->Form->end(array('label' => '')); + $expected = array( + 'div' => array('class' => 'submit'), + 'input' => array('type' => 'submit', 'value' => ''), + '/div', + '/form' + ); + $this->assertTags($result, $expected); + $result = $this->Form->end('save'); $expected = array( 'div' => array('class' => 'submit'), From 7526d017f0764522a3bcdbdfe85f29d15516bbc4 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Mar 2011 21:00:53 -0500 Subject: [PATCH 454/668] Clarifying what tld means. --- cake/libs/cake_request.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index 90d42826f..d51e808d5 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -532,7 +532,8 @@ class CakeRequest implements ArrayAccess { /** * Get the domain name and include $tldLength segments of the tld. * - * @param int $tldLength Number of segments your tld contains + * @param int $tldLength Number of segments your tld contains. For example: `example.com` contains 1 tld. + * While `example.co.uk` contains 2. * @return string Domain name without subdomains. */ public function domain($tldLength = 1) { @@ -544,7 +545,8 @@ class CakeRequest implements ArrayAccess { /** * Get the subdomains for a host. * - * @param int $tldLength Number of segments your tld contains. + * @param int $tldLength Number of segments your tld contains. For example: `example.com` contains 1 tld. + * While `example.co.uk` contains 2. * @return array of subdomains. */ public function subdomains($tldLength = 1) { From 2145fd8078d395e71ff12b54ac36c155719bed70 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Mar 2011 21:46:28 -0500 Subject: [PATCH 455/668] Adding CakeRequest::here() for getting complete 'here' values including query string parameters. $request->here does not include query string params. Adding test cases. --- cake/libs/cake_request.php | 17 +++++++++++++++ cake/tests/cases/libs/cake_request.test.php | 24 +++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index d51e808d5..90435ed8b 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -497,6 +497,23 @@ class CakeRequest implements ArrayAccess { return $this; } +/** + * Get the value of the current requests url. Will include named parameters and querystring arguments. + * + * @param boolean $base Include the base path, set to false to trim the base path off. + * @return string the current request url including query string args. + */ + public function here($base = true) { + $url = $this->here; + if (!empty($this->query)) { + $url .= '?' . http_build_query($this->query); + } + if (!$base) { + $url = preg_replace('/^' . preg_quote($this->base, '/') . '/', '', $url, 1); + } + return $url; + } + /** * Read an HTTP header from the Request information. * diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index a28838a14..3df9a8713 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -1401,6 +1401,30 @@ class CakeRequestTestCase extends CakeTestCase { $this->assertFalse($result); } +/** + * test the here() method + * + * @return void + */ + function testHere() { + Configure::write('App.base', '/base_path'); + $_GET = array('test' => 'value'); + $request = new CakeRequest('/posts/add/1/name:value'); + + $result = $request->here(); + $this->assertEquals('/base_path/posts/add/1/name:value?test=value', $result); + + $result = $request->here(false); + $this->assertEquals('/posts/add/1/name:value?test=value', $result); + + $request = new CakeRequest('/posts/base_path/1/name:value'); + $result = $request->here(); + $this->assertEquals('/base_path/posts/base_path/1/name:value?test=value', $result); + + $result = $request->here(false); + $this->assertEquals('/posts/base_path/1/name:value?test=value', $result); + } + /** * loadEnvironment method * From af16b13e5f70b05b5d761c58a70d56990ff357dd Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Mar 2011 21:47:11 -0500 Subject: [PATCH 456/668] Fixing issues with double base dir in FormHelper::create(). Fixes #1568 --- cake/libs/view/helpers/form.php | 2 +- .../cases/libs/view/helpers/form.test.php | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 54cadd400..7b0b29b93 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -239,7 +239,7 @@ class FormHelper extends AppHelper { $this->_inputDefaults = $options['inputDefaults']; unset($options['inputDefaults']); if ($options['action'] === null && $options['url'] === null) { - $options['action'] = $this->request->here; + $options['action'] = $this->request->here(false); if (!isset($options['id'])) { $options['id'] = $this->domId($this->request['action'] . 'Form'); } diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index a94246ad5..532476960 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -662,12 +662,13 @@ class FormHelperTest extends CakeTestCase { function setUp() { parent::setUp(); + Configure::write('App.base', ''); $this->Controller = new ContactTestController(); $this->View = new View($this->Controller); $this->Form = new FormHelper($this->View); $this->Form->Html = new HtmlHelper($this->View); - $this->Form->request = new CakeRequest(null, false); + $this->Form->request = new CakeRequest('contacts/add', false); $this->Form->request->here = '/contacts/add'; $this->Form->request['action'] = 'add'; $this->Form->request->webroot = ''; @@ -5664,12 +5665,21 @@ class FormHelperTest extends CakeTestCase { '/div' ); $this->assertTags($result, $expected); + } - $this->Form->request->here = '/contacts/add/Contact:1'; - $result = $this->Form->create(); +/** + * test create() with automatic url generation + * + * @return void + */ + function testCreateAutoUrl() { + Router::setRequestInfo(array(array(), array('base' => '/base_url'))); + $this->Form->request->here = '/base_url/contacts/add/Contact:1'; + $this->Form->request->base = '/base_url'; + $result = $this->Form->create('Contact'); $expected = array( 'form' => array( - 'id' => 'ContactAddForm', 'method' => 'post', 'action' => '/contacts/add/Contact:1', + 'id' => 'ContactAddForm', 'method' => 'post', 'action' => '/base_url/contacts/add/Contact:1', 'accept-charset' => 'utf-8' ), 'div' => array('style' => 'display:none;'), @@ -5679,11 +5689,12 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); $this->Form->request['action'] = 'delete'; - $this->Form->request->here = '/contacts/delete/10/User:42'; - $result = $this->Form->create(); + $this->Form->request->here = '/base_url/contacts/delete/10/User:42'; + $this->Form->request->base = '/base_url'; + $result = $this->Form->create('Contact'); $expected = array( 'form' => array( - 'id' => 'ContactDeleteForm', 'method' => 'post', 'action' => '/contacts/delete/10/User:42', + 'id' => 'ContactDeleteForm', 'method' => 'post', 'action' => '/base_url/contacts/delete/10/User:42', 'accept-charset' => 'utf-8' ), 'div' => array('style' => 'display:none;'), From a6abd61f3f419116b93eb13b3c9b339c36dd1f62 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Mar 2011 21:52:25 -0500 Subject: [PATCH 457/668] Removing Dispatcher::$here, it wasn't really used outside of a cached() which had a param that it just ignored. Making Dispatcher::cached() pay attention to its parameter. Updating tests. --- cake/libs/dispatcher.php | 19 ++++-------------- cake/tests/cases/libs/dispatcher.test.php | 24 +++++++++++------------ 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index f8c833bc9..387eac89c 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -37,14 +37,6 @@ App::import('Controller', 'Controller', false); */ class Dispatcher { -/** - * Current URL - * - * @var string - * @access public - */ - public $here = false; - /** * The request object * @@ -91,9 +83,7 @@ class Dispatcher { * are encountered. */ public function dispatch(CakeRequest $request, $additionalParams = array()) { - $this->here = $request->here; - - if ($this->asset($request->url) || $this->cached($request->url)) { + if ($this->asset($request->url) || $this->cached($request->here)) { return; } @@ -260,12 +250,11 @@ class Dispatcher { /** * Outputs cached dispatch view cache * - * @param string $url Requested URL + * @param string $path Requested URL path */ - public function cached($url) { + public function cached($path) { if (Configure::read('Cache.check') === true) { - $path = $this->here; - if ($this->here == '/') { + if ($path == '/') { $path = 'home'; } $path = strtolower(Inflector::slug($path)); diff --git a/cake/tests/cases/libs/dispatcher.test.php b/cake/tests/cases/libs/dispatcher.test.php index 0f9a6bbbb..e7e3ae8b9 100644 --- a/cake/tests/cases/libs/dispatcher.test.php +++ b/cake/tests/cases/libs/dispatcher.test.php @@ -1424,7 +1424,7 @@ class DispatcherTest extends CakeTestCase { $out = ob_get_clean(); ob_start(); - $dispatcher->cached($request); + $dispatcher->cached($request->here); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); @@ -1433,7 +1433,7 @@ class DispatcherTest extends CakeTestCase { $this->assertEqual($result, $expected); - $filename = $this->__cachePath($dispatcher->here); + $filename = $this->__cachePath($request->here); unlink($filename); $request = new CakeRequest('test_cached_pages/index'); @@ -1446,7 +1446,7 @@ class DispatcherTest extends CakeTestCase { $out = ob_get_clean(); ob_start(); - $dispatcher->cached($request); + $dispatcher->cached($request->here); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); @@ -1454,7 +1454,7 @@ class DispatcherTest extends CakeTestCase { $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); - $filename = $this->__cachePath($dispatcher->here); + $filename = $this->__cachePath($request->here); unlink($filename); $request = new CakeRequest('TestCachedPages/index'); @@ -1464,7 +1464,7 @@ class DispatcherTest extends CakeTestCase { $out = ob_get_clean(); ob_start(); - $dispatcher->cached($request); + $dispatcher->cached($request->here); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); @@ -1472,7 +1472,7 @@ class DispatcherTest extends CakeTestCase { $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); - $filename = $this->__cachePath($dispatcher->here); + $filename = $this->__cachePath($request->here); unlink($filename); $request = new CakeRequest('TestCachedPages/test_nocache_tags'); @@ -1482,7 +1482,7 @@ class DispatcherTest extends CakeTestCase { $out = ob_get_clean(); ob_start(); - $dispatcher->cached($request); + $dispatcher->cached($request->here); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); @@ -1490,7 +1490,7 @@ class DispatcherTest extends CakeTestCase { $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); - $filename = $this->__cachePath($dispatcher->here); + $filename = $this->__cachePath($request->here); unlink($filename); $request = new CakeRequest('test_cached_pages/view/param/param'); @@ -1500,7 +1500,7 @@ class DispatcherTest extends CakeTestCase { $out = ob_get_clean(); ob_start(); - $dispatcher->cached($request); + $dispatcher->cached($request->here); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); @@ -1508,7 +1508,7 @@ class DispatcherTest extends CakeTestCase { $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); - $filename = $this->__cachePath($dispatcher->here); + $filename = $this->__cachePath($request->here); unlink($filename); $request = new CakeRequest('test_cached_pages/view/foo:bar/value:goo'); @@ -1518,7 +1518,7 @@ class DispatcherTest extends CakeTestCase { $out = ob_get_clean(); ob_start(); - $dispatcher->cached($request); + $dispatcher->cached($request->here); $cached = ob_get_clean(); $result = str_replace(array("\t", "\r\n", "\n"), "", $out); @@ -1526,7 +1526,7 @@ class DispatcherTest extends CakeTestCase { $expected = str_replace(array("\t", "\r\n", "\n"), "", $cached); $this->assertEqual($result, $expected); - $filename = $this->__cachePath($dispatcher->here); + $filename = $this->__cachePath($request->here); $this->assertTrue(file_exists($filename)); unlink($filename); From 5e3cd74b03b220cbfe7c1e64d3761bb5531af02f Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Mar 2011 22:03:21 -0500 Subject: [PATCH 458/668] Replacing request->here with request->here(). Saves a call to Router::normalize() in a few places. --- cake/libs/error/exception_renderer.php | 6 +++--- cake/libs/view/helpers/cache.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cake/libs/error/exception_renderer.php b/cake/libs/error/exception_renderer.php index f62b75833..25adff3aa 100644 --- a/cake/libs/error/exception_renderer.php +++ b/cake/libs/error/exception_renderer.php @@ -172,7 +172,7 @@ class ExceptionRenderer { * @return void */ protected function _cakeError(CakeException $error) { - $url = Router::normalize($this->controller->request->here); + $url = $this->controller->request->here(); $code = $error->getCode(); $this->controller->response->statusCode($code); $this->controller->set(array( @@ -195,7 +195,7 @@ class ExceptionRenderer { if (Configure::read('debug') == 0 && $error instanceof CakeException) { $message = __('Not Found'); } - $url = Router::normalize($this->controller->request->here); + $url = $this->controller->request->here(); $this->controller->response->statusCode($error->getCode()); $this->controller->set(array( 'name' => $message, @@ -211,7 +211,7 @@ class ExceptionRenderer { * @param array $params Parameters for controller */ public function error500($error) { - $url = Router::normalize($this->controller->request->here); + $url = $this->controller->request->here(); $code = ($error->getCode() > 500) ? $error->getCode() : 500; $this->controller->response->statusCode($code); $this->controller->set(array( diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 3ee75c3fd..ef63994e1 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -213,8 +213,8 @@ class CacheHelper extends AppHelper { } else { $cacheTime = strtotime($timestamp, $now); } - $path = $this->request->here; - if ($this->here == '/') { + $path = $this->request->here(); + if ($path == '/') { $path = 'home'; } $cache = strtolower(Inflector::slug($path)); From b70a5124705d9da10ed6a8a352f9a9ecc71afff6 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Mar 2011 06:20:45 -0500 Subject: [PATCH 459/668] Moving Router::$named to be protected, and adding an accessor method. This will help with later refactoring. --- cake/libs/route/cake_route.php | 8 ++-- cake/libs/router.php | 57 ++++++++++++++++----------- cake/tests/cases/libs/router.test.php | 3 +- 3 files changed, 42 insertions(+), 26 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index ca96428ba..be357d632 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -274,8 +274,9 @@ class CakeRoute { return false; } - $greedyNamed = Router::$named['greedy']; - $allowedNamedParams = Router::$named['rules']; + $namedConfig = Router::namedConfig(); + $greedyNamed = $namedConfig['greedy']; + $allowedNamedParams = $namedConfig['rules']; $named = $pass = $_query = array(); @@ -352,7 +353,8 @@ class CakeRoute { $params['pass'] = implode('/', $params['pass']); } - $separator = Router::$named['separator']; + $namedConfig = Router::namedConfig(); + $separator = $namedConfig['separator']; if (!empty($params['named']) && is_array($params['named'])) { $named = array(); diff --git a/cake/libs/router.php b/cake/libs/router.php index 71f6e7bc5..7ed994ce0 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -85,7 +85,7 @@ class Router { const ID = '[0-9]+'; const UUID = '[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}'; - private static $__named = array( + private static $__namedExpressions = array( 'Action' => Router::ACTION, 'Year' => Router::YEAR, 'Month' => Router::MONTH, @@ -100,7 +100,7 @@ class Router { * @var string * @access public */ - public static $named = array( + protected static $_namedConfig = array( 'default' => array('page', 'fields', 'order', 'limit', 'recursive', 'sort', 'direction', 'step'), 'greedy' => true, 'separator' => ':', @@ -186,10 +186,10 @@ class Router { * Gets the named route elements for use in app/config/routes.php * * @return array Named route elements - * @see Router::$__named + * @see Router::$__namedExpressions */ public static function getNamedExpressions() { - return self::$__named; + return self::$__namedExpressions; } /** @@ -369,7 +369,7 @@ class Router { */ public static function connectNamed($named, $options = array()) { if (isset($options['separator'])) { - self::$named['separator'] = $options['separator']; + self::$_namedConfig['separator'] = $options['separator']; unset($options['separator']); } @@ -380,23 +380,33 @@ class Router { $options = array_merge(array('default' => false, 'reset' => false, 'greedy' => true), $options); } - if ($options['reset'] == true || self::$named['rules'] === false) { - self::$named['rules'] = array(); + if ($options['reset'] == true || self::$_namedConfig['rules'] === false) { + self::$_namedConfig['rules'] = array(); } if ($options['default']) { - $named = array_merge($named, self::$named['default']); + $named = array_merge($named, self::$_namedConfig['default']); } foreach ($named as $key => $val) { if (is_numeric($key)) { - self::$named['rules'][$val] = true; + self::$_namedConfig['rules'][$val] = true; } else { - self::$named['rules'][$key] = $val; + self::$_namedConfig['rules'][$key] = $val; } } - self::$named['greedy'] = $options['greedy']; - return self::$named; + self::$_namedConfig['greedy'] = $options['greedy']; + return self::$_namedConfig; + } + +/** + * Gets the current named parameter configuration values. + * + * @return array + * @see Router::$_namedConfig + */ + public static function namedConfig() { + return self::$_namedConfig; } /** @@ -426,7 +436,10 @@ class Router { * @return array Array of mapped resources */ public static function mapResources($controller, $options = array()) { - $options = array_merge(array('prefix' => '/', 'id' => self::$__named['ID'] . '|' . self::$__named['UUID']), $options); + $options = array_merge(array( + 'prefix' => '/', + 'id' => self::ID . '|' . self::UUID + ), $options); $prefix = $options['prefix']; foreach ((array)$controller as $ctlName) { @@ -621,7 +634,7 @@ class Router { self::connect('/:controller', array('action' => 'index')); self::connect('/:controller/:action/*'); - if (self::$named['rules'] === false) { + if (self::$_namedConfig['rules'] === false) { self::connectNamed(true); } self::$_defaultsMapped = true; @@ -971,10 +984,10 @@ class Router { if (is_array($value)) { $flattend = Set::flatten($value, ']['); foreach ($flattend as $namedKey => $namedValue) { - $output .= '/' . $name . "[$namedKey]" . self::$named['separator'] . $namedValue; + $output .= '/' . $name . "[$namedKey]" . self::$_namedConfig['separator'] . $namedValue; } } else { - $output .= '/' . $name . self::$named['separator'] . $value; + $output .= '/' . $name . self::$_namedConfig['separator'] . $value; } } } @@ -996,8 +1009,8 @@ class Router { $named = array(); foreach ($params as $param => $val) { - if (isset(self::$named['rules'][$param])) { - $rule = self::$named['rules'][$param]; + if (isset(self::$_namedConfig['rules'][$param])) { + $rule = self::$_namedConfig['rules'][$param]; if (Router::matchNamed($param, $val, $rule, compact('controller', 'action'))) { $named[substr($param, 1)] = $val; unset($params[$param]); @@ -1215,12 +1228,12 @@ class Router { $pass = $named = array(); $args = explode('/', $args); - $greedy = isset($options['greedy']) ? $options['greedy'] : self::$named['greedy']; + $greedy = isset($options['greedy']) ? $options['greedy'] : self::$_namedConfig['greedy']; $context = array(); if (isset($options['context'])) { $context = $options['context']; } - $rules = self::$named['rules']; + $rules = self::$_namedConfig['rules']; if (isset($options['named'])) { $greedy = isset($options['greedy']) && $options['greedy'] === true; foreach ((array)$options['named'] as $key => $val) { @@ -1237,9 +1250,9 @@ class Router { continue; } - $separatorIsPresent = strpos($param, self::$named['separator']) !== false; + $separatorIsPresent = strpos($param, self::$_namedConfig['separator']) !== false; if ((!isset($options['named']) || !empty($options['named'])) && $separatorIsPresent) { - list($key, $val) = explode(self::$named['separator'], $param, 2); + list($key, $val) = explode(self::$_namedConfig['separator'], $param, 2); $hasRule = isset($rules[$key]); $passIt = (!$hasRule && !$greedy) || ($hasRule && !self::matchNamed($key, $val, $rules[$key], $context)); if ($passIt) { diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index d656e46da..f194b4a35 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1436,7 +1436,8 @@ class RouterTest extends CakeTestCase { Router::reload(); $result = Router::connectNamed(true); - $this->assertEqual(array_keys($result['rules']), Router::$named['default']); + $named = Router::namedConfig(); + $this->assertEqual(array_keys($result['rules']), $named['default']); $this->assertTrue($result['greedy']); Router::reload(); Router::connectNamed(array('param1' => 'not-matching')); From 155db768251d531532f88d4ee0ab05338ab3c2fd Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 05:50:58 -0500 Subject: [PATCH 460/668] Removing junk. --- cake/libs/route/cake_route.php | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index be357d632..a4a70758a 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -333,7 +333,7 @@ class CakeRoute { } } } - return $this->_writeUrl(array_merge($url, compact('pass', 'named', '_query'))); + return $this->_writeUrl(array_merge($url, compact('pass', 'named'))); } /** @@ -391,20 +391,4 @@ class CakeRoute { return $out; } -/** - * Generates a well-formed querystring from $q - * - * Will compose an array or nested array into a proper querystring. - * - * @param mixed $q An array of parameters to compose into a query string. - * @param bool $escape Whether or not to use escaped & - * @return string - */ - public function queryString($q, $escape = false) { - $join = '&'; - if ($escape === true) { - $join = '&'; - } - return '?' . http_build_query($q, null, $join); - } } \ No newline at end of file From cf26a8e430a8f991ec166979a8ed7ab3d609f9a9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 06:11:41 -0500 Subject: [PATCH 461/668] Initial port of Router::getArgs() to CakeRoute. --- cake/libs/route/cake_route.php | 82 ++++++++++++++++++- .../cases/libs/route/cake_route.test.php | 31 ++++++- 2 files changed, 108 insertions(+), 5 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index a4a70758a..add9d1e36 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -214,19 +214,93 @@ class CakeRoute { unset($route[$i]); } $route['pass'] = $route['named'] = array(); - $route += $this->defaults; - //move numerically indexed elements from the defaults into pass. - foreach ($route as $key => $value) { + // Assign defaults, set passed args to pass + foreach ($this->defaults as $key => $value) { + if (isset($route[$key])) { + continue; + } if (is_integer($key)) { $route['pass'][] = $value; - unset($route[$key]); + continue; } + $route[$key] = $value; + } + + if (isset($route['_args_'])) { + list($pass, $named) = $this->parseArgs($route['_args_'], $route['controller'], $route['action']); + $route['pass'] = array_merge($route['pass'], $pass); + $route['named'] = $named; + unset($route['_args_']); } return $route; } } +/** + * Parse passed and Named parameters into a list of passed args, and a hash of named parameters. + * The local and global configuration for named parameters will be used. + * + * @param string $args A string with the passed & named params. eg. /1/page:2 + * @return array Array of ($pass, $named) + */ + public function parseArgs($args, $controller = null, $action = null) { + $pass = $named = array(); + $args = explode('/', $args); + + $context = compact('controller', 'action'); + $namedConfig = Router::namedConfig(); + $greedy = isset($this->options['greedy']) ? $this->options['greedy'] : $namedConfig['greedy']; + $rules = $namedConfig['rules']; + if (isset($this->options['named'])) { + $greedy = isset($this->options['greedy']) && $this->options['greedy'] === true; + foreach ((array)$this->options['named'] as $key => $val) { + if (is_numeric($key)) { + $rules[$val] = true; + continue; + } + $rules[$key] = $val; + } + } + + foreach ($args as $param) { + if (empty($param) && $param !== '0' && $param !== 0) { + continue; + } + + $separatorIsPresent = strpos($param, $namedConfig['separator']) !== false; + if ((!isset($options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { + list($key, $val) = explode($namedConfig['separator'], $param, 2); + $hasRule = isset($rules[$key]); + $passIt = (!$hasRule && !$greedy) || ($hasRule && !Router::matchNamed($key, $val, $rules[$key], $context)); + if ($passIt) { + $pass[] = $param; + } else { + if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) { + $matches = array_reverse($matches); + $parts = explode('[', $key); + $key = array_shift($parts); + $arr = $val; + foreach ($matches as $match) { + if (empty($match[1])) { + $arr = array($arr); + } else { + $arr = array( + $match[1] => $arr + ); + } + } + $val = $arr; + } + $named = array_merge_recursive($named, array($key => $val)); + } + } else { + $pass[] = $param; + } + } + return array($pass, $named); + } + /** * Apply persistent parameters to a url array. Persistant parameters are a special * key used during route creation to force route parameters to persist when omitted from diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index c1433451c..bf3eba263 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -171,12 +171,14 @@ class CakeRouteTestCase extends CakeTestCase { $this->assertPattern($result, '/posts/08/01/2007/title-of-post'); $result = $route->parse('/posts/08/01/2007/title-of-post'); - $this->assertEqual(count($result), 8); + $this->assertEqual(count($result), 7); $this->assertEqual($result['controller'], 'posts'); $this->assertEqual($result['action'], 'view'); $this->assertEqual($result['year'], '2007'); $this->assertEqual($result['month'], '08'); $this->assertEqual($result['day'], '01'); + $this->assertEquals($result['pass'][0], 'title-of-post'); + $route = new CakeRoute( "/:extra/page/:slug/*", @@ -473,4 +475,31 @@ class CakeRouteTestCase extends CakeTestCase { $this->assertFalse($result); } +/** + * test the parseArgs method + * + * @return void + */ + function testPassedArgumentParsing() { + $route = new CakeRoute('/:controller/:action/*'); + $result = $route->parse('/posts/edit/1/2/0'); + $expected = array( + 'controller' => 'posts', + 'action' => 'edit', + 'pass' => array('1', '2', '0'), + 'named' => array() + ); + $this->assertEquals($expected, $result); + + $result = $route->parse('/posts/edit/a-string/page:1'); + $expected = array( + 'controller' => 'posts', + 'action' => 'edit', + 'pass' => array('a-string'), + 'named' => array( + 'page' => 1 + ) + ); + $this->assertEquals($expected, $result); + } } \ No newline at end of file From 636188efeb32a4edffc5639ca11621ac0fc71eac Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 06:22:59 -0500 Subject: [PATCH 462/668] Adding tests for array named params from router test to cakeroute test. --- .../cases/libs/route/cake_route.test.php | 63 ++++++++++++++++++- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index bf3eba263..ec798d4a4 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -490,16 +490,73 @@ class CakeRouteTestCase extends CakeTestCase { 'named' => array() ); $this->assertEquals($expected, $result); - - $result = $route->parse('/posts/edit/a-string/page:1'); + + $result = $route->parse('/posts/edit/a-string/page:1/sort:value'); $expected = array( 'controller' => 'posts', 'action' => 'edit', 'pass' => array('a-string'), 'named' => array( - 'page' => 1 + 'page' => 1, + 'sort' => 'value' ) ); $this->assertEquals($expected, $result); } + +/** + * test that parsing array format named parameters works + * + * @return void + */ + function testArrayNamedParameters() { + $route = new CakeRoute('/:controller/:action/*'); + $result = $route->parse('/tests/action/var[]:val1/var[]:val2'); + $expected = array( + 'controller' => 'tests', + 'action' => 'action', + 'named' => array( + 'var' => array( + 'val1', + 'val2' + ) + ), + 'pass' => array(), + ); + $this->assertEqual($result, $expected); + + $result = $route->parse('/tests/action/theanswer[is]:42/var[]:val2/var[]:val3'); + $expected = array( + 'controller' => 'tests', + 'action' => 'action', + 'named' => array( + 'theanswer' => array( + 'is' => 42 + ), + 'var' => array( + 'val2', + 'val3' + ) + ), + 'pass' => array(), + ); + $this->assertEqual($result, $expected); + + $result = $route->parse('/tests/action/theanswer[is][not]:42/theanswer[]:5/theanswer[is]:6'); + $expected = array( + 'controller' => 'tests', + 'action' => 'action', + 'named' => array( + 'theanswer' => array( + 5, + 'is' => array( + 6, + 'not' => 42 + ) + ), + ), + 'pass' => array(), + ); + $this->assertEqual($result, $expected); + } } \ No newline at end of file From 3eef281e1ccf4166e2376e4354608fb90550a258 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 06:36:02 -0500 Subject: [PATCH 463/668] Adding tests for named parameter rules on the route level. --- cake/libs/route/cake_route.php | 2 + .../cases/libs/route/cake_route.test.php | 54 ++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index add9d1e36..81ccaf425 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -242,6 +242,8 @@ class CakeRoute { * The local and global configuration for named parameters will be used. * * @param string $args A string with the passed & named params. eg. /1/page:2 + * @param string $controller The current actions controller name, used to match named parameter rules + * @param string $action The current action name, used to match named parameter rules. * @return array Array of ($pass, $named) */ public function parseArgs($args, $controller = null, $action = null) { diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index ec798d4a4..a29ebe665 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -480,7 +480,7 @@ class CakeRouteTestCase extends CakeTestCase { * * @return void */ - function testPassedArgumentParsing() { + function testParsePassedArgument() { $route = new CakeRoute('/:controller/:action/*'); $result = $route->parse('/posts/edit/1/2/0'); $expected = array( @@ -504,12 +504,62 @@ class CakeRouteTestCase extends CakeTestCase { $this->assertEquals($expected, $result); } +/** + * test that only named parameter rules are followed. + * + * @return void + */ + function testParseNamedParametersWithRules() { + $route = new CakeRoute('/:controller/:action/*', array(), array( + 'named' => array( + 'wibble', + 'fish' => array('action' => 'index'), + 'fizz' => array('controller' => 'comments') + ) + )); + $result = $route->parse('/posts/display/wibble:spin/fish:trout/fizz:buzz'); + $expected = array( + 'controller' => 'posts', + 'action' => 'display', + 'pass' => array('fish:trout', 'fizz:buzz'), + 'named' => array( + 'wibble' => 'spin' + ) + ); + $this->assertEquals($expected, $result, 'Fish should not be parsed, as action != index'); + + $result = $route->parse('/posts/index/wibble:spin/fish:trout/fizz:buzz'); + $expected = array( + 'controller' => 'posts', + 'action' => 'index', + 'pass' => array('fizz:buzz'), + 'named' => array( + 'wibble' => 'spin', + 'fish' => 'trout' + ) + ); + $this->assertEquals($expected, $result, 'Fish should be parsed, as action == index'); + + $result = $route->parse('/comments/index/wibble:spin/fish:trout/fizz:buzz'); + $expected = array( + 'controller' => 'comments', + 'action' => 'index', + 'pass' => array(), + 'named' => array( + 'wibble' => 'spin', + 'fish' => 'trout', + 'fizz' => 'buzz' + ) + ); + $this->assertEquals($expected, $result, 'All params should be parsed as conditions were met.'); + } + /** * test that parsing array format named parameters works * * @return void */ - function testArrayNamedParameters() { + function testParseArrayNamedParameters() { $route = new CakeRoute('/:controller/:action/*'); $result = $route->parse('/tests/action/var[]:val1/var[]:val2'); $expected = array( From 97175aac901d11beb8460b6eb32f1f7c302d1557 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 06:49:11 -0500 Subject: [PATCH 464/668] Making greedy -> greedyNamed its clearer and doesn't consume a possibly easy to use named parameter key. Expanding tests for named parameter rules/conditions. --- cake/libs/route/cake_route.php | 4 +- cake/libs/router.php | 2 +- .../cases/libs/route/cake_route.test.php | 50 +++++++++++++++++-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 81ccaf425..369c127dd 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -252,10 +252,10 @@ class CakeRoute { $context = compact('controller', 'action'); $namedConfig = Router::namedConfig(); - $greedy = isset($this->options['greedy']) ? $this->options['greedy'] : $namedConfig['greedy']; + $greedy = isset($this->options['greedyNamed']) ? $this->options['greedyNamed'] : $namedConfig['greedy']; $rules = $namedConfig['rules']; if (isset($this->options['named'])) { - $greedy = isset($this->options['greedy']) && $this->options['greedy'] === true; + $greedy = isset($this->options['greedyNamed']) && $this->options['greedyNamed'] === true; foreach ((array)$this->options['named'] as $key => $val) { if (is_numeric($key)) { $rules[$val] = true; diff --git a/cake/libs/router.php b/cake/libs/router.php index 7ed994ce0..0ac9338c2 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -395,7 +395,7 @@ class Router { self::$_namedConfig['rules'][$key] = $val; } } - self::$_namedConfig['greedy'] = $options['greedy']; + self::$_namedConfig['greedyNamed'] = $options['greedy']; return self::$_namedConfig; } diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index a29ebe665..4a337f02f 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -514,14 +514,15 @@ class CakeRouteTestCase extends CakeTestCase { 'named' => array( 'wibble', 'fish' => array('action' => 'index'), - 'fizz' => array('controller' => 'comments') + 'fizz' => array('controller' => 'comments'), + 'pattern' => 'val-[\d]+' ) )); - $result = $route->parse('/posts/display/wibble:spin/fish:trout/fizz:buzz'); + $result = $route->parse('/posts/display/wibble:spin/fish:trout/fizz:buzz/unknown:value'); $expected = array( 'controller' => 'posts', 'action' => 'display', - 'pass' => array('fish:trout', 'fizz:buzz'), + 'pass' => array('fish:trout', 'fizz:buzz', 'unknown:value'), 'named' => array( 'wibble' => 'spin' ) @@ -552,6 +553,49 @@ class CakeRouteTestCase extends CakeTestCase { ) ); $this->assertEquals($expected, $result, 'All params should be parsed as conditions were met.'); + + $result = $route->parse('/comments/index/pattern:val--'); + $expected = array( + 'controller' => 'comments', + 'action' => 'index', + 'pass' => array('pattern:val--'), + 'named' => array() + ); + $this->assertEquals($expected, $result, 'Named parameter pattern unmet.'); + + $result = $route->parse('/comments/index/pattern:val-2'); + $expected = array( + 'controller' => 'comments', + 'action' => 'index', + 'pass' => array(), + 'named' => array('pattern' => 'val-2') + ); + $this->assertEquals($expected, $result, 'Named parameter pattern met.'); + } + +/** + * test that greedyNamed ignores rules. + * + * @return void + */ + function testParseGreedyNamed() { + $route = new CakeRoute('/:controller/:action/*', array(), array( + 'named' => array( + 'fizz' => array('controller' => 'comments'), + 'pattern' => 'val-[\d]+', + ), + 'greedyNamed' => true + )); + $result = $route->parse('/posts/display/wibble:spin/fizz:buzz/pattern:ignored'); + $expected = array( + 'controller' => 'posts', + 'action' => 'display', + 'pass' => array('fizz:buzz', 'pattern:ignored'), + 'named' => array( + 'wibble' => 'spin', + ) + ); + $this->assertEquals($expected, $result, 'Greedy named grabs everything, rules are followed'); } /** From 15275eddaceb577a50068e07c43be130a508f66f Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 06:54:46 -0500 Subject: [PATCH 465/668] Moving matchNamed() into CakeRoute. This will allow its removal from Router. --- cake/libs/route/cake_route.php | 34 ++++++++++++++++++- .../cases/libs/route/cake_route.test.php | 2 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 369c127dd..38a45a30a 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -274,7 +274,7 @@ class CakeRoute { if ((!isset($options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { list($key, $val) = explode($namedConfig['separator'], $param, 2); $hasRule = isset($rules[$key]); - $passIt = (!$hasRule && !$greedy) || ($hasRule && !Router::matchNamed($key, $val, $rules[$key], $context)); + $passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($key, $val, $rules[$key], $context)); if ($passIt) { $pass[] = $param; } else { @@ -303,6 +303,38 @@ class CakeRoute { return array($pass, $named); } +/** + * Return true if a given named $param's $val matches a given $rule depending on $context. Currently implemented + * rule types are controller, action and match that can be combined with each other. + * + * @param string $param The name of the named parameter + * @param string $val The value of the named parameter + * @param array $rule The rule(s) to apply, can also be a match string + * @param string $context An array with additional context information (controller / action) + * @return boolean + */ + protected function _matchNamed($param, $val, $rule, $context) { + if ($rule === true || $rule === false) { + return $rule; + } + if (is_string($rule)) { + $rule = array('match' => $rule); + } + if (!is_array($rule)) { + return false; + } + + $controllerMatches = !isset($rule['controller'], $context['controller']) || in_array($context['controller'], (array)$rule['controller']); + if (!$controllerMatches) { + return false; + } + $actionMatches = !isset($rule['action'], $context['action']) || in_array($context['action'], (array)$rule['action']); + if (!$actionMatches) { + return false; + } + return (!isset($rule['match']) || preg_match('/' . $rule['match'] . '/', $val)); + } + /** * Apply persistent parameters to a url array. Persistant parameters are a special * key used during route creation to force route parameters to persist when omitted from diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index 4a337f02f..b68e05338 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -514,7 +514,7 @@ class CakeRouteTestCase extends CakeTestCase { 'named' => array( 'wibble', 'fish' => array('action' => 'index'), - 'fizz' => array('controller' => 'comments'), + 'fizz' => array('controller' => array('comments', 'other')), 'pattern' => 'val-[\d]+' ) )); From 171830df3319f24bc76a03686c0bdcb46f4fccf0 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 07:11:32 -0500 Subject: [PATCH 466/668] Minor cleanup and reformattting. Changing greedy -> greedyNamed for clarity and consistency. --- cake/libs/route/cake_route.php | 115 +++++++++++++++++---------------- cake/libs/router.php | 2 +- 2 files changed, 61 insertions(+), 56 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 38a45a30a..015abb42b 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -185,56 +185,55 @@ class CakeRoute { } if (!preg_match($this->_compiledRoute, $url, $route)) { return false; - } else { - foreach ($this->defaults as $key => $val) { - if ($key[0] === '[' && preg_match('/^\[(\w+)\]$/', $key, $header)) { - if (isset($this->__headerMap[$header[1]])) { - $header = $this->__headerMap[$header[1]]; - } else { - $header = 'http_' . $header[1]; - } - $header = strtoupper($header); - - $val = (array)$val; - $h = false; - - foreach ($val as $v) { - if (env($header) === $v) { - $h = true; - } - } - if (!$h) { - return false; - } - } - } - array_shift($route); - $count = count($this->keys); - for ($i = 0; $i <= $count; $i++) { - unset($route[$i]); - } - $route['pass'] = $route['named'] = array(); - - // Assign defaults, set passed args to pass - foreach ($this->defaults as $key => $value) { - if (isset($route[$key])) { - continue; - } - if (is_integer($key)) { - $route['pass'][] = $value; - continue; - } - $route[$key] = $value; - } - - if (isset($route['_args_'])) { - list($pass, $named) = $this->parseArgs($route['_args_'], $route['controller'], $route['action']); - $route['pass'] = array_merge($route['pass'], $pass); - $route['named'] = $named; - unset($route['_args_']); - } - return $route; } + foreach ($this->defaults as $key => $val) { + if ($key[0] === '[' && preg_match('/^\[(\w+)\]$/', $key, $header)) { + if (isset($this->__headerMap[$header[1]])) { + $header = $this->__headerMap[$header[1]]; + } else { + $header = 'http_' . $header[1]; + } + $header = strtoupper($header); + + $val = (array)$val; + $h = false; + + foreach ($val as $v) { + if (env($header) === $v) { + $h = true; + } + } + if (!$h) { + return false; + } + } + } + array_shift($route); + $count = count($this->keys); + for ($i = 0; $i <= $count; $i++) { + unset($route[$i]); + } + $route['pass'] = $route['named'] = array(); + + // Assign defaults, set passed args to pass + foreach ($this->defaults as $key => $value) { + if (isset($route[$key])) { + continue; + } + if (is_integer($key)) { + $route['pass'][] = $value; + continue; + } + $route[$key] = $value; + } + + if (isset($route['_args_'])) { + list($pass, $named) = $this->parseArgs($route['_args_'], $route['controller'], $route['action']); + $route['pass'] = array_merge($route['pass'], $pass); + $route['named'] = $named; + unset($route['_args_']); + } + return $route; } /** @@ -252,9 +251,9 @@ class CakeRoute { $context = compact('controller', 'action'); $namedConfig = Router::namedConfig(); - $greedy = isset($this->options['greedyNamed']) ? $this->options['greedyNamed'] : $namedConfig['greedy']; + $greedy = $namedConfig['greedyNamed']; $rules = $namedConfig['rules']; - if (isset($this->options['named'])) { + if (!empty($this->options['named'])) { $greedy = isset($this->options['greedyNamed']) && $this->options['greedyNamed'] === true; foreach ((array)$this->options['named'] as $key => $val) { if (is_numeric($key)) { @@ -271,7 +270,7 @@ class CakeRoute { } $separatorIsPresent = strpos($param, $namedConfig['separator']) !== false; - if ((!isset($options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { + if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { list($key, $val) = explode($namedConfig['separator'], $param, 2); $hasRule = isset($rules[$key]); $passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($key, $val, $rules[$key], $context)); @@ -324,11 +323,17 @@ class CakeRoute { return false; } - $controllerMatches = !isset($rule['controller'], $context['controller']) || in_array($context['controller'], (array)$rule['controller']); + $controllerMatches = ( + !isset($rule['controller'], $context['controller']) || + in_array($context['controller'], (array)$rule['controller']) + ); if (!$controllerMatches) { return false; } - $actionMatches = !isset($rule['action'], $context['action']) || in_array($context['action'], (array)$rule['action']); + $actionMatches = ( + !isset($rule['action'], $context['action']) || + in_array($context['action'], (array)$rule['action']) + ); if (!$actionMatches) { return false; } @@ -383,7 +388,7 @@ class CakeRoute { } $namedConfig = Router::namedConfig(); - $greedyNamed = $namedConfig['greedy']; + $greedyNamed = $namedConfig['greedyNamed']; $allowedNamedParams = $namedConfig['rules']; $named = $pass = $_query = array(); diff --git a/cake/libs/router.php b/cake/libs/router.php index 0ac9338c2..db98384e2 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -102,7 +102,7 @@ class Router { */ protected static $_namedConfig = array( 'default' => array('page', 'fields', 'order', 'limit', 'recursive', 'sort', 'direction', 'step'), - 'greedy' => true, + 'greedyNamed' => true, 'separator' => ':', 'rules' => false, ); From 217938a97084655540ea869cbcb4da7c92aedbb9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 07:30:22 -0500 Subject: [PATCH 467/668] Moving pass key restructuring into CakeRoute. Adding tests for that and http header matching. --- cake/libs/route/cake_route.php | 10 ++++ .../cases/libs/route/cake_route.test.php | 49 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index 015abb42b..da29b3e26 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -233,6 +233,16 @@ class CakeRoute { $route['named'] = $named; unset($route['_args_']); } + + // restructure 'pass' key route params + if (isset($this->options['pass'])) { + $j = count($this->options['pass']); + while($j--) { + if (isset($route[$this->options['pass'][$j]])) { + array_unshift($route['pass'], $route[$this->options['pass'][$j]]); + } + } + } return $route; } diff --git a/cake/tests/cases/libs/route/cake_route.test.php b/cake/tests/cases/libs/route/cake_route.test.php index b68e05338..d70eed4e6 100644 --- a/cake/tests/cases/libs/route/cake_route.test.php +++ b/cake/tests/cases/libs/route/cake_route.test.php @@ -450,6 +450,35 @@ class CakeRouteTestCase extends CakeTestCase { $this->assertEqual($result['action'], 'index'); } +/** + * test numerically indexed defaults, get appeneded to pass + * + * @return void + */ + function testParseWithPassDefaults() { + $route = new Cakeroute('/:controller', array('action' => 'display', 'home')); + $result = $route->parse('/posts'); + $expected = array( + 'controller' => 'posts', + 'action' => 'display', + 'pass' => array('home'), + 'named' => array() + ); + $this->assertEquals($expected, $result); + } + +/** + * test that http header conditions can cause route failures. + * + * @return void + */ + function testParseWithHttpHeaderConditions() { + $_SERVER['REQUEST_METHOD'] = 'GET'; + $route = new CakeRoute('/sample', array('controller' => 'posts', 'action' => 'index', '[method]' => 'POST')); + + $this->assertFalse($route->parse('/sample')); + } + /** * test that patterns work for :action * @@ -653,4 +682,24 @@ class CakeRouteTestCase extends CakeTestCase { ); $this->assertEqual($result, $expected); } + +/** + * test restructuring args with pass key + * + * @return void + */ + function testPassArgRestructure() { + $route = new CakeRoute('/:controller/:action/:slug', array(), array( + 'pass' => array('slug') + )); + $result = $route->parse('/posts/view/my-title'); + $expected = array( + 'controller' => 'posts', + 'action' => 'view', + 'slug' => 'my-title', + 'pass' => array('my-title'), + 'named' => array() + ); + $this->assertEquals($expected, $result, 'Slug should have moved'); + } } \ No newline at end of file From 9cf940853b712b1bcd2b012b44807309b6b5ee95 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 07:32:06 -0500 Subject: [PATCH 468/668] Updating router tests to use/expect greedyNamed. Removing code that has been moved to CakeRoute or is no longer needed. --- cake/libs/router.php | 148 -------------------------- cake/tests/cases/libs/router.test.php | 13 ++- 2 files changed, 8 insertions(+), 153 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index db98384e2..08372f7c7 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -499,36 +499,7 @@ class Router { if (($r = $route->parse($url)) !== false) { self::$_currentRoute[] =& $route; - - $params = $route->options; - $argOptions = array(); - - if (array_key_exists('named', $params)) { - $argOptions['named'] = $params['named']; - unset($params['named']); - } - if (array_key_exists('greedy', $params)) { - $argOptions['greedy'] = $params['greedy']; - unset($params['greedy']); - } $out = $r; - - if (isset($out['_args_'])) { - $argOptions['context'] = array('action' => $out['action'], 'controller' => $out['controller']); - $parsedArgs = self::getArgs($out['_args_'], $argOptions); - $out['pass'] = array_merge($out['pass'], $parsedArgs['pass']); - $out['named'] = $parsedArgs['named']; - unset($out['_args_']); - } - - if (isset($params['pass'])) { - $j = count($params['pass']); - while($j--) { - if (isset($out[$params['pass'][$j]])) { - array_unshift($out['pass'], $out[$params['pass'][$j]]); - } - } - } break; } } @@ -997,61 +968,6 @@ class Router { return $output; } -/** - * Takes an array of URL parameters and separates the ones that can be used as named arguments - * - * @param array $params Associative array of URL parameters. - * @param string $controller Name of controller being routed. Used in scoping. - * @param string $action Name of action being routed. Used in scoping. - * @return array - */ - public static function getNamedElements($params, $controller = null, $action = null) { - $named = array(); - - foreach ($params as $param => $val) { - if (isset(self::$_namedConfig['rules'][$param])) { - $rule = self::$_namedConfig['rules'][$param]; - if (Router::matchNamed($param, $val, $rule, compact('controller', 'action'))) { - $named[substr($param, 1)] = $val; - unset($params[$param]); - } - } - } - return array($named, $params); - } - -/** - * Return true if a given named $param's $val matches a given $rule depending on $context. Currently implemented - * rule types are controller, action and match that can be combined with each other. - * - * @param string $param The name of the named parameter - * @param string $val The value of the named parameter - * @param array $rule The rule(s) to apply, can also be a match string - * @param string $context An array with additional context information (controller / action) - * @return boolean - */ - public static function matchNamed($param, $val, $rule, $context = array()) { - if ($rule === true || $rule === false) { - return $rule; - } - if (is_string($rule)) { - $rule = array('match' => $rule); - } - if (!is_array($rule)) { - return false; - } - - $controllerMatches = !isset($rule['controller'], $context['controller']) || in_array($context['controller'], (array)$rule['controller']); - if (!$controllerMatches) { - return false; - } - $actionMatches = !isset($rule['action'], $context['action']) || in_array($context['action'], (array)$rule['action']); - if (!$actionMatches) { - return false; - } - return (!isset($rule['match']) || preg_match('/' . $rule['match'] . '/', $val)); - } - /** * Generates a well-formed querystring from $q * @@ -1218,70 +1134,6 @@ class Router { return self::$_validExtensions; } -/** - * Takes a passed params and converts it to args - * - * @param array $params - * @return array Array containing passed and named parameters - */ - public static function getArgs($args, $options = array()) { - $pass = $named = array(); - $args = explode('/', $args); - - $greedy = isset($options['greedy']) ? $options['greedy'] : self::$_namedConfig['greedy']; - $context = array(); - if (isset($options['context'])) { - $context = $options['context']; - } - $rules = self::$_namedConfig['rules']; - if (isset($options['named'])) { - $greedy = isset($options['greedy']) && $options['greedy'] === true; - foreach ((array)$options['named'] as $key => $val) { - if (is_numeric($key)) { - $rules[$val] = true; - continue; - } - $rules[$key] = $val; - } - } - - foreach ($args as $param) { - if (empty($param) && $param !== '0' && $param !== 0) { - continue; - } - - $separatorIsPresent = strpos($param, self::$_namedConfig['separator']) !== false; - if ((!isset($options['named']) || !empty($options['named'])) && $separatorIsPresent) { - list($key, $val) = explode(self::$_namedConfig['separator'], $param, 2); - $hasRule = isset($rules[$key]); - $passIt = (!$hasRule && !$greedy) || ($hasRule && !self::matchNamed($key, $val, $rules[$key], $context)); - if ($passIt) { - $pass[] = $param; - } else { - if (preg_match_all('/\[([A-Za-z0-9_-]+)?\]/', $key, $matches, PREG_SET_ORDER)) { - $matches = array_reverse($matches); - $parts = explode('[', $key); - $key = array_shift($parts); - $arr = $val; - foreach ($matches as $match) { - if (empty($match[1])) { - $arr = array($arr); - } else { - $arr = array( - $match[1] => $arr - ); - } - } - $val = $arr; - } - $named = array_merge_recursive($named, array($key => $val)); - } - } else { - $pass[] = $param; - } - } - return compact('pass', 'named'); - } } //Save the initial state diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index f194b4a35..9a4ce30d7 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -436,6 +436,7 @@ class RouterTest extends CakeTestCase { $expected = '/tests/index/namedParam[keyed]:is an array/namedParam[0]:test'; $this->assertEqual($result, $expected); + //@todo Delete from here down, tests are in CakeRoute now. $result = Router::parse('/tests/action/var[]:val1/var[]:val2'); $expected = array( 'controller' => 'tests', @@ -1017,7 +1018,7 @@ class RouterTest extends CakeTestCase { $this->assertEqual($result, $expected); Router::reload(); - Router::connect('/posts/view/*', array('controller' => 'posts', 'action' => 'view'), array('named' => array('foo', 'answer'), 'greedy' => true)); + Router::connect('/posts/view/*', array('controller' => 'posts', 'action' => 'view'), array('named' => array('foo', 'answer'), 'greedyNamed' => true)); $result = Router::parse('/posts/view/foo:bar/routing:fun/answer:42'); $expected = array('pass' => array(), 'named' => array('foo' => 'bar', 'routing' => 'fun', 'answer' => '42'), 'plugin' => null, 'controller' => 'posts', 'action' => 'view'); $this->assertEqual($result, $expected); @@ -1328,7 +1329,7 @@ class RouterTest extends CakeTestCase { */ function testConnectNamed() { $named = Router::connectNamed(false, array('default' => true)); - $this->assertFalse($named['greedy']); + $this->assertFalse($named['greedyNamed']); $this->assertEqual(array_keys($named['rules']), $named['default']); Router::reload(); @@ -1429,7 +1430,7 @@ class RouterTest extends CakeTestCase { Router::reload(); $result = Router::connectNamed(false); $this->assertEqual(array_keys($result['rules']), array()); - $this->assertFalse($result['greedy']); + $this->assertFalse($result['greedyNamed']); $result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value'); $expected = array('pass' => array('param1:value1:1', 'param2:value2:3', 'param:value'), 'named' => array(), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); $this->assertEqual($result, $expected); @@ -1438,15 +1439,16 @@ class RouterTest extends CakeTestCase { $result = Router::connectNamed(true); $named = Router::namedConfig(); $this->assertEqual(array_keys($result['rules']), $named['default']); - $this->assertTrue($result['greedy']); + $this->assertTrue($result['greedyNamed']); Router::reload(); Router::connectNamed(array('param1' => 'not-matching')); $result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value'); $expected = array('pass' => array('param1:value1:1'), 'named' => array('param2' => 'value2:3', 'param' => 'value'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); $this->assertEqual($result, $expected); + //@todo delete this test. Router::reload(); - Router::connect('/foo/:action/*', array('controller' => 'bar'), array('named' => array('param1' => array('action' => 'index')), 'greedy' => true)); + Router::connect('/foo/:action/*', array('controller' => 'bar'), array('named' => array('param1' => array('action' => 'index')), 'greedyNamed' => true)); $result = Router::parse('/foo/index/param1:value1:1/param2:value2:3/param:value'); $expected = array('pass' => array(), 'named' => array('param1' => 'value1:1', 'param2' => 'value2:3', 'param' => 'value'), 'controller' => 'bar', 'action' => 'index', 'plugin' => null); $this->assertEqual($result, $expected); @@ -1473,6 +1475,7 @@ class RouterTest extends CakeTestCase { $expected = array('pass' => array('param2:value2:3', 'param3:value'), 'named' => array('param1' => 'value1:1'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); $this->assertEqual($result, $expected); + //@todo delete this test. Router::reload(); Router::connect('/foo/*', array('controller' => 'bar', 'action' => 'fubar'), array('named' => array('param1' => 'value[\d]:[\d]'))); Router::connectNamed(array(), array('greedy' => false)); From 2e76d32cf9312ff9bc502e492cb092493fcdb477 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 20:46:43 -0500 Subject: [PATCH 469/668] Fixing transposition of parameters to setLastError. Fixes #1570 --- cake/libs/cake_socket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/cake_socket.php b/cake/libs/cake_socket.php index e55eb8004..9b5af2ecc 100644 --- a/cake/libs/cake_socket.php +++ b/cake/libs/cake_socket.php @@ -122,7 +122,7 @@ class CakeSocket extends Object { } if (!empty($errNum) || !empty($errStr)) { - $this->setLastError($errStr, $errNum); + $this->setLastError($errNum, $errStr); } $this->connected = is_resource($this->connection); From b8aa78ce9f8f0534bb414d8ee1ff623da8a6b6e1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 21:16:43 -0500 Subject: [PATCH 470/668] Making a method protected, it doesn't need to public really. --- cake/libs/route/cake_route.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index da29b3e26..e260f122b 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -228,7 +228,7 @@ class CakeRoute { } if (isset($route['_args_'])) { - list($pass, $named) = $this->parseArgs($route['_args_'], $route['controller'], $route['action']); + list($pass, $named) = $this->_parseArgs($route['_args_'], $route['controller'], $route['action']); $route['pass'] = array_merge($route['pass'], $pass); $route['named'] = $named; unset($route['_args_']); @@ -255,7 +255,7 @@ class CakeRoute { * @param string $action The current action name, used to match named parameter rules. * @return array Array of ($pass, $named) */ - public function parseArgs($args, $controller = null, $action = null) { + protected function _parseArgs($args, $controller = null, $action = null) { $pass = $named = array(); $args = explode('/', $args); From 0d3288bab0d183b3d707968ac942f51519532f33 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 3 Mar 2011 21:18:35 -0500 Subject: [PATCH 471/668] Refactoring protected methods. --- cake/libs/route/cake_route.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cake/libs/route/cake_route.php b/cake/libs/route/cake_route.php index e260f122b..c40c84e18 100644 --- a/cake/libs/route/cake_route.php +++ b/cake/libs/route/cake_route.php @@ -228,7 +228,7 @@ class CakeRoute { } if (isset($route['_args_'])) { - list($pass, $named) = $this->_parseArgs($route['_args_'], $route['controller'], $route['action']); + list($pass, $named) = $this->_parseArgs($route['_args_'], $route); $route['pass'] = array_merge($route['pass'], $pass); $route['named'] = $named; unset($route['_args_']); @@ -251,15 +251,13 @@ class CakeRoute { * The local and global configuration for named parameters will be used. * * @param string $args A string with the passed & named params. eg. /1/page:2 - * @param string $controller The current actions controller name, used to match named parameter rules - * @param string $action The current action name, used to match named parameter rules. + * @param string $context The current route context, which should contain controller/action keys. * @return array Array of ($pass, $named) */ - protected function _parseArgs($args, $controller = null, $action = null) { + protected function _parseArgs($args, $context) { $pass = $named = array(); $args = explode('/', $args); - $context = compact('controller', 'action'); $namedConfig = Router::namedConfig(); $greedy = $namedConfig['greedyNamed']; $rules = $namedConfig['rules']; From 3ee49c0c5cd3a8ec499cccc3f8c1295a2be7af91 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 5 Mar 2011 17:37:09 -0430 Subject: [PATCH 472/668] Moving BaseAuthenticate class --- .../Auth/{basic_authenticate.php => BasicAuthenticate.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/Cake/Controller/Component/Auth/{basic_authenticate.php => BasicAuthenticate.php} (100%) diff --git a/lib/Cake/Controller/Component/Auth/basic_authenticate.php b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php similarity index 100% rename from lib/Cake/Controller/Component/Auth/basic_authenticate.php rename to lib/Cake/Controller/Component/Auth/BasicAuthenticate.php From f1e2f5e949bde7c6b65b52e39bce1b55bee953d3 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 5 Mar 2011 17:40:42 -0430 Subject: [PATCH 473/668] Starting to migrate AuthComponent to the new class loader --- .../Controller/Component/Auth/ActionsAuthorize.php | 3 ++- .../Controller/Component/Auth/BaseAuthenticate.php | 3 ++- .../Controller/Component/Auth/BasicAuthenticate.php | 3 ++- .../Controller/Component/Auth/ControllerAuthorize.php | 3 ++- lib/Cake/Controller/Component/Auth/CrudAuthorize.php | 3 ++- .../Controller/Component/Auth/DigestAuthenticate.php | 3 ++- .../Controller/Component/Auth/FormAuthenticate.php | 3 ++- lib/Cake/Controller/Component/AuthComponent.php | 8 ++++++-- lib/Cake/Core/App.php | 2 +- .../cases/libs/controller/components/acl.test.php | 7 ++++--- .../cases/libs/controller/components/auth.test.php | 11 ++--------- 11 files changed, 27 insertions(+), 22 deletions(-) diff --git a/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php b/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php index c2f1f35d2..684fb47a0 100644 --- a/lib/Cake/Controller/Component/Auth/ActionsAuthorize.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/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php index 1cfcc8896..aba2a8328 100644 --- a/lib/Cake/Controller/Component/Auth/BaseAuthenticate.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/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php index 2ba467e98..b2dc5d2d0 100644 --- a/lib/Cake/Controller/Component/Auth/BasicAuthenticate.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('BaseAuthorize', 'Controller/Component/Auth'); /** * Basic Authentication adapter for AuthComponent. diff --git a/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php b/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php index 8fd66b10d..275cf6875 100644 --- a/lib/Cake/Controller/Component/Auth/ControllerAuthorize.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/lib/Cake/Controller/Component/Auth/CrudAuthorize.php b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php index be127f43a..51cfa7cda 100644 --- a/lib/Cake/Controller/Component/Auth/CrudAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/CrudAuthorize.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 CRUD mappings. diff --git a/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php b/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php index c27f293c0..69c3ae228 100644 --- a/lib/Cake/Controller/Component/Auth/DigestAuthenticate.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/lib/Cake/Controller/Component/Auth/FormAuthenticate.php b/lib/Cake/Controller/Component/Auth/FormAuthenticate.php index d24d9acf2..f0f708088 100644 --- a/lib/Cake/Controller/Component/Auth/FormAuthenticate.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/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 10e9bcdef..06278ed72 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -407,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')) { @@ -645,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/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 36cdd31fc..03c543c6e 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -425,7 +425,7 @@ class App { public static function objects($type, $path = null, $cache = true) { $objects = array(); $extension = '/\.php$/'; - $directories = false; + $includeDirectories = false; $name = $type; if (isset(self::$legacy[$type . 's'])) { diff --git a/lib/Cake/tests/cases/libs/controller/components/acl.test.php b/lib/Cake/tests/cases/libs/controller/components/acl.test.php index c7a4ecd70..102a040d4 100644 --- a/lib/Cake/tests/cases/libs/controller/components/acl.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/acl.test.php @@ -16,9 +16,10 @@ * @since CakePHP(tm) v 1.2.0.5435 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('AclComponent', 'Component'); -App::uses('DbAcl', 'Model'); - + +App::uses('AclComponent', 'Controller/Component'); +App::uses('AclNode', 'Model'); +class_exists('AclComponent'); /** * AclNodeTwoTestBase class diff --git a/lib/Cake/tests/cases/libs/controller/components/auth.test.php b/lib/Cake/tests/cases/libs/controller/components/auth.test.php index 0c47bdc62..9fb68b078 100644 --- a/lib/Cake/tests/cases/libs/controller/components/auth.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/auth.test.php @@ -332,15 +332,11 @@ class AuthTest extends CakeTestCase { $this->Controller = new AuthTestController($request); -<<<<<<< HEAD - ClassRegistry::addObject('view', new View($this->Controller)); -======= $collection = new ComponentCollection(); $collection->init($this->Controller); $this->Auth = new TestAuthComponent($collection); $this->Auth->request = $request; $this->Auth->response = $this->getMock('CakeResponse'); ->>>>>>> origin/2.0 $this->Controller->Components->init($this->Controller); @@ -935,7 +931,6 @@ class AuthTest extends CakeTestCase { } /** -<<<<<<< HEAD * testPluginModel method * * @access public @@ -946,7 +941,7 @@ class AuthTest extends CakeTestCase { Cache::delete('object_map', '_cake_core_'); App::build(array( 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), - 'models' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS) + 'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS) ), true); App::objects('plugin', null, false); @@ -996,8 +991,6 @@ class AuthTest extends CakeTestCase { } /** -======= ->>>>>>> origin/2.0 * testAjaxLogin method * * @access public @@ -1005,7 +998,7 @@ class AuthTest extends CakeTestCase { */ function testAjaxLogin() { App::build(array( - 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) + 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); $_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest"; From f844283463dd3890e82cc117f8d62312fbbb1b2c Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 5 Mar 2011 17:45:52 -0430 Subject: [PATCH 474/668] Updating test case with a bad merge to match the original one in branch 2.0 --- .../libs/controller/components/auth.test.php | 62 +------------------ 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/lib/Cake/tests/cases/libs/controller/components/auth.test.php b/lib/Cake/tests/cases/libs/controller/components/auth.test.php index 9fb68b078..e894e32ea 100644 --- a/lib/Cake/tests/cases/libs/controller/components/auth.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/auth.test.php @@ -44,7 +44,7 @@ class TestAuthComponent extends AuthComponent { * @access public * @return void */ - function _stop() { + function _stop($status = 0) { $this->testStop = true; } @@ -930,66 +930,6 @@ class AuthTest extends CakeTestCase { Configure::write('Routing.prefixes', $prefixes); } -/** - * testPluginModel method - * - * @access public - * @return void - */ - function testPluginModel() { - // Adding plugins - Cache::delete('object_map', '_cake_core_'); - App::build(array( - 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), - 'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS) - ), true); - App::objects('plugin', null, false); - - $PluginModel = ClassRegistry::init('TestPlugin.TestPluginAuthUser'); - $user['id'] = 1; - $user['username'] = 'gwoo'; - $user['password'] = Security::hash(Configure::read('Security.salt') . 'cake'); - $PluginModel->save($user, false); - - $authUser = $PluginModel->find(); - - $this->Controller->request->data['TestPluginAuthUser'] = array( - 'username' => $authUser['TestPluginAuthUser']['username'], 'password' => 'cake' - ); - - $this->Controller->request->addParams(Router::parse('auth_test/login')); - $this->Controller->request->query['url'] = 'auth_test/login'; - - $this->Controller->Auth->initialize($this->Controller); - - $this->Controller->Auth->loginAction = 'auth_test/login'; - $this->Controller->Auth->userModel = 'TestPlugin.TestPluginAuthUser'; - - $this->Controller->Auth->startup($this->Controller); - $user = $this->Controller->Auth->user(); - $expected = array('TestPluginAuthUser' => array( - 'id' => 1, 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23', 'updated' => date('Y-m-d H:i:s') - )); - $this->assertEqual($user, $expected); - $sessionKey = $this->Controller->Auth->sessionKey; - $this->assertEqual('Auth.TestPluginAuthUser', $sessionKey); - - $this->Controller->Auth->loginAction = null; - $this->Controller->Auth->__setDefaults(); - $loginAction = $this->Controller->Auth->loginAction; - $expected = array( - 'controller' => 'test_plugin_auth_users', - 'action' => 'login', - 'plugin' => 'test_plugin' - ); - $this->assertEqual($loginAction, $expected); - - // Reverting changes - Cache::delete('object_map', '_cake_core_'); - App::build(); - App::objects('plugin', null, false); - } - /** * testAjaxLogin method * From cacbab168ad0dd46b5d86cb05747a0119118d697 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 5 Mar 2011 17:54:42 -0430 Subject: [PATCH 475/668] Fixing som package location in AuthComponent --- lib/Cake/Controller/Component/AuthComponent.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 06278ed72..c4927be0f 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -25,8 +25,8 @@ App::uses('Router', 'Routing'); App::uses('Security', 'Utility'); App::uses('Debugger', 'Utility'); App::uses('CakeSession', 'Model/Datasource'); -App::uses('BaseAuthorize', 'Component/Auth'); -App::uses('BaseAuthenticate', 'Component/Auth'); +App::uses('BaseAuthorize', 'Controller/Component/Auth'); +App::uses('BaseAuthenticate', 'Controller/Component/Auth'); /** * Authentication control component class From 98c8cda6f51724e62d6d487699a89002106195df Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 5 Mar 2011 19:22:06 -0430 Subject: [PATCH 476/668] Fixing FormAuthenticate test --- .../components/auth/form_authenticate.test.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/form_authenticate.test.php index 7e99b3b7b..cc0e22bd1 100644 --- a/lib/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); From 6d96c38cd397733b9dd3fc4267386c50d4c41e15 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 5 Mar 2011 19:25:33 -0430 Subject: [PATCH 477/668] Fixing DigestAuthenticate Test --- .../components/auth/digest_authenticate.test.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/Cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/digest_authenticate.test.php index 5d81c0bf1..829d5bda6 100644 --- a/lib/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'; From ec8577a562873446e88045fb2127ec510a4fd607 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 5 Mar 2011 19:30:05 -0430 Subject: [PATCH 478/668] Fixing CrudAuthorize test --- lib/Cake/Controller/Component/Auth/CrudAuthorize.php | 1 + .../components/auth/crud_authorize.test.php | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Cake/Controller/Component/Auth/CrudAuthorize.php b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php index 51cfa7cda..b9fa8329c 100644 --- a/lib/Cake/Controller/Component/Auth/CrudAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php @@ -14,6 +14,7 @@ */ 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/lib/Cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/crud_authorize.test.php index a78fb71ec..853b01e32 100644 --- a/lib/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 { From 6b46c5cd17101dc232d3eb1b0a026ceedd81e4e8 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 5 Mar 2011 19:33:36 -0430 Subject: [PATCH 479/668] Fixing ControllerAuthorize test --- .../components/auth/controller_authorize.test.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/controller_authorize.test.php index a3f687f0d..09ef5c6f8 100644 --- a/lib/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 { From 0696dd920054e561678ba10fd26961529d9d4db8 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 5 Mar 2011 19:37:56 -0430 Subject: [PATCH 480/668] Fixing BasicAuthenticate test --- .../Controller/Component/Auth/BasicAuthenticate.php | 2 +- .../components/auth/basic_authenticate.test.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php index b2dc5d2d0..148734629 100644 --- a/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php +++ b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php @@ -13,7 +13,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('BaseAuthorize', 'Controller/Component/Auth'); +App::uses('BaseAuthenticate', 'Controller/Component/Auth'); /** * Basic Authentication adapter for AuthComponent. diff --git a/lib/Cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/basic_authenticate.test.php index f310faac5..6e0c9df57 100644 --- a/lib/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'; From 13e9a9ef7cb72cc7b74f6caf53e4259d691dc7d3 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 5 Mar 2011 19:41:33 -0430 Subject: [PATCH 481/668] Fixing ActionsAuthorize test --- .../components/auth/actions_authorize.test.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php b/lib/Cake/tests/cases/libs/controller/components/auth/actions_authorize.test.php index 242606416..d4d967214 100644 --- a/lib/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 { From 3ff41b4f56020a7c6f8c3c0a6e09f47851d51a98 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sun, 6 Mar 2011 00:08:49 -0430 Subject: [PATCH 482/668] Fixing problem in cache helper test --- lib/Cake/tests/cases/libs/view/helpers/cache.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/libs/view/helpers/cache.test.php b/lib/Cake/tests/cases/libs/view/helpers/cache.test.php index 108585059..9fee782c9 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/cache.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/cache.test.php @@ -83,7 +83,7 @@ class CacheHelperTest extends CakeTestCase { Configure::write('Cache.check', true); Configure::write('Cache.disable', false); App::build(array( - 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) + 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) ), true); } From eb709123a86efc43ed82bdb94dc50cf5e228deaf Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sun, 6 Mar 2011 00:20:50 -0430 Subject: [PATCH 483/668] Canging view package location form email component test --- lib/Cake/tests/cases/libs/controller/components/email.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/libs/controller/components/email.test.php b/lib/Cake/tests/cases/libs/controller/components/email.test.php index 788378467..a3b1bd358 100755 --- a/lib/Cake/tests/cases/libs/controller/components/email.test.php +++ b/lib/Cake/tests/cases/libs/controller/components/email.test.php @@ -255,7 +255,7 @@ class EmailComponentTest extends CakeTestCase { ClassRegistry::addObject('view', new View($this->Controller)); App::build(array( - 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) + 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); } From b286ff052322d37d3b6e0ae4054b5468c62ca1d0 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sun, 6 Mar 2011 00:26:31 -0430 Subject: [PATCH 484/668] Fixing cache engine tests --- lib/Cake/tests/cases/libs/cache/apc.test.php | 5 ++--- lib/Cake/tests/cases/libs/cache/file.test.php | 5 ++--- lib/Cake/tests/cases/libs/cache/memcache.test.php | 7 +++---- lib/Cake/tests/cases/libs/cache/xcache.test.php | 5 ++--- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/Cake/tests/cases/libs/cache/apc.test.php b/lib/Cake/tests/cases/libs/cache/apc.test.php index 0abd07778..28043b908 100644 --- a/lib/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/lib/Cake/tests/cases/libs/cache/file.test.php b/lib/Cake/tests/cases/libs/cache/file.test.php index fb6741a7a..50d20181e 100644 --- a/lib/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/lib/Cake/tests/cases/libs/cache/memcache.test.php b/lib/Cake/tests/cases/libs/cache/memcache.test.php index 61bcec550..ada9c52bc 100644 --- a/lib/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/lib/Cake/tests/cases/libs/cache/xcache.test.php b/lib/Cake/tests/cases/libs/cache/xcache.test.php index eea1c4b2c..5788118c3 100644 --- a/lib/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 From ff31792e8dfc93c13097e97a95c38c83c923469d Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Mon, 7 Mar 2011 00:34:36 -0430 Subject: [PATCH 485/668] Fixing paths in test.php file --- app/webroot/test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/webroot/test.php b/app/webroot/test.php index 5b667a0ff..deef49aa5 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -49,7 +49,7 @@ ini_set('display_errors', 1); * */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT . DS .'lib'); + define('CAKE_CORE_INCLUDE_PATH', ROOT); } /** @@ -65,7 +65,7 @@ if (!defined('WWW_ROOT')) { } if (!defined('CORE_PATH')) { define('APP_PATH', ROOT . DS . APP_DIR . DS); - define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); + define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS . 'lib' . DS); } 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); From 2ef02ba29b95f4cba63829a4ec37574dcb9ff029 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Mon, 7 Mar 2011 00:45:00 -0430 Subject: [PATCH 486/668] Starting to move all console related classes, ViewTask tests passing --- app/console/{shells => }/templates/empty | 0 lib/Cake/Console/Command/Task/TemplateTask.php | 4 ++-- lib/Cake/Console/Command/Task/ViewTask.php | 4 ++-- lib/Cake/Console/TaskCollection.php | 2 +- lib/Cake/Core/App.php | 12 ++++++++++-- .../cases/console/libs/task_collection.test.php | 2 +- .../tests/cases/console/shells/tasks/view.test.php | 4 ++++ 7 files changed, 20 insertions(+), 8 deletions(-) rename app/console/{shells => }/templates/empty (100%) 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/lib/Cake/Console/Command/Task/TemplateTask.php b/lib/Cake/Console/Command/Task/TemplateTask.php index cdf308868..34c122ed9 100644 --- a/lib/Cake/Console/Command/Task/TemplateTask.php +++ b/lib/Cake/Console/Command/Task/TemplateTask.php @@ -54,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/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index 6483312fd..c69813320 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -147,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)) { @@ -277,7 +277,7 @@ class ViewTask extends BakeTask { } $controllerClassName = $this->controllerName . 'Controller'; - App::uses($controllerName, $plugin . '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)); diff --git a/lib/Cake/Console/TaskCollection.php b/lib/Cake/Console/TaskCollection.php index 4a8513890..3c911a2ce 100644 --- a/lib/Cake/Console/TaskCollection.php +++ b/lib/Cake/Console/TaskCollection.php @@ -60,7 +60,7 @@ class TaskCollection extends ObjectCollection { } $taskFile = Inflector::underscore($name); $taskClass = $name . 'Task'; - App::uses($taskClass, 'Console/Command/Task'); + App::uses($taskClass, $plugin . 'Console/Command/Task'); if (!class_exists($taskClass)) { if (!class_exists($taskClass)) { throw new MissingTaskClassException($taskClass); diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 03c543c6e..88b68668a 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -302,13 +302,21 @@ class App { '%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 + ), 'libs' => array('%s' . 'libs' . DS), 'locales' => array('%s' . 'locale' . DS), 'vendors' => array('%s' . 'vendors' . DS, VENDORS), 'plugins' => array(APP . 'plugins' . DS) ); - - self::$__packageFormat['Console/Command'] = self::$__packageFormat['Console']; } if ($reset == true) { diff --git a/lib/Cake/tests/cases/console/libs/task_collection.test.php b/lib/Cake/tests/cases/console/libs/task_collection.test.php index 7ed3f7822..bb961736f 100644 --- a/lib/Cake/tests/cases/console/libs/task_collection.test.php +++ b/lib/Cake/tests/cases/console/libs/task_collection.test.php @@ -72,7 +72,7 @@ class TaskCollectionTest extends CakeTestCase { /** * test missinghelper exception * - * @expectedException MissingTaskFileException + * @expectedException MissingTaskClassException * @return void */ function testLoadMissingTaskFile() { diff --git a/lib/Cake/tests/cases/console/shells/tasks/view.test.php b/lib/Cake/tests/cases/console/shells/tasks/view.test.php index 56fb5c977..b41cdd233 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/view.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/view.test.php @@ -20,12 +20,16 @@ */ 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 From d4b07b6c27268e33238400e42b05655933048f29 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Mon, 7 Mar 2011 00:57:21 -0430 Subject: [PATCH 487/668] Making TestTask test pass --- .../tests/cases/console/shells/tasks/test.test.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Cake/tests/cases/console/shells/tasks/test.test.php b/lib/Cake/tests/cases/console/shells/tasks/test.test.php index 9e2f2a4dd..3de416b8e 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/test.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/test.test.php @@ -20,6 +20,8 @@ */ 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'); @@ -371,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; } @@ -536,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( @@ -556,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(); } From 0be09cbfb3e766ac3f310a67743bc818d99767e4 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Mon, 7 Mar 2011 01:01:45 -0430 Subject: [PATCH 488/668] Fixing TemplateTask test --- .../tests/cases/console/shells/tasks/template.test.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Cake/tests/cases/console/shells/tasks/template.test.php b/lib/Cake/tests/cases/console/shells/tasks/template.test.php index e0e4c8ba9..693637fb4 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/template.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/template.test.php @@ -21,6 +21,8 @@ */ App::uses('ShellDispatcher', 'Console'); +App::uses('ConsoleOutput', 'Console'); +App::uses('ConsoleInput', 'Console'); App::uses('Shell', 'Console'); App::uses('TemplateTask', 'Console/Command/Task'); /** @@ -85,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); } @@ -97,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')); @@ -123,7 +125,7 @@ class TemplateTaskTest extends CakeTestCase { */ public function testGenerate() { App::build(array( - 'shells' => array( + 'Console' => array( LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS ) )); @@ -143,7 +145,7 @@ class TemplateTaskTest extends CakeTestCase { */ public function testGenerateWithTemplateFallbacks() { App::build(array( - 'shells' => array( + 'Console' => array( LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS, CAKE_CORE_INCLUDE_PATH . DS . 'console' . DS ) From a56c4bff773f9708f981a50bbf4cf3be8eb8213c Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Mon, 7 Mar 2011 01:25:05 -0430 Subject: [PATCH 489/668] Fxing ProjectTask tests --- lib/Cake/Console/Command/Task/ProjectTask.php | 5 ++--- lib/Cake/Console/templates/skel/console/cake.php | 3 +-- lib/Cake/Console/templates/skel/webroot/test.php | 2 +- lib/Cake/tests/cases/console/shells/tasks/project.test.php | 7 +++++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index 46dd01bfe..4503f276f 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -19,6 +19,8 @@ */ App::uses('File', 'Utility'); +App::uses('String', 'Utility'); +App::uses('Security', 'Utility'); /** * Task class for creating new project apps and plugins @@ -237,9 +239,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)) { diff --git a/lib/Cake/Console/templates/skel/console/cake.php b/lib/Cake/Console/templates/skel/console/cake.php index 9616b97b8..d4f4ef1c0 100644 --- a/lib/Cake/Console/templates/skel/console/cake.php +++ b/lib/Cake/Console/templates/skel/console/cake.php @@ -19,7 +19,6 @@ * @since CakePHP(tm) v 1.2.0.5012 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR. 'ShellDispatcher.php'); +require_once(__CAKE_PATH__ . 'shell_dispatcher.php'); return ShellDispatcher::run($argv); - diff --git a/lib/Cake/Console/templates/skel/webroot/test.php b/lib/Cake/Console/templates/skel/webroot/test.php index 5b667a0ff..cb9180331 100644 --- a/lib/Cake/Console/templates/skel/webroot/test.php +++ b/lib/Cake/Console/templates/skel/webroot/test.php @@ -49,7 +49,7 @@ ini_set('display_errors', 1); * */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT . DS .'lib'); + define('CAKE_CORE_INCLUDE_PATH', ROOT); } /** diff --git a/lib/Cake/tests/cases/console/shells/tasks/project.test.php b/lib/Cake/tests/cases/console/shells/tasks/project.test.php index c3f349524..9816b145a 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/project.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/project.test.php @@ -20,8 +20,11 @@ */ App::uses('ShellDispatcher', 'Console'); +App::uses('ConsoleOutput', 'Console'); +App::uses('ConsoleInput', 'Console'); App::uses('Shell', 'Console'); -App::uses('ProjecTask', 'Console/Command/Task'); +App::uses('ProjectTask', 'Console/Command/Task'); +App::uses('Folder', 'Utility'); App::uses('File', 'Utility'); /** @@ -67,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); } From de57802f05fc50577724e77f32fad887058c2129 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 7 Mar 2011 21:50:53 -0500 Subject: [PATCH 490/668] Fixing left over action from previos refactoring of viewClass/view. --- cake/libs/view/view.php | 2 +- cake/tests/cases/libs/view/view.test.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 7939aa910..89d5ae5d5 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -680,7 +680,7 @@ class View extends Object { } if ($name === null) { - $name = $this->action; + $name = $this->view; } $name = str_replace('/', DS, $name); diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 2b6417e5a..74058c3db 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -701,6 +701,20 @@ class ViewTest extends CakeTestCase { $this->assertPattern("/
    posts index<\/div>/", $result); } +/** + * test that View::$view works + * + * @return void + */ + function testRenderUsingViewProperty() { + $this->PostsController->view = 'cache_form'; + $View = new TestView($this->PostsController); + + $this->assertEquals('cache_form', $View->view); + $result = $View->render(); + $this->assertRegExp('/Add User/', $result); + } + /** * test that view vars can replace the local helper variables * and not overwrite the $this->Helper references From 7853189328b16cdf0ce646799aa1364407744f05 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 7 Mar 2011 21:58:11 -0500 Subject: [PATCH 491/668] Adding 'style' as a known html attribute. Fixes #1573 --- cake/libs/view/helpers/js.php | 5 ++++- cake/tests/cases/libs/view/helpers/js.test.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cake/libs/view/helpers/js.php b/cake/libs/view/helpers/js.php index 5c3571bef..8ecb5c5bc 100644 --- a/cake/libs/view/helpers/js.php +++ b/cake/libs/view/helpers/js.php @@ -428,7 +428,10 @@ class JsHelper extends AppHelper { * @access protected */ function _getHtmlOptions($options, $additional = array()) { - $htmlKeys = array_merge(array('class', 'id', 'escape', 'onblur', 'onfocus', 'rel', 'title'), $additional); + $htmlKeys = array_merge( + array('class', 'id', 'escape', 'onblur', 'onfocus', 'rel', 'title', 'style'), + $additional + ); $htmlOptions = array(); foreach ($htmlKeys as $key) { if (isset($options[$key])) { diff --git a/cake/tests/cases/libs/view/helpers/js.test.php b/cake/tests/cases/libs/view/helpers/js.test.php index b4dfecb60..dd8b279e5 100644 --- a/cake/tests/cases/libs/view/helpers/js.test.php +++ b/cake/tests/cases/libs/view/helpers/js.test.php @@ -402,7 +402,7 @@ CODE; function testSubmitWithMock() { $this->_useMock(); - $options = array('update' => '#content', 'id' => 'test-submit'); + $options = array('update' => '#content', 'id' => 'test-submit', 'style' => 'margin: 0'); $this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'serialize-code', array('serializeform', '*')); $this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'serialize-code', array('serializeForm', '*')); $this->Js->TestJsEngine->setReturnValue('dispatchMethod', 'ajax-code', array('request', '*')); @@ -422,7 +422,7 @@ CODE; $result = $this->Js->submit('Save', $options); $expected = array( 'div' => array('class' => 'submit'), - 'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save'), + 'input' => array('type' => 'submit', 'id' => $options['id'], 'value' => 'Save', 'style' => 'margin: 0'), '/div' ); $this->assertTags($result, $expected); From e2b37d8ec92fbf01f79b42576479b6cc19f72c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hallet?= Date: Mon, 28 Feb 2011 11:54:54 +0100 Subject: [PATCH 492/668] Allow to disable cache gc. By using a falsey value for probability you can disable cache gc calls. --- cake/libs/cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/cache.php b/cake/libs/cache.php index 3164b5ec9..922dc9e60 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -149,7 +149,7 @@ class Cache { $cacheClass = $class . 'Engine'; $this->_engines[$name] =& new $cacheClass(); if ($this->_engines[$name]->init($config)) { - if (time() % $this->_engines[$name]->settings['probability'] === 0) { + if ($this->_engines[$name]->settings['probability'] && time() % $this->_engines[$name]->settings['probability'] === 0) { $this->_engines[$name]->gc(); } return true; From 5bb173013eb9455b8091bdbe38d5542d24b551e5 Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 7 Mar 2011 22:17:52 -0500 Subject: [PATCH 493/668] Adding doc block info for Cache::config. --- cake/libs/cache.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cake/libs/cache.php b/cake/libs/cache.php index 922dc9e60..44b3d9538 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -89,6 +89,21 @@ class Cache { * * `Cache::config('default');` * + * The following keys are used in core cache engines: + * + * - `duration` Specify how long items in this cache configuration last. + * - `prefix` Prefix appended to all entries. Good for when you need to share a keyspace + * with either another cache config or annother application. + * - `probability` Probability of hitting a cache gc cleanup. Setting to 0 will disable + * cache::gc from ever being called automatically. + * - `servers' Used by memcache. Give the address of the memcached servers to use. + * - `compress` Used by memcache. Enables memcache's compressed format. + * - `serialize` Used by FileCache. Should cache objects be serialized first. + * - `path` Used by FileCache. Path to where cachefiles should be saved. + * - `lock` Used by FileCache. Should files be locked before writing to them? + * - `user` Used by Xcache. Username for XCache + * - `password` Used by Xcache. Password for XCache + * * @see app/config/core.php for configuration settings * @param string $name Name of the configuration * @param array $settings Optional associative array of settings passed to the engine From 0f993fa767f1b7a7106aefb3eb9b0a91ef797f19 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 00:50:07 -0430 Subject: [PATCH 494/668] Fixing ModelTaks tests and starting to work on PluginTask tests --- lib/Cake/Console/Command/Task/ModelTask.php | 1 + lib/Cake/Console/Command/Task/PluginTask.php | 1 + lib/Cake/tests/cases/console/shells/tasks/model.test.php | 2 ++ lib/Cake/tests/cases/console/shells/tasks/plugin.test.php | 3 +++ 4 files changed, 7 insertions(+) diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index fc184c54b..1cfd0eac4 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -20,6 +20,7 @@ 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. diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index 37ea34f67..a08212423 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -18,6 +18,7 @@ */ App::uses('File', 'Utility'); +App::uses('Folder', 'Utility'); /** * Task class for creating a plugin diff --git a/lib/Cake/tests/cases/console/shells/tasks/model.test.php b/lib/Cake/tests/cases/console/shells/tasks/model.test.php index 2ec7b62af..470496e06 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/model.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/model.test.php @@ -21,6 +21,8 @@ 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'); diff --git a/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php b/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php index 89922043f..a46465857 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/plugin.test.php @@ -20,9 +20,12 @@ */ 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'); /** From e46bfff6a0ff7d57bc3d661a1e6fb30ab3787751 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 00:51:58 -0430 Subject: [PATCH 495/668] Fixing FixtureTask tests --- lib/Cake/tests/cases/console/shells/tasks/fixture.test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php b/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php index cedbf472d..1fd607f85 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/fixture.test.php @@ -19,6 +19,8 @@ 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'); From 0fe22f598a1bfa39dd36893d57f87137bb664142 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 00:53:06 -0430 Subject: [PATCH 496/668] Fixing DbConfigTask tests --- lib/Cake/tests/cases/console/shells/tasks/db_config.test.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php b/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php index 2f6b76796..e00e31249 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/db_config.test.php @@ -18,6 +18,8 @@ */ App::uses('ShellDispatcher', 'Console'); +App::uses('ConsoleOutput', 'Console'); +App::uses('ConsoleInput', 'Console'); App::uses('Shell', 'Console'); App::uses('DbConfigTask', 'Console/Command/Task'); From fd8a7ed6d629b7a37a0073409930ed5ba72a4ea0 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 01:25:01 -0430 Subject: [PATCH 497/668] Fixing ControllerTask tests --- lib/Cake/Console/Command/Task/ControllerTask.php | 6 +++--- .../tests/cases/console/shells/tasks/controller.test.php | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 318f68681..e7d7995b2 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -107,7 +107,7 @@ class ControllerTask extends BakeTask { $model = $this->_modelName($table); $controller = $this->_controllerName($model); App::uses($model, 'Model'); - if (!class_exists($model)) { + if (class_exists($model)) { $actions = $this->bakeActions($controller); if ($this->bake($controller, $actions) && $unitTestExists) { $this->bakeTest($controller); @@ -270,9 +270,9 @@ class ControllerTask extends BakeTask { $currentModelName = $modelImport = $this->_modelName($controllerName); $plugin = $this->plugin; if ($plugin) { - $modelImport = $plugin . '.' . $modelImport; + $plugin .= '.'; } - App::uses($modelImport, 'Model'); + 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(); diff --git a/lib/Cake/tests/cases/console/shells/tasks/controller.test.php b/lib/Cake/tests/cases/console/shells/tasks/controller.test.php index cd92ba2c8..19b16df02 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/controller.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/controller.test.php @@ -29,7 +29,12 @@ App::uses('TemplateTask', 'Console/Command/Task'); App::uses('TestTask', 'Console/Command/Task'); App::uses('Model', 'Model'); -if (class_exists('BakeArticle')) { +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); class BakeArticle extends Model { From 8442d93d9e6fe3fb9fa79a1ef2861b210405b68a Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 01:26:21 -0430 Subject: [PATCH 498/668] Fixing the Sell tests --- lib/Cake/Console/Shell.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index d51b24e8e..31b64433f 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -22,6 +22,7 @@ App::uses('ConsoleOutput', 'Console'); App::uses('ConsoleInput', 'Console'); App::uses('ConsoleInputSubcommand', 'Console'); App::uses('ConsoleOptionParser', 'Console'); +App::uses('File', 'Utility'); /** * Base class for command-line utilities for automating programmer chores. @@ -609,10 +610,6 @@ class Shell extends Object { $this->out(__('Creating file %s', $path)); } - if (!class_exists('File')) { - require LIBS . 'file.php'; - } - if ($File = new File($path, true)) { $data = $File->prepare($contents); $File->write($data); From 0c9f4c19358566dd7a34e5b23a883958ace900d6 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 01:27:52 -0430 Subject: [PATCH 499/668] Fixing schema shell tests --- lib/Cake/tests/cases/console/shells/schema.test.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Cake/tests/cases/console/shells/schema.test.php b/lib/Cake/tests/cases/console/shells/schema.test.php index 1c11998c7..ce48e0626 100644 --- a/lib/Cake/tests/cases/console/shells/schema.test.php +++ b/lib/Cake/tests/cases/console/shells/schema.test.php @@ -18,8 +18,11 @@ */ 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 From 48b3593a2528ae9f0dc7e88b65e45807c6dc3064 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 14:15:44 -0430 Subject: [PATCH 500/668] Fixing the CommandList shell, renaming the TestSuiteShell to TestsuiteShell for BC --- lib/Cake/Console/Command/CommandListShell.php | 33 ++++++++----------- ...{TestSuiteShell.php => TestsuiteShell.php} | 0 lib/Cake/Core/App.php | 7 ++-- .../console/shells/command_list.test.php | 9 ++--- .../shells/{sample.php => SampleShell.php} | 0 5 files changed, 22 insertions(+), 27 deletions(-) rename lib/Cake/Console/Command/{TestSuiteShell.php => TestsuiteShell.php} (100%) rename lib/Cake/tests/test_app/console/shells/{sample.php => SampleShell.php} (100%) diff --git a/lib/Cake/Console/Command/CommandListShell.php b/lib/Cake/Console/Command/CommandListShell.php index 81d16a22f..bce1d0a75 100644 --- a/lib/Cake/Console/Command/CommandListShell.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,20 +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) { - $shell = str_replace('Shell.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/lib/Cake/Console/Command/TestSuiteShell.php b/lib/Cake/Console/Command/TestsuiteShell.php similarity index 100% rename from lib/Cake/Console/Command/TestSuiteShell.php rename to lib/Cake/Console/Command/TestsuiteShell.php diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 88b68668a..dbc220db1 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -454,7 +454,7 @@ class App { if ($type === 'file' && !$path) { return false; } elseif ($type === 'file') { - $extension = '/.*/'; + $extension = '/\.php$/'; $name = $type . str_replace(DS, '', $path); } @@ -477,9 +477,10 @@ class App { $files = new RegexIterator(new DirectoryIterator($dir), $extension); foreach ($files as $file) { if (!$file->isDot()) { - if ($file->isDir() && $includeDirectories) { + $isDir = $file->isDir() ; + if ($isDir && $includeDirectories) { $objects[] = basename($file); - } elseif (!$includeDirectories) { + } elseif (!$includeDirectories && !$isDir) { $objects[] = substr(basename($file), 0, -4); } } diff --git a/lib/Cake/tests/cases/console/shells/command_list.test.php b/lib/Cake/tests/cases/console/shells/command_list.test.php index d9cb3fd6a..461fe00c0 100644 --- a/lib/Cake/tests/cases/console/shells/command_list.test.php +++ b/lib/Cake/tests/cases/console/shells/command_list.test.php @@ -18,6 +18,9 @@ */ App::uses('CommandListShell', 'Console/Command'); +App::uses('ConsoleOutput', 'Console'); +App::uses('ConsoleInput', 'Console'); +App::uses('Shell', 'Console'); class TestStringOutput extends ConsoleOutput { @@ -40,10 +43,7 @@ class CommandListTest extends CakeTestCase { 'plugins' => array( 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, + 'Console/Command' => array( LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS . 'shells' . DS ) ), true); @@ -84,6 +84,7 @@ class CommandListTest extends CakeTestCase { $expected = "/welcome \[.*TestPluginTwo.*\]/"; $this->assertPattern($expected, $output); + $expected = "/acl \[.*CORE.*\]/"; $this->assertPattern($expected, $output); diff --git a/lib/Cake/tests/test_app/console/shells/sample.php b/lib/Cake/tests/test_app/console/shells/SampleShell.php similarity index 100% rename from lib/Cake/tests/test_app/console/shells/sample.php rename to lib/Cake/tests/test_app/console/shells/SampleShell.php From ac3caf3154d85bbcf45dd5497d7d1a8f6fa73363 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 14:18:46 -0430 Subject: [PATCH 501/668] Fixing the testsuite shell and renaming class for BC --- lib/Cake/Console/Command/TestsuiteShell.php | 3 ++- lib/Cake/tests/cases/console/shells/testsuite.test.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Console/Command/TestsuiteShell.php b/lib/Cake/Console/Command/TestsuiteShell.php index c61f58a9f..d235dad63 100644 --- a/lib/Cake/Console/Command/TestsuiteShell.php +++ b/lib/Cake/Console/Command/TestsuiteShell.php @@ -19,11 +19,12 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ +App::uses('Shell', 'Console'); App::uses('CakeTestSuiteDispatcher', 'TestSuite'); App::uses('CakeTestSuiteCommand', 'TestSuite'); App::uses('CakeTestLoader', 'TestSuite'); -class TestSuiteShell extends Shell { +class TestsuiteShell extends Shell { /** * Dispatcher object for the run. diff --git a/lib/Cake/tests/cases/console/shells/testsuite.test.php b/lib/Cake/tests/cases/console/shells/testsuite.test.php index 4bc67a53a..5d0d2914a 100644 --- a/lib/Cake/tests/cases/console/shells/testsuite.test.php +++ b/lib/Cake/tests/cases/console/shells/testsuite.test.php @@ -18,9 +18,9 @@ */ App::uses('ShellDispatcher', 'Console'); -App::uses('TestSuiteShell', 'Console/Command'); +App::uses('TestsuiteShell', 'Console/Command'); -class TestSuiteShellTest extends CakeTestCase { +class TestsuiteShellTest extends CakeTestCase { /** @@ -33,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) ); From 9f189d39dbf3e9f02b4217ff66b33573cbfe0ce2 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 14:43:00 -0430 Subject: [PATCH 502/668] Fixing the HelpFormatter test --- lib/Cake/Console/Command/TestsuiteShell.php | 2 +- lib/Cake/Console/ConsoleOptionParser.php | 2 ++ lib/Cake/tests/cases/console/libs/help_formatter.test.php | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Console/Command/TestsuiteShell.php b/lib/Cake/Console/Command/TestsuiteShell.php index d235dad63..d788cae3d 100644 --- a/lib/Cake/Console/Command/TestsuiteShell.php +++ b/lib/Cake/Console/Command/TestsuiteShell.php @@ -137,7 +137,7 @@ class TestsuiteShell extends Shell { ))->addOption('bootstrap', array( 'help' => __(' A "bootstrap" PHP file that is run before the tests.'), 'default' => false - ))->addOption('configuraion', array( + ))->addOption('configuration', array( 'help' => __(' Read configuration from XML file.'), 'default' => false ))->addOption('no-configuration', array( diff --git a/lib/Cake/Console/ConsoleOptionParser.php b/lib/Cake/Console/ConsoleOptionParser.php index 82e49d1d0..b84615ea5 100644 --- a/lib/Cake/Console/ConsoleOptionParser.php +++ b/lib/Cake/Console/ConsoleOptionParser.php @@ -16,9 +16,11 @@ * @since CakePHP(tm) v 2.0 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + App::uses('TaskCollection', 'Console'); App::uses('ConsoleOutput', 'Console'); App::uses('ConsoleInput', 'Console'); +App::uses('ConsoleInputSubcommand', 'Console'); App::uses('ConsoleInputOption', 'Console'); App::uses('ConsoleInputArgument', 'Console'); App::uses('ConsoleOptionParser', 'Console'); diff --git a/lib/Cake/tests/cases/console/libs/help_formatter.test.php b/lib/Cake/tests/cases/console/libs/help_formatter.test.php index 5caae1490..f296a84ea 100644 --- a/lib/Cake/tests/cases/console/libs/help_formatter.test.php +++ b/lib/Cake/tests/cases/console/libs/help_formatter.test.php @@ -1,7 +1,7 @@ Date: Tue, 8 Mar 2011 14:44:03 -0430 Subject: [PATCH 503/668] Fixing ConsoleOutput test --- lib/Cake/tests/cases/console/libs/console_output.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/console/libs/console_output.test.php b/lib/Cake/tests/cases/console/libs/console_output.test.php index d2af99d04..1063a2640 100644 --- a/lib/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 { From d2a38787a2b8cd3c53375e1f5e3f13c17cfcb248 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 14:45:23 -0430 Subject: [PATCH 504/668] Fixing the ConsoleOptionParser test --- .../tests/cases/console/libs/console_option_parser.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/console/libs/console_option_parser.test.php b/lib/Cake/tests/cases/console/libs/console_option_parser.test.php index fac420ecd..1c60f414b 100644 --- a/lib/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 { From 234d781f7723578f5a1a376dba66c7667407049a Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 14:46:21 -0430 Subject: [PATCH 505/668] Fixing the ConsoleErrorHandler test --- .../tests/cases/console/libs/console_error_handler.test.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/console/libs/console_error_handler.test.php b/lib/Cake/tests/cases/console/libs/console_error_handler.test.php index 51d16ab0f..6b4538d41 100644 --- a/lib/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. From 65136e8cb1ed930794e903a84774e133cb559db7 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 15:08:28 -0430 Subject: [PATCH 506/668] Re-adding the support for the topmost plugins folder and homogenizing some constants in shell dispatcher --- lib/Cake/Console/ShellDispatcher.php | 4 ++-- lib/Cake/Core/App.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index 6198bc338..0d4ef5d6f 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -85,10 +85,10 @@ class ShellDispatcher { if (!defined('CAKE_CORE_INCLUDE_PATH')) { define('DS', DIRECTORY_SEPARATOR); - define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__)))); + define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(dirname(__FILE__))))); define('CAKEPHP_SHELL', true); if (!defined('CORE_PATH')) { - define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); + define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS . 'lib' . DS); } } } diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index dbc220db1..583143e8a 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -315,7 +315,7 @@ class App { 'libs' => array('%s' . 'libs' . DS), 'locales' => array('%s' . 'locale' . DS), 'vendors' => array('%s' . 'vendors' . DS, VENDORS), - 'plugins' => array(APP . 'plugins' . DS) + 'plugins' => array(APP . 'plugins' . DS, CAKE_CORE_INCLUDE_PATH . DS . 'plugins' . DS) ); } From 6dee1277c406b6faa3f8eb619183849bf535cb11 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 15:13:49 -0430 Subject: [PATCH 507/668] Fixing the AclShell test --- lib/Cake/tests/cases/console/shells/acl.test.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Cake/tests/cases/console/shells/acl.test.php b/lib/Cake/tests/cases/console/shells/acl.test.php index cd41387c1..7f03ae7d8 100644 --- a/lib/Cake/tests/cases/console/shells/acl.test.php +++ b/lib/Cake/tests/cases/console/shells/acl.test.php @@ -20,6 +20,7 @@ App::uses('ShellDispatcher', 'Console'); App::uses('Shell', 'Console'); App::uses('AclShell', 'Console/Command'); +App::uses('ComponentCollection', 'Controller'); /** * AclShellTest class From dac34555f83a5a7cc2b86415562b39a25ba9e473 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 15:18:10 -0430 Subject: [PATCH 508/668] Fixing parse error in bake shell --- lib/Cake/Console/Command/BakeShell.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Console/Command/BakeShell.php b/lib/Cake/Console/Command/BakeShell.php index 64bd045f7..718f8d8ff 100644 --- a/lib/Cake/Console/Command/BakeShell.php +++ b/lib/Cake/Console/Command/BakeShell.php @@ -176,7 +176,7 @@ class BakeShell extends Shell { $this->Controller->bakeTest($controller); } } - App::uses($controller . 'Controller', 'Controller') + App::uses($controller . 'Controller', 'Controller'); if (class_exists($controller . 'Controller')) { $this->View->args = array($controller); $this->View->execute(); From 4c908686526f6e0a6439cf1578a3f6de5ca3b788 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 15:37:15 -0430 Subject: [PATCH 509/668] Fixing the Api shell --- lib/Cake/Console/Command/ApiShell.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/Cake/Console/Command/ApiShell.php b/lib/Cake/Console/Command/ApiShell.php index 20de1d097..47db18f71 100644 --- a/lib/Cake/Console/Command/ApiShell.php +++ b/lib/Cake/Console/Command/ApiShell.php @@ -41,13 +41,13 @@ class ApiShell extends Shell { */ public function initialize() { $this->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) { From a1fe95e072e7992181e39552d0a4bb55a7737ff5 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Tue, 8 Mar 2011 17:32:22 -0430 Subject: [PATCH 510/668] REverting some changes made to constants --- app/webroot/index.php | 4 ++-- app/webroot/test.php | 6 +++--- lib/Cake/Console/ShellDispatcher.php | 4 ++-- lib/Cake/tests/cases/console/shell_dispatcher.test.php | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/webroot/index.php b/app/webroot/index.php index c0e90b343..77b9db786 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'); } /** @@ -65,7 +65,7 @@ } if (!defined('CORE_PATH')) { define('APP_PATH', ROOT . DS . APP_DIR . DS); - define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS . 'lib' . DS); + define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } 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); diff --git a/app/webroot/test.php b/app/webroot/test.php index deef49aa5..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'); } /** @@ -65,7 +65,7 @@ if (!defined('WWW_ROOT')) { } if (!defined('CORE_PATH')) { define('APP_PATH', ROOT . DS . APP_DIR . DS); - define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS . 'lib' . DS); + define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } 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); diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index 0d4ef5d6f..6198bc338 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -85,10 +85,10 @@ class ShellDispatcher { if (!defined('CAKE_CORE_INCLUDE_PATH')) { define('DS', DIRECTORY_SEPARATOR); - define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(dirname(__FILE__))))); + define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__)))); define('CAKEPHP_SHELL', true); if (!defined('CORE_PATH')) { - define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS . 'lib' . DS); + define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } } } diff --git a/lib/Cake/tests/cases/console/shell_dispatcher.test.php b/lib/Cake/tests/cases/console/shell_dispatcher.test.php index 5438efdfb..4e2f8efe4 100644 --- a/lib/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 @@ -118,8 +119,7 @@ class ShellDispatcherTest extends CakeTestCase { 'plugins' => array( LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS ), - 'shells' => array( - CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS, + 'Console/Command' => array( LIBS . 'tests' . DS . 'test_app' . DS . 'console' . DS . 'shells' . DS ) ), true); From ca32143292ae4e1ea4fc0dd98fb147d9f466784b Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 9 Mar 2011 01:05:58 -0430 Subject: [PATCH 511/668] Fixing the ControllerTestCase tests --- lib/Cake/TestSuite/ControllerTestCase.php | 15 +++++++++++---- lib/Cake/View/View.php | 2 +- .../cases/libs/controller_test_case.test.php | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/Cake/TestSuite/ControllerTestCase.php b/lib/Cake/TestSuite/ControllerTestCase.php index ebf2af08c..9c78bcfae 100644 --- a/lib/Cake/TestSuite/ControllerTestCase.php +++ b/lib/Cake/TestSuite/ControllerTestCase.php @@ -254,7 +254,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(); @@ -295,10 +301,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/lib/Cake/View/View.php b/lib/Cake/View/View.php index 9fecab65e..26b9f2e35 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -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; } diff --git a/lib/Cake/tests/cases/libs/controller_test_case.test.php b/lib/Cake/tests/cases/libs/controller_test_case.test.php index b06159ced..a64d36521 100644 --- a/lib/Cake/tests/cases/libs/controller_test_case.test.php +++ b/lib/Cake/tests/cases/libs/controller_test_case.test.php @@ -123,9 +123,9 @@ class ControllerTestCaseTest extends CakeTestCase { parent::setUp(); App::build(array( 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), - 'controllers' => array(LIBS . '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) + '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(); From c8f33b77a154e0227d59bbc477bba728ece69566 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 9 Mar 2011 07:31:11 -0500 Subject: [PATCH 512/668] Fixing failing tests, and issues around Controller::$view not getting set properly. --- cake/libs/controller/controller.php | 11 +++++++++-- cake/libs/route/redirect_route.php | 3 +-- cake/tests/cases/libs/controller/scaffold.test.php | 2 +- cake/tests/lib/controller_test_case.php | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index 8040297ec..f09601c86 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -403,7 +403,14 @@ class Controller extends Object { /** * Sets the request objects and configures a number of controller properties - * based on the contents of the request. + * based on the contents of the request. The properties that get set are + * + * - $this->request - To the $request parameter + * - $this->plugin - To the $request->params['plugin'] + * - $this->view - To the $request->params['action'] + * - $this->autoLayout - To the false if $request->params['bare']; is set. + * - $this->autoRender - To false if $request->params['return'] == 1 + * - $this->passedArgs - The the combined results of params['named'] and params['pass] * * @param CakeRequest $request * @return void @@ -411,7 +418,7 @@ class Controller extends Object { public function setRequest(CakeRequest $request) { $this->request = $request; $this->plugin = isset($request->params['plugin']) ? $request->params['plugin'] : null; - + $this->view = isset($request->params['action']) ? $request->params['action'] : null; if (isset($request->params['pass']) && isset($request->params['named'])) { $this->passedArgs = array_merge($request->params['pass'], $request->params['named']); } diff --git a/cake/libs/route/redirect_route.php b/cake/libs/route/redirect_route.php index 8b9a63fe2..9746b7814 100644 --- a/cake/libs/route/redirect_route.php +++ b/cake/libs/route/redirect_route.php @@ -68,8 +68,7 @@ class RedirectRoute extends CakeRoute { $redirect = $this->redirect[0]; } if (isset($this->options['persist']) && is_array($redirect)) { - $argOptions['context'] = array('action' => $redirect['action'], 'controller' => $redirect['controller']); - $redirect += Router::getArgs($params['_args_'], $argOptions) + array('url' => array()); + $redirect += array('named' => $params['named'], 'pass' => $params['pass'], 'url' => array()); $redirect = Router::reverse($redirect); } $status = 301; diff --git a/cake/tests/cases/libs/controller/scaffold.test.php b/cake/tests/cases/libs/controller/scaffold.test.php index 54a67beff..7c1e4d51c 100644 --- a/cake/tests/cases/libs/controller/scaffold.test.php +++ b/cake/tests/cases/libs/controller/scaffold.test.php @@ -485,7 +485,7 @@ class ScaffoldViewTest extends CakeTestCase { function testEditScaffold() { $this->Controller->request->base = ''; $this->Controller->request->webroot = '/'; - $this->Controller->request->here = '/scaffold_mock'; + $this->Controller->request->here = '/scaffold_mock/edit/1'; $params = array( 'plugin' => null, diff --git a/cake/tests/lib/controller_test_case.php b/cake/tests/lib/controller_test_case.php index 150bf12a5..76d34f310 100644 --- a/cake/tests/lib/controller_test_case.php +++ b/cake/tests/lib/controller_test_case.php @@ -171,6 +171,7 @@ class ControllerTestCase extends CakeTestCase { * Tests a controller action. * * ### Options: + * * - `data` POST or GET data to pass * - `method` POST or GET * From 95d44c36946d93a13bd639d4bc82c0fe65b97758 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 10 Mar 2011 03:54:20 +0530 Subject: [PATCH 513/668] Updating example code in comment to reflect renaming of Controller::$view to Controller::$viewClass. Closes #1579 --- cake/libs/view/media.php | 2 +- cake/libs/view/theme.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cake/libs/view/media.php b/cake/libs/view/media.php index 34b047aef..a2b9c1cff 100644 --- a/cake/libs/view/media.php +++ b/cake/libs/view/media.php @@ -38,7 +38,7 @@ App::import('View', 'View', false); * {{{ * class ExampleController extends AppController { * function download () { - * $this->view = 'Media'; + * $this->viewClass = 'Media'; * $params = array( * 'id' => 'example.zip', * 'name' => 'example', diff --git a/cake/libs/view/theme.php b/cake/libs/view/theme.php index 24e06e29b..544aacdc3 100644 --- a/cake/libs/view/theme.php +++ b/cake/libs/view/theme.php @@ -23,7 +23,7 @@ App::import('View', 'View'); * * Allows the creation of multiple themes to be used in an app. Theme views are regular view files * that can provide unique HTML and static assets. If theme views are not found for the current view - * the default app view files will be used. You can set `$this->theme` and `$this->view = 'Theme'` + * the default app view files will be used. You can set `$this->theme` and `$this->viewClass = 'Theme'` * in your Controller to use the ThemeView. * * Example of theme path with `$this->theme = 'super_hot';` Would be `app/views/themed/super_hot/posts` From f05a105dfbb6902686471a045e10c03fbb76ca30 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 9 Mar 2011 21:39:05 -0430 Subject: [PATCH 514/668] Fixing the HelperCollection test --- lib/Cake/tests/cases/libs/view/helper_collection.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/libs/view/helper_collection.test.php b/lib/Cake/tests/cases/libs/view/helper_collection.test.php index ede4c5cab..a98fa88e2 100644 --- a/lib/Cake/tests/cases/libs/view/helper_collection.test.php +++ b/lib/Cake/tests/cases/libs/view/helper_collection.test.php @@ -17,7 +17,7 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('HelperCollection', 'View/Helper'); +App::uses('HelperCollection', 'View'); App::uses('HtmlHelper', 'View/Helper'); App::uses('View', 'View'); From 022702506e7639002d0a5928f60e44c71adfed05 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 9 Mar 2011 22:11:13 -0430 Subject: [PATCH 515/668] Properly testing the App::build() method and bugfixing some issues --- lib/Cake/Core/App.php | 15 +++- lib/Cake/bootstrap.php | 2 +- lib/Cake/tests/cases/libs/app.test.php | 104 +++++++++++++++++++++++-- 3 files changed, 110 insertions(+), 11 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 583143e8a..709fc8965 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -226,10 +226,10 @@ class App { 'behaviors' => 'Model/Behavior', 'datasources' => 'Model/Datasource', 'controllers' => 'Controller', - 'components' => 'Model/Datasource', + 'components' => 'Controller/Component', 'views' => 'View', 'helpers' => 'View/Helper', - 'shells' => 'Console' + 'shells' => 'Console/Command' ); /** @@ -329,6 +329,16 @@ class App { 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) { @@ -340,7 +350,6 @@ class App { $appLibs = empty($paths['libs']) ? $defaults['libs'] : $paths['libs']; foreach ($defaults as $type => $default) { - if (empty(self::$__packages[$type]) || empty($paths)) { self::$__packages[$type] = $default; } diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index 2ec1d4e0d..459d60196 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -192,7 +192,7 @@ if (!defined('TMP')) { * Path to the vendors directory. */ if (!defined('VENDORS')) { - define('VENDORS', CAKE_CORE_INCLUDE_PATH.DS.'vendors'.DS); + define('VENDORS', ROOT . DS . 'vendors' . DS); } /** diff --git a/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php index d9ba83066..4323f8db1 100644 --- a/lib/Cake/tests/cases/libs/app.test.php +++ b/lib/Cake/tests/cases/libs/app.test.php @@ -14,11 +14,37 @@ class AppImportTest extends CakeTestCase { * @return void */ function testBuild() { + $old = App::path('Model'); + $expected = array( + APP . 'models' . DS + ); + $this->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, - APP, - LIBS . 'model' . DS + APP . 'models' . DS ); $this->assertEqual($expected, $old); @@ -28,14 +54,78 @@ class AppImportTest extends CakeTestCase { $expected = array( '/path/to/models/', - APP . 'models' . DS, - APP, - LIBS . 'model' . DS + 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('models'); + $defaults = App::path('Model'); $this->assertEqual($old, $defaults); } From 38d33e4a9acb93c5a1b8aa48245ae1e595c82333 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 9 Mar 2011 22:15:20 -0430 Subject: [PATCH 516/668] Improving tests for App::core() --- lib/Cake/tests/cases/libs/app.test.php | 32 +++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php index 4323f8db1..d071ae971 100644 --- a/lib/Cake/tests/cases/libs/app.test.php +++ b/lib/Cake/tests/cases/libs/app.test.php @@ -136,17 +136,15 @@ class AppImportTest extends CakeTestCase { * @return void */ function testBuildWithReset() { - $old = App::path('models'); + $old = App::path('Model'); $expected = array( - APP . 'models' . DS, - APP, - LIBS . 'model' . DS + APP . 'models' . DS ); $this->assertEqual($expected, $old); - App::build(array('models' => array('/path/to/models/')), true); + App::build(array('Model' => array('/path/to/models/')), true); - $new = App::path('models'); + $new = App::path('Model'); $expected = array( '/path/to/models/' @@ -154,7 +152,7 @@ class AppImportTest extends CakeTestCase { $this->assertEqual($expected, $new); App::build(); //reset defaults - $defaults = App::path('models'); + $defaults = App::path('Model'); $this->assertEqual($old, $defaults); } @@ -165,15 +163,23 @@ class AppImportTest extends CakeTestCase { * @return void */ function testCore() { - $model = App::core('models'); - $this->assertEqual(array(LIBS . 'model' . DS), $model); + $model = App::core('Model'); + $this->assertEqual(array(LIBS . 'Model' . DS), $model); - $view = App::core('views'); - $this->assertEqual(array(LIBS . 'view' . DS), $view); + $view = App::core('View'); + $this->assertEqual(array(LIBS . 'View' . DS), $view); - $controller = App::core('controllers'); - $this->assertEqual(array(LIBS . 'controller' . DS), $controller); + $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); } /** From 21286cb8c22a95a29ba8d73ebdcf7be2527d03a8 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 9 Mar 2011 22:29:52 -0430 Subject: [PATCH 517/668] Updating tests for App::objects() --- lib/Cake/tests/cases/libs/app.test.php | 44 ++++++++++++++++++-------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php index d071ae971..5ddeba067 100644 --- a/lib/Cake/tests/cases/libs/app.test.php +++ b/lib/Cake/tests/cases/libs/app.test.php @@ -189,31 +189,47 @@ class AppImportTest extends CakeTestCase { * @return void */ function testListObjects() { - $result = App::objects('class', LIBS . 'libs', false); - $this->assertTrue(in_array('Xml', $result)); - $this->assertTrue(in_array('Cache', $result)); - $this->assertTrue(in_array('HttpSocket', $result)); + $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('Tree', $result)); + $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('Pages', $result)); + $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('Auth', $result)); + $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('Media', $result)); + $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('Html', $result)); + $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); - $notExpected = array('AppModel', 'ModelBehavior', 'ConnectionManager', 'DbAcl', 'Model', 'CakeSchema'); - foreach ($notExpected as $class) { - $this->assertFalse(in_array($class, $result)); - } + $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); @@ -223,7 +239,7 @@ class AppImportTest extends CakeTestCase { $this->assertEqual($result, $expected); $result = App::objects('NonExistingType'); - $this->assertFalse($result); + $this->assertEqual($result, array()); App::build(array( 'plugins' => array( From 0cc55d8f45aa0ee1497d98b5086c2e4478615936 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 9 Mar 2011 22:27:19 -0500 Subject: [PATCH 518/668] Removing calls to Dispatcher::_stop(). Updating tests. Fixes #1578 --- cake/libs/dispatcher.php | 6 ++-- cake/tests/cases/libs/dispatcher.test.php | 35 +++++------------------ 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index 387eac89c..c7cce1188 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -302,13 +302,13 @@ class Dispatcher { if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) { $this->response->statusCode(404); $this->response->send(); - return $this->_stop(); + return true; } elseif ($isCss) { include WWW_ROOT . DS . $filters['css']; - $this->_stop(); + return true; } elseif ($isJs) { include WWW_ROOT . DS . $filters['js']; - $this->_stop(); + return true; } $controller = null; $pathSegments = explode('.', $url); diff --git a/cake/tests/cases/libs/dispatcher.test.php b/cake/tests/cases/libs/dispatcher.test.php index e7e3ae8b9..07823552a 100644 --- a/cake/tests/cases/libs/dispatcher.test.php +++ b/cake/tests/cases/libs/dispatcher.test.php @@ -59,15 +59,6 @@ class TestDispatcher extends Dispatcher { return $controller; } -/** - * _stop method - * - * @return void - */ - protected function _stop() { - $this->stopped = true; - return true; - } } /** @@ -1356,9 +1347,8 @@ class DispatcherTest extends CakeTestCase { )); ob_start(); - $Dispatcher->asset('ccss/cake.generic.css'); + $this->assertTrue($Dispatcher->asset('ccss/cake.generic.css')); $result = ob_get_clean(); - $this->assertTrue($Dispatcher->stopped); } /** @@ -1373,28 +1363,17 @@ class DispatcherTest extends CakeTestCase { 'js' => '', 'css' => '' )); - $Dispatcher->asset('theme/test_theme/ccss/cake.generic.css'); - $this->assertTrue($Dispatcher->stopped); + $this->assertTrue($Dispatcher->asset('theme/test_theme/ccss/cake.generic.css')); - $Dispatcher->stopped = false; - $Dispatcher->asset('theme/test_theme/cjs/debug_kit.js'); - $this->assertTrue($Dispatcher->stopped); + $this->assertTrue($Dispatcher->asset('theme/test_theme/cjs/debug_kit.js')); - $Dispatcher->stopped = false; - $Dispatcher->asset('test_plugin/ccss/cake.generic.css'); - $this->assertTrue($Dispatcher->stopped); + $this->assertTrue($Dispatcher->asset('test_plugin/ccss/cake.generic.css')); - $Dispatcher->stopped = false; - $Dispatcher->asset('test_plugin/cjs/debug_kit.js'); - $this->assertTrue($Dispatcher->stopped); + $this->assertTrue($Dispatcher->asset('test_plugin/cjs/debug_kit.js')); - $Dispatcher->stopped = false; - $Dispatcher->asset('css/ccss/debug_kit.css'); - $this->assertFalse($Dispatcher->stopped); + $this->assertFalse($Dispatcher->asset('css/ccss/debug_kit.css')); - $Dispatcher->stopped = false; - $Dispatcher->asset('js/cjs/debug_kit.js'); - $this->assertFalse($Dispatcher->stopped); + $this->assertFalse($Dispatcher->asset('js/cjs/debug_kit.js')); } /** * testFullPageCachingDispatch method From 472257c3473ca92ee939e46ac8d3964ae5abd817 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 9 Mar 2011 23:33:03 -0430 Subject: [PATCH 519/668] Removing unused variables and properly testing more methods in App class --- lib/Cake/Core/App.php | 95 ++------------------------ lib/Cake/View/pages/home.ctp | 2 +- lib/Cake/tests/cases/libs/app.test.php | 25 +++++-- 3 files changed, 26 insertions(+), 96 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 709fc8965..e203147e4 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -66,90 +66,6 @@ class App { 'plugin' => array('suffix' => '', 'extends' => null, 'core' => true) ); -/** - * List of additional path(s) where model files reside. - * - * @var array - */ - public static $models = array(); - -/** - * List of additional path(s) where behavior files reside. - * - * @var array - */ - public static $behaviors = array(); - -/** - * List of additional path(s) where controller files reside. - * - * @var array - */ - public static $controllers = array(); - -/** - * List of additional path(s) where component files reside. - * - * @var array - */ - public static $components = array(); - -/** - * List of additional path(s) where datasource files reside. - * - * @var array - */ - public static $datasources = array(); - -/** - * List of additional path(s) where libs files reside. - * - * @var array - */ - public static $libs = array(); - -/** - * List of additional path(s) where view files reside. - * - * @var array - */ - public static $views = array(); - -/** - * List of additional path(s) where helper files reside. - * - * @var array - */ - public static $helpers = array(); - -/** - * List of additional path(s) where plugins reside. - * - * @var array - */ - public static $plugins = array(); - -/** - * List of additional path(s) where vendor packages reside. - * - * @var array - */ - public static $vendors = array(); - -/** - * List of additional path(s) where locale files reside. - * - * @var array - */ - public static $locales = array(); - -/** - * List of additional path(s) where console shell files reside. - * - * @var array - */ - public static $shells = array(); - /** * Paths to search for files. * @@ -218,7 +134,7 @@ class App { private static $__packageFormat = array(); /** - * Maps an old style cakephp class type to the corresponding package + * Maps an old style CakePHP class type to the corresponding package * */ public static $legacy = array( @@ -445,10 +361,6 @@ class App { $includeDirectories = false; $name = $type; - if (isset(self::$legacy[$type . 's'])) { - $type = self::$legacy[$type . 's']; - } - if ($type === 'plugin') { $type = 'plugins'; } @@ -460,6 +372,10 @@ class App { list($plugin, $type) = pluginSplit($type); + if (isset(self::$legacy[$type . 's'])) { + $type = self::$legacy[$type . 's']; + } + if ($type === 'file' && !$path) { return false; } elseif ($type === 'file') { @@ -479,6 +395,7 @@ class App { if (empty($path)) { $path = self::path($type, $plugin); } + $items = array(); foreach ((array)$path as $dir) { diff --git a/lib/Cake/View/pages/home.ctp b/lib/Cake/View/pages/home.ctp index 319422586..4c51432de 100644 --- a/lib/Cake/View/pages/home.ctp +++ b/lib/Cake/View/pages/home.ctp @@ -24,7 +24,7 @@ App::import('Core', 'Debugger'); 0): - //Debugger::checkSecurityKeys(); + Debugger::checkSecurityKeys(); endif; ?>

    diff --git a/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php index 5ddeba067..6a0f3657b 100644 --- a/lib/Cake/tests/cases/libs/app.test.php +++ b/lib/Cake/tests/cases/libs/app.test.php @@ -260,32 +260,45 @@ class AppImportTest extends CakeTestCase { */ function testListObjectsInPlugin() { App::build(array( - 'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS), - 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) + 'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS), + 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) )); - $oldCache = App::$models; $result = App::objects('TestPlugin.model'); $this->assertTrue(in_array('TestPluginPost', $result)); - $this->assertEquals($oldCache, App::$models); + $result = App::objects('TestPlugin.Model'); + $this->assertTrue(in_array('TestPluginPost', $result)); $result = App::objects('TestPlugin.behavior'); $this->assertTrue(in_array('TestPluginPersisterOne', $result)); + $result = App::objects('TestPlugin.Model/Behavior'); + $this->assertTrue(in_array('TestPluginPersisterOne', $result)); $result = App::objects('TestPlugin.helper'); - $expected = array('OtherHelper', 'PluggedHelper', 'TestPluginApp'); + $expected = array('OtherHelperHelper', 'PluggedHelper', 'TestPluginApp'); + $this->assertEquals($result, $expected); + $result = App::objects('TestPlugin.View/Helper'); + $expected = array('OtherHelperHelper', 'PluggedHelper', 'TestPluginApp'); $this->assertEquals($result, $expected); $result = App::objects('TestPlugin.component'); $this->assertTrue(in_array('OtherComponent', $result)); + $result = App::objects('TestPlugin.Controller/Component'); + $this->assertTrue(in_array('OtherComponent', $result)); $result = App::objects('TestPluginTwo.behavior'); $this->assertEquals($result, array()); + $result = App::objects('TestPluginTwo.Model/Behavior'); + $this->assertEquals($result, array()); $result = App::objects('model', null, false); $this->assertTrue(in_array('Comment', $result)); $this->assertTrue(in_array('Post', $result)); + $result = App::objects('Model', null, false); + $this->assertTrue(in_array('Comment', $result)); + $this->assertTrue(in_array('Post', $result)); + App::build(); } @@ -319,7 +332,7 @@ class AppImportTest extends CakeTestCase { */ function testThemePath() { App::build(array( - 'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS) + 'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS) )); $path = App::themePath('test_theme'); $expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS; From ab4ce97cad7812724f53577724f6f71c7bee3706 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 10 Mar 2011 22:00:08 -0500 Subject: [PATCH 520/668] Fixin CakeErrorController's constructor, so it matches the parent class. Removing duplicated code. --- cake/libs/controller/cake_error_controller.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cake/libs/controller/cake_error_controller.php b/cake/libs/controller/cake_error_controller.php index f55649672..7fd3b46f4 100644 --- a/cake/libs/controller/cake_error_controller.php +++ b/cake/libs/controller/cake_error_controller.php @@ -22,10 +22,8 @@ class CakeErrorController extends AppController { * @access public * @return void */ - function __construct() { - parent::__construct(); - $this->_set(Router::getPaths()); - $this->request = Router::getRequest(false); + function __construct($request = null) { + parent::__construct($request); $this->constructClasses(); $this->Components->trigger('initialize', array(&$this)); $this->_set(array('cacheAction' => false, 'viewPath' => 'errors')); From b292f4ffaa60483c71f66e8ae8de322101cd9eec Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 10 Mar 2011 22:01:23 -0500 Subject: [PATCH 521/668] Fixing tests that were failing due to missing methods, and changes in CakeRoute. Making ExceptionRenderer pass in the current request to the controller constructor. This fixes fatal errors on PrivateActionExceptions. --- cake/libs/error/exception_renderer.php | 4 ++-- .../cases/libs/controller/components/auth.test.php | 10 ++++++++++ .../tests/cases/libs/error/exception_renderer.test.php | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cake/libs/error/exception_renderer.php b/cake/libs/error/exception_renderer.php index 25adff3aa..328fffd8d 100644 --- a/cake/libs/error/exception_renderer.php +++ b/cake/libs/error/exception_renderer.php @@ -146,9 +146,9 @@ class ExceptionRenderer { if ($__previousError != $exception) { $__previousError = $exception; - $controller = new CakeErrorController(); + $controller = new CakeErrorController(Router::getRequest(false)); } else { - $controller = new Controller(); + $controller = new Controller(Router::getRequest(false)); $controller->viewPath = 'errors'; } return $controller; diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index 2c6701e93..fc32e2709 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -147,6 +147,15 @@ class AuthTestController extends Controller { function admin_login() { } +/** + * admin_add method + * + * @access public + * @return void + */ + function admin_add() { + } + /** * logout method * @@ -916,6 +925,7 @@ class AuthTest extends CakeTestCase { $this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->query['url'] = ltrim($url, '/'); $this->Auth->request->base = ''; + Router::setRequestInfo($this->Auth->request); $this->Auth->initialize($this->Controller); diff --git a/cake/tests/cases/libs/error/exception_renderer.test.php b/cake/tests/cases/libs/error/exception_renderer.test.php index 1f0c0a150..b8a25ddfb 100644 --- a/cake/tests/cases/libs/error/exception_renderer.test.php +++ b/cake/tests/cases/libs/error/exception_renderer.test.php @@ -356,7 +356,7 @@ class ExceptionRendererTest extends CakeTestCase { $result = ob_get_clean(); $this->assertPattern('/

    Custom message<\/h2>/', $result); - $this->assertPattern("/'\/posts\/view\/1000'<\/strong>/", $result); + $this->assertPattern("/'.*?\/posts\/view\/1000'<\/strong>/", $result); } /** From 7f18f05de4d5303f9ce137899ebbe8c49b9f6dd9 Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 10 Mar 2011 22:04:46 -0500 Subject: [PATCH 522/668] Moving appending of prefix to action into the Router. This makes Router::parse() always return what you get in the controller. Updating Dispatcher to not hold a reference to the current request, as its not used. Updating private action detection so its simpler. Fixes issues with prefix actions not getting the correct default view. Fixes #1580 --- cake/libs/dispatcher.php | 24 ++++++------------------ cake/libs/router.php | 3 +++ cake/tests/cases/libs/router.test.php | 8 ++++++-- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/cake/libs/dispatcher.php b/cake/libs/dispatcher.php index c7cce1188..9d82935a8 100644 --- a/cake/libs/dispatcher.php +++ b/cake/libs/dispatcher.php @@ -37,14 +37,6 @@ App::import('Controller', 'Controller', false); */ class Dispatcher { -/** - * The request object - * - * @var CakeRequest - * @access public - */ - public $request = null; - /** * Response object used for asset/cached responses. * @@ -87,18 +79,16 @@ class Dispatcher { return; } - $this->request = $this->parseParams($request, $additionalParams); - $controller = $this->_getController($this->request); + $request = $this->parseParams($request, $additionalParams); + Router::setRequestInfo($request); + $controller = $this->_getController($request); - if (!is_object($controller)) { - Router::setRequestInfo($request); + if (!($controller instanceof Controller)) { throw new MissingControllerException(array( 'controller' => Inflector::camelize($request->params['controller']) . 'Controller' )); } - Router::setRequestInfo($request); - if ($this->_isPrivateAction($request)) { throw new PrivateActionException(array( 'controller' => Inflector::camelize($request->params['controller']) . "Controller", @@ -120,10 +110,8 @@ class Dispatcher { $privateAction = $request->params['action'][0] === '_'; $prefixes = Router::prefixes(); - if (!empty($prefixes)) { - if (isset($request->params['prefix'])) { - $request->params['action'] = $request->params['prefix'] . '_' . $request->params['action']; - } elseif (strpos($request->params['action'], '_') > 0) { + if (!$privateAction && !empty($prefixes)) { + if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) { list($prefix, $action) = explode('_', $request->params['action']); $privateAction = in_array($prefix, $prefixes); } diff --git a/cake/libs/router.php b/cake/libs/router.php index 08372f7c7..53f2da089 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -503,6 +503,9 @@ class Router { break; } } + if (isset($out['prefix'])) { + $out['action'] = $out['prefix'] . '_' . $out['action']; + } if (!empty($ext) && !isset($out['url']['ext'])) { $out['url']['ext'] = $ext; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 9a4ce30d7..682c9238c 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -1877,7 +1877,7 @@ class RouterTest extends CakeTestCase { ); $result = Router::parse('/admin/posts/'); - $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'admin', 'plugin' => null, 'controller' => 'posts', 'action' => 'index', 'admin' => true); + $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'admin', 'plugin' => null, 'controller' => 'posts', 'action' => 'admin_index', 'admin' => true); $this->assertEqual($result, $expected); $result = Router::parse('/admin/posts'); @@ -1911,7 +1911,7 @@ class RouterTest extends CakeTestCase { ); $result = Router::parse('/members/posts/index'); - $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'members', 'plugin' => null, 'controller' => 'posts', 'action' => 'index', 'members' => true); + $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'members', 'plugin' => null, 'controller' => 'posts', 'action' => 'members_index', 'members' => true); $this->assertEqual($result, $expected); $result = Router::url(array('members' => true, 'controller' => 'posts', 'action' =>'index', 'page' => 2)); @@ -1941,6 +1941,10 @@ class RouterTest extends CakeTestCase { $expected = '/company/users/login'; $this->assertEqual($result, $expected); + $result = Router::url(array('controller' => 'users', 'action' => 'company_login', 'company' => true)); + $expected = '/company/users/login'; + $this->assertEqual($result, $expected); + $request = new CakeRequest(); Router::setRequestInfo( $request->addParams(array( From e6b253ec0f806a5144088cd8d329e9dca84b9e6d Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 11 Mar 2011 00:50:14 -0430 Subject: [PATCH 523/668] Starting to write a new App::import() that keeps where possible the backwards compatibility --- lib/Cake/Core/App.php | 51 +++++++++++++++++--------- lib/Cake/TestSuite/CakeTestRunner.php | 3 +- lib/Cake/tests/cases/libs/app.test.php | 20 ++-------- 3 files changed, 40 insertions(+), 34 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index e203147e4..5da8cea86 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -52,18 +52,18 @@ class App { * @var array */ public static $types = array( - 'class' => array('suffix' => '.php', 'extends' => null, 'core' => true), - 'file' => array('suffix' => '.php', 'extends' => null, 'core' => true), - 'model' => array('suffix' => '.php', 'extends' => 'AppModel', 'core' => false), - 'behavior' => array('suffix' => '.php', 'extends' => 'ModelBehavior', 'core' => true), - 'controller' => array('suffix' => '_controller.php', 'extends' => 'AppController', 'core' => true), - 'component' => array('suffix' => '.php', 'extends' => null, 'core' => true), - '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) + 'class' => 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) ); /** @@ -525,11 +525,28 @@ class App { extract($parent, EXTR_OVERWRITE); } - if ($name === null && $file === null) { - $name = $type; - $type = 'Core'; - } elseif ($name === null) { - $type = 'File'; + if ($name == null && $file == null) { + return false; + } + + $originalType = $type = strtolower($type); + $specialPackage = in_array($type, array('core', 'file', 'vendor')); + if (!$specialPackage && isset(self::$legacy[$type . 's'])) { + $type = self::$legacy[$type . 's']; + } + + if (!$specialPackage) { + list($plugin, $name) = pluginSplit($name, true); + + if ($type == 'Console/Command' && $name == 'Shell') { + $type = 'Console'; + } else if (isset(self::$types[$originalType]['suffix'])) { + $suffix = self::$types[$originalType]['suffix']; + $name .= ($suffix == $name) ? '' : $suffix; + } + + App::uses(Inflector::camelize($name), $plugin . $type); + return (bool) self::load($name); } if (is_array($name)) { diff --git a/lib/Cake/TestSuite/CakeTestRunner.php b/lib/Cake/TestSuite/CakeTestRunner.php index f1d2c9eda..94295dd8c 100644 --- a/lib/Cake/TestSuite/CakeTestRunner.php +++ b/lib/Cake/TestSuite/CakeTestRunner.php @@ -85,7 +85,8 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { } 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/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php index 6a0f3657b..35e64c493 100644 --- a/lib/Cake/tests/cases/libs/app.test.php +++ b/lib/Cake/tests/cases/libs/app.test.php @@ -352,9 +352,6 @@ class AppImportTest extends CakeTestCase { * @return void */ function testClassLoading() { - $file = App::import(); - $this->assertTrue($file); - $file = App::import('Model', 'Model', false); $this->assertTrue($file); $this->assertTrue(class_exists('Model')); @@ -363,15 +360,15 @@ class AppImportTest extends CakeTestCase { $this->assertTrue($file); $this->assertTrue(class_exists('Controller')); - $file = App::import('Component', 'Component', false); + $file = App::import('Component', 'Auth', false); $this->assertTrue($file); - $this->assertTrue(class_exists('Component')); + $this->assertTrue(class_exists('AuthComponent')); $file = App::import('Shell', 'Shell', false); $this->assertTrue($file); $this->assertTrue(class_exists('Shell')); - $file = App::import('Lib', 'config/PhpReader'); + $file = App::import('Configure', 'PhpReader'); $this->assertTrue($file); $this->assertTrue(class_exists('PhpReader')); @@ -383,23 +380,14 @@ class AppImportTest extends CakeTestCase { $this->assertTrue(class_exists('AppModel')); $file = App::import('WrongType', null, true, array(), ''); - $this->assertTrue($file); + $this->assertFalse($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()); From 02955fb923befe97f7868fcabf238b8afa180965 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 11 Mar 2011 01:04:41 -0430 Subject: [PATCH 524/668] Removing unused code in App class, improving backwards compatibility in App::import() --- lib/Cake/Core/App.php | 261 ++---------------------------------------- 1 file changed, 10 insertions(+), 251 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 5da8cea86..c5c8e37f5 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -529,6 +529,14 @@ class App { return false; } + if (is_array($name)) { + foreach ($name as $class) { + if (!App::import(compact('type', 'parent', 'search', 'file', 'return') + array('name' => $class))) { + return false; + } + } + } + $originalType = $type = strtolower($type); $specialPackage = in_array($type, array('core', 'file', 'vendor')); if (!$specialPackage && isset(self::$legacy[$type . 's'])) { @@ -549,6 +557,8 @@ class App { return (bool) self::load($name); } + return false; + if (is_array($name)) { foreach ($name as $class) { $tempType = $type; @@ -656,83 +666,6 @@ class App { 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])) { - App::uses('Folder', 'Utility'); - $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. * @@ -773,180 +706,6 @@ class App { 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': - App::uses('Model', 'Model'); - 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) { - App::uses('Folder', 'Utility'); - $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. * From 3f7a7cc5d1d4d30bee3d152832f03083bb6d862e Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 11 Mar 2011 01:07:46 -0430 Subject: [PATCH 525/668] Removing more un-used code in App class --- lib/Cake/Core/App.php | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index c5c8e37f5..88cb24ed6 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -559,35 +559,6 @@ class App { return false; - 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); From 0bf51d92caf9380da99d708993826ec5a4eb2cc4 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 11 Mar 2011 01:31:01 -0430 Subject: [PATCH 526/668] Improving App::import() to make importing from plugins work again --- lib/Cake/Core/App.php | 18 ++++++++++++++---- .../models/datasources/TestSource.php | 2 ++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 88cb24ed6..91260321d 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -145,7 +145,8 @@ class App { 'components' => 'Controller/Component', 'views' => 'View', 'helpers' => 'View/Helper', - 'shells' => 'Console/Command' + 'shells' => 'Console/Command', + 'libs' => 'Lib' ); /** @@ -228,7 +229,7 @@ class App { '%s' . 'vendors' . DS . 'shells' . DS . 'tasks' . DS, VENDORS . 'shells' . DS . 'tasks' . DS ), - 'libs' => array('%s' . 'libs' . 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) @@ -262,8 +263,8 @@ class App { } } - $mergeExclude = array('libs', 'locales', 'vendors', 'plugins'); - $appLibs = empty($paths['libs']) ? $defaults['libs'] : $paths['libs']; + $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)) { @@ -553,6 +554,15 @@ class App { $name .= ($suffix == $name) ? '' : $suffix; } + if (isset(self::$types[$originalType]['extends'])) { + $extends = self::$types[$originalType]['extends']; + App::uses($extends, $type); + if ($plugin && in_array($originalType, array('controller', 'model'))) { + $pluginName = substr($plugin, 0 , -1); + App::uses($pluginName . $extends, $plugin . $type); + } + } + App::uses(Inflector::camelize($name), $plugin . $type); return (bool) self::load($name); } diff --git a/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/TestSource.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/TestSource.php index 2fc4026b0..dee54101a 100644 --- a/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/TestSource.php +++ b/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/TestSource.php @@ -1,4 +1,6 @@ Date: Fri, 11 Mar 2011 20:20:55 +0530 Subject: [PATCH 527/668] Fixed bug where default class name 'checkbox' was dropped in case of validation error for div wrapping checkbox for multiple checkboxes --- cake/libs/view/helpers/form.php | 6 ++- .../cases/libs/view/helpers/form.test.php | 38 ++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 84bc7a2e2..481d5edfd 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -1422,7 +1422,7 @@ class FormHelper extends AppHelper { $style = null; $tag = null; $attributes += array( - 'class' => null, + 'class' => null, 'escape' => true, 'secure' => null, 'empty' => '', @@ -2048,6 +2048,8 @@ class FormHelper extends AppHelper { if (empty($attributes['class'])) { $attributes['class'] = 'checkbox'; + } elseif ($attributes['class'] === 'form-error') { + $attributes['class'] = 'checkbox ' . $attributes['class']; } $label = $this->label(null, $title, $label); $item = sprintf( @@ -2189,7 +2191,7 @@ class FormHelper extends AppHelper { } else { $secure = (isset($this->params['_Token']) && !empty($this->params['_Token'])); } - + $fieldName = null; if ($secure && !empty($options['name'])) { preg_match_all('/\[(.*?)\]/', $options['name'], $matches); diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 8816fe816..fe8cd424b 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -3589,6 +3589,42 @@ class FormHelperTest extends CakeTestCase { 'label' => false )); $this->assertTags($result, $expected); + + $this->Form->validationErrors['Model']['tags'] = 'Select atleast one option'; + $result = $this->Form->input('Model.tags', array( + 'options' => array('one'), + 'multiple' => 'checkbox', + 'label' => false, + 'div' => false + )); + $expected = array( + 'input' => array('type' => 'hidden', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'), + array('div' => array('class' => 'checkbox form-error')), + array('input' => array('type' => 'checkbox', 'name' => 'data[Model][tags][]', 'value' => '0', 'id' => 'ModelTags0')), + array('label' => array('for' => 'ModelTags0')), + 'one', + '/label', + '/div' + ); + $this->assertTags($result, $expected); + + $result = $this->Form->input('Model.tags', array( + 'options' => array('one'), + 'multiple' => 'checkbox', + 'class' => 'mycheckbox', + 'label' => false, + 'div' => false + )); + $expected = array( + 'input' => array('type' => 'hidden', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'), + array('div' => array('class' => 'mycheckbox form-error')), + array('input' => array('type' => 'checkbox', 'name' => 'data[Model][tags][]', 'value' => '0', 'id' => 'ModelTags0')), + array('label' => array('for' => 'ModelTags0')), + 'one', + '/label', + '/div' + ); + $this->assertTags($result, $expected); } /** @@ -6349,7 +6385,7 @@ class FormHelperTest extends CakeTestCase { '/form' ); $this->assertTags($result, $expected); - + $result = $this->Form->end(array('label' => '')); $expected = array( 'div' => array('class' => 'submit'), From 6ac87eef68f61319f0431245cc503a705ae4a99f Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 11 Mar 2011 18:18:58 -0430 Subject: [PATCH 528/668] Making more App::import() tests pass --- lib/Cake/tests/cases/libs/app.test.php | 13 ++++++------- lib/Cake/tests/test_app/views/helpers/banana.php | 3 +++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php index 35e64c493..cece9d3c9 100644 --- a/lib/Cake/tests/cases/libs/app.test.php +++ b/lib/Cake/tests/cases/libs/app.test.php @@ -471,20 +471,19 @@ class AppImportTest extends CakeTestCase { * @link http://cakephp.lighthouseapp.com/projects/42648/tickets/410 */ function testImportingHelpersFromAlternatePaths() { - App::build(); - $this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.'); + + $this->assertFalse(class_exists('BananaHelper', false), '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.'); + $this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper was not found because the path does not exist.'); App::build(array( - 'helpers' => array( + 'View/Helper' => array( LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS ) )); - App::build(array('vendors' => array(LIBS))); - $this->assertFalse(class_exists('BananaHelper'), 'BananaHelper exists, cannot test importing it.'); + $this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper exists, cannot test importing it.'); App::import('Helper', 'Banana'); - $this->assertTrue(class_exists('BananaHelper'), 'BananaHelper was not loaded.'); + $this->assertTrue(class_exists('BananaHelper', false), 'BananaHelper was not loaded.'); App::build(); } diff --git a/lib/Cake/tests/test_app/views/helpers/banana.php b/lib/Cake/tests/test_app/views/helpers/banana.php index f57db5219..3cc656dbd 100644 --- a/lib/Cake/tests/test_app/views/helpers/banana.php +++ b/lib/Cake/tests/test_app/views/helpers/banana.php @@ -15,5 +15,8 @@ * @since CakePHP(tm) v 1.3 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + +App::uses('Helper', 'View'); + class BananaHelper extends Helper { } From 5a57f2c3c3bf9b5b26d73a2919ef908deeab76f7 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 11 Mar 2011 18:56:32 -0430 Subject: [PATCH 529/668] Re-implmenting file loading in App::import(), search it is not longer recursive... if it ever was --- lib/Cake/Core/App.php | 39 ++++++++++++++++++++---- lib/Cake/tests/cases/libs/app.test.php | 42 +++++++++++++++----------- 2 files changed, 58 insertions(+), 23 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 91260321d..c7999a89c 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -543,10 +543,9 @@ class App { if (!$specialPackage && isset(self::$legacy[$type . 's'])) { $type = self::$legacy[$type . 's']; } + list($plugin, $name) = pluginSplit($name); if (!$specialPackage) { - list($plugin, $name) = pluginSplit($name, true); - if ($type == 'Console/Command' && $name == 'Shell') { $type = 'Console'; } else if (isset(self::$types[$originalType]['suffix'])) { @@ -554,19 +553,47 @@ class App { $name .= ($suffix == $name) ? '' : $suffix; } - if (isset(self::$types[$originalType]['extends'])) { + if ($parent && isset(self::$types[$originalType]['extends'])) { $extends = self::$types[$originalType]['extends']; App::uses($extends, $type); if ($plugin && in_array($originalType, array('controller', 'model'))) { - $pluginName = substr($plugin, 0 , -1); - App::uses($pluginName . $extends, $plugin . $type); + App::uses($plugin . $extends, $plugin . '.' .$type); } } - + if ($plugin) { + $plugin .= '.'; + } App::uses(Inflector::camelize($name), $plugin . $type); return (bool) self::load($name); } + if ($type == 'file' && !empty($file)) { + $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; if ($name != null && strpos($name, '.') !== false) { diff --git a/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php index cece9d3c9..d2793cf16 100644 --- a/lib/Cake/tests/cases/libs/app.test.php +++ b/lib/Cake/tests/cases/libs/app.test.php @@ -547,7 +547,7 @@ class AppImportTest extends CakeTestCase { * @return void */ function testLoadingWithSearch () { - $file = App::import('File', 'NewName', false, array(LIBS ), 'config.php'); + $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'); @@ -560,12 +560,24 @@ class AppImportTest extends CakeTestCase { * @access public * @return void */ - function testLoadingWithSearchArray () { - $type = array('type' => 'File', 'name' => 'RandomName', 'parent' => false, 'file' => 'config.php', 'search' => array(LIBS )); + 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)); + $type = array( + 'type' => 'File', + 'name' => 'AnotherRandomName', + 'parent' => false, + 'file' => 'config.php', + 'search' => array(LIBS) + ); $file = App::import($type); $this->assertFalse($file); } @@ -577,28 +589,24 @@ class AppImportTest extends CakeTestCase { * @return void */ function testMultipleLoading() { - if (class_exists('I18n', false) || class_exists('CakeSocket', false)) { + if (class_exists('PersisterOne', false) || class_exists('PersisterTwo', 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); + 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['I18n'])); + $this->assertTrue(isset($classes['PersisterOne'])); + $this->assertTrue(isset($classes['PersisterTwo'])); - $load = App::import(array('I18n', 'SomeNotFoundClass', 'CakeSocket')); + $load = App::import('Model', array('PersisterOne', 'SomeNotFoundClass', 'PersisterTwo')); $this->assertFalse($load); - - $load = App::import($toLoad); - $this->assertTrue($load); } /** From ebd8d1d0c2002c0c94f5bf5f2c47903d7304320c Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 11 Mar 2011 18:59:08 -0430 Subject: [PATCH 530/668] Fixing multiple classes loading in App::import() --- lib/Cake/Core/App.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index c7999a89c..5ed769b07 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -536,6 +536,7 @@ class App { return false; } } + return true; } $originalType = $type = strtolower($type); @@ -563,8 +564,9 @@ class App { if ($plugin) { $plugin .= '.'; } - App::uses(Inflector::camelize($name), $plugin . $type); - return (bool) self::load($name); + $name = Inflector::camelize($name); + App::uses($name, $plugin . $type); + return class_exists($name); } if ($type == 'file' && !empty($file)) { From db089ac22050895c1805c62b40bd4b8717f80bbb Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 11 Mar 2011 23:21:34 -0430 Subject: [PATCH 531/668] Implementing vendor loading and refactoring code in App::import() --- lib/Cake/Core/App.php | 185 +++++++++++-------------- lib/Cake/tests/cases/libs/app.test.php | 36 +---- 2 files changed, 85 insertions(+), 136 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 5ed769b07..cb680c18c 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -516,7 +516,7 @@ class App { * @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; + $ext = $plugin = $directory = null; if (is_array($type)) { extract($type, EXTR_OVERWRITE); @@ -540,129 +540,106 @@ class App { } $originalType = $type = strtolower($type); - $specialPackage = in_array($type, array('core', 'file', 'vendor')); + $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) { - 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); + return self::_loadClass($name, $plugin, $type, $originalType, $parent); } if ($type == 'file' && !empty($file)) { - $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 self::_loadFile($name, $plugin, $search, $file, $return); + } + + if ($type == 'vendor') { + return self::_loadVendor($name, $plugin, $file, $ext); } return false; + } - if ($name != null && strpos($name, '.') !== false) { - list($plugin, $name) = explode('.', $name); - $plugin = Inflector::camelize($plugin); + 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; } - self::$return = $return; - if (isset($ext)) { - $file = Inflector::underscore($name) . ".{$ext}"; + 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); + } } - $ext = self::__settings($type, $plugin, $parent); - $className = $name; - if (strpos($className, '/') !== false) { - $className = substr($className, strrpos($className, '/') + 1); + if ($plugin) { + $plugin .= '.'; } - 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; + $name = Inflector::camelize($name); + App::uses($name, $plugin . $type); + return class_exists($name); + } + + 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($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; + if (!empty($file) && file_exists($file)) { + self::__map($file, $name, $plugin); + $returnValue = include $file; + if ($return) { + return $returnValue; + } + return (bool) $returnValue; + } + return false; + } + + 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; } /** diff --git a/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php index d2793cf16..3009b337a 100644 --- a/lib/Cake/tests/cases/libs/app.test.php +++ b/lib/Cake/tests/cases/libs/app.test.php @@ -473,9 +473,6 @@ class AppImportTest extends CakeTestCase { function testImportingHelpersFromAlternatePaths() { $this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper exists, cannot test importing it.'); - App::import('Helper', 'Banana'); - $this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper was not found because the path does not exist.'); - App::build(array( 'View/Helper' => array( LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS @@ -609,26 +606,7 @@ class AppImportTest extends CakeTestCase { $this->assertFalse($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(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), @@ -636,27 +614,21 @@ class AppImportTest extends CakeTestCase { ), 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')); + $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.SamplePlugin'); + $result = App::import('Vendor', 'TestPlugin.sample/SamplePlugin'); $this->assertTrue($result); $this->assertTrue(class_exists('SamplePluginClassTestName')); - $result = App::import('Vendor', 'ConfigureTestVendorSample'); + $result = App::import('Vendor', 'sample/ConfigureTestVendorSample'); $this->assertTrue($result); $this->assertTrue(class_exists('ConfigureTestVendorSample')); ob_start(); - $result = App::import('Vendor', 'SomeName', array('file' => 'some.name.php')); + $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'); From fe52c200e3a5e14cdc0aaedfaf165a175e0673b2 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 11 Mar 2011 23:30:16 -0430 Subject: [PATCH 532/668] Documenting auxiliary functions in App class --- lib/Cake/Core/App.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index cb680c18c..49c4e4e44 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -564,6 +564,18 @@ class App { 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'; @@ -587,6 +599,16 @@ class App { 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) { @@ -615,6 +637,15 @@ class App { 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); From fea2ac23c7a86c33cf07c68fd19ecfea4a8f2581 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 12 Mar 2011 00:09:58 -0430 Subject: [PATCH 533/668] Improving Documentation in App class --- lib/Cake/Core/App.php | 83 ++++++++++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 49c4e4e44..89d60a84b 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -16,8 +16,9 @@ * @since CakePHP(tm) v 1.2.0.6001 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ + /** - * App is responsible for path managment, class location and class loading. + * App is responsible for path management, class location and class loading. * * ### Adding paths * @@ -25,11 +26,26 @@ * additional controller paths for example would alter where CakePHP looks for controllers. * This allows you to split your application up across the filesystem. * + * ### Packages + * + * CakePHP is organized around the idea of packages, each class belongs to a package or folder where other + * classes reside. You can configure each package location in your application using `App::build('APackage/SubPackage', $paths)` + * to inform the framework where should each class be loaded. Almost every class in the CakePHP framework can be swapped + * by your own compatible implementation. If you wish to use you own class instead of the classes the framework provides, + * just add the class to your libs folder mocking the directory location of where CakePHP expects to find it. + * + * For instance if you'd like to use your own HttpSocket class, put it under + * + * app/libs/Network/Http/HttpSocket.php + * * ### Inspecting loaded paths * - * You can inspect the currently loaded paths using `App::path('controller')` for example to see loaded + * You can inspect the currently loaded paths using `App::path('Controller')` for example to see loaded * controller paths. * + * It is also possible to inspect paths for plugin classes, for instance, to see a plugin's helpers you would call + * `App::path('View/Helper', 'MyPlugin')` + * * ### Locating plugins and themes * * Plugins and Themes can be located with App as well. Using App::pluginPath('DebugKit') for example, will @@ -38,7 +54,7 @@ * * ### Inspecting known objects * - * You can find out which objects App knows about using App::objects('controller') for example to find + * You can find out which objects App knows about using App::objects('Controller') for example to find * which application controllers App knows about. * * @link http://book.cakephp.org/view/933/The-App-Class @@ -128,7 +144,7 @@ class App { private static $__packages = array(); /** - * + * Holds the templates for each customizable package path in the application * */ private static $__packageFormat = array(); @@ -166,9 +182,12 @@ class App { * * Usage: * - * `App::path('models'); will return all paths for models` + * `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) { @@ -195,10 +214,19 @@ class App { } /** - * Build path references. Merges the supplied $paths - * with the base paths and the default core paths. + * 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` * - * @param array $paths paths defines in config/bootstrap.php + * `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 */ @@ -282,7 +310,11 @@ class App { } /** - * Get the path that a plugin is on. Searches through the defined plugin paths. + * 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. @@ -298,8 +330,12 @@ class App { } /** - * Find the path that a theme is on. Search through the defined theme paths. + * 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. */ @@ -314,28 +350,19 @@ class App { } /** - * 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. + * 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 valid values are: 'cake' ,'plugins', 'vendors' and 'shells' - * @return array numeric keyed array of core lib paths + * @param string $type + * @return string full path to package */ - public static function core($type = null) { - static $paths = false; - if (!$paths) { - $paths = array(); - $root = dirname(dirname(LIBS)) . DS; - $paths['cake'][] = LIBS; - $paths['plugins'][] = $root . 'plugins' . DS; - $paths['vendors'][] = $root . 'vendors' . DS; - $paths['shells'][] = LIBS . 'Console' . DS . 'Command' . DS; - // Provide BC path to vendors/shells - $paths['shells'][] = $root . 'vendors' . DS . 'shells' . DS; - } + public static function core($type) { if ($type) { return isset($paths[$type]) ? $paths[$type] : array(LIBS . $type . DS); } - return $paths; } /** @@ -348,7 +375,7 @@ class App { * You can also search only within a plugin's objects by using the plugin dot * syntax. * - * `App::objects('MyPlugin.model');` returns `array('Post', 'Comment');` + * `App::objects('MyPlugin.Model');` returns `array('MyPluginPost', 'MyPluginComment');` * * @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 From 96fa5e79bacc5d69568b9326c7352dd2c51e173f Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 12 Mar 2011 00:27:50 -0430 Subject: [PATCH 534/668] Fixing fixture loading after recent changes in App::core() --- lib/Cake/TestSuite/CakeTestRunner.php | 3 ++- lib/Cake/TestSuite/Fixture/CakeFixtureManager.php | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Cake/TestSuite/CakeTestRunner.php b/lib/Cake/TestSuite/CakeTestRunner.php index 94295dd8c..c0eea1b56 100644 --- a/lib/Cake/TestSuite/CakeTestRunner.php +++ b/lib/Cake/TestSuite/CakeTestRunner.php @@ -80,7 +80,8 @@ 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'])); diff --git a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php index c8671bdde..7f2b307f0 100644 --- a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php +++ b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php @@ -105,9 +105,7 @@ class CakeFixtureManager { 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( From c188d1a91cfc476a710ff765f00412927ab3bb64 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 12 Mar 2011 00:29:44 -0430 Subject: [PATCH 535/668] Fixing Dispatcher tests after recent changes in App::core() --- lib/Cake/tests/cases/libs/dispatcher.test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/tests/cases/libs/dispatcher.test.php b/lib/Cake/tests/cases/libs/dispatcher.test.php index fadf9b6b3..bcfa6517a 100644 --- a/lib/Cake/tests/cases/libs/dispatcher.test.php +++ b/lib/Cake/tests/cases/libs/dispatcher.test.php @@ -538,7 +538,7 @@ class DispatcherTest extends CakeTestCase { $this->_debug = Configure::read('debug'); - App::build(App::core()); + App::build(); App::objects('plugin', null, false); } From bab30bd48dfce2c89de21ba8e038c625380189a8 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 12 Mar 2011 00:32:44 -0430 Subject: [PATCH 536/668] More fixes after the recent changes in App::core() --- lib/Cake/Console/Command/Task/ProjectTask.php | 2 +- lib/Cake/Utility/Debugger.php | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index 4503f276f..addf35a00 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -53,7 +53,7 @@ class ProjectTask extends Shell { } if (empty($this->params['skel'])) { - $core = App::core('shells'); + $core = App::core('Console'); $skelPath = dirname($core[0]) . DS . 'templates' . DS . 'skel'; if (is_dir($skelPath) === true) { $this->params['skel'] = $skelPath; diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index eb748ac70..e92edb4bf 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -400,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; } From d8908967775edb38d74515e1260c56923f412094 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 12 Mar 2011 00:40:43 -0430 Subject: [PATCH 537/668] Updating Lib package usage in App::load() --- lib/Cake/Core/App.php | 2 +- lib/Cake/tests/cases/libs/cache.test.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 89d60a84b..3db3db5db 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -490,7 +490,7 @@ class App { $paths = self::path($package, $plugin); if (empty($plugin)) { - $appLibs = empty(self::$__packages['libs']) ? APPLIBS : current(self::$__packages['libs']); + $appLibs = empty(self::$__packages['Lib']) ? APPLIBS : current(self::$__packages['Lib']); $paths[] = $appLibs . self::$__classMap[$className] . DS; $paths[] = LIBS . self::$__classMap[$className] . DS; } diff --git a/lib/Cake/tests/cases/libs/cache.test.php b/lib/Cake/tests/cases/libs/cache.test.php index 433f3bb5e..5476f837a 100644 --- a/lib/Cake/tests/cases/libs/cache.test.php +++ b/lib/Cake/tests/cases/libs/cache.test.php @@ -89,7 +89,7 @@ class CacheTest extends CakeTestCase { */ function testConfigWithLibAndPluginEngines() { App::build(array( - 'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS), + 'Lib' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS), 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) ), true); From 2bbac9e9b017ded1dc0211e57257bdceecdb33ed Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 12 Mar 2011 00:52:23 -0430 Subject: [PATCH 538/668] Fixing Folder class tests --- lib/Cake/tests/cases/libs/folder.test.php | 24 ++++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/Cake/tests/cases/libs/folder.test.php b/lib/Cake/tests/cases/libs/folder.test.php index 5b063800f..65d153b9f 100644 --- a/lib/Cake/tests/cases/libs/folder.test.php +++ b/lib/Cake/tests/cases/libs/folder.test.php @@ -322,7 +322,6 @@ class FolderTest extends CakeTestCase { ), array( LIBS . 'config' . DS . 'config.php', - LIBS . 'config' . DS . 'paths.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', @@ -473,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); } @@ -490,29 +488,29 @@ class FolderTest extends CakeTestCase { $Folder = new Folder(); $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); @@ -544,16 +542,14 @@ class FolderTest extends CakeTestCase { $Folder->cd(LIBS); $result = $Folder->findRecursive('(config|paths)\.php'); $expected = array( - LIBS . 'config' . DS . 'config.php', - LIBS . '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( - LIBS . 'config' . DS . 'config.php', - LIBS . 'config' . DS . 'paths.php' + LIBS . 'config' . DS . 'config.php' ); $this->assertIdentical($result, $expected); From fd84b1494dade3a8930c315a1d1c4320f7697d53 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 12 Mar 2011 01:15:56 -0430 Subject: [PATCH 539/668] Documenting remaining methods in App class --- lib/Cake/Core/App.php | 62 +++++++++++++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 3db3db5db..4d651abe2 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -27,17 +27,17 @@ * This allows you to split your application up across the filesystem. * * ### Packages - * + * * CakePHP is organized around the idea of packages, each class belongs to a package or folder where other * classes reside. You can configure each package location in your application using `App::build('APackage/SubPackage', $paths)` * to inform the framework where should each class be loaded. Almost every class in the CakePHP framework can be swapped * by your own compatible implementation. If you wish to use you own class instead of the classes the framework provides, * just add the class to your libs folder mocking the directory location of where CakePHP expects to find it. - * + * * For instance if you'd like to use your own HttpSocket class, put it under - * + * * app/libs/Network/Http/HttpSocket.php - * + * * ### Inspecting loaded paths * * You can inspect the currently loaded paths using `App::path('Controller')` for example to see loaded @@ -45,7 +45,7 @@ * * It is also possible to inspect paths for plugin classes, for instance, to see a plugin's helpers you would call * `App::path('View/Helper', 'MyPlugin')` - * + * * ### Locating plugins and themes * * Plugins and Themes can be located with App as well. Using App::pluginPath('DebugKit') for example, will @@ -183,7 +183,7 @@ class App { * 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 @@ -217,15 +217,15 @@ class App { * 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 @@ -311,9 +311,9 @@ class App { /** * 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. @@ -333,9 +333,9 @@ class App { * 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. */ @@ -351,9 +351,9 @@ class App { /** * 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 @@ -372,14 +372,15 @@ class App { * * `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', 'helper', or 'plugin' - * @param mixed $path Optional Scan only the path given. If null, paths for the chosen - * type will be used. + * @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. */ @@ -475,10 +476,31 @@ class App { 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)) { @@ -693,7 +715,7 @@ class App { foreach ($paths as $path) { if (file_exists($path . $file)) { self::__map($path . $file, $name, $plugin); - return (bool) include($path . $file); + return (bool) include($path . $file); } } } From ecc6a22b3b20149c8a370d3f2a6f86319363a956 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 12 Mar 2011 01:56:34 -0430 Subject: [PATCH 540/668] Adding tests for loading classes from the libs folder --- lib/Cake/Core/App.php | 4 ++-- lib/Cake/tests/cases/libs/app.test.php | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 4d651abe2..07aea99ef 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -513,8 +513,8 @@ class App { if (empty($plugin)) { $appLibs = empty(self::$__packages['Lib']) ? APPLIBS : current(self::$__packages['Lib']); - $paths[] = $appLibs . self::$__classMap[$className] . DS; - $paths[] = LIBS . self::$__classMap[$className] . DS; + $paths[] = $appLibs . $package . DS; + $paths[] = LIBS . $package . DS; } foreach ($paths as $path) { diff --git a/lib/Cake/tests/cases/libs/app.test.php b/lib/Cake/tests/cases/libs/app.test.php index 3009b337a..e90e1b06b 100644 --- a/lib/Cake/tests/cases/libs/app.test.php +++ b/lib/Cake/tests/cases/libs/app.test.php @@ -657,4 +657,24 @@ class AppImportTest extends CakeTestCase { $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')); + } } From 6f232c454378b40372b999dad3fe6b128f98c220 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Sat, 12 Mar 2011 02:06:50 -0430 Subject: [PATCH 541/668] Fixing the loading of the HtmlCodeCoverageReport class --- lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php index e9ccd4934..e676c570d 100755 --- a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php @@ -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(); } From d0dfd7f18c80fd8d279cac424e048c304665b82f Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Mar 2011 11:10:31 -0500 Subject: [PATCH 542/668] Removing more calls to strtolower(). Instead type the method names with the correct casing. --- cake/libs/controller/components/security.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index 79977b799..7b1f6cac8 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -184,7 +184,7 @@ class SecurityComponent extends Component { */ public function startup($controller) { $this->request = $controller->request; - $this->_action = strtolower($this->request->params['action']); + $this->_action = $this->request->params['action']; $this->_methodsRequired($controller); $this->_secureRequired($controller); $this->_authRequired($controller); @@ -319,10 +319,10 @@ class SecurityComponent extends Component { foreach (array('Post', 'Get', 'Put', 'Delete') as $method) { $property = 'require' . $method; if (is_array($this->$property) && !empty($this->$property)) { - $require = array_map('strtolower', $this->$property); + $require = $this->$property; if (in_array($this->_action, $require) || $this->$property == array('*')) { - if (!$this->request->is(strtolower($method))) { - if (!$this->blackHole($controller, strtolower($method))) { + if (!$this->request->is($method)) { + if (!$this->blackHole($controller, $method)) { return null; } } @@ -340,7 +340,7 @@ class SecurityComponent extends Component { */ protected function _secureRequired($controller) { if (is_array($this->requireSecure) && !empty($this->requireSecure)) { - $requireSecure = array_map('strtolower', $this->requireSecure); + $requireSecure = $this->requireSecure; if (in_array($this->_action, $requireSecure) || $this->requireSecure == array('*')) { if (!$this->request->is('ssl')) { @@ -361,7 +361,7 @@ class SecurityComponent extends Component { */ protected function _authRequired($controller) { if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) { - $requireAuth = array_map('strtolower', $this->requireAuth); + $requireAuth = $this->requireAuth; if (in_array($this->request->params['action'], $requireAuth) || $this->requireAuth == array('*')) { if (!isset($controller->request->data['_Token'] )) { From 70d334f7eb11fdd55494d4e454f34e21ca0f7ddf Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 23 Feb 2011 11:15:52 -0500 Subject: [PATCH 543/668] Moving core cache configuration out of Configure and into core.php. This makes the cache configurations cake uses internally more transparent, and easier for the end developer to configure. Fixes #1586 --- app/config/core.php | 41 ++++++++++++++++++++++++++++++++++++++++- cake/libs/configure.php | 37 ------------------------------------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/app/config/core.php b/app/config/core.php index 9744da06c..18c3e3926 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -283,4 +283,43 @@ * )); * */ - Cache::config('default', array('engine' => 'File')); + +// Pick the caching engine to use. If APC is enabled use it. +$engine = 'File'; +if (extension_loaded('apc')) { + $engine = 'Apc'; +} + +// Setup a 'default' cache configuration for use in the application. +Cache::config('default', array('engine' => $engine)); + +// In development mode, caches should expire quickly. +$duration = '+999 days'; +if (Configure::read('debug') >= 1) { + $duration = '+10 seconds'; +} + +/** + * Configure the cache used for general framework caching. Path information, + * object listings, and translation cache files are stored with this configuration. + */ +Cache::config('_cake_core_', array( + 'engine' => $engine, + 'prefix' => 'cake_core_', + 'path' => CACHE . 'persistent' . DS, + 'serialize' => ($engine === 'File'), + 'duration' => $duration +)); + +/** + * Configure the cache for model, and datasource caches. This cache configuration + * is used to store schema descriptions, and table listings in connections. + */ +Cache::config('_cake_model_', array( + 'engine' => $engine, + 'prefix' => 'cake_model_', + 'path' => CACHE . 'models' . DS, + 'serialize' => ($engine === 'File'), + 'duration' => $duration +)); + diff --git a/cake/libs/configure.php b/cake/libs/configure.php index 5c4cc74b8..29633732c 100644 --- a/cake/libs/configure.php +++ b/cake/libs/configure.php @@ -73,43 +73,6 @@ class Configure { trigger_error(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR); } - if (empty(self::$_values['Cache']['disable'])) { - $cache = Cache::config('default'); - - if (empty($cache['settings'])) { - trigger_error(__('Cache not configured properly. Please check Cache::config(); in APP/config/core.php'), E_USER_WARNING); - $cache = Cache::config('default', array('engine' => 'File')); - } - $path = $prefix = $duration = null; - - if (!empty($cache['settings']['path'])) { - $path = realpath($cache['settings']['path']); - } else { - $prefix = $cache['settings']['prefix']; - } - - if (self::$_values['debug'] >= 1) { - $duration = '+10 seconds'; - } else { - $duration = '+999 days'; - } - $cacheConfigs = Cache::configured(); - - if (!in_array('_cake_core_', $cacheConfigs)) { - Cache::config('_cake_core_', array_merge((array)$cache['settings'], array( - 'prefix' => $prefix . 'cake_core_', 'path' => $path . DS . 'persistent' . DS, - 'serialize' => true, 'duration' => $duration - ))); - } - - if (!in_array('_cake_model_', $cacheConfigs)) { - Cache::config('_cake_model_', array_merge((array)$cache['settings'], array( - 'prefix' => $prefix . 'cake_model_', 'path' => $path . DS . 'models' . DS, - 'serialize' => true, 'duration' => $duration - ))); - } - } - App::init(); App::build(); if (!include(CONFIGS . 'bootstrap.php')) { From 20299c9138ea635f6fde5da79cab7e9fed0d8008 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Mar 2011 12:06:10 -0500 Subject: [PATCH 544/668] Removing duplicate package string. Updating FileEngine tests to use file_test config instead of inheriting 'default' as default could be an APC config now. Removing tests that were testing clearCache(), as that is not part of FileEngine's features. --- cake/libs/cache/file.php | 2 - cake/tests/cases/libs/cache/file.test.php | 164 +++++++--------------- 2 files changed, 54 insertions(+), 112 deletions(-) diff --git a/cake/libs/cache/file.php b/cake/libs/cache/file.php index 46ff892a3..11bcf523c 100644 --- a/cake/libs/cache/file.php +++ b/cake/libs/cache/file.php @@ -13,7 +13,6 @@ * * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @link http://cakephp.org CakePHP(tm) Project - * @package cake.libs.cache * @since CakePHP(tm) v 1.2.0.4933 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ @@ -21,7 +20,6 @@ /** * File Storage engine for cache * - * @todo use the File and Folder classes (if it's not a too big performance hit) * @package cake.libs.cache */ class FileEngine extends CacheEngine { diff --git a/cake/tests/cases/libs/cache/file.test.php b/cake/tests/cases/libs/cache/file.test.php index fb6741a7a..e38a09872 100644 --- a/cake/tests/cases/libs/cache/file.test.php +++ b/cake/tests/cases/libs/cache/file.test.php @@ -42,10 +42,9 @@ class FileEngineTest extends CakeTestCase { * @return void */ function setUp() { - $this->_cacheDisable = Configure::read('Cache.disable'); - $this->_cacheConfig = Cache::config('default'); + parent::setUp(); Configure::write('Cache.disable', false); - Cache::config('default', array('engine' => 'File', 'path' => CACHE)); + Cache::config('file_test', array('engine' => 'File', 'path' => CACHE)); } /** @@ -55,9 +54,9 @@ class FileEngineTest extends CakeTestCase { * @return void */ function tearDown() { - Cache::clear(false, 'default'); - Configure::write('Cache.disable', $this->_cacheDisable); - Cache::config('default', $this->_cacheConfig['settings']); + parent::tearDown(); + Cache::clear(false, 'file_test'); + Cache::drop('file_test'); } /** @@ -84,24 +83,24 @@ class FileEngineTest extends CakeTestCase { function testReadAndWriteCache() { Cache::config('default'); - $result = Cache::write(null, 'here'); + $result = Cache::write(null, 'here', 'file_test'); $this->assertFalse($result); - Cache::set(array('duration' => 1)); + Cache::set(array('duration' => 1), 'file_test'); - $result = Cache::read('test'); + $result = Cache::read('test', 'file_test'); $expecting = ''; $this->assertEqual($result, $expecting); $data = 'this is a test of the emergency broadcasting system'; - $result = Cache::write('test', $data); + $result = Cache::write('test', $data, 'file_test'); $this->assertTrue(file_exists(CACHE . 'cake_test')); - $result = Cache::read('test'); + $result = Cache::read('test', 'file_test'); $expecting = $data; $this->assertEqual($result, $expecting); - Cache::delete('test'); + Cache::delete('test', 'file_test'); } /** @@ -111,27 +110,27 @@ class FileEngineTest extends CakeTestCase { * @return void */ function testExpiry() { - Cache::set(array('duration' => 1)); + Cache::set(array('duration' => 1), 'file_test'); - $result = Cache::read('test'); + $result = Cache::read('test', 'file_test'); $this->assertFalse($result); $data = 'this is a test of the emergency broadcasting system'; - $result = Cache::write('other_test', $data); + $result = Cache::write('other_test', $data, 'file_test'); $this->assertTrue($result); sleep(2); - $result = Cache::read('other_test'); + $result = Cache::read('other_test', 'file_test'); $this->assertFalse($result); - Cache::set(array('duration' => "+1 second")); + Cache::set(array('duration' => "+1 second"), 'file_test'); $data = 'this is a test of the emergency broadcasting system'; - $result = Cache::write('other_test', $data); + $result = Cache::write('other_test', $data, 'file_test'); $this->assertTrue($result); sleep(2); - $result = Cache::read('other_test'); + $result = Cache::read('other_test', 'file_test'); $this->assertFalse($result); } @@ -143,14 +142,14 @@ class FileEngineTest extends CakeTestCase { */ function testDeleteCache() { $data = 'this is a test of the emergency broadcasting system'; - $result = Cache::write('delete_test', $data); + $result = Cache::write('delete_test', $data, 'file_test'); $this->assertTrue($result); - $result = Cache::delete('delete_test'); + $result = Cache::delete('delete_test', 'file_test'); $this->assertTrue($result); $this->assertFalse(file_exists(TMP . 'tests' . DS . 'delete_test')); - $result = Cache::delete('delete_test'); + $result = Cache::delete('delete_test', 'file_test'); $this->assertFalse($result); } @@ -161,17 +160,17 @@ class FileEngineTest extends CakeTestCase { * @return void */ function testSerialize() { - Cache::config('default', array('engine' => 'File', 'serialize' => true)); + Cache::config('file_test', array('engine' => 'File', 'serialize' => true)); $data = 'this is a test of the emergency broadcasting system'; - $write = Cache::write('serialize_test', $data); + $write = Cache::write('serialize_test', $data, 'file_test'); $this->assertTrue($write); - Cache::config('default', array('serialize' => false)); - $read = Cache::read('serialize_test'); + Cache::config('file_test', array('serialize' => false)); + $read = Cache::read('serialize_test', 'file_test'); - $newread = Cache::read('serialize_test'); + $newread = Cache::read('serialize_test', 'file_test'); - $delete = Cache::delete('serialize_test'); + $delete = Cache::delete('serialize_test', 'file_test'); $this->assertIdentical($read, serialize($data)); @@ -185,91 +184,35 @@ class FileEngineTest extends CakeTestCase { * @return void */ function testClear() { - Cache::config('default', array('engine' => 'File', 'duration' => 1)); + Cache::config('file_test', array('engine' => 'File', 'duration' => 1)); + $data = 'this is a test of the emergency broadcasting system'; - $write = Cache::write('serialize_test1', $data); - $write = Cache::write('serialize_test2', $data); - $write = Cache::write('serialize_test3', $data); + $write = Cache::write('serialize_test1', $data, 'file_test'); + $write = Cache::write('serialize_test2', $data, 'file_test'); + $write = Cache::write('serialize_test3', $data, 'file_test'); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test1')); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test2')); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test3')); sleep(2); - $result = Cache::clear(true); + $result = Cache::clear(true, 'file_test'); $this->assertTrue($result); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test1')); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test2')); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test3')); $data = 'this is a test of the emergency broadcasting system'; - $write = Cache::write('serialize_test1', $data); - $write = Cache::write('serialize_test2', $data); - $write = Cache::write('serialize_test3', $data); + $write = Cache::write('serialize_test1', $data, 'file_test'); + $write = Cache::write('serialize_test2', $data, 'file_test'); + $write = Cache::write('serialize_test3', $data, 'file_test'); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test1')); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test2')); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test3')); - $result = Cache::clear(); + $result = Cache::clear(false, 'file_test'); $this->assertTrue($result); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test1')); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test2')); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test3')); - - Cache::config('default', array('engine' => 'File', 'path' => CACHE . 'views' . DS)); - - $data = 'this is a test of the emergency broadcasting system'; - $write = Cache::write('controller_view_1', $data); - $write = Cache::write('controller_view_2', $data); - $write = Cache::write('controller_view_3', $data); - $write = Cache::write('controller_view_10', $data); - $write = Cache::write('controller_view_11', $data); - $write = Cache::write('controller_view_12', $data); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_1')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_2')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_3')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_10')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_11')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_12')); - - clearCache('controller_view_1', 'views', ''); - $this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_1')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_2')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_3')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_10')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_11')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_12')); - - clearCache('controller_view', 'views', ''); - $this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_1')); - $this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_2')); - $this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_3')); - $this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_10')); - $this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_11')); - $this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_12')); - - $write = Cache::write('controller_view_1', $data); - $write = Cache::write('controller_view_2', $data); - $write = Cache::write('controller_view_3', $data); - $write = Cache::write('controller_view_10', $data); - $write = Cache::write('controller_view_11', $data); - $write = Cache::write('controller_view_12', $data); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_1')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_2')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_3')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_10')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_11')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_12')); - - clearCache(array('controller_view_2', 'controller_view_11', 'controller_view_12'), 'views', ''); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_1')); - $this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_2')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_3')); - $this->assertTrue(file_exists(CACHE . 'views'. DS . 'cake_controller_view_10')); - $this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_11')); - $this->assertFalse(file_exists(CACHE . 'views'. DS . 'cake_controller_view_12')); - - clearCache('controller_view'); - - Cache::config('default', array('engine' => 'File', 'path' => CACHE)); } /** @@ -290,14 +233,15 @@ class FileEngineTest extends CakeTestCase { )); $data1 = $data2 = $expected = 'content to cache'; - $FileOne->write('key_one', $data1, DAY); - $FileTwo->write('key_two', $data2, DAY); + $FileOne->write('prefix_one_key_one', $data1, DAY); + $FileTwo->write('prefix_two_key_two', $data2, DAY); - $this->assertEqual($FileOne->read('key_one'), $expected); - $this->assertEqual($FileTwo->read('key_two'), $expected); + $this->assertEqual($FileOne->read('prefix_one_key_one'), $expected); + $this->assertEqual($FileTwo->read('prefix_two_key_two'), $expected); $FileOne->clear(false); - $this->assertEqual($FileTwo->read('key_two'), $expected, 'secondary config was cleared by accident.'); + $this->assertEqual($FileTwo->read('prefix_two_key_two'), $expected, 'secondary config was cleared by accident.'); + $FileTwo->clear(false); } /** @@ -307,11 +251,11 @@ class FileEngineTest extends CakeTestCase { * @return void */ function testKeyPath() { - $result = Cache::write('views.countries.something', 'here'); + $result = Cache::write('views.countries.something', 'here', 'file_test'); $this->assertTrue($result); $this->assertTrue(file_exists(CACHE . 'cake_views_countries_something')); - $result = Cache::read('views.countries.something'); + $result = Cache::read('views.countries.something', 'file_test'); $this->assertEqual($result, 'here'); $result = Cache::clear(); @@ -371,16 +315,16 @@ class FileEngineTest extends CakeTestCase { * @return void */ function testWriteQuotedString() { - Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests')); - Cache::write('App.doubleQuoteTest', '"this is a quoted string"'); - $this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"'); - Cache::write('App.singleQuoteTest', "'this is a quoted string'"); - $this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'"); + Cache::config('file_test', array('engine' => 'File', 'path' => TMP . 'tests')); + Cache::write('App.doubleQuoteTest', '"this is a quoted string"', 'file_test'); + $this->assertIdentical(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"'); + Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test'); + $this->assertIdentical(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'"); - Cache::config('default', array('isWindows' => true, 'path' => TMP . 'tests')); - $this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"'); - Cache::write('App.singleQuoteTest', "'this is a quoted string'"); - $this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'"); + Cache::config('file_test', array('isWindows' => true, 'path' => TMP . 'tests')); + $this->assertIdentical(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"'); + Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test'); + $this->assertIdentical(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'"); } /** From 31e82b08df86064e669c057a79debfa5a9642daa Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Mar 2011 12:14:43 -0500 Subject: [PATCH 545/668] More documentation for Cache. --- cake/libs/cache.php | 14 ++++++++++++-- cake/libs/cache/file.php | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cake/libs/cache.php b/cake/libs/cache.php index 66f255b34..e0b627b15 100644 --- a/cake/libs/cache.php +++ b/cake/libs/cache.php @@ -71,14 +71,24 @@ class Cache { * both create new configurations, return the settings for already configured * configurations. * - * To create a new configuration: + * To create a new configuration, or to modify an existing configuration permanently: * * `Cache::config('my_config', array('engine' => 'File', 'path' => TMP));` * - * To get the settings for a configuration, and set it as the currently selected configuration + * If you need to modify a configuration temporarily, use Cache::set(). + * To get the settings for a configuration: * * `Cache::config('default');` * + * There are 4 built-in caching engines: + * + * - `FileEngine` - Uses simple files to store content. Poor performance, but good for + * storing large objects, or things that are not IO sensitive. + * - `ApcEngine` - Uses the APC object cache, one of the fastest caching engines. + * - `MemcacheEngine` - Uses the PECL::Memcache extension and Memcached for storage. + * Fast reads/writes, and benefits from memcache being distributed. + * - `XcacheEngine` - Uses the Xcache extension, an alternative to APC. + * * @see app/config/core.php for configuration settings * @param string $name Name of the configuration * @param array $settings Optional associative array of settings passed to the engine diff --git a/cake/libs/cache/file.php b/cake/libs/cache/file.php index 11bcf523c..f6db44d09 100644 --- a/cake/libs/cache/file.php +++ b/cake/libs/cache/file.php @@ -1,7 +1,10 @@ Date: Sat, 12 Mar 2011 12:18:21 -0500 Subject: [PATCH 546/668] Moving the default cache configuration to app/config/bootstrap.php, as its not used by CakePHP anymore, and is an application configuration value. --- app/config/bootstrap.php | 12 +++++++++--- app/config/core.php | 3 --- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/config/bootstrap.php b/app/config/bootstrap.php index ceeb85670..2e36a893e 100644 --- a/app/config/bootstrap.php +++ b/app/config/bootstrap.php @@ -1,9 +1,12 @@ 'File')); + /** * The settings below can be used to set additional paths to models, views and controllers. * This is related to Ticket #470 (https://trac.cakephp.org/ticket/470) diff --git a/app/config/core.php b/app/config/core.php index 18c3e3926..3a7613b85 100644 --- a/app/config/core.php +++ b/app/config/core.php @@ -290,9 +290,6 @@ if (extension_loaded('apc')) { $engine = 'Apc'; } -// Setup a 'default' cache configuration for use in the application. -Cache::config('default', array('engine' => $engine)); - // In development mode, caches should expire quickly. $duration = '+999 days'; if (Configure::read('debug') >= 1) { From 30a9543a65c95d9eb07feae0aebde97b9b1ca6eb Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 12 Mar 2011 12:19:06 -0500 Subject: [PATCH 547/668] Syncing skel folder with app folder. --- .../templates/skel/config/bootstrap.php | 14 +++++-- cake/console/templates/skel/config/core.php | 38 ++++++++++++++++++- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/cake/console/templates/skel/config/bootstrap.php b/cake/console/templates/skel/config/bootstrap.php index 697274852..2e36a893e 100644 --- a/cake/console/templates/skel/config/bootstrap.php +++ b/cake/console/templates/skel/config/bootstrap.php @@ -1,9 +1,12 @@ 'File')); + /** * The settings below can be used to set additional paths to models, views and controllers. * This is related to Ticket #470 (https://trac.cakephp.org/ticket/470) @@ -28,7 +34,7 @@ * 'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'), * 'models' => array('/full/path/to/models/', '/next/full/path/to/models/'), * 'views' => array('/full/path/to/views/', '/next/full/path/to/views/'), - * 'controllers' => array(/full/path/to/controllers/', '/next/full/path/to/controllers/'), + * 'controllers' => array('/full/path/to/controllers/', '/next/full/path/to/controllers/'), * 'datasources' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'), * 'behaviors' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'), * 'components' => array('/full/path/to/components/', '/next/full/path/to/components/'), diff --git a/cake/console/templates/skel/config/core.php b/cake/console/templates/skel/config/core.php index 9744da06c..3a7613b85 100644 --- a/cake/console/templates/skel/config/core.php +++ b/cake/console/templates/skel/config/core.php @@ -283,4 +283,40 @@ * )); * */ - Cache::config('default', array('engine' => 'File')); + +// Pick the caching engine to use. If APC is enabled use it. +$engine = 'File'; +if (extension_loaded('apc')) { + $engine = 'Apc'; +} + +// In development mode, caches should expire quickly. +$duration = '+999 days'; +if (Configure::read('debug') >= 1) { + $duration = '+10 seconds'; +} + +/** + * Configure the cache used for general framework caching. Path information, + * object listings, and translation cache files are stored with this configuration. + */ +Cache::config('_cake_core_', array( + 'engine' => $engine, + 'prefix' => 'cake_core_', + 'path' => CACHE . 'persistent' . DS, + 'serialize' => ($engine === 'File'), + 'duration' => $duration +)); + +/** + * Configure the cache for model, and datasource caches. This cache configuration + * is used to store schema descriptions, and table listings in connections. + */ +Cache::config('_cake_model_', array( + 'engine' => $engine, + 'prefix' => 'cake_model_', + 'path' => CACHE . 'models' . DS, + 'serialize' => ($engine === 'File'), + 'duration' => $duration +)); + From dd40e7dbfa790c3e6041cc657773580dcbf49ee6 Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 19:48:02 +0100 Subject: [PATCH 548/668] use the 'cake' domain for any references in the app folder --- app/webroot/test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/webroot/test.php b/app/webroot/test.php index c7b718ca7..ffcedfe39 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -72,7 +72,7 @@ if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { } if (Configure::read('debug') < 1) { - die(__('Debug setting does not allow access to this url.')); + die(__d('cake', 'Debug setting does not allow access to this url.')); } require_once CAKE_TESTS_LIB . 'CakeTestSuiteDispatcher.php'; From d7f275d70559c6164a58ae723c974c13196a27da Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 19:48:57 +0100 Subject: [PATCH 549/668] translation changes in the cache folder modified: lib/Cake/Network/Http/HttpResponse.php --- lib/Cake/Cache/Cache.php | 4 ++-- lib/Cake/Cache/Engine/FileEngine.php | 6 +++--- lib/Cake/Cache/Engine/MemcacheEngine.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Cake/Cache/Cache.php b/lib/Cake/Cache/Cache.php index 59b62fd7a..00cd64c52 100644 --- a/lib/Cake/Cache/Cache.php +++ b/lib/Cake/Cache/Cache.php @@ -133,7 +133,7 @@ class Cache { } $cacheClass = $class . 'Engine'; if (!is_subclass_of($cacheClass, 'CacheEngine')) { - throw new CacheException(__('Cache engines must use CacheEngine as a base class.')); + throw new CacheException(__d('cake', 'Cache engines must use CacheEngine as a base class.')); } self::$_engines[$name] = new $cacheClass(); if (self::$_engines[$name]->init($config)) { @@ -273,7 +273,7 @@ class Cache { self::set(null, $config); if ($success === false && $value !== '') { trigger_error( - __("%s cache was unable to write '%s' to cache", $config, $key), + __d('cake', "%s cache was unable to write '%s' to cache", $config, $key), E_USER_WARNING ); } diff --git a/lib/Cake/Cache/Engine/FileEngine.php b/lib/Cake/Cache/Engine/FileEngine.php index 46ff892a3..f7c55e7e8 100644 --- a/lib/Cake/Cache/Engine/FileEngine.php +++ b/lib/Cake/Cache/Engine/FileEngine.php @@ -250,7 +250,7 @@ class FileEngine extends CacheEngine { * @throws CacheException */ public function decrement($key, $offset = 1) { - throw new CacheException(__('Files cannot be atomically decremented.')); + throw new CacheException(__d('cake', 'Files cannot be atomically decremented.')); } /** @@ -260,7 +260,7 @@ class FileEngine extends CacheEngine { * @throws CacheException */ public function increment($key, $offset = 1) { - throw new CacheException(__('Files cannot be atomically incremented.')); + throw new CacheException(__d('cake', 'Files cannot be atomically incremented.')); } /** @@ -296,7 +296,7 @@ class FileEngine extends CacheEngine { $dir = new SplFileInfo($this->settings['path']); if ($this->_init && !($dir->isDir() && $dir->isWritable())) { $this->_init = false; - trigger_error(__('%s is not writable', $this->settings['path']), E_USER_WARNING); + trigger_error(__d('cake', '%s is not writable', $this->settings['path']), E_USER_WARNING); return false; } return true; diff --git a/lib/Cake/Cache/Engine/MemcacheEngine.php b/lib/Cake/Cache/Engine/MemcacheEngine.php index 012eceba0..e0e34a06a 100644 --- a/lib/Cake/Cache/Engine/MemcacheEngine.php +++ b/lib/Cake/Cache/Engine/MemcacheEngine.php @@ -153,7 +153,7 @@ class MemcacheEngine extends CacheEngine { public function increment($key, $offset = 1) { if ($this->settings['compress']) { throw new CacheException( - __('Method increment() not implemented for compressed cache in %s', __CLASS__) + __d('cake', 'Method increment() not implemented for compressed cache in %s', __CLASS__) ); } return $this->_Memcache->increment($key, $offset); @@ -171,7 +171,7 @@ class MemcacheEngine extends CacheEngine { public function decrement($key, $offset = 1) { if ($this->settings['compress']) { throw new CacheException( - __('Method decrement() not implemented for compressed cache in %s', __CLASS__) + __d('cake', 'Method decrement() not implemented for compressed cache in %s', __CLASS__) ); } return $this->_Memcache->decrement($key, $offset); From 5ae97871da25aaba54d97cf6bb9c1bc7b44191a3 Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 19:50:52 +0100 Subject: [PATCH 550/668] translations changes in the Configure folder --- lib/Cake/Configure/IniReader.php | 2 +- lib/Cake/Configure/PhpReader.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Cake/Configure/IniReader.php b/lib/Cake/Configure/IniReader.php index 7ab9694ce..fcbb47b4b 100644 --- a/lib/Cake/Configure/IniReader.php +++ b/lib/Cake/Configure/IniReader.php @@ -74,7 +74,7 @@ class IniReader implements ConfigReaderInterface { if (!file_exists($filename)) { $filename .= '.ini'; if (!file_exists($filename)) { - throw new ConfigureException(__('Could not load configuration files: %s or %s', substr($filename, 0, -4), $filename)); + throw new ConfigureException(__d('cake', 'Could not load configuration files: %s or %s', substr($filename, 0, -4), $filename)); } } $contents = parse_ini_file($filename, true); diff --git a/lib/Cake/Configure/PhpReader.php b/lib/Cake/Configure/PhpReader.php index acd0f94df..5138a37fc 100644 --- a/lib/Cake/Configure/PhpReader.php +++ b/lib/Cake/Configure/PhpReader.php @@ -55,7 +55,7 @@ class PhpReader implements ConfigReaderInterface { */ public function read($key) { if (strpos($key, '..') !== false) { - throw new ConfigureException(__('Cannot load configuration files with ../ in them.')); + throw new ConfigureException(__d('cake', 'Cannot load configuration files with ../ in them.')); } if (substr($key, -4) === '.php') { $key = substr($key, 0, -4); @@ -70,13 +70,13 @@ class PhpReader implements ConfigReaderInterface { if (!file_exists($file)) { $file .= '.php'; if (!file_exists($file)) { - throw new ConfigureException(__('Could not load configuration files: %s or %s', substr($file, 0, -4), $file)); + throw new ConfigureException(__d('cake', 'Could not load configuration files: %s or %s', substr($file, 0, -4), $file)); } } include $file; if (!isset($config)) { throw new ConfigureException( - sprintf(__('No variable $config found in %s.php'), $file) + sprintf(__d('cake', 'No variable $config found in %s.php'), $file) ); } return $config; From 8f0c923cf6642cefd03a8fed00a83f0d02e605b8 Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 19:59:06 +0100 Subject: [PATCH 551/668] translations for the console dir --- lib/Cake/Console/Command/AclShell.php | 156 +++++++++--------- lib/Cake/Console/Command/ApiShell.php | 14 +- lib/Cake/Console/Command/BakeShell.php | 30 ++-- lib/Cake/Console/Command/CommandListShell.php | 4 +- lib/Cake/Console/Command/I18nShell.php | 22 +-- lib/Cake/Console/Command/SchemaShell.php | 88 +++++----- .../Console/Command/Task/ControllerTask.php | 64 +++---- .../Console/Command/Task/DbConfigTask.php | 4 +- lib/Cake/Console/Command/Task/ExtractTask.php | 74 ++++----- lib/Cake/Console/Command/Task/FixtureTask.php | 20 +-- lib/Cake/Console/Command/Task/ModelTask.php | 106 ++++++------ lib/Cake/Console/Command/Task/PluginTask.php | 20 +-- lib/Cake/Console/Command/Task/ProjectTask.php | 74 ++++----- .../Console/Command/Task/TemplateTask.php | 8 +- lib/Cake/Console/Command/Task/TestTask.php | 30 ++-- lib/Cake/Console/Command/Task/ViewTask.php | 46 +++--- lib/Cake/Console/Command/TestsuiteShell.php | 78 ++++----- lib/Cake/Console/ConsoleErrorHandler.php | 6 +- lib/Cake/Console/ConsoleInputArgument.php | 6 +- lib/Cake/Console/ConsoleInputOption.php | 6 +- lib/Cake/Console/ConsoleOptionParser.php | 10 +- lib/Cake/Console/HelpFormatter.php | 2 +- lib/Cake/Console/Shell.php | 16 +- 23 files changed, 442 insertions(+), 442 deletions(-) diff --git a/lib/Cake/Console/Command/AclShell.php b/lib/Cake/Console/Command/AclShell.php index 7d715e579..74137f1ec 100644 --- a/lib/Cake/Console/Command/AclShell.php +++ b/lib/Cake/Console/Command/AclShell.php @@ -71,12 +71,12 @@ class AclShell extends Shell { if (!in_array(Configure::read('Acl.classname'), array('DbAcl', 'DB_ACL'))) { $out = "--------------------------------------------------\n"; - $out .= __('Error: Your current Cake configuration is set to') . "\n"; - $out .= __('an ACL implementation other than DB. Please change') . "\n"; - $out .= __('your core config to reflect your decision to use') . "\n"; - $out .= __('DbAcl before attempting to use this script') . ".\n"; + $out .= __d('cake', 'Error: Your current Cake configuration is set to') . "\n"; + $out .= __d('cake', 'an ACL implementation other than DB. Please change') . "\n"; + $out .= __d('cake', 'your core config to reflect your decision to use') . "\n"; + $out .= __d('cake', 'DbAcl before attempting to use this script') . ".\n"; $out .= "--------------------------------------------------\n"; - $out .= __('Current ACL Classname: %s', Configure::read('Acl.classname')) . "\n"; + $out .= __d('cake', 'Current ACL Classname: %s', Configure::read('Acl.classname')) . "\n"; $out .= "--------------------------------------------------\n"; $this->err($out); $this->_stop(); @@ -84,7 +84,7 @@ class AclShell extends Shell { if ($this->command) { if (!config('database')) { - $this->out(__('Your database configuration was not found. Take a moment to create one.'), true); + $this->out(__d('cake', 'Your database configuration was not found. Take a moment to create one.'), true); $this->args = null; return $this->DbConfig->execute(); } @@ -127,15 +127,15 @@ class AclShell extends Shell { if (is_string($data) && $data != '/') { $data = array('alias' => $data); } elseif (is_string($data)) { - $this->error(__('/ can not be used as an alias!') . __(" / is the root, please supply a sub alias")); + $this->error(__d('cake', '/ can not be used as an alias!') . __d('cake', " / is the root, please supply a sub alias")); } $data['parent_id'] = $parent; $this->Acl->{$class}->create(); if ($this->Acl->{$class}->save($data)) { - $this->out(__("New %s '%s' created.", $class, $this->args[2]), 2); + $this->out(__d('cake', "New %s '%s' created.", $class, $this->args[2]), 2); } else { - $this->err(__("There was a problem creating a new %s '%s'.", $class, $this->args[2])); + $this->err(__d('cake', "There was a problem creating a new %s '%s'.", $class, $this->args[2])); } } @@ -150,9 +150,9 @@ class AclShell extends Shell { $nodeId = $this->_getNodeId($class, $identifier); if (!$this->Acl->{$class}->delete($nodeId)) { - $this->error(__('Node Not Deleted') . __('There was an error deleting the %s. Check that the node exists', $class) . ".\n"); + $this->error(__d('cake', 'Node Not Deleted') . __d('cake', 'There was an error deleting the %s. Check that the node exists', $class) . ".\n"); } - $this->out(__('%s deleted.', $class), 2); + $this->out(__d('cake', '%s deleted.', $class), 2); } /** @@ -172,9 +172,9 @@ class AclShell extends Shell { ); $this->Acl->{$class}->create(); if (!$this->Acl->{$class}->save($data)) { - $this->out(__('Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.'), true); + $this->out(__d('cake', 'Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.'), true); } else { - $this->out(__('Node parent set to %s', $this->args[2]) . "\n", true); + $this->out(__d('cake', 'Node parent set to %s', $this->args[2]) . "\n", true); } } @@ -191,11 +191,11 @@ class AclShell extends Shell { if (empty($nodes)) { $this->error( - __("Supplied Node '%s' not found", $this->args[1]), - __('No tree returned.') + __d('cake', "Supplied Node '%s' not found", $this->args[1]), + __d('cake', 'No tree returned.') ); } - $this->out(__('Path:')); + $this->out(__d('cake', 'Path:')); $this->hr(); for ($i = 0; $i < count($nodes); $i++) { $this->_outputNode($class, $nodes[$i], $i); @@ -228,9 +228,9 @@ class AclShell extends Shell { extract($this->__getParams()); if ($this->Acl->check($aro, $aco, $action)) { - $this->out(__('%s is allowed.', $aroName), true); + $this->out(__d('cake', '%s is allowed.', $aroName), true); } else { - $this->out(__('%s is not allowed.', $aroName), true); + $this->out(__d('cake', '%s is not allowed.', $aroName), true); } } @@ -242,9 +242,9 @@ class AclShell extends Shell { extract($this->__getParams()); if ($this->Acl->allow($aro, $aco, $action)) { - $this->out(__('Permission granted.'), true); + $this->out(__d('cake', 'Permission granted.'), true); } else { - $this->out(__('Permission was not granted.'), true); + $this->out(__d('cake', 'Permission was not granted.'), true); } } @@ -256,9 +256,9 @@ class AclShell extends Shell { extract($this->__getParams()); if ($this->Acl->deny($aro, $aco, $action)) { - $this->out(__('Permission denied.'), true); + $this->out(__d('cake', 'Permission denied.'), true); } else { - $this->out(__('Permission was not denied.'), true); + $this->out(__d('cake', 'Permission was not denied.'), true); } } @@ -270,9 +270,9 @@ class AclShell extends Shell { extract($this->__getParams()); if ($this->Acl->inherit($aro, $aco, $action)) { - $this->out(__('Permission inherited.'), true); + $this->out(__d('cake', 'Permission inherited.'), true); } else { - $this->out(__('Permission was not inherited.'), true); + $this->out(__d('cake', 'Permission was not inherited.'), true); } } @@ -303,9 +303,9 @@ class AclShell extends Shell { if (empty($nodes)) { if (isset($this->args[1])) { - $this->error(__('%s not found', $this->args[1]), __('No tree returned.')); + $this->error(__d('cake', '%s not found', $this->args[1]), __d('cake', 'No tree returned.')); } elseif (isset($this->args[0])) { - $this->error(__('%s not found', $this->args[0]), __('No tree returned.')); + $this->error(__d('cake', '%s not found', $this->args[0]), __d('cake', 'No tree returned.')); } } $this->out($class . " tree:"); @@ -354,140 +354,140 @@ class AclShell extends Shell { $type = array( 'choices' => array('aro', 'aco'), 'required' => true, - 'help' => __('Type of node to create.') + 'help' => __d('cake', 'Type of node to create.') ); $parser->description('A console tool for managing the DbAcl') ->addSubcommand('create', array( - 'help' => __('Create a new ACL node'), + 'help' => __d('cake', 'Create a new ACL node'), 'parser' => array( - 'description' => __('Creates a new ACL object under the parent'), + 'description' => __d('cake', 'Creates a new ACL object under the parent'), 'arguments' => array( 'type' => $type, 'parent' => array( - 'help' => __('The node selector for the parent.'), + 'help' => __d('cake', 'The node selector for the parent.'), 'required' => true ), 'alias' => array( - 'help' => __('The alias to use for the newly created node.'), + 'help' => __d('cake', 'The alias to use for the newly created node.'), 'required' => true ) ) ) ))->addSubcommand('delete', array( - 'help' => __('Deletes the ACL object with the given reference'), + 'help' => __d('cake', 'Deletes the ACL object with the given reference'), 'parser' => array( - 'description' => __('Delete an ACL node.'), + 'description' => __d('cake', 'Delete an ACL node.'), 'arguments' => array( 'type' => $type, 'node' => array( - 'help' => __('The node identifier to delete.'), + 'help' => __d('cake', 'The node identifier to delete.'), 'required' => true, ) ) ) ))->addSubcommand('setparent', array( - 'help' => __('Moves the ACL node under a new parent.'), + 'help' => __d('cake', 'Moves the ACL node under a new parent.'), 'parser' => array( - 'description' => __('Moves the ACL object specified by beneath '), + 'description' => __d('cake', 'Moves the ACL object specified by beneath '), 'arguments' => array( 'type' => $type, 'node' => array( - 'help' => __('The node to move'), + 'help' => __d('cake', 'The node to move'), 'required' => true, ), 'parent' => array( - 'help' => __('The new parent for .'), + 'help' => __d('cake', 'The new parent for .'), 'required' => true ) ) ) ))->addSubcommand('getpath', array( - 'help' => __('Print out the path to an ACL node.'), + 'help' => __d('cake', 'Print out the path to an ACL node.'), 'parser' => array( 'description' => array( - __("Returns the path to the ACL object specified by ."), - __("This command is useful in determining the inhertiance of permissions"), - __("for a certain object in the tree.") + __d('cake', "Returns the path to the ACL object specified by ."), + __d('cake', "This command is useful in determining the inhertiance of permissions"), + __d('cake', "for a certain object in the tree.") ), 'arguments' => array( 'type' => $type, 'node' => array( - 'help' => __('The node to get the path of'), + 'help' => __d('cake', 'The node to get the path of'), 'required' => true, ) ) ) ))->addSubcommand('check', array( - 'help' => __('Check the permissions between an ACO and ARO.'), + 'help' => __d('cake', 'Check the permissions between an ACO and ARO.'), 'parser' => array( 'description' => array( - __("Use this command to grant ACL permissions. Once executed, the ARO "), - __("specified (and its children, if any) will have ALLOW access to the"), - __("specified ACO action (and the ACO's children, if any).") + __d('cake', "Use this command to grant ACL permissions. Once executed, the ARO "), + __d('cake', "specified (and its children, if any) will have ALLOW access to the"), + __d('cake', "specified ACO action (and the ACO's children, if any).") ), 'arguments' => array( - 'aro' => array('help' => __('ARO to check.'), 'required' => true), - 'aco' => array('help' => __('ACO to check.'), 'required' => true), - 'action' => array('help' => __('Action to check'), 'default' => 'all') + 'aro' => array('help' => __d('cake', 'ARO to check.'), 'required' => true), + 'aco' => array('help' => __d('cake', 'ACO to check.'), 'required' => true), + 'action' => array('help' => __d('cake', 'Action to check'), 'default' => 'all') ) ) ))->addSubcommand('grant', array( - 'help' => __('Grant an ARO permissions to an ACO.'), + 'help' => __d('cake', 'Grant an ARO permissions to an ACO.'), 'parser' => array( 'description' => array( - __("Use this command to grant ACL permissions. Once executed, the ARO"), - __("specified (and its children, if any) will have ALLOW access to the"), - __("specified ACO action (and the ACO's children, if any).") + __d('cake', "Use this command to grant ACL permissions. Once executed, the ARO"), + __d('cake', "specified (and its children, if any) will have ALLOW access to the"), + __d('cake', "specified ACO action (and the ACO's children, if any).") ), 'arguments' => array( - 'aro' => array('help' => __('ARO to grant permission to.'), 'required' => true), - 'aco' => array('help' => __('ACO to grant access to.'), 'required' => true), - 'action' => array('help' => __('Action to grant'), 'default' => 'all') + 'aro' => array('help' => __d('cake', 'ARO to grant permission to.'), 'required' => true), + 'aco' => array('help' => __d('cake', 'ACO to grant access to.'), 'required' => true), + 'action' => array('help' => __d('cake', 'Action to grant'), 'default' => 'all') ) ) ))->addSubcommand('deny', array( - 'help' => __('Deny an ARO permissions to an ACO.'), + 'help' => __d('cake', 'Deny an ARO permissions to an ACO.'), 'parser' => array( 'description' => array( - __("Use this command to deny ACL permissions. Once executed, the ARO"), - __("specified (and its children, if any) will have DENY access to the"), - __("specified ACO action (and the ACO's children, if any).") + __d('cake', "Use this command to deny ACL permissions. Once executed, the ARO"), + __d('cake', "specified (and its children, if any) will have DENY access to the"), + __d('cake', "specified ACO action (and the ACO's children, if any).") ), 'arguments' => array( - 'aro' => array('help' => __('ARO to deny.'), 'required' => true), - 'aco' => array('help' => __('ACO to deny.'), 'required' => true), - 'action' => array('help' => __('Action to deny'), 'default' => 'all') + 'aro' => array('help' => __d('cake', 'ARO to deny.'), 'required' => true), + 'aco' => array('help' => __d('cake', 'ACO to deny.'), 'required' => true), + 'action' => array('help' => __d('cake', 'Action to deny'), 'default' => 'all') ) ) ))->addSubcommand('inherit', array( - 'help' => __('Inherit an ARO\'s parent permissions.'), + 'help' => __d('cake', 'Inherit an ARO\'s parent permissions.'), 'parser' => array( 'description' => array( - __("Use this command to force a child ARO object to inherit its"), - __("permissions settings from its parent.") + __d('cake', "Use this command to force a child ARO object to inherit its"), + __d('cake', "permissions settings from its parent.") ), 'arguments' => array( - 'aro' => array('help' => __('ARO to have permisssions inherit.'), 'required' => true), - 'aco' => array('help' => __('ACO to inherit permissions on.'), 'required' => true), - 'action' => array('help' => __('Action to inherit'), 'default' => 'all') + 'aro' => array('help' => __d('cake', 'ARO to have permisssions inherit.'), 'required' => true), + 'aco' => array('help' => __d('cake', 'ACO to inherit permissions on.'), 'required' => true), + 'action' => array('help' => __d('cake', 'Action to inherit'), 'default' => 'all') ) ) ))->addSubcommand('view', array( - 'help' => __('View a tree or a single node\'s subtree.'), + 'help' => __d('cake', 'View a tree or a single node\'s subtree.'), 'parser' => array( 'description' => array( - __("The view command will return the ARO or ACO tree."), - __("The optional node parameter allows you to return"), - __("only a portion of the requested tree.") + __d('cake', "The view command will return the ARO or ACO tree."), + __d('cake', "The optional node parameter allows you to return"), + __d('cake', "only a portion of the requested tree.") ), 'arguments' => array( 'type' => $type, - 'node' => array('help' => __('The optional node to view the subtree of.')) + 'node' => array('help' => __d('cake', 'The optional node to view the subtree of.')) ) ) ))->addSubcommand('initdb', array( - 'help' => __('Initialize the DbAcl tables. Uses this command : cake schema run create DbAcl') + 'help' => __d('cake', 'Initialize the DbAcl tables. Uses this command : cake schema run create DbAcl') ))->epilog( array( 'Node and parent arguments can be in one of the following formats:', @@ -520,7 +520,7 @@ class AclShell extends Shell { $conditions = array($class . '.' . $key => $this->args[1]); $possibility = $this->Acl->{$class}->find('all', compact('conditions')); if (empty($possibility)) { - $this->error(__('%s not found', $this->args[1]), __('No tree returned.')); + $this->error(__d('cake', '%s not found', $this->args[1]), __d('cake', 'No tree returned.')); } return $possibility; } @@ -556,7 +556,7 @@ class AclShell extends Shell { if (is_array($identifier)) { $identifier = var_export($identifier, true); } - $this->error(__('Could not find node using reference "%s"', $identifier)); + $this->error(__d('cake', 'Could not find node using reference "%s"', $identifier)); } return Set::extract($node, "0.{$class}.id"); } diff --git a/lib/Cake/Console/Command/ApiShell.php b/lib/Cake/Console/Command/ApiShell.php index 47db18f71..1813e6555 100644 --- a/lib/Cake/Console/Command/ApiShell.php +++ b/lib/Cake/Console/Command/ApiShell.php @@ -85,7 +85,7 @@ class ApiShell extends Shell { } } else { - $this->error(__('%s not found', $class)); + $this->error(__d('cake', '%s not found', $class)); } $parsed = $this->__parseClass($path . $class .'.php', $class); @@ -93,7 +93,7 @@ class ApiShell extends Shell { if (!empty($parsed)) { if (isset($this->params['method'])) { if (!isset($parsed[$this->params['method']])) { - $this->err(__('%s::%s() could not be found', $class, $this->params['method'])); + $this->err(__d('cake', '%s::%s() could not be found', $class, $this->params['method'])); $this->_stop(); } $method = $parsed[$this->params['method']]; @@ -110,9 +110,9 @@ class ApiShell extends Shell { $this->out($list); $methods = array_keys($parsed); - while ($number = strtolower($this->in(__('Select a number to see the more information about a specific method. q to quit. l to list.'), null, 'q'))) { + while ($number = strtolower($this->in(__d('cake', 'Select a number to see the more information about a specific method. q to quit. l to list.'), null, 'q'))) { if ($number === 'q') { - $this->out(__('Done')); + $this->out(__d('cake', 'Done')); return $this->_stop(); } @@ -145,8 +145,8 @@ class ApiShell extends Shell { 'help' => 'A CakePHP core class name (e.g: Component, HtmlHelper).' ))->addOption('method', array( 'short' => 'm', - 'help' => __('The specific method you want help on.') - ))->description(__('Lookup doc block comments for classes in CakePHP.')); + 'help' => __d('cake', 'The specific method you want help on.') + ))->description(__d('cake', 'Lookup doc block comments for classes in CakePHP.')); return $parser; } /** @@ -199,7 +199,7 @@ class ApiShell extends Shell { if (!class_exists($class)) { if (!include_once($path)) { - $this->err(__('%s could not be found', $path)); + $this->err(__d('cake', '%s could not be found', $path)); } } diff --git a/lib/Cake/Console/Command/BakeShell.php b/lib/Cake/Console/Command/BakeShell.php index 718f8d8ff..2703629d7 100644 --- a/lib/Cake/Console/Command/BakeShell.php +++ b/lib/Cake/Console/Command/BakeShell.php @@ -75,7 +75,7 @@ class BakeShell extends Shell { } if (!config('database')) { - $this->out(__('Your database configuration was not found. Take a moment to create one.')); + $this->out(__d('cake', 'Your database configuration was not found. Take a moment to create one.')); $this->args = null; return $this->DbConfig->execute(); } @@ -90,7 +90,7 @@ class BakeShell extends Shell { $this->out('[T]est case'); $this->out('[Q]uit'); - $classToBake = strtoupper($this->in(__('What would you like to Bake?'), array('D', 'M', 'V', 'C', 'P', 'F', 'T', 'Q'))); + $classToBake = strtoupper($this->in(__d('cake', 'What would you like to Bake?'), array('D', 'M', 'V', 'C', 'P', 'F', 'T', 'Q'))); switch ($classToBake) { case 'D': $this->DbConfig->execute(); @@ -117,7 +117,7 @@ class BakeShell extends Shell { exit(0); break; default: - $this->out(__('You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.')); + $this->out(__d('cake', 'You have made an invalid selection. Please choose a type of class to Bake by entering D, M, V, F, T, or C.')); } $this->hr(); $this->main(); @@ -182,10 +182,10 @@ class BakeShell extends Shell { $this->View->execute(); } $this->out('', 1, Shell::QUIET); - $this->out(__('Bake All complete'), 1, Shell::QUIET); + $this->out(__d('cake', 'Bake All complete'), 1, Shell::QUIET); array_shift($this->args); } else { - $this->error(__('Bake All could not continue without a valid model')); + $this->error(__d('cake', 'Bake All could not continue without a valid model')); } return $this->_stop(); } @@ -203,33 +203,33 @@ class BakeShell extends Shell { 'creation process. You can customize the generation process by telling Bake' . 'where different parts of your application are using command line arguments.' )->addSubcommand('all', array( - 'help' => __('Bake a complete MVC. optional of a Model'), + 'help' => __d('cake', 'Bake a complete MVC. optional of a Model'), ))->addSubcommand('project', array( - 'help' => __('Bake a new app folder in the path supplied or in current directory if no path is specified'), + 'help' => __d('cake', 'Bake a new app folder in the path supplied or in current directory if no path is specified'), 'parser' => $this->Project->getOptionParser() ))->addSubcommand('plugin', array( - 'help' => __('Bake a new plugin folder in the path supplied or in current directory if no path is specified.'), + 'help' => __d('cake', 'Bake a new plugin folder in the path supplied or in current directory if no path is specified.'), 'parser' => $this->Plugin->getOptionParser() ))->addSubcommand('db_config', array( - 'help' => __('Bake a database.php file in config directory.'), + 'help' => __d('cake', 'Bake a database.php file in config directory.'), 'parser' => $this->DbConfig->getOptionParser() ))->addSubcommand('model', array( - 'help' => __('Bake a model.'), + 'help' => __d('cake', 'Bake a model.'), 'parser' => $this->Model->getOptionParser() ))->addSubcommand('view', array( - 'help' => __('Bake views for controllers.'), + 'help' => __d('cake', 'Bake views for controllers.'), 'parser' => $this->View->getOptionParser() ))->addSubcommand('controller', array( - 'help' => __('Bake a controller.'), + 'help' => __d('cake', 'Bake a controller.'), 'parser' => $this->Controller->getOptionParser() ))->addSubcommand('fixture', array( - 'help' => __('Bake a fixture.'), + 'help' => __d('cake', 'Bake a fixture.'), 'parser' => $this->Fixture->getOptionParser() ))->addSubcommand('test', array( - 'help' => __('Bake a unit test.'), + 'help' => __d('cake', 'Bake a unit test.'), 'parser' => $this->Test->getOptionParser() ))->addOption('connection', array( - 'help' => __('Database connection to use in conjunction with `bake all`.'), + 'help' => __d('cake', 'Database connection to use in conjunction with `bake all`.'), 'short' => 'c', 'default' => 'default' )); diff --git a/lib/Cake/Console/Command/CommandListShell.php b/lib/Cake/Console/Command/CommandListShell.php index bce1d0a75..764a36b81 100644 --- a/lib/Cake/Console/Command/CommandListShell.php +++ b/lib/Cake/Console/Command/CommandListShell.php @@ -214,10 +214,10 @@ class CommandListShell extends Shell { $parser = parent::getOptionParser(); return $parser->description('Get the list of available shells for this CakePHP application.') ->addOption('xml', array( - 'help' => __('Get the listing as XML.'), + 'help' => __d('cake', 'Get the listing as XML.'), 'boolean' => true ))->addOption('sort', array( - 'help' => __('Sorts the commands by where they are located.'), + 'help' => __d('cake', 'Sorts the commands by where they are located.'), 'boolean' => true )); } diff --git a/lib/Cake/Console/Command/I18nShell.php b/lib/Cake/Console/Command/I18nShell.php index 0a2bdeef6..72e11ee41 100644 --- a/lib/Cake/Console/Command/I18nShell.php +++ b/lib/Cake/Console/Command/I18nShell.php @@ -52,7 +52,7 @@ class I18nShell extends Shell { if ($this->command && !in_array($this->command, array('help'))) { if (!config('database')) { - $this->out(__('Your database configuration was not found. Take a moment to create one.'), true); + $this->out(__d('cake', 'Your database configuration was not found. Take a moment to create one.'), true); return $this->DbConfig->execute(); } } @@ -63,14 +63,14 @@ class I18nShell extends Shell { * */ public function main() { - $this->out(__('I18n Shell')); + $this->out(__d('cake', 'I18n Shell')); $this->hr(); - $this->out(__('[E]xtract POT file from sources')); - $this->out(__('[I]nitialize i18n database table')); - $this->out(__('[H]elp')); - $this->out(__('[Q]uit')); + $this->out(__d('cake', '[E]xtract POT file from sources')); + $this->out(__d('cake', '[I]nitialize i18n database table')); + $this->out(__d('cake', '[H]elp')); + $this->out(__d('cake', '[Q]uit')); - $choice = strtolower($this->in(__('What would you like to do?'), array('E', 'I', 'H', 'Q'))); + $choice = strtolower($this->in(__d('cake', 'What would you like to do?'), array('E', 'I', 'H', 'Q'))); switch ($choice) { case 'e': $this->Extract->execute(); @@ -85,7 +85,7 @@ class I18nShell extends Shell { exit(0); break; default: - $this->out(__('You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.')); + $this->out(__d('cake', 'You have made an invalid selection. Please choose a command to execute by entering E, I, H, or Q.')); } $this->hr(); $this->main(); @@ -107,11 +107,11 @@ class I18nShell extends Shell { public function getOptionParser() { $parser = parent::getOptionParser(); return $parser->description( - __('I18n Shell initializes i18n database table for your application and generates .pot files(s) with translations.') + __d('cake', 'I18n Shell initializes i18n database table for your application and generates .pot files(s) with translations.') )->addSubcommand('initdb', array( - 'help' => __('Initialize the i18n table.') + 'help' => __d('cake', 'Initialize the i18n table.') ))->addSubcommand('extract', array( - 'help' => __('Extract the po translations from your application'), + 'help' => __d('cake', 'Extract the po translations from your application'), 'parser' => $this->Extract->getOptionParser() )); } diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 8282c4ce7..5aa15d9f5 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -112,7 +112,7 @@ class SchemaShell extends Shell { $this->_stop(); } else { $file = $this->Schema->path . DS . $this->params['file']; - $this->err(__('Schema file (%s) could not be found.', $file)); + $this->err(__d('cake', 'Schema file (%s) could not be found.', $file)); $this->_stop(); } } @@ -123,7 +123,7 @@ class SchemaShell extends Shell { * */ public function generate() { - $this->out(__('Generating Schema...')); + $this->out(__d('cake', 'Generating Schema...')); $options = array(); if (isset($this->params['force'])) { $options = array('models' => false); @@ -182,10 +182,10 @@ class SchemaShell extends Shell { } if ($this->Schema->write($content)) { - $this->out(__('Schema file: %s generated', $content['file'])); + $this->out(__d('cake', 'Schema file: %s generated', $content['file'])); $this->_stop(); } else { - $this->err(__('Schema file: %s generated')); + $this->err(__d('cake', 'Schema file: %s generated')); $this->_stop(); } } @@ -202,7 +202,7 @@ class SchemaShell extends Shell { $write = false; $Schema = $this->Schema->load(); if (!$Schema) { - $this->err(__('Schema could not be loaded')); + $this->err(__d('cake', 'Schema could not be loaded')); $this->_stop(); } if (!empty($this->params['write'])) { @@ -227,10 +227,10 @@ class SchemaShell extends Shell { } if ($File->write($contents)) { - $this->out(__('SQL dump file created in %s', $File->pwd())); + $this->out(__d('cake', 'SQL dump file created in %s', $File->pwd())); $this->_stop(); } else { - $this->err(__('SQL dump could not be created')); + $this->err(__d('cake', 'SQL dump could not be created')); $this->_stop(); } } @@ -274,7 +274,7 @@ class SchemaShell extends Shell { if (!empty($this->params['dry'])) { $this->__dry = true; - $this->out(__('Performing a dry run.')); + $this->out(__d('cake', 'Performing a dry run.')); } $options = array('name' => $name, 'plugin' => $plugin); @@ -286,7 +286,7 @@ class SchemaShell extends Shell { $Schema = $this->Schema->load($options); if (!$Schema) { - $this->err(__('%s could not be loaded', $this->Schema->path . DS . $this->Schema->file)); + $this->err(__d('cake', '%s could not be loaded', $this->Schema->path . DS . $this->Schema->file)); $this->_stop(); } $table = null; @@ -317,26 +317,26 @@ class SchemaShell extends Shell { $create[$table] = $db->createSchema($Schema, $table); } if (empty($drop) || empty($create)) { - $this->out(__('Schema is up to date.')); + $this->out(__d('cake', 'Schema is up to date.')); $this->_stop(); } - $this->out("\n" . __('The following table(s) will be dropped.')); + $this->out("\n" . __d('cake', 'The following table(s) will be dropped.')); $this->out(array_keys($drop)); - if ('y' == $this->in(__('Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n')) { - $this->out(__('Dropping table(s).')); + if ('y' == $this->in(__d('cake', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n')) { + $this->out(__d('cake', 'Dropping table(s).')); $this->__run($drop, 'drop', $Schema); } - $this->out("\n" . __('The following table(s) will be created.')); + $this->out("\n" . __d('cake', 'The following table(s) will be created.')); $this->out(array_keys($create)); - if ('y' == $this->in(__('Are you sure you want to create the table(s)?'), array('y', 'n'), 'y')) { - $this->out(__('Creating table(s).')); + if ('y' == $this->in(__d('cake', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y')) { + $this->out(__d('cake', 'Creating table(s).')); $this->__run($create, 'create', $Schema); } - $this->out(__('End create.')); + $this->out(__d('cake', 'End create.')); } /** @@ -348,7 +348,7 @@ class SchemaShell extends Shell { function __update(&$Schema, $table = null) { $db = ConnectionManager::getDataSource($this->Schema->connection); - $this->out(__('Comparing Database to Schema...')); + $this->out(__d('cake', 'Comparing Database to Schema...')); $options = array(); if (isset($this->params['force'])) { $options['models'] = false; @@ -367,19 +367,19 @@ class SchemaShell extends Shell { } if (empty($contents)) { - $this->out(__('Schema is up to date.')); + $this->out(__d('cake', 'Schema is up to date.')); $this->_stop(); } - $this->out("\n" . __('The following statements will run.')); + $this->out("\n" . __d('cake', 'The following statements will run.')); $this->out(array_map('trim', $contents)); - if ('y' == $this->in(__('Are you sure you want to alter the tables?'), array('y', 'n'), 'n')) { + if ('y' == $this->in(__d('cake', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n')) { $this->out(); - $this->out(__('Updating Database...')); + $this->out(__d('cake', 'Updating Database...')); $this->__run($contents, 'update', $Schema); } - $this->out(__('End update.')); + $this->out(__d('cake', 'End update.')); } /** @@ -389,7 +389,7 @@ class SchemaShell extends Shell { */ function __run($contents, $event, &$Schema) { if (empty($contents)) { - $this->err(__('Sql could not be run')); + $this->err(__d('cake', 'Sql could not be run')); return; } Configure::write('debug', 2); @@ -397,10 +397,10 @@ class SchemaShell extends Shell { foreach ($contents as $table => $sql) { if (empty($sql)) { - $this->out(__('%s is up to date.', $table)); + $this->out(__d('cake', '%s is up to date.', $table)); } else { if ($this->__dry === true) { - $this->out(__('Dry run for %s :', $table)); + $this->out(__d('cake', 'Dry run for %s :', $table)); $this->out($sql); } else { if (!$Schema->before(array($event => $table))) { @@ -416,7 +416,7 @@ class SchemaShell extends Shell { if (!empty($error)) { $this->out($error); } else { - $this->out(__('%s updated.', $table)); + $this->out(__d('cake', '%s updated.', $table)); } } } @@ -430,26 +430,26 @@ class SchemaShell extends Shell { */ public function getOptionParser() { $plugin = array( - 'help' => __('The plugin to use.'), + 'help' => __d('cake', 'The plugin to use.'), ); $connection = array( - 'help' => __('Set the db config to use.'), + 'help' => __d('cake', 'Set the db config to use.'), 'default' => 'default' ); $path = array( - 'help' => __('Path to read and write schema.php'), + 'help' => __d('cake', 'Path to read and write schema.php'), 'default' => CONFIGS . 'schema' ); $file = array( - 'help' => __('File name to read and write.'), + 'help' => __d('cake', 'File name to read and write.'), 'default' => 'schema.php' ); $name = array( - 'help' => __('Classname to use. If its Plugin.class, both name and plugin options will be set.') + 'help' => __d('cake', 'Classname to use. If its Plugin.class, both name and plugin options will be set.') ); $snapshot = array( 'short' => 's', - 'help' => __('Snapshot number to use/make.') + 'help' => __d('cake', 'Snapshot number to use/make.') ); $dry = array( 'help' => 'Perform a dry run on create and update commands. Queries will be output instead of run.', @@ -457,11 +457,11 @@ class SchemaShell extends Shell { ); $force = array( 'short' => 'f', - 'help' => __('Force "generate" to create a new schema'), + 'help' => __d('cake', 'Force "generate" to create a new schema'), 'boolean' => true ); $write = array( - 'help' => __('Write the dumped SQL to a file.') + 'help' => __d('cake', 'Write the dumped SQL to a file.') ); $parser = parent::getOptionParser(); @@ -475,42 +475,42 @@ class SchemaShell extends Shell { 'arguments' => compact('name') ) ))->addSubcommand('generate', array( - 'help' => __('Reads from --connection and writes to --path. Generate snapshots with -s'), + 'help' => __d('cake', 'Reads from --connection and writes to --path. Generate snapshots with -s'), 'parser' => array( 'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'snapshot', 'force'), 'arguments' => array( - 'snapshot' => array('help' => __('Generate a snapshot.')) + 'snapshot' => array('help' => __d('cake', 'Generate a snapshot.')) ) ) ))->addSubcommand('dump', array( - 'help' => __('Dump database SQL based on a schema file to stdout.'), + 'help' => __d('cake', 'Dump database SQL based on a schema file to stdout.'), 'parser' => array( 'options' => compact('plugin', 'path', 'file', 'name', 'connection'), 'arguments' => compact('name') ) ))->addSubcommand('create', array( - 'help' => __('Drop and create tables based on the schema file.'), + 'help' => __d('cake', 'Drop and create tables based on the schema file.'), 'parser' => array( 'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'dry', 'snapshot'), 'args' => array( 'name' => array( - 'help' => __('Name of schema to use.') + 'help' => __d('cake', 'Name of schema to use.') ), 'table' => array( - 'help' => __('Only create the specified table.') + 'help' => __d('cake', 'Only create the specified table.') ) ) ) ))->addSubcommand('update', array( - 'help' => __('Alter the tables based on the schema file.'), + 'help' => __d('cake', 'Alter the tables based on the schema file.'), 'parser' => array( 'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'dry', 'snapshot'), 'args' => array( 'name' => array( - 'help' => __('Name of schema to use.') + 'help' => __d('cake', 'Name of schema to use.') ), 'table' => array( - 'help' => __('Only create the specified table.') + 'help' => __d('cake', 'Only create the specified table.') ) ) ) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index e7d7995b2..e4afd7056 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -71,13 +71,13 @@ class ControllerTask extends BakeTask { $actions = ''; if (!empty($this->params['public'])) { - $this->out(__('Baking basic crud methods for ') . $controller); + $this->out(__d('cake', 'Baking basic crud methods for ') . $controller); $actions .= $this->bakeActions($controller); } if (!empty($this->params['admin'])) { $admin = $this->Project->getPrefix(); if ($admin) { - $this->out(__('Adding %s methods', $admin)); + $this->out(__d('cake', 'Adding %s methods', $admin)); $actions .= "\n" . $this->bakeActions($controller, $admin); } } @@ -124,7 +124,7 @@ class ControllerTask extends BakeTask { protected function _interactive() { $this->interactive = true; $this->hr(); - $this->out(__("Bake Controller\nPath: %s", $this->path)); + $this->out(__d('cake', "Bake Controller\nPath: %s", $this->path)); $this->hr(); if (empty($this->connection)) { @@ -133,7 +133,7 @@ class ControllerTask extends BakeTask { $controllerName = $this->getName(); $this->hr(); - $this->out(__('Baking %sController', $controllerName)); + $this->out(__d('cake', 'Baking %sController', $controllerName)); $this->hr(); $helpers = $components = array(); @@ -145,16 +145,16 @@ class ControllerTask extends BakeTask { $controllerFile = strtolower(Inflector::underscore($controllerName)); - $question[] = __("Would you like to build your controller interactively?"); + $question[] = __d('cake', "Would you like to build your controller interactively?"); if (file_exists($this->path . $controllerFile .'_controller.php')) { - $question[] = __("Warning: Choosing no will overwrite the %sController.", $controllerName); + $question[] = __d('cake', "Warning: Choosing no will overwrite the %sController.", $controllerName); } $doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y'); if (strtolower($doItInteractive) == 'y') { $this->interactive = true; $useDynamicScaffold = $this->in( - __("Would you like to use dynamic scaffolding?"), array('y','n'), 'n' + __d('cake', "Would you like to use dynamic scaffolding?"), array('y','n'), 'n' ); if (strtolower($useDynamicScaffold) == 'y') { @@ -167,7 +167,7 @@ class ControllerTask extends BakeTask { $components = $this->doComponents(); $wannaUseSession = $this->in( - __("Would you like to use Session flash messages?"), array('y','n'), 'y' + __d('cake', "Would you like to use Session flash messages?"), array('y','n'), 'y' ); } } else { @@ -185,7 +185,7 @@ class ControllerTask extends BakeTask { $baked = false; if ($this->interactive === true) { $this->confirmController($controllerName, $useDynamicScaffold, $helpers, $components); - $looksGood = $this->in(__('Look okay?'), array('y','n'), 'y'); + $looksGood = $this->in(__d('cake', 'Look okay?'), array('y','n'), 'y'); if (strtolower($looksGood) == 'y') { $baked = $this->bake($controllerName, $actions, $helpers, $components); @@ -210,17 +210,17 @@ class ControllerTask extends BakeTask { public function confirmController($controllerName, $useDynamicScaffold, $helpers, $components) { $this->out(); $this->hr(); - $this->out(__('The following controller will be created:')); + $this->out(__d('cake', 'The following controller will be created:')); $this->hr(); - $this->out(__("Controller Name:\n\t%s", $controllerName)); + $this->out(__d('cake', "Controller Name:\n\t%s", $controllerName)); if (strtolower($useDynamicScaffold) == 'y') { $this->out("var \$scaffold;"); } $properties = array( - 'helpers' => __('Helpers:'), - 'components' => __('Components:'), + 'helpers' => __d('cake', 'Helpers:'), + 'components' => __d('cake', 'Components:'), ); foreach ($properties as $var => $title) { @@ -247,11 +247,11 @@ class ControllerTask extends BakeTask { */ protected function _askAboutMethods() { $wannaBakeCrud = $this->in( - __("Would you like to create some basic class methods \n(index(), add(), view(), edit())?"), + __d('cake', "Would you like to create some basic class methods \n(index(), add(), view(), edit())?"), array('y','n'), 'n' ); $wannaBakeAdminCrud = $this->in( - __("Would you like to create the basic class methods for admin routing?"), + __d('cake', "Would you like to create the basic class methods for admin routing?"), array('y','n'), 'n' ); return array($wannaBakeCrud, $wannaBakeAdminCrud); @@ -274,7 +274,7 @@ class ControllerTask extends BakeTask { } 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->err(__d('cake', 'You must have a model for this class to build basic methods. Please try again.')); $this->_stop(); } @@ -342,8 +342,8 @@ class ControllerTask extends BakeTask { */ public function doHelpers() { return $this->_doPropertyChoices( - __("Would you like this controller to use other helpers\nbesides HtmlHelper and FormHelper?"), - __("Please provide a comma separated list of the other\nhelper names you'd like to use.\nExample: 'Ajax, Javascript, Time'") + __d('cake', "Would you like this controller to use other helpers\nbesides HtmlHelper and FormHelper?"), + __d('cake', "Please provide a comma separated list of the other\nhelper names you'd like to use.\nExample: 'Ajax, Javascript, Time'") ); } @@ -354,8 +354,8 @@ class ControllerTask extends BakeTask { */ public function doComponents() { return $this->_doPropertyChoices( - __("Would you like this controller to use any components?"), - __("Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'") + __d('cake', "Would you like this controller to use any components?"), + __d('cake', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'") ); } @@ -391,7 +391,7 @@ class ControllerTask extends BakeTask { $this->__tables = $this->Model->getAllTables($useDbConfig); if ($this->interactive == true) { - $this->out(__('Possible Controllers based on your current database:')); + $this->out(__d('cake', 'Possible Controllers based on your current database:')); $this->_controllerNames = array(); $count = count($this->__tables); for ($i = 0; $i < $count; $i++) { @@ -414,14 +414,14 @@ class ControllerTask extends BakeTask { $enteredController = ''; while ($enteredController == '') { - $enteredController = $this->in(__("Enter a number from the list above,\ntype in the name of another controller, or 'q' to exit"), null, 'q'); + $enteredController = $this->in(__d('cake', "Enter a number from the list above,\ntype in the name of another controller, or 'q' to exit"), null, 'q'); if ($enteredController === 'q') { - $this->out(__('Exit')); + $this->out(__d('cake', 'Exit')); return $this->_stop(); } if ($enteredController == '' || intval($enteredController) > count($controllers)) { - $this->err(__("The Controller name you supplied was empty,\nor the number you selected was not an option. Please try again.")); + $this->err(__d('cake', "The Controller name you supplied was empty,\nor the number you selected was not an option. Please try again.")); $enteredController = ''; } } @@ -442,24 +442,24 @@ class ControllerTask extends BakeTask { public function getOptionParser() { $parser = parent::getOptionParser(); return $parser->description( - __('Bake a controller for a model. Using options you can bake public, admin or both.') + __d('cake', 'Bake a controller for a model. Using options you can bake public, admin or both.') )->addArgument('name', array( - 'help' => __('Name of the controller to bake. Can use Plugin.name to bake controllers into plugins.') + 'help' => __d('cake', 'Name of the controller to bake. Can use Plugin.name to bake controllers into plugins.') ))->addOption('public', array( - 'help' => __('Bake a controller with basic crud actions (index, view, add, edit, delete).'), + 'help' => __d('cake', 'Bake a controller with basic crud actions (index, view, add, edit, delete).'), 'boolean' => true ))->addOption('admin', array( - 'help' => __('Bake a controller with crud actions for one of the Routing.prefixes.'), + 'help' => __d('cake', 'Bake a controller with crud actions for one of the Routing.prefixes.'), 'boolean' => true ))->addOption('plugin', array( 'short' => 'p', - 'help' => __('Plugin to bake the controller into.') + 'help' => __d('cake', 'Plugin to bake the controller into.') ))->addOption('connection', array( 'short' => 'c', - 'help' => __('The connection the controller\'s model is on.') + 'help' => __d('cake', 'The connection the controller\'s model is on.') ))->addSubcommand('all', array( - 'help' => __('Bake all controllers with CRUD methods.') - ))->epilog(__('Omitting all arguments and options will enter into an interactive mode.')); + 'help' => __d('cake', 'Bake all controllers with CRUD methods.') + ))->epilog(__d('cake', 'Omitting all arguments and options will enter into an interactive mode.')); } /** diff --git a/lib/Cake/Console/Command/Task/DbConfigTask.php b/lib/Cake/Console/Command/Task/DbConfigTask.php index e33850bbc..f301ac9a0 100644 --- a/lib/Cake/Console/Command/Task/DbConfigTask.php +++ b/lib/Cake/Console/Command/Task/DbConfigTask.php @@ -361,7 +361,7 @@ class DbConfigTask extends Shell { $connections = array_keys($configs); if (count($connections) > 1) { - $useDbConfig = $this->in(__('Use Database Config') .':', $connections, 'default'); + $useDbConfig = $this->in(__d('cake', 'Use Database Config') .':', $connections, 'default'); } return $useDbConfig; } @@ -374,7 +374,7 @@ class DbConfigTask extends Shell { public function getOptionParser() { $parser = parent::getOptionParser(); return $parser->description( - __('Bake new database configuration settings.') + __d('cake', 'Bake new database configuration settings.') ); } } diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index a5ece60c7..631e3ccce 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -112,11 +112,11 @@ 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", $defaultPath); + $message = __d('cake', "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') { - $this->out(__('Extract Aborted')); + $this->out(__d('cake', 'Extract Aborted')); $this->_stop(); } elseif (strtoupper($response) === 'D') { $this->out(); @@ -125,7 +125,7 @@ class ExtractTask extends Shell { $this->__paths[] = $response; $defaultPath = 'D'; } else { - $this->err(__('The directory path you supplied was not found. Please try again.')); + $this->err(__d('cake', 'The directory path you supplied was not found. Please try again.')); } $this->out(); } @@ -134,17 +134,17 @@ class ExtractTask extends Shell { if (isset($this->params['output'])) { $this->__output = $this->params['output']; } else { - $message = __("What is the full path you would like to output?\nExample: %s\n[Q]uit", $this->__paths[0] . DS . 'locale'); + $message = __d('cake', "What is the full path you would like to output?\nExample: %s\n[Q]uit", $this->__paths[0] . DS . 'locale'); while (true) { $response = $this->in($message, null, $this->__paths[0] . DS . 'locale'); if (strtoupper($response) === 'Q') { - $this->out(__('Extract Aborted')); + $this->out(__d('cake', 'Extract Aborted')); $this->_stop(); } elseif (is_dir($response)) { $this->__output = $response . DS; break; } else { - $this->err(__('The directory path you supplied was not found. Please try again.')); + $this->err(__d('cake', 'The directory path you supplied was not found. Please try again.')); } $this->out(); } @@ -154,7 +154,7 @@ class ExtractTask extends Shell { $this->__merge = !(strtolower($this->params['merge']) === 'no'); } else { $this->out(); - $response = $this->in(__('Would you like to merge all domains strings into the default.pot file?'), array('y', 'n'), 'n'); + $response = $this->in(__d('cake', 'Would you like to merge all domains strings into the default.pot file?'), array('y', 'n'), 'n'); $this->__merge = strtolower($response) === 'y'; } @@ -173,13 +173,13 @@ class ExtractTask extends Shell { function __extract() { $this->out(); $this->out(); - $this->out(__('Extracting...')); + $this->out(__d('cake', 'Extracting...')); $this->hr(); - $this->out(__('Paths:')); + $this->out(__d('cake', 'Paths:')); foreach ($this->__paths as $path) { $this->out(' ' . $path); } - $this->out(__('Output Directory: ') . $this->__output); + $this->out(__d('cake', 'Output Directory: ') . $this->__output); $this->hr(); $this->__extractTokens(); $this->__buildFiles(); @@ -187,7 +187,7 @@ class ExtractTask extends Shell { $this->__paths = $this->__files = $this->__storage = array(); $this->__strings = $this->__tokens = array(); $this->out(); - $this->out(__('Done.')); + $this->out(__d('cake', 'Done.')); } /** @@ -197,17 +197,17 @@ class ExtractTask extends Shell { */ public function getOptionParser() { $parser = parent::getOptionParser(); - return $parser->description(__('CakePHP Language String Extraction:')) - ->addOption('app', array('help' => __('Directory where your application is located.'))) - ->addOption('paths', array('help' => __('Comma separted list of paths, full paths are needed.'))) + return $parser->description(__d('cake', 'CakePHP Language String Extraction:')) + ->addOption('app', array('help' => __d('cake', 'Directory where your application is located.'))) + ->addOption('paths', array('help' => __d('cake', 'Comma separted list of paths, full paths are needed.'))) ->addOption('merge', array( - 'help' => __('Merge all domain strings into the default.po file.'), + 'help' => __d('cake', 'Merge all domain strings into the default.po file.'), 'choices' => array('yes', 'no') )) - ->addOption('output', array('help' => __('Full path to output directory.'))) - ->addOption('files', array('help' => __('Comma separated list of files, full paths are needed.'))) + ->addOption('output', array('help' => __d('cake', 'Full path to output directory.'))) + ->addOption('files', array('help' => __d('cake', 'Comma separated list of files, full paths are needed.'))) ->addOption('exclude', array( - 'help' => __('Comma separated list of directories to exclude. Any path containing a path segment with the provided values will be skipped. E.g. test,vendors') + 'help' => __d('cake', 'Comma separated list of directories to exclude. Any path containing a path segment with the provided values will be skipped. E.g. test,vendors') )); } @@ -217,25 +217,25 @@ class ExtractTask extends Shell { * @return void */ public function help() { - $this->out(__('CakePHP Language String Extraction:')); + $this->out(__d('cake', 'CakePHP Language String Extraction:')); $this->hr(); - $this->out(__('The Extract script generates .pot file(s) with translations')); - $this->out(__('By default the .pot file(s) will be place in the locale directory of -app')); - $this->out(__('By default -app is ROOT/app')); + $this->out(__d('cake', 'The Extract script generates .pot file(s) with translations')); + $this->out(__d('cake', 'By default the .pot file(s) will be place in the locale directory of -app')); + $this->out(__d('cake', 'By default -app is ROOT/app')); $this->hr(); - $this->out(__('Usage: cake i18n extract ...')); + $this->out(__d('cake', 'Usage: cake i18n extract ...')); $this->out(); - $this->out(__('Params:')); - $this->out(__(' -app [path...]: directory where your application is located')); - $this->out(__(' -root [path...]: path to install')); - $this->out(__(' -core [path...]: path to cake directory')); - $this->out(__(' -paths [comma separated list of paths, full path is needed]')); - $this->out(__(' -merge [yes|no]: Merge all domains strings into the default.pot file')); - $this->out(__(' -output [path...]: Full path to output directory')); - $this->out(__(' -files: [comma separated list of files, full path to file is needed]')); + $this->out(__d('cake', 'Params:')); + $this->out(__d('cake', ' -app [path...]: directory where your application is located')); + $this->out(__d('cake', ' -root [path...]: path to install')); + $this->out(__d('cake', ' -core [path...]: path to cake directory')); + $this->out(__d('cake', ' -paths [comma separated list of paths, full path is needed]')); + $this->out(__d('cake', ' -merge [yes|no]: Merge all domains strings into the default.pot file')); + $this->out(__d('cake', ' -output [path...]: Full path to output directory')); + $this->out(__d('cake', ' -files: [comma separated list of files, full path to file is needed]')); $this->out(); - $this->out(__('Commands:')); - $this->out(__(' cake i18n extract help: Shows this help message.')); + $this->out(__d('cake', 'Commands:')); + $this->out(__d('cake', ' cake i18n extract help: Shows this help message.')); $this->out(); } @@ -248,7 +248,7 @@ class ExtractTask extends Shell { function __extractTokens() { foreach ($this->__files as $file) { $this->__file = $file; - $this->out(__('Processing %s...', $file)); + $this->out(__d('cake', 'Processing %s...', $file)); $code = file_get_contents($file); $allTokens = token_get_all($code); @@ -411,11 +411,11 @@ class ExtractTask extends Shell { $response = ''; while ($overwriteAll === false && $File->exists() && strtoupper($response) !== 'Y') { $this->out(); - $response = $this->in(__('Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll', $filename), array('y', 'n', 'a'), 'y'); + $response = $this->in(__d('cake', 'Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll', $filename), array('y', 'n', 'a'), 'y'); if (strtoupper($response) === 'N') { $response = ''; while ($response == '') { - $response = $this->in(__("What would you like to name this file?\nExample: %s", 'new_' . $filename), null, 'new_' . $filename); + $response = $this->in(__d('cake', "What would you like to name this file?\nExample: %s", 'new_' . $filename), null, 'new_' . $filename); $File = new File($this->__output . $response); $filename = $response; } @@ -483,7 +483,7 @@ class ExtractTask extends Shell { * @access private */ function __markerError($file, $line, $marker, $count) { - $this->out(__("Invalid marker content in %s:%s\n* %s(", $file, $line, $marker), true); + $this->out(__d('cake', "Invalid marker content in %s:%s\n* %s(", $file, $line, $marker), true); $count += 2; $tokenCount = count($this->__tokens); $parenthesis = 1; diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index 9352e539d..ec0b063d0 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -68,25 +68,25 @@ class FixtureTask extends BakeTask { public function getOptionParser() { $parser = parent::getOptionParser(); return $parser->description( - __('Generate fixtures for use with the test suite. You can use `bake fixture all` to bake all fixtures.') + __d('cake', 'Generate fixtures for use with the test suite. You can use `bake fixture all` to bake all fixtures.') )->addArgument('name', array( - 'help' => __('Name of the fixture to bake. Can use Plugin.name to bake plugin fixtures.') + 'help' => __d('cake', 'Name of the fixture to bake. Can use Plugin.name to bake plugin fixtures.') ))->addOption('count', array( - 'help' => __('When using generated data, the number of records to include in the fixture(s).'), + 'help' => __d('cake', 'When using generated data, the number of records to include in the fixture(s).'), 'short' => 'n', 'default' => 10 ))->addOption('connection', array( - 'help' => __('Which database configuration to use for baking.'), + 'help' => __d('cake', 'Which database configuration to use for baking.'), 'short' => 'c', 'default' => 'default' ))->addOption('plugin', array( - 'help' => __('CamelCased name of the plugin to bake fixtures for.'), + 'help' => __d('cake', 'CamelCased name of the plugin to bake fixtures for.'), 'short' => 'p', ))->addOption('records', array( 'help' => 'Used with --count and /all commands to pull [n] records from the live tables, where [n] is either --count or the default of 10', 'short' => 'r', 'boolean' => true - ))->epilog(__('Omitting all arguments and options will enter into an interactive mode.'));; + ))->epilog(__d('cake', 'Omitting all arguments and options will enter into an interactive mode.'));; } /** @@ -158,16 +158,16 @@ class FixtureTask extends BakeTask { */ public function importOptions($modelName) { $options = array(); - $doSchema = $this->in(__('Would you like to import schema for this fixture?'), array('y', 'n'), 'n'); + $doSchema = $this->in(__d('cake', 'Would you like to import schema for this fixture?'), array('y', 'n'), 'n'); if ($doSchema == 'y') { $options['schema'] = $modelName; } - $doRecords = $this->in(__('Would you like to use record importing for this fixture?'), array('y', 'n'), 'n'); + $doRecords = $this->in(__d('cake', 'Would you like to use record importing for this fixture?'), array('y', 'n'), 'n'); if ($doRecords == 'y') { $options['records'] = true; } if ($doRecords == 'n') { - $prompt = __("Would you like to build this fixture with data from %s's table?", $modelName); + $prompt = __d('cake', "Would you like to build this fixture with data from %s's table?", $modelName); $fromTable = $this->in($prompt, array('y', 'n'), 'n'); if (strtolower($fromTable) == 'y') { $options['fromTable'] = true; @@ -387,7 +387,7 @@ class FixtureTask extends BakeTask { protected function _getRecordsFromTable($modelName, $useTable = null) { if ($this->interactive) { $condition = null; - $prompt = __("Please provide a SQL fragment to use as conditions\nExample: WHERE 1=1 LIMIT 10"); + $prompt = __d('cake', "Please provide a SQL fragment to use as conditions\nExample: WHERE 1=1 LIMIT 10"); while (!$condition) { $condition = $this->in($prompt, null, 'WHERE 1=1 LIMIT 10'); } diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 1cfd0eac4..349997dda 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -112,7 +112,7 @@ class ModelTask extends BakeTask { continue; } $modelClass = Inflector::classify($table); - $this->out(__('Baking %s', $modelClass)); + $this->out(__d('cake', 'Baking %s', $modelClass)); $object = $this->_getModelObject($modelClass); if ($this->bake($object, false) && $unitTestExists) { $this->bakeFixture($modelClass); @@ -151,7 +151,7 @@ class ModelTask extends BakeTask { $this->out($i + 1 .'. ' . $option); } if (empty($prompt)) { - $prompt = __('Make a selection from the choices above'); + $prompt = __d('cake', 'Make a selection from the choices above'); } $choice = $this->in($prompt, null, $default); if (intval($choice) > 0 && intval($choice) <= $max) { @@ -190,7 +190,7 @@ class ModelTask extends BakeTask { $primaryKey = $this->findPrimaryKey($fields); } } else { - $this->err(__('Table %s does not exist, cannot bake a model without a table.', $useTable)); + $this->err(__d('cake', 'Table %s does not exist, cannot bake a model without a table.', $useTable)); $this->_stop(); return false; } @@ -199,13 +199,13 @@ class ModelTask extends BakeTask { $displayField = $this->findDisplayField($tempModel->schema()); } - $prompt = __("Would you like to supply validation criteria \nfor the fields in your model?"); + $prompt = __d('cake', "Would you like to supply validation criteria \nfor the fields in your model?"); $wannaDoValidation = $this->in($prompt, array('y','n'), 'y'); if (array_search($useTable, $this->_tables) !== false && strtolower($wannaDoValidation) == 'y') { $validate = $this->doValidation($tempModel); } - $prompt = __("Would you like to define model associations\n(hasMany, hasOne, belongsTo, etc.)?"); + $prompt = __d('cake', "Would you like to define model associations\n(hasMany, hasOne, belongsTo, etc.)?"); $wannaDoAssoc = $this->in($prompt, array('y','n'), 'y'); if (strtolower($wannaDoAssoc) == 'y') { $associations = $this->doAssociations($tempModel); @@ -213,24 +213,24 @@ class ModelTask extends BakeTask { $this->out(); $this->hr(); - $this->out(__('The following Model will be created:')); + $this->out(__d('cake', 'The following Model will be created:')); $this->hr(); $this->out("Name: " . $currentModelName); if ($this->connection !== 'default') { - $this->out(__("DB Config: %s", $this->connection)); + $this->out(__d('cake', "DB Config: %s", $this->connection)); } if ($fullTableName !== Inflector::tableize($currentModelName)) { - $this->out(__('DB Table: %s', $fullTableName)); + $this->out(__d('cake', 'DB Table: %s', $fullTableName)); } if ($primaryKey != 'id') { - $this->out(__('Primary Key: %s', $primaryKey)); + $this->out(__d('cake', 'Primary Key: %s', $primaryKey)); } if (!empty($validate)) { - $this->out(__('Validation: %s', print_r($validate, true))); + $this->out(__d('cake', 'Validation: %s', print_r($validate, true))); } if (!empty($associations)) { - $this->out(__('Associations:')); + $this->out(__d('cake', 'Associations:')); $assocKeys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); foreach ($assocKeys as $assocKey) { $this->_printAssociation($currentModelName, $assocKey, $associations); @@ -238,7 +238,7 @@ class ModelTask extends BakeTask { } $this->hr(); - $looksGood = $this->in(__('Look okay?'), array('y','n'), 'y'); + $looksGood = $this->in(__d('cake', 'Look okay?'), array('y','n'), 'y'); if (strtolower($looksGood) == 'y') { $vars = compact('associations', 'validate', 'primaryKey', 'useTable', 'displayField'); @@ -283,7 +283,7 @@ class ModelTask extends BakeTask { break; } } - return $this->in(__('What is the primaryKey?'), null, $name); + return $this->in(__d('cake', 'What is the primaryKey?'), null, $name); } /** @@ -294,12 +294,12 @@ class ModelTask extends BakeTask { */ public function findDisplayField($fields) { $fieldNames = array_keys($fields); - $prompt = __("A displayField could not be automatically detected\nwould you like to choose one?"); + $prompt = __d('cake', "A displayField could not be automatically detected\nwould you like to choose one?"); $continue = $this->in($prompt, array('y', 'n')); if (strtolower($continue) == 'n') { return false; } - $prompt = __('Choose a field from the options above:'); + $prompt = __d('cake', 'Choose a field from the options above:'); $choice = $this->inOptions($fieldNames, $prompt); return $fieldNames[$choice]; } @@ -367,10 +367,10 @@ class ModelTask extends BakeTask { while ($anotherValidator == 'y') { if ($this->interactive) { $this->out(); - $this->out(__('Field: %s', $fieldName)); - $this->out(__('Type: %s', $metaData['type'])); + $this->out(__d('cake', 'Field: %s', $fieldName)); + $this->out(__d('cake', 'Type: %s', $metaData['type'])); $this->hr(); - $this->out(__('Please select one of the following validation options:')); + $this->out(__d('cake', 'Please select one of the following validation options:')); $this->hr(); } @@ -378,8 +378,8 @@ class ModelTask extends BakeTask { for ($i = 1; $i < $defaultChoice; $i++) { $prompt .= $i . ' - ' . $this->_validations[$i] . "\n"; } - $prompt .= __("%s - Do not do any validation on this field.\n", $defaultChoice); - $prompt .= __("... or enter in a valid regex validation string.\n"); + $prompt .= __d('cake', "%s - Do not do any validation on this field.\n", $defaultChoice); + $prompt .= __d('cake', "... or enter in a valid regex validation string.\n"); $methods = array_flip($this->_validations); $guess = $defaultChoice; @@ -402,11 +402,11 @@ class ModelTask extends BakeTask { if ($this->interactive === true) { $choice = $this->in($prompt, null, $guess); if (in_array($choice, $alreadyChosen)) { - $this->out(__("You have already chosen that validation rule,\nplease choose again")); + $this->out(__d('cake', "You have already chosen that validation rule,\nplease choose again")); continue; } if (!isset($this->_validations[$choice]) && is_numeric($choice)) { - $this->out(__('Please make a valid selection.')); + $this->out(__d('cake', 'Please make a valid selection.')); continue; } $alreadyChosen[] = $choice; @@ -428,7 +428,7 @@ class ModelTask extends BakeTask { } } if ($this->interactive == true && $choice != $defaultChoice) { - $anotherValidator = $this->in(__('Would you like to add another validation rule?'), array('y', 'n'), 'n'); + $anotherValidator = $this->in(__d('cake', 'Would you like to add another validation rule?'), array('y', 'n'), 'n'); } else { $anotherValidator = 'n'; } @@ -447,7 +447,7 @@ class ModelTask extends BakeTask { return false; } if ($this->interactive === true) { - $this->out(__('One moment while the associations are detected.')); + $this->out(__d('cake', 'One moment while the associations are detected.')); } $fields = $model->schema(true); @@ -475,9 +475,9 @@ class ModelTask extends BakeTask { if ($this->interactive === true) { $this->hr(); if (empty($associations)) { - $this->out(__('None found.')); + $this->out(__d('cake', 'None found.')); } else { - $this->out(__('Please confirm the following associations:')); + $this->out(__d('cake', 'Please confirm the following associations:')); $this->hr(); $associations = $this->confirmAssociations($model, $associations); } @@ -634,19 +634,19 @@ class ModelTask extends BakeTask { * @return array Array of associations. */ public function doMoreAssociations($model, $associations) { - $prompt = __('Would you like to define some additional model associations?'); + $prompt = __d('cake', 'Would you like to define some additional model associations?'); $wannaDoMoreAssoc = $this->in($prompt, array('y','n'), 'n'); $possibleKeys = $this->_generatePossibleKeys(); while (strtolower($wannaDoMoreAssoc) == 'y') { $assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); - $this->out(__('What is the association type?')); - $assocType = intval($this->inOptions($assocs, __('Enter a number'))); + $this->out(__d('cake', 'What is the association type?')); + $assocType = intval($this->inOptions($assocs, __d('cake', 'Enter a number'))); - $this->out(__("For the following options be very careful to match your setup exactly.\nAny spelling mistakes will cause errors.")); + $this->out(__d('cake', "For the following options be very careful to match your setup exactly.\nAny spelling mistakes will cause errors.")); $this->hr(); - $alias = $this->in(__('What is the alias for this association?')); - $className = $this->in(__('What className will %s use?', $alias), null, $alias ); + $alias = $this->in(__d('cake', 'What is the alias for this association?')); + $className = $this->in(__d('cake', 'What className will %s use?', $alias), null, $alias ); $suggestedForeignKey = null; if ($assocType == 0) { @@ -661,22 +661,22 @@ class ModelTask extends BakeTask { $showKeys = null; } } else { - $otherTable = $this->in(__('What is the table for this model?')); + $otherTable = $this->in(__d('cake', 'What is the table for this model?')); $showKeys = $possibleKeys[$otherTable]; } $suggestedForeignKey = $this->_modelKey($model->name); } if (!empty($showKeys)) { - $this->out(__('A helpful List of possible keys')); - $foreignKey = $this->inOptions($showKeys, __('What is the foreignKey?')); + $this->out(__d('cake', 'A helpful List of possible keys')); + $foreignKey = $this->inOptions($showKeys, __d('cake', 'What is the foreignKey?')); $foreignKey = $showKeys[intval($foreignKey)]; } if (!isset($foreignKey)) { - $foreignKey = $this->in(__('What is the foreignKey? Specify your own.'), null, $suggestedForeignKey); + $foreignKey = $this->in(__d('cake', 'What is the foreignKey? Specify your own.'), null, $suggestedForeignKey); } if ($assocType == 3) { - $associationForeignKey = $this->in(__('What is the associationForeignKey?'), null, $this->_modelKey($model->name)); - $joinTable = $this->in(__('What is the joinTable?')); + $associationForeignKey = $this->in(__d('cake', 'What is the associationForeignKey?'), null, $this->_modelKey($model->name)); + $joinTable = $this->in(__d('cake', 'What is the joinTable?')); } $associations[$assocs[$assocType]] = array_values((array)$associations[$assocs[$assocType]]); $count = count($associations[$assocs[$assocType]]); @@ -688,7 +688,7 @@ class ModelTask extends BakeTask { $associations[$assocs[$assocType]][$i]['associationForeignKey'] = $associationForeignKey; $associations[$assocs[$assocType]][$i]['joinTable'] = $joinTable; } - $wannaDoMoreAssoc = $this->in(__('Define another association?'), array('y','n'), 'y'); + $wannaDoMoreAssoc = $this->in(__d('cake', 'Define another association?'), array('y','n'), 'y'); } return $associations; } @@ -769,7 +769,7 @@ class ModelTask extends BakeTask { $this->_tables = $this->getAllTables($useDbConfig); if ($this->interactive === true) { - $this->out(__('Possible Models based on your current database:')); + $this->out(__d('cake', 'Possible Models based on your current database:')); $this->_modelNames = array(); $count = count($this->_tables); for ($i = 0; $i < $count; $i++) { @@ -799,11 +799,11 @@ class ModelTask extends BakeTask { if (array_search($useTable, $this->_tables) === false) { $this->out(); - $this->out(__("Given your model named '%s',\nCake would expect a database table named '%s'", $modelName, $fullTableName)); - $tableIsGood = $this->in(__('Do you want to use this table?'), array('y','n'), 'y'); + $this->out(__d('cake', "Given your model named '%s',\nCake would expect a database table named '%s'", $modelName, $fullTableName)); + $tableIsGood = $this->in(__d('cake', 'Do you want to use this table?'), array('y','n'), 'y'); } if (strtolower($tableIsGood) == 'n') { - $useTable = $this->in(__('What is the name of the table?')); + $useTable = $this->in(__d('cake', 'What is the name of the table?')); } return $useTable; } @@ -834,7 +834,7 @@ class ModelTask extends BakeTask { $tables = $db->listSources(); } if (empty($tables)) { - $this->err(__('Your database does not have any tables.')); + $this->err(__d('cake', 'Your database does not have any tables.')); $this->_stop(); } return $tables; @@ -851,15 +851,15 @@ class ModelTask extends BakeTask { $enteredModel = ''; while ($enteredModel == '') { - $enteredModel = $this->in(__("Enter a number from the list above,\ntype in the name of another model, or 'q' to exit"), null, 'q'); + $enteredModel = $this->in(__d('cake', "Enter a number from the list above,\ntype in the name of another model, or 'q' to exit"), null, 'q'); if ($enteredModel === 'q') { - $this->out(__('Exit')); + $this->out(__d('cake', 'Exit')); $this->_stop(); } if ($enteredModel == '' || intval($enteredModel) > count($this->_modelNames)) { - $this->err(__("The model name you supplied was empty,\nor the number you selected was not an option. Please try again.")); + $this->err(__d('cake', "The model name you supplied was empty,\nor the number you selected was not an option. Please try again.")); $enteredModel = ''; } } @@ -879,18 +879,18 @@ class ModelTask extends BakeTask { public function getOptionParser() { $parser = parent::getOptionParser(); return $parser->description( - __('Bake models.') + __d('cake', 'Bake models.') )->addArgument('name', array( - 'help' => __('Name of the model to bake. Can use Plugin.name to bake plugin models.') + 'help' => __d('cake', 'Name of the model to bake. Can use Plugin.name to bake plugin models.') ))->addSubcommand('all', array( - 'help' => __('Bake all model files with associations and validation.') + 'help' => __d('cake', 'Bake all model files with associations and validation.') ))->addOption('plugin', array( 'short' => 'p', - 'help' => __('Plugin to bake the model into.') + 'help' => __d('cake', 'Plugin to bake the model into.') ))->addOption('connection', array( 'short' => 'c', - 'help' => __('The connection the model table is on.') - ))->epilog(__('Omitting all arguments and options will enter into an interactive mode.')); + 'help' => __d('cake', 'The connection the model table is on.') + ))->epilog(__d('cake', 'Omitting all arguments and options will enter into an interactive mode.')); } /** diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index a08212423..841a38814 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -56,8 +56,8 @@ class PluginTask extends Shell { $plugin = Inflector::camelize($this->args[0]); $pluginPath = $this->_pluginPath($plugin); if (is_dir($pluginPath)) { - $this->out(__('Plugin: %s', $plugin)); - $this->out(__('Path: %s', $pluginPath)); + $this->out(__d('cake', 'Plugin: %s', $plugin)); + $this->out(__d('cake', 'Path: %s', $pluginPath)); } else { $this->_interactive($plugin); } @@ -74,11 +74,11 @@ class PluginTask extends Shell { */ protected function _interactive($plugin = null) { while ($plugin === null) { - $plugin = $this->in(__('Enter the name of the plugin in CamelCase format')); + $plugin = $this->in(__d('cake', 'Enter the name of the plugin in CamelCase format')); } if (!$this->bake($plugin)) { - $this->error(__("An error occured trying to bake: %s in %s", $plugin, $this->path . Inflector::underscore($pluginPath))); + $this->error(__d('cake', "An error occured trying to bake: %s in %s", $plugin, $this->path . Inflector::underscore($pluginPath))); } } @@ -97,11 +97,11 @@ class PluginTask extends Shell { $this->findPath($pathOptions); } $this->hr(); - $this->out(__("Plugin Name: %s", $plugin)); - $this->out(__("Plugin Directory: %s", $this->path . $pluginPath)); + $this->out(__d('cake', "Plugin Name: %s", $plugin)); + $this->out(__d('cake', "Plugin Directory: %s", $this->path . $pluginPath)); $this->hr(); - $looksGood = $this->in(__('Look okay?'), array('y', 'n', 'q'), 'y'); + $looksGood = $this->in(__d('cake', 'Look okay?'), array('y', 'n', 'q'), 'y'); if (strtolower($looksGood) == 'y') { $Folder = new Folder($this->path . $pluginPath); @@ -156,7 +156,7 @@ class PluginTask extends Shell { $this->createFile($this->path . $pluginPath . DS . $modelFileName, $out); $this->hr(); - $this->out(__('Created: %s in %s', $plugin, $this->path . $pluginPath), 2); + $this->out(__d('cake', 'Created: %s in %s', $plugin, $this->path . $pluginPath), 2); } return true; @@ -174,7 +174,7 @@ class PluginTask extends Shell { foreach ($pathOptions as $i => $option) { $this->out($i + 1 .'. ' . $option); } - $prompt = __('Choose a plugin path from the paths above.'); + $prompt = __d('cake', 'Choose a plugin path from the paths above.'); $choice = $this->in($prompt); if (intval($choice) > 0 && intval($choice) <= $max) { $valid = true; @@ -194,7 +194,7 @@ class PluginTask extends Shell { 'Create the directory structure, AppModel and AppController classes for a new plugin. ' . 'Can create plugins in any of your bootstrapped plugin paths.' )->addArgument('name', array( - 'help' => __('CamelCased name of the plugin to create.') + 'help' => __d('cake', 'CamelCased name of the plugin to create.') )); } diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index addf35a00..862b7f83a 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -61,7 +61,7 @@ class ProjectTask extends Shell { } while (!$project) { - $prompt = __("What is the full path for this app including the app directory name?\n Example:"); + $prompt = __d('cake', "What is the full path for this app including the app directory name?\n Example:"); $default = APP_PATH . 'myapp'; $project = $this->in($prompt . $default, null, $default); } @@ -69,7 +69,7 @@ class ProjectTask extends Shell { if ($project) { $response = false; while ($response == false && is_dir($project) === true && file_exists($project . 'config' . 'core.php')) { - $prompt = __('A project already exists in this location: %s Overwrite?', $project); + $prompt = __d('cake', 'A project already exists in this location: %s Overwrite?', $project); $response = $this->in($prompt, array('y','n'), 'n'); if (strtolower($response) === 'n') { $response = $project = false; @@ -81,51 +81,51 @@ class ProjectTask extends Shell { if ($this->bake($project)) { $path = Folder::slashTerm($project); if ($this->createHome($path)) { - $this->out(__(' * Welcome page created')); + $this->out(__d('cake', ' * Welcome page created')); } else { - $this->err(__('The Welcome page was NOT created')); + $this->err(__d('cake', 'The Welcome page was NOT created')); $success = false; } if ($this->securitySalt($path) === true) { - $this->out(__(' * Random hash key created for \'Security.salt\'')); + $this->out(__d('cake', ' * Random hash key created for \'Security.salt\'')); } else { - $this->err(__('Unable to generate random hash for \'Security.salt\', you should change it in %s', CONFIGS . 'core.php')); + $this->err(__d('cake', 'Unable to generate random hash for \'Security.salt\', you should change it in %s', CONFIGS . 'core.php')); $success = false; } if ($this->securityCipherSeed($path) === true) { - $this->out(__(' * Random seed created for \'Security.cipherSeed\'')); + $this->out(__d('cake', ' * Random seed created for \'Security.cipherSeed\'')); } else { - $this->err(__('Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', CONFIGS . 'core.php')); + $this->err(__d('cake', 'Unable to generate random seed for \'Security.cipherSeed\', you should change it in %s', CONFIGS . 'core.php')); $success = false; } if ($this->corePath($path) === true) { - $this->out(__(' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH)); - $this->out(__(' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH)); - $this->out(__(' * Remember to check these value after moving to production server')); + $this->out(__d('cake', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH)); + $this->out(__d('cake', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH)); + $this->out(__d('cake', ' * Remember to check these value after moving to production server')); } else { - $this->err(__('Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' .DS .'index.php')); + $this->err(__d('cake', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' .DS .'index.php')); $success = false; } if ($this->consolePath($path) === true) { - $this->out(__(' * app/console/cake.php path set.')); + $this->out(__d('cake', ' * app/console/cake.php path set.')); } else { - $this->err(__('Unable to set console path for app/console.')); + $this->err(__d('cake', 'Unable to set console path for app/console.')); $success = false; } $Folder = new Folder($path); if (!$Folder->chmod($path . 'tmp', 0777)) { - $this->err(__('Could not set permissions on %s', $path . DS .'tmp')); - $this->out(__('chmod -R 0777 %s', $path . DS .'tmp')); + $this->err(__d('cake', 'Could not set permissions on %s', $path . DS .'tmp')); + $this->out(__d('cake', 'chmod -R 0777 %s', $path . DS .'tmp')); $success = false; } if ($success) { - $this->out(__('Project baked successfully!')); + $this->out(__d('cake', 'Project baked successfully!')); } else { - $this->out(__('Project baked but with some issues..')); + $this->out(__d('cake', 'Project baked but with some issues..')); } return $path; } @@ -147,23 +147,23 @@ class ProjectTask extends Shell { $skel = $this->params['skel']; } while (!$skel) { - $skel = $this->in(__("What is the path to the directory layout you wish to copy?\nExample: %s", APP, null, ROOT . DS . 'myapp' . DS)); + $skel = $this->in(__d('cake', "What is the path to the directory layout you wish to copy?\nExample: %s", APP, null, ROOT . DS . 'myapp' . DS)); if ($skel == '') { - $this->err(__('The directory path you supplied was empty. Please try again.')); + $this->err(__d('cake', 'The directory path you supplied was empty. Please try again.')); } else { while (is_dir($skel) === false) { - $skel = $this->in(__('Directory path does not exist please choose another:')); + $skel = $this->in(__d('cake', 'Directory path does not exist please choose another:')); } } } $app = basename($path); - $this->out(__('Skel Directory: ') . $skel); - $this->out(__('Will be copied to: ') . $path); + $this->out(__d('cake', 'Skel Directory: ') . $skel); + $this->out(__d('cake', 'Will be copied to: ') . $path); $this->hr(); - $looksGood = $this->in(__('Look okay?'), array('y', 'n', 'q'), 'y'); + $looksGood = $this->in(__d('cake', 'Look okay?'), array('y', 'n', 'q'), 'y'); if (strtolower($looksGood) == 'y') { $Folder = new Folder($skel); @@ -173,10 +173,10 @@ class ProjectTask extends Shell { if ($Folder->copy(array('to' => $path, 'skip' => $skip))) { $this->hr(); - $this->out(__('Created: %s in %s', $app, $path)); + $this->out(__d('cake', 'Created: %s in %s', $app, $path)); $this->hr(); } else { - $this->err(__("Could not create '%s' properly.", $app)); + $this->err(__d('cake', "Could not create '%s' properly.", $app)); return false; } @@ -186,7 +186,7 @@ class ProjectTask extends Shell { return true; } elseif (strtolower($looksGood) == 'q') { - $this->out(__('Bake Aborted.')); + $this->out(__d('cake', 'Bake Aborted.')); } else { $this->execute(false); return false; @@ -343,7 +343,7 @@ class ProjectTask extends Shell { } if ($this->interactive) { $this->out(); - $this->out(__('You have more than one routing prefix configured')); + $this->out(__d('cake', 'You have more than one routing prefix configured')); } $options = array(); foreach ($prefixes as $i => $prefix) { @@ -352,19 +352,19 @@ class ProjectTask extends Shell { $this->out($i + 1 . '. ' . $prefix); } } - $selection = $this->in(__('Please choose a prefix to bake with.'), $options, 1); + $selection = $this->in(__d('cake', 'Please choose a prefix to bake with.'), $options, 1); return $prefixes[$selection - 1] . '_'; } if ($this->interactive) { $this->hr(); $this->out('You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.'); - $this->out(__('What would you like the prefix route to be?')); - $this->out(__('Example: www.example.com/admin/controller')); + $this->out(__d('cake', 'What would you like the prefix route to be?')); + $this->out(__d('cake', 'Example: www.example.com/admin/controller')); while ($admin == '') { - $admin = $this->in(__('Enter a routing prefix:'), null, 'admin'); + $admin = $this->in(__d('cake', 'Enter a routing prefix:'), null, 'admin'); } if ($this->cakeAdmin($admin) !== true) { - $this->out(__('Unable to write to /app/config/core.php.')); + $this->out(__d('cake', 'Unable to write to /app/config/core.php.')); $this->out('You need to enable Configure::write(\'Routing.prefixes\',array(\'admin\')) in /app/config/core.php to use prefix routing.'); $this->_stop(); } @@ -381,13 +381,13 @@ class ProjectTask extends Shell { public function getOptionParser() { $parser = parent::getOptionParser(); return $parser->description( - __('Generate a new CakePHP project skeleton.') + __d('cake', 'Generate a new CakePHP project skeleton.') )->addArgument('name', array( - 'help' => __('Application directory to make, if it starts with "/" the path is absolute.') + 'help' => __d('cake', 'Application directory to make, if it starts with "/" the path is absolute.') ))->addOption('empty', array( - 'help' => __('Create empty files in each of the directories. Good if you are using git') + 'help' => __d('cake', 'Create empty files in each of the directories. Good if you are using git') ))->addOption('skel', array( - 'help' => __('The directory layout to use for the new application skeleton. Defaults to cake/console/templates/skel of CakePHP used to create the project.') + 'help' => __d('cake', '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/lib/Cake/Console/Command/Task/TemplateTask.php b/lib/Cake/Console/Command/Task/TemplateTask.php index 34c122ed9..85e4a48c0 100644 --- a/lib/Cake/Console/Command/Task/TemplateTask.php +++ b/lib/Cake/Console/Command/Task/TemplateTask.php @@ -170,8 +170,8 @@ class TemplateTask extends Shell { } $this->hr(); - $this->out(__('You have more than one set of templates installed.')); - $this->out(__('Please choose the template set you wish to use:')); + $this->out(__d('cake', 'You have more than one set of templates installed.')); + $this->out(__d('cake', 'Please choose the template set you wish to use:')); $this->hr(); $i = 1; @@ -181,7 +181,7 @@ class TemplateTask extends Shell { $indexedPaths[$i] = $path; $i++; } - $index = $this->in(__('Which bake theme would you like to use?'), range(1, $i - 1), 1); + $index = $this->in(__d('cake', 'Which bake theme would you like to use?'), range(1, $i - 1), 1); $themeNames = array_keys($this->templatePaths); $this->params['theme'] = $themeNames[$index - 1]; return $indexedPaths[$index]; @@ -208,7 +208,7 @@ class TemplateTask extends Shell { return $templatePath; } } - $this->err(__('Could not find template for %s', $filename)); + $this->err(__d('cake', 'Could not find template for %s', $filename)); return false; } } diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index 1fdab02d6..56e6b9561 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -89,14 +89,14 @@ class TestTask extends BakeTask { protected function _interactive($type = null) { $this->interactive = true; $this->hr(); - $this->out(__('Bake Tests')); - $this->out(__('Path: %s', $this->path)); + $this->out(__d('cake', 'Bake Tests')); + $this->out(__d('cake', 'Path: %s', $this->path)); $this->hr(); if ($type) { $type = Inflector::camelize($type); if (!in_array($type, $this->classTypes)) { - $this->error(__('Incorrect type provided. Please choose one of %s', implode(', ', $this->classTypes))); + $this->error(__d('cake', 'Incorrect type provided. Please choose one of %s', implode(', ', $this->classTypes))); } } else { $type = $this->getObjectType(); @@ -113,7 +113,7 @@ class TestTask extends BakeTask { */ public function bake($type, $className) { if ($this->typeCanDetectFixtures($type) && $this->isLoadableClass($type, $className)) { - $this->out(__('Bake is detecting possible fixtures...')); + $this->out(__d('cake', 'Bake is detecting possible fixtures...')); $testSubject = $this->buildTestSubject($type, $className); $this->generateFixtureList($testSubject); } elseif ($this->interactive) { @@ -154,7 +154,7 @@ class TestTask extends BakeTask { */ public function getObjectType() { $this->hr(); - $this->out(__('Select an object type:')); + $this->out(__d('cake', 'Select an object type:')); $this->hr(); $keys = array(); @@ -163,7 +163,7 @@ class TestTask extends BakeTask { $keys[] = $key; } $keys[] = 'q'; - $selection = $this->in(__('Enter the type of object to bake a test for or (q)uit'), $keys, 'q'); + $selection = $this->in(__d('cake', 'Enter the type of object to bake a test for or (q)uit'), $keys, 'q'); if ($selection == 'q') { return $this->_stop(); } @@ -191,13 +191,13 @@ class TestTask extends BakeTask { } else { $options = App::objects($type); } - $this->out(__('Choose a %s class', $objectType)); + $this->out(__d('cake', 'Choose a %s class', $objectType)); $keys = array(); foreach ($options as $key => $option) { $this->out(++$key . '. ' . $option); $keys[] = $key; } - $selection = $this->in(__('Choose an existing class, or enter the name of a class that does not exist')); + $selection = $this->in(__d('cake', 'Choose an existing class, or enter the name of a class that does not exist')); if (isset($options[$selection - 1])) { return $options[$selection - 1]; } @@ -365,10 +365,10 @@ class TestTask extends BakeTask { * @return array Array of fixtures the user wants to add. */ public function getUserFixtures() { - $proceed = $this->in(__('Bake could not detect fixtures, would you like to add some?'), array('y','n'), 'n'); + $proceed = $this->in(__d('cake', 'Bake could not detect fixtures, would you like to add some?'), array('y','n'), 'n'); $fixtures = array(); if (strtolower($proceed) == 'y') { - $fixtureList = $this->in(__("Please provide a comma separated list of the fixtures names you'd like to use.\nExample: 'app.comment, app.post, plugin.forums.post'")); + $fixtureList = $this->in(__d('cake', "Please provide a comma separated list of the fixtures names you'd like to use.\nExample: 'app.comment, app.post, plugin.forums.post'")); $fixtureListTrimmed = str_replace(' ', '', $fixtureList); $fixtures = explode(',', $fixtureListTrimmed); } @@ -431,15 +431,15 @@ class TestTask extends BakeTask { */ public function getOptionParser() { $parser = parent::getOptionParser(); - return $parser->description(__('Bake test case skeletons for classes.')) + return $parser->description(__d('cake', 'Bake test case skeletons for classes.')) ->addArgument('type', array( - 'help' => __('Type of class to bake, can be any of the following: controller, model, helper, component or behavior.'), + 'help' => __d('cake', 'Type of class to bake, can be any of the following: controller, model, helper, component or behavior.'), 'choices' => array('controller', 'model', 'helper', 'component', 'behavior') ))->addArgument('name', array( - 'help' => __('An existing class to bake tests for.') + 'help' => __d('cake', 'An existing class to bake tests for.') ))->addOption('plugin', array( 'short' => 'p', - 'help' => __('CamelCased name of the plugin to bake tests for.') - ))->epilog(__('Omitting all arguments and options will enter into an interactive mode.')); + 'help' => __d('cake', 'CamelCased name of the plugin to bake tests for.') + ))->epilog(__d('cake', 'Omitting all arguments and options will enter into an interactive mode.')); } } diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index c69813320..a0604b2f8 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -221,17 +221,17 @@ class ViewTask extends BakeTask { $this->controllerPath = strtolower(Inflector::underscore($this->controllerName)); - $prompt = __("Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite %s views if it exist.", $this->controllerName); + $prompt = __d('cake', "Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite %s views if it exist.", $this->controllerName); $interactive = $this->in($prompt, array('y', 'n'), 'n'); if (strtolower($interactive) == 'n') { $this->interactive = false; } - $prompt = __("Would you like to create some CRUD views\n(index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller\nand model classes (including associated models)."); + $prompt = __d('cake', "Would you like to create some CRUD views\n(index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller\nand model classes (including associated models)."); $wannaDoScaffold = $this->in($prompt, array('y','n'), 'y'); - $wannaDoAdmin = $this->in(__("Would you like to create the views for admin routing?"), array('y','n'), 'n'); + $wannaDoAdmin = $this->in(__d('cake', "Would you like to create the views for admin routing?"), array('y','n'), 'n'); if (strtolower($wannaDoScaffold) == 'y' || strtolower($wannaDoAdmin) == 'y') { $vars = $this->__loadController(); @@ -250,7 +250,7 @@ class ViewTask extends BakeTask { } $this->hr(); $this->out(); - $this->out(__("View Scaffolding Complete.\n")); + $this->out(__d('cake', "View Scaffolding Complete.\n")); } else { $this->customAction(); } @@ -268,7 +268,7 @@ class ViewTask extends BakeTask { */ private function __loadController() { if (!$this->controllerName) { - $this->err(__('Controller not found')); + $this->err(__d('cake', 'Controller not found')); } $plugin = null; @@ -280,7 +280,7 @@ class ViewTask extends BakeTask { 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->err(__d('cake', "The file '%s' could not be found.\nIn order to bake a view, you'll need to first create the controller.", $file)); $this->_stop(); } $controllerObj = new $controllerClassName(); @@ -331,25 +331,25 @@ class ViewTask extends BakeTask { public function customAction() { $action = ''; while ($action == '') { - $action = $this->in(__('Action Name? (use lowercase_underscored function name)')); + $action = $this->in(__d('cake', 'Action Name? (use lowercase_underscored function name)')); if ($action == '') { - $this->out(__('The action name you supplied was empty. Please try again.')); + $this->out(__d('cake', 'The action name you supplied was empty. Please try again.')); } } $this->out(); $this->hr(); - $this->out(__('The following view will be created:')); + $this->out(__d('cake', 'The following view will be created:')); $this->hr(); - $this->out(__('Controller Name: %s', $this->controllerName)); - $this->out(__('Action Name: %s', $action)); - $this->out(__('Path: %s', $this->params['app'] . DS . $this->controllerPath . DS . Inflector::underscore($action) . ".ctp")); + $this->out(__d('cake', 'Controller Name: %s', $this->controllerName)); + $this->out(__d('cake', 'Action Name: %s', $action)); + $this->out(__d('cake', 'Path: %s', $this->params['app'] . DS . $this->controllerPath . DS . Inflector::underscore($action) . ".ctp")); $this->hr(); - $looksGood = $this->in(__('Look okay?'), array('y','n'), 'y'); + $looksGood = $this->in(__d('cake', 'Look okay?'), array('y','n'), 'y'); if (strtolower($looksGood) == 'y') { $this->bake($action, ' '); $this->_stop(); } else { - $this->out(__('Bake Aborted.')); + $this->out(__d('cake', 'Bake Aborted.')); } } @@ -431,25 +431,25 @@ class ViewTask extends BakeTask { public function getOptionParser() { $parser = parent::getOptionParser(); return $parser->description( - __('Bake views for a controller, using built-in or custom templates.') + __d('cake', 'Bake views for a controller, using built-in or custom templates.') )->addArgument('controller', array( - 'help' => __('Name of the controller views to bake. Can be Plugin.name as a shortcut for plugin baking.') + 'help' => __d('cake', 'Name of the controller views to bake. Can be Plugin.name as a shortcut for plugin baking.') ))->addArgument('action', array( - 'help' => __("Will bake a single action's file. core templates are (index, add, edit, view)") + 'help' => __d('cake', "Will bake a single action's file. core templates are (index, add, edit, view)") ))->addArgument('alias', array( - 'help' => __('Will bake the template in but create the filename after .') + 'help' => __d('cake', 'Will bake the template in but create the filename after .') ))->addOption('plugin', array( 'short' => 'p', - 'help' => __('Plugin to bake the view into.') + 'help' => __d('cake', 'Plugin to bake the view into.') ))->addOption('admin', array( - 'help' => __('Set to only bake views for a prefix in Routing.prefixes'), + 'help' => __d('cake', 'Set to only bake views for a prefix in Routing.prefixes'), 'boolean' => true ))->addOption('connection', array( 'short' => 'c', - 'help' => __('The connection the connected model is on.') + 'help' => __d('cake', 'The connection the connected model is on.') ))->addSubcommand('all', array( - 'help' => __('Bake all CRUD action views for all controllers. Requires models and controllers to exist.') - ))->epilog(__('Omitting all arguments and options will enter into an interactive mode.')); + 'help' => __d('cake', 'Bake all CRUD action views for all controllers. Requires models and controllers to exist.') + ))->epilog(__d('cake', 'Omitting all arguments and options will enter into an interactive mode.')); } /** diff --git a/lib/Cake/Console/Command/TestsuiteShell.php b/lib/Cake/Console/Command/TestsuiteShell.php index d788cae3d..22f5a6479 100644 --- a/lib/Cake/Console/Command/TestsuiteShell.php +++ b/lib/Cake/Console/Command/TestsuiteShell.php @@ -44,113 +44,113 @@ class TestsuiteShell extends Shell { 'The CakePHP Testsuite allows you to run test cases from the command line', 'If run with no command line arguments, a list of available core test cases will be shown' ))->addArgument('category', array( - 'help' => __('app, core or name of a plugin.'), + 'help' => __d('cake', 'app, core or name of a plugin.'), 'required' => true ))->addArgument('file', array( - 'help' => __('file name with folder prefix and without the test.php suffix.'), + 'help' => __d('cake', 'file name with folder prefix and without the test.php suffix.'), 'required' => false, ))->addOption('log-junit', array( - 'help' => __(' Log test execution in JUnit XML format to file.'), + 'help' => __d('cake', ' Log test execution in JUnit XML format to file.'), 'default' => false ))->addOption('log-json', array( - 'help' => __(' Log test execution in TAP format to file.'), + 'help' => __d('cake', ' Log test execution in TAP format to file.'), 'default' => false ))->addOption('log-tap', array( - 'help' => __(' Log test execution in TAP format to file.'), + 'help' => __d('cake', ' Log test execution in TAP format to file.'), 'default' => false ))->addOption('log-dbus', array( - 'help' => __('Log test execution to DBUS.'), + 'help' => __d('cake', 'Log test execution to DBUS.'), 'default' => false ))->addOption('coverage-html', array( - 'help' => __(' Generate code coverage report in HTML format.'), + 'help' => __d('cake', ' Generate code coverage report in HTML format.'), 'default' => false ))->addOption('coverage-clover', array( - 'help' => __(' Write code coverage data in Clover XML format.'), + 'help' => __d('cake', ' Write code coverage data in Clover XML format.'), 'default' => false ))->addOption('testdox-html', array( - 'help' => __(' Write agile documentation in HTML format to file.'), + 'help' => __d('cake', ' Write agile documentation in HTML format to file.'), 'default' => false ))->addOption('testdox-text', array( - 'help' => __(' Write agile documentation in Text format to file.'), + 'help' => __d('cake', ' Write agile documentation in Text format to file.'), 'default' => false ))->addOption('filter', array( - 'help' => __(' Filter which tests to run.'), + 'help' => __d('cake', ' Filter which tests to run.'), 'default' => false ))->addOption('group', array( - 'help' => __(' Only runs tests from the specified group(s).'), + 'help' => __d('cake', ' Only runs tests from the specified group(s).'), 'default' => false ))->addOption('exclude-group', array( - 'help' => __(' Exclude tests from the specified group(s).'), + 'help' => __d('cake', ' Exclude tests from the specified group(s).'), 'default' => false ))->addOption('list-groups', array( - 'help' => __('List available test groups.'), + 'help' => __d('cake', 'List available test groups.'), 'boolean' => true ))->addOption('loader', array( - 'help' => __('TestSuiteLoader implementation to use.'), + 'help' => __d('cake', 'TestSuiteLoader implementation to use.'), 'default' => false ))->addOption('repeat', array( - 'help' => __(' Runs the test(s) repeatedly.'), + 'help' => __d('cake', ' Runs the test(s) repeatedly.'), 'default' => false ))->addOption('tap', array( - 'help' => __('Report test execution progress in TAP format.'), + 'help' => __d('cake', 'Report test execution progress in TAP format.'), 'boolean' => true ))->addOption('testdox', array( - 'help' => __('Report test execution progress in TestDox format.'), + 'help' => __d('cake', 'Report test execution progress in TestDox format.'), 'default' => false, 'boolean' => true ))->addOption('no-colors', array( - 'help' => __('Do not use colors in output.'), + 'help' => __d('cake', 'Do not use colors in output.'), 'boolean' => true ))->addOption('stderr', array( - 'help' => __('Write to STDERR instead of STDOUT.'), + 'help' => __d('cake', 'Write to STDERR instead of STDOUT.'), 'boolean' => true ))->addOption('stop-on-error', array( - 'help' => __('Stop execution upon first error or failure.'), + 'help' => __d('cake', 'Stop execution upon first error or failure.'), 'boolean' => true ))->addOption('stop-on-failure', array( - 'help' => __('Stop execution upon first failure.'), + 'help' => __d('cake', 'Stop execution upon first failure.'), 'boolean' => true ))->addOption('stop-on-skipped ', array( - 'help' => __('Stop execution upon first skipped test.'), + 'help' => __d('cake', 'Stop execution upon first skipped test.'), 'boolean' => true ))->addOption('stop-on-incomplete', array( - 'help' => __('Stop execution upon first incomplete test.'), + 'help' => __d('cake', 'Stop execution upon first incomplete test.'), 'boolean' => true ))->addOption('strict', array( - 'help' => __('Mark a test as incomplete if no assertions are made.'), + 'help' => __d('cake', 'Mark a test as incomplete if no assertions are made.'), 'boolean' => true ))->addOption('wait', array( - 'help' => __('Waits for a keystroke after each test.'), + 'help' => __d('cake', 'Waits for a keystroke after each test.'), 'boolean' => true ))->addOption('process-isolation', array( - 'help' => __('Run each test in a separate PHP process.'), + 'help' => __d('cake', 'Run each test in a separate PHP process.'), 'boolean' => true ))->addOption('no-globals-backup', array( - 'help' => __('Do not backup and restore $GLOBALS for each test.'), + 'help' => __d('cake', 'Do not backup and restore $GLOBALS for each test.'), 'boolean' => true ))->addOption('static-backup ', array( - 'help' => __('Backup and restore static attributes for each test.'), + 'help' => __d('cake', 'Backup and restore static attributes for each test.'), 'boolean' => true ))->addOption('syntax-check', array( - 'help' => __('Try to check source files for syntax errors.'), + 'help' => __d('cake', 'Try to check source files for syntax errors.'), 'boolean' => true ))->addOption('bootstrap', array( - 'help' => __(' A "bootstrap" PHP file that is run before the tests.'), + 'help' => __d('cake', ' A "bootstrap" PHP file that is run before the tests.'), 'default' => false ))->addOption('configuration', array( - 'help' => __(' Read configuration from XML file.'), + 'help' => __d('cake', ' Read configuration from XML file.'), 'default' => false ))->addOption('no-configuration', array( - 'help' => __('Ignore default configuration file (phpunit.xml).'), + 'help' => __d('cake', 'Ignore default configuration file (phpunit.xml).'), 'boolean' => true ))->addOption('include-path', array( - 'help' => __(' Prepend PHP include_path with given path(s).'), + 'help' => __d('cake', ' Prepend PHP include_path with given path(s).'), 'default' => false ))->addOption('directive', array( - 'help' => __('key[=value] Sets a php.ini value.'), + 'help' => __d('cake', 'key[=value] Sets a php.ini value.'), 'default' => false ))->addOption('fixture', array( - 'help' => __('Choose a custom fixture manager.'), + 'help' => __d('cake', 'Choose a custom fixture manager.'), )); return $parser; @@ -232,7 +232,7 @@ class TestsuiteShell extends Shell { * @return void */ public function main() { - $this->out(__('CakePHP Test Shell')); + $this->out(__d('cake', 'CakePHP Test Shell')); $this->hr(); $args = $this->parseArgs(); @@ -281,7 +281,7 @@ class TestsuiteShell extends Shell { } if (empty($testCases)) { - $this->out(__("No test cases available \n\n")); + $this->out(__d('cake', "No test cases available \n\n")); return $this->out($this->OptionParser->help()); } @@ -297,7 +297,7 @@ class TestsuiteShell extends Shell { $i++; } - while ($choice = $this->in(__('What test case would you like to run?'), null, 'q')) { + while ($choice = $this->in(__d('cake', 'What test case would you like to run?'), null, 'q')) { if (is_numeric($choice) && isset($cases[$choice])) { $this->args[0] = $category; $this->args[1] = $cases[$choice]; diff --git a/lib/Cake/Console/ConsoleErrorHandler.php b/lib/Cake/Console/ConsoleErrorHandler.php index 6fe08ca55..476ebeba4 100644 --- a/lib/Cake/Console/ConsoleErrorHandler.php +++ b/lib/Cake/Console/ConsoleErrorHandler.php @@ -58,7 +58,7 @@ class ConsoleErrorHandler extends ErrorHandler { public static function handleException(Exception $exception) { $stderr = self::getStderr(); $stderr->write(sprintf( - __("Error: %s\n%s"), + __d('cake', "Error: %s\n%s"), $exception->getMessage(), $exception->getTraceAsString() )); @@ -80,8 +80,8 @@ class ConsoleErrorHandler extends ErrorHandler { } $stderr = self::getStderr(); list($name, $log) = self::_mapErrorCode($code); - $message = __('%s in [%s, line %s]', $description, $file, $line); - $stderr->write(__("%s Error: %s\n", $name, $message)); + $message = __d('cake', '%s in [%s, line %s]', $description, $file, $line); + $stderr->write(__d('cake', "%s Error: %s\n", $name, $message)); if (Configure::read('debug') == 0) { CakeLog::write($log, $message); diff --git a/lib/Cake/Console/ConsoleInputArgument.php b/lib/Cake/Console/ConsoleInputArgument.php index 263475e9d..a3ec01b21 100644 --- a/lib/Cake/Console/ConsoleInputArgument.php +++ b/lib/Cake/Console/ConsoleInputArgument.php @@ -95,10 +95,10 @@ class ConsoleInputArgument { } $optional = ''; if (!$this->isRequired()) { - $optional = __(' (optional)'); + $optional = __d('cake', ' (optional)'); } if (!empty($this->_choices)) { - $optional .= __(' (choices: %s)', implode('|', $this->_choices)); + $optional .= __d('cake', ' (choices: %s)', implode('|', $this->_choices)); } return sprintf('%s%s%s', $name, $this->_help, $optional); } @@ -140,7 +140,7 @@ class ConsoleInputArgument { } if (!in_array($value, $this->_choices)) { throw new ConsoleException(sprintf( - __('"%s" is not a valid value for %s. Please use one of "%s"'), + __d('cake', '"%s" is not a valid value for %s. Please use one of "%s"'), $value, $this->_name, implode(', ', $this->_choices) )); } diff --git a/lib/Cake/Console/ConsoleInputOption.php b/lib/Cake/Console/ConsoleInputOption.php index 3c9049248..270f306e3 100644 --- a/lib/Cake/Console/ConsoleInputOption.php +++ b/lib/Cake/Console/ConsoleInputOption.php @@ -119,10 +119,10 @@ class ConsoleInputOption { public function help($width = 0) { $default = $short = ''; if (!empty($this->_default) && $this->_default !== true) { - $default = __(' (default: %s)', $this->_default); + $default = __d('cake', ' (default: %s)', $this->_default); } if (!empty($this->_choices)) { - $default .= __(' (choices: %s)', implode('|', $this->_choices)); + $default .= __d('cake', ' (choices: %s)', implode('|', $this->_choices)); } if (!empty($this->_short)) { $short = ', -' . $this->_short; @@ -180,7 +180,7 @@ class ConsoleInputOption { } if (!in_array($value, $this->_choices)) { throw new ConsoleException(sprintf( - __('"%s" is not a valid value for --%s. Please use one of "%s"'), + __d('cake', '"%s" is not a valid value for --%s. Please use one of "%s"'), $value, $this->_name, implode(', ', $this->_choices) )); } diff --git a/lib/Cake/Console/ConsoleOptionParser.php b/lib/Cake/Console/ConsoleOptionParser.php index b84615ea5..7cb45c555 100644 --- a/lib/Cake/Console/ConsoleOptionParser.php +++ b/lib/Cake/Console/ConsoleOptionParser.php @@ -134,11 +134,11 @@ class ConsoleOptionParser { if ($defaultOptions) { $this->addOption('verbose', array( 'short' => 'v', - 'help' => __('Enable verbose output.'), + 'help' => __d('cake', 'Enable verbose output.'), 'boolean' => true ))->addOption('quiet', array( 'short' => 'q', - 'help' => __('Enable quiet output.'), + 'help' => __d('cake', 'Enable quiet output.'), 'boolean' => true )); } @@ -461,7 +461,7 @@ class ConsoleOptionParser { foreach ($this->_args as $i => $arg) { if ($arg->isRequired() && !isset($args[$i]) && empty($params['help'])) { throw new ConsoleException( - __('Missing required arguments. %s is required.', $arg->name()) + __d('cake', 'Missing required arguments. %s is required.', $arg->name()) ); } } @@ -555,7 +555,7 @@ class ConsoleOptionParser { */ protected function _parseOption($name, $params) { if (!isset($this->_options[$name])) { - throw new ConsoleException(__('Unknown option `%s`', $name)); + throw new ConsoleException(__d('cake', 'Unknown option `%s`', $name)); } $option = $this->_options[$name]; $isBoolean = $option->isBoolean(); @@ -589,7 +589,7 @@ class ConsoleOptionParser { } $next = count($args); if (!isset($this->_args[$next])) { - throw new ConsoleException(__('Too many arguments.')); + throw new ConsoleException(__d('cake', 'Too many arguments.')); } if ($this->_args[$next]->validChoice($argument)) { diff --git a/lib/Cake/Console/HelpFormatter.php b/lib/Cake/Console/HelpFormatter.php index c3cc45f2e..ccc175194 100644 --- a/lib/Cake/Console/HelpFormatter.php +++ b/lib/Cake/Console/HelpFormatter.php @@ -69,7 +69,7 @@ class HelpFormatter { } $out[] = ''; $out[] = sprintf( - __('To see help on a subcommand use `cake %s [subcommand] --help`'), + __d('cake', 'To see help on a subcommand use `cake %s [subcommand] --help`'), $parser->command() ); $out[] = ''; diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 31b64433f..9660e0cc9 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -560,7 +560,7 @@ class Shell extends Object { * @param string $message An optional error message */ public function error($title, $message = null) { - $this->err(__('Error: %s', $title)); + $this->err(__d('cake', 'Error: %s', $title)); if (!empty($message)) { $this->err($message); @@ -596,27 +596,27 @@ class Shell extends Object { $this->out(); if (is_file($path) && $this->interactive === true) { - $this->out(__('File `%s` exists', $path)); - $key = $this->in(__('Do you want to overwrite?'), array('y', 'n', 'q'), 'n'); + $this->out(__d('cake', 'File `%s` exists', $path)); + $key = $this->in(__d('cake', 'Do you want to overwrite?'), array('y', 'n', 'q'), 'n'); if (strtolower($key) == 'q') { - $this->out(__('Quitting.'), 2); + $this->out(__d('cake', 'Quitting.'), 2); $this->_stop(); } elseif (strtolower($key) != 'y') { - $this->out(__('Skip `%s`', $path), 2); + $this->out(__d('cake', 'Skip `%s`', $path), 2); return false; } } else { - $this->out(__('Creating file %s', $path)); + $this->out(__d('cake', 'Creating file %s', $path)); } if ($File = new File($path, true)) { $data = $File->prepare($contents); $File->write($data); - $this->out(__('Wrote `%s`', $path)); + $this->out(__d('cake', 'Wrote `%s`', $path)); return true; } else { - $this->err(__('Could not write to `%s`.', $path), 2); + $this->err(__d('cake', 'Could not write to `%s`.', $path), 2); return false; } } From cb7f0f087ec1dfd19b611afded64b896c5316290 Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 19:59:40 +0100 Subject: [PATCH 552/668] translation changes in the controller ditranslation changes in the controller dirr --- .../Controller/Component/AclComponent.php | 16 +++++++-------- .../Component/Auth/BaseAuthorize.php | 2 +- .../Component/Auth/ControllerAuthorize.php | 2 +- .../Component/Auth/CrudAuthorize.php | 2 +- .../Controller/Component/AuthComponent.php | 10 +++++----- .../Controller/Component/EmailComponent.php | 2 +- lib/Cake/Controller/Scaffold.php | 20 +++++++++---------- 7 files changed, 27 insertions(+), 27 deletions(-) mode change 100755 => 100644 lib/Cake/Controller/Component/EmailComponent.php diff --git a/lib/Cake/Controller/Component/AclComponent.php b/lib/Cake/Controller/Component/AclComponent.php index e8809f864..d0b9dd188 100644 --- a/lib/Cake/Controller/Component/AclComponent.php +++ b/lib/Cake/Controller/Component/AclComponent.php @@ -68,7 +68,7 @@ class AclComponent extends Component { list($plugin, $name) = pluginSplit($name); $name .= 'Component'; } else { - throw new CakeException(__('Could not find %s.', $name)); + throw new CakeException(__d('cake', 'Could not find %s.', $name)); } } $this->adapter($name); @@ -92,7 +92,7 @@ class AclComponent extends Component { $adapter = new $adapter(); } if (!$adapter instanceof AclInterface) { - throw new CakeException(__('AclComponent adapters must implement AclInterface')); + throw new CakeException(__d('cake', 'AclComponent adapters must implement AclInterface')); } $this->_Instance = $adapter; $this->_Instance->initialize($this); @@ -163,7 +163,7 @@ class AclComponent extends Component { * @deprecated */ public function grant($aro, $aco, $action = "*") { - trigger_error(__('AclComponent::grant() is deprecated, use allow() instead'), E_USER_WARNING); + trigger_error(__d('cake', 'AclComponent::grant() is deprecated, use allow() instead'), E_USER_WARNING); return $this->_Instance->allow($aro, $aco, $action); } @@ -177,7 +177,7 @@ class AclComponent extends Component { * @deprecated */ public function revoke($aro, $aco, $action = "*") { - trigger_error(__('AclComponent::revoke() is deprecated, use deny() instead'), E_USER_WARNING); + trigger_error(__d('cake', 'AclComponent::revoke() is deprecated, use deny() instead'), E_USER_WARNING); return $this->_Instance->deny($aro, $aco, $action); } } @@ -299,12 +299,12 @@ class DbAcl extends Object implements AclInterface { $acoPath = $this->Aco->node($aco); if (empty($aroPath) || empty($acoPath)) { - trigger_error(__("DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING); + trigger_error(__d('cake', "DbAcl::check() - Failed ARO/ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING); return false; } if ($acoPath == null || $acoPath == array()) { - trigger_error(__("DbAcl::check() - Failed ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING); + trigger_error(__d('cake', "DbAcl::check() - Failed ACO node lookup in permissions check. Node references:\nAro: ") . print_r($aro, true) . "\nAco: " . print_r($aco, true), E_USER_WARNING); return false; } @@ -312,7 +312,7 @@ class DbAcl extends Object implements AclInterface { $acoNode = $acoPath[0]; if ($action != '*' && !in_array('_' . $action, $permKeys)) { - trigger_error(__("ACO permissions key %s does not exist in DbAcl::check()", $action), E_USER_NOTICE); + trigger_error(__d('cake', "ACO permissions key %s does not exist in DbAcl::check()", $action), E_USER_NOTICE); return false; } @@ -386,7 +386,7 @@ class DbAcl extends Object implements AclInterface { $save = array(); if ($perms == false) { - trigger_error(__('DbAcl::allow() - Invalid node'), E_USER_WARNING); + trigger_error(__d('cake', 'DbAcl::allow() - Invalid node'), E_USER_WARNING); return false; } if (isset($perms[0])) { diff --git a/lib/Cake/Controller/Component/Auth/BaseAuthorize.php b/lib/Cake/Controller/Component/Auth/BaseAuthorize.php index 911bbdb24..7a5245174 100644 --- a/lib/Cake/Controller/Component/Auth/BaseAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/BaseAuthorize.php @@ -87,7 +87,7 @@ abstract class BaseAuthorize { public function controller($controller = null) { if ($controller) { if (!$controller instanceof Controller) { - throw new CakeException(__('$controller needs to be an instance of Controller')); + throw new CakeException(__d('cake', '$controller needs to be an instance of Controller')); } $this->_Controller = $controller; return true; diff --git a/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php b/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php index 275cf6875..816cb836d 100644 --- a/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/ControllerAuthorize.php @@ -46,7 +46,7 @@ class ControllerAuthorize extends BaseAuthorize { public function controller($controller = null) { if ($controller) { if (!method_exists($controller, 'isAuthorized')) { - throw new CakeException(__('$controller does not implement an isAuthorized() method.')); + throw new CakeException(__d('cake', '$controller does not implement an isAuthorized() method.')); } } return parent::controller($controller); diff --git a/lib/Cake/Controller/Component/Auth/CrudAuthorize.php b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php index b9fa8329c..1adda536e 100644 --- a/lib/Cake/Controller/Component/Auth/CrudAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php @@ -81,7 +81,7 @@ class CrudAuthorize extends BaseAuthorize { */ public function authorize($user, CakeRequest $request) { if (!isset($this->settings['actionMap'][$request->params['action']])) { - trigger_error(__( + trigger_error(__d('cake', 'CrudAuthorize::authorize() - Attempted access of un-mapped action "%1$s" in controller "%2$s"', $request->action, $request->controller diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index c4927be0f..34df18bcc 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -351,7 +351,7 @@ class AuthComponent extends Component { function __setDefaults() { $defaults = array( 'logoutRedirect' => $this->loginAction, - 'authError' => __('You are not authorized to access that location.') + 'authError' => __d('cake', 'You are not authorized to access that location.') ); foreach ($defaults as $key => $value) { if (empty($this->{$key})) { @@ -411,10 +411,10 @@ class AuthComponent extends Component { $className = $class . 'Authorize'; App::uses($className, $plugin . 'Controller/Component/Auth'); if (!class_exists($className)) { - throw new CakeException(__('Authorization adapter "%s" was not found.', $class)); + throw new CakeException(__d('cake', 'Authorization adapter "%s" was not found.', $class)); } if (!method_exists($className, 'authorize')) { - throw new CakeException(__('Authorization objects must implement an authorize method.')); + throw new CakeException(__d('cake', 'Authorization objects must implement an authorize method.')); } $settings = array_merge($global, (array)$settings); $this->_authorizeObjects[] = new $className($this->_Collection, $settings); @@ -651,10 +651,10 @@ class AuthComponent extends Component { $className = $class . 'Authenticate'; App::uses($className, $plugin . 'Controller/Component/Auth'); if (!class_exists($className)) { - throw new CakeException(__('Authentication adapter "%s" was not found.', $class)); + throw new CakeException(__d('cake', 'Authentication adapter "%s" was not found.', $class)); } if (!method_exists($className, 'authenticate')) { - throw new CakeException(__('Authentication objects must implement an authenticate method.')); + throw new CakeException(__d('cake', 'Authentication objects must implement an authenticate method.')); } $settings = array_merge($global, (array)$settings); $this->_authenticateObjects[] = new $className($this->_Collection, $settings); diff --git a/lib/Cake/Controller/Component/EmailComponent.php b/lib/Cake/Controller/Component/EmailComponent.php old mode 100755 new mode 100644 index 735a50d63..b260c1561 --- a/lib/Cake/Controller/Component/EmailComponent.php +++ b/lib/Cake/Controller/Component/EmailComponent.php @@ -725,7 +725,7 @@ class EmailComponent extends Component { $formatted = array(); if ($this->_lineLength !== null) { - trigger_error(__('_lineLength cannot be accessed please use lineLength'), E_USER_WARNING); + trigger_error(__d('cake', '_lineLength cannot be accessed please use lineLength'), E_USER_WARNING); $this->lineLength = $this->_lineLength; } diff --git a/lib/Cake/Controller/Scaffold.php b/lib/Cake/Controller/Scaffold.php index 3eb718df1..054e3a1a3 100644 --- a/lib/Cake/Controller/Scaffold.php +++ b/lib/Cake/Controller/Scaffold.php @@ -127,7 +127,7 @@ class Scaffold { $this->ScaffoldModel = $this->controller->{$this->modelClass}; $this->scaffoldTitle = Inflector::humanize($this->viewPath); $this->scaffoldActions = $controller->scaffold; - $title_for_layout = __('Scaffold :: ') . Inflector::humanize($request->action) . ' :: ' . $this->scaffoldTitle; + $title_for_layout = __d('cake', 'Scaffold :: ') . Inflector::humanize($request->action) . ' :: ' . $this->scaffoldTitle; $modelClass = $this->controller->modelClass; $primaryKey = $this->ScaffoldModel->primaryKey; $displayField = $this->ScaffoldModel->displayField; @@ -174,7 +174,7 @@ class Scaffold { $this->ScaffoldModel->id = $request->params['pass'][0]; } if (!$this->ScaffoldModel->exists()) { - throw new NotFoundException(__('Invalid %s', Inflector::humanize($this->modelKey))); + throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelKey))); } $this->ScaffoldModel->recursive = 1; $this->controller->request->data = $this->ScaffoldModel->read(); @@ -231,10 +231,10 @@ class Scaffold { */ protected function _scaffoldSave(CakeRequest $request, $action = 'edit') { $formAction = 'edit'; - $success = __('updated'); + $success = __d('cake', 'updated'); if ($action === 'add') { $formAction = 'add'; - $success = __('saved'); + $success = __d('cake', 'saved'); } if ($this->controller->_beforeScaffold($action)) { @@ -243,7 +243,7 @@ class Scaffold { $this->ScaffoldModel->id = $request['pass'][0]; } if (!$this->ScaffoldModel->exists()) { - throw new NotFoundException(__('Invalid %s', Inflector::humanize($this->modelKey))); + throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelKey))); } } @@ -254,7 +254,7 @@ class Scaffold { if ($this->ScaffoldModel->save($request->data)) { if ($this->controller->_afterScaffoldSave($action)) { - $message = __( + $message = __d('cake', 'The %1$s has been %2$s', Inflector::humanize($this->modelKey), $success @@ -265,7 +265,7 @@ class Scaffold { } } else { if ($this->_validSession) { - $this->controller->Session->setFlash(__('Please correct errors below.')); + $this->controller->Session->setFlash(__d('cake', 'Please correct errors below.')); } } } @@ -312,13 +312,13 @@ class Scaffold { } $this->ScaffoldModel->id = $id; if (!$this->ScaffoldModel->exists()) { - throw new NotFoundException(__('Invalid %s', Inflector::humanize($this->modelClass))); + throw new NotFoundException(__d('cake', 'Invalid %s', Inflector::humanize($this->modelClass))); } if ($this->ScaffoldModel->delete()) { - $message = __('The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id); + $message = __d('cake', 'The %1$s with id: %2$d has been deleted.', Inflector::humanize($this->modelClass), $id); return $this->_sendMessage($message); } else { - $message = __( + $message = __d('cake', 'There was an error deleting the %1$s with id: %2$d', Inflector::humanize($this->modelClass), $id From d264d0feb5bb931fce81c0587cf9ccfba7437835 Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 20:00:15 +0100 Subject: [PATCH 553/668] changes in the core dir --- lib/Cake/Core/Configure.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index bf995d507..096de5da7 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -70,14 +70,14 @@ class Configure { )); if (!include(CONFIGS . 'core.php')) { - trigger_error(__("Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR); + trigger_error(__d('cake', "Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR); } if (empty(self::$_values['Cache']['disable'])) { $cache = Cache::config('default'); if (empty($cache['settings'])) { - trigger_error(__('Cache not configured properly. Please check Cache::config(); in APP/config/core.php'), E_USER_WARNING); + trigger_error(__d('cake', 'Cache not configured properly. Please check Cache::config(); in APP/config/core.php'), E_USER_WARNING); $cache = Cache::config('default', array('engine' => 'File')); } $path = $prefix = $duration = null; @@ -113,7 +113,7 @@ class Configure { App::init(); App::build(); if (!include(CONFIGS . 'bootstrap.php')) { - trigger_error(__("Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR); + trigger_error(__d('cake', "Can't find application bootstrap file. Please create %sbootstrap.php, and make sure it is readable by PHP.", CONFIGS), E_USER_ERROR); } $level = -1; if (isset(self::$_values['Error']['level'])) { From afc5cd42776900e9b730b199e27574d5f58cddbd Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 20:00:27 +0100 Subject: [PATCH 554/668] changes in the error dir --- lib/Cake/Error/ExceptionRenderer.php | 4 ++-- lib/Cake/Error/exceptions.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 1b0eb68fe..f2b8c395f 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -194,7 +194,7 @@ class ExceptionRenderer { public function error400($error) { $message = $error->getMessage(); if (Configure::read('debug') == 0 && $error instanceof CakeException) { - $message = __('Not Found'); + $message = __d('cake', 'Not Found'); } $url = $this->controller->request->here(); $this->controller->response->statusCode($error->getCode()); @@ -216,7 +216,7 @@ class ExceptionRenderer { $code = ($error->getCode() > 500) ? $error->getCode() : 500; $this->controller->response->statusCode($code); $this->controller->set(array( - 'name' => __('An Internal Error Has Occurred'), + 'name' => __d('cake', 'An Internal Error Has Occurred'), 'message' => h($url), 'error' => $error, )); diff --git a/lib/Cake/Error/exceptions.php b/lib/Cake/Error/exceptions.php index d1a941594..8c5a80b86 100644 --- a/lib/Cake/Error/exceptions.php +++ b/lib/Cake/Error/exceptions.php @@ -182,7 +182,7 @@ class CakeException extends RuntimeException { public function __construct($message, $code = 500) { if (is_array($message)) { $this->_attributes = $message; - $message = __($this->_messageTemplate, $message); + $message = __d('cake', $this->_messageTemplate, $message); } parent::__construct($message, $code); } From f7e2bb1021b10ad079175579ba53f27f0971eb6d Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 20:00:55 +0100 Subject: [PATCH 555/668] translation changes in the log dir --- lib/Cake/Log/CakeLog.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Log/CakeLog.php b/lib/Cake/Log/CakeLog.php index 0a1875a23..144b8665f 100644 --- a/lib/Cake/Log/CakeLog.php +++ b/lib/Cake/Log/CakeLog.php @@ -82,7 +82,7 @@ class CakeLog { */ public static function config($key, $config) { if (empty($config['engine'])) { - throw new CakeLogException(__('Missing logger classname')); + throw new CakeLogException(__d('cake', 'Missing logger classname')); } $loggerName = $config['engine']; unset($config['engine']); @@ -90,7 +90,7 @@ class CakeLog { $logger = new $className($config); if (!$logger instanceof CakeLogInterface) { throw new CakeLogException(sprintf( - __('logger class %s does not implement a write method.'), $loggerName + __d('cake', 'logger class %s does not implement a write method.'), $loggerName )); } self::$_streams[$key] = $logger; @@ -109,7 +109,7 @@ class CakeLog { App::uses($loggerName, $plugin . 'Log/Engine'); if (!class_exists($loggerName)) { - throw new CakeLogException(__('Could not load class %s', $loggerName)); + throw new CakeLogException(__d('cake', 'Could not load class %s', $loggerName)); } return $loggerName; } From 38180e895105f551396e2006038ed0503f2ad384 Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 20:01:12 +0100 Subject: [PATCH 556/668] translation changes in the model dir --- lib/Cake/Model/AclNode.php | 4 ++-- lib/Cake/Model/Behavior/AclBehavior.php | 2 +- lib/Cake/Model/Behavior/ContainableBehavior.php | 2 +- lib/Cake/Model/Behavior/TranslateBehavior.php | 4 ++-- lib/Cake/Model/BehaviorCollection.php | 2 +- lib/Cake/Model/CakeSchema.php | 2 +- lib/Cake/Model/Datasource/CakeSession.php | 8 ++++---- lib/Cake/Model/Datasource/Database/Mssql.php | 2 +- lib/Cake/Model/Datasource/Database/Mysql.php | 2 +- lib/Cake/Model/Datasource/Database/Oracle.php | 6 +++--- lib/Cake/Model/Datasource/Database/Sqlite.php | 2 +- lib/Cake/Model/Datasource/DboSource.php | 16 ++++++++-------- lib/Cake/Model/Model.php | 8 ++++---- 13 files changed, 30 insertions(+), 30 deletions(-) mode change 100755 => 100644 lib/Cake/Model/Datasource/DboSource.php diff --git a/lib/Cake/Model/AclNode.php b/lib/Cake/Model/AclNode.php index 0db0266a5..cbd1dce1d 100644 --- a/lib/Cake/Model/AclNode.php +++ b/lib/Cake/Model/AclNode.php @@ -133,7 +133,7 @@ class AclNode extends AppModel { $model = ClassRegistry::init(array('class' => $name, 'alias' => $name)); if (empty($model)) { - trigger_error(__("Model class '%s' not found in AclNode::node() when trying to bind %s object", $type, $this->alias), E_USER_WARNING); + trigger_error(__d('cake', "Model class '%s' not found in AclNode::node() when trying to bind %s object", $type, $this->alias), E_USER_WARNING); return null; } @@ -178,7 +178,7 @@ class AclNode extends AppModel { $result = $db->read($this, $queryData, -1); if (!$result) { - trigger_error(__("AclNode::node() - Couldn't find %s node identified by \"%s\"", $type, print_r($ref, true)), E_USER_WARNING); + trigger_error(__d('cake', "AclNode::node() - Couldn't find %s node identified by \"%s\"", $type, print_r($ref, true)), E_USER_WARNING); } } return $result; diff --git a/lib/Cake/Model/Behavior/AclBehavior.php b/lib/Cake/Model/Behavior/AclBehavior.php index c04abca6d..38cd7c443 100644 --- a/lib/Cake/Model/Behavior/AclBehavior.php +++ b/lib/Cake/Model/Behavior/AclBehavior.php @@ -54,7 +54,7 @@ class AclBehavior extends ModelBehavior { } $model->{$type} = ClassRegistry::init($type); if (!method_exists($model, 'parentNode')) { - trigger_error(__('Callback parentNode() not defined in %s', $model->alias), E_USER_WARNING); + trigger_error(__d('cake', 'Callback parentNode() not defined in %s', $model->alias), E_USER_WARNING); } } diff --git a/lib/Cake/Model/Behavior/ContainableBehavior.php b/lib/Cake/Model/Behavior/ContainableBehavior.php index 03963a723..60c6b6414 100644 --- a/lib/Cake/Model/Behavior/ContainableBehavior.php +++ b/lib/Cake/Model/Behavior/ContainableBehavior.php @@ -359,7 +359,7 @@ class ContainableBehavior extends ModelBehavior { if (!isset($Model->{$name}) || !is_object($Model->{$name})) { if ($throwErrors) { - trigger_error(__('Model "%s" is not associated with model "%s"', $Model->alias, $name), E_USER_WARNING); + trigger_error(__d('cake', 'Model "%s" is not associated with model "%s"', $Model->alias, $name), E_USER_WARNING); } continue; } diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index 416881c4c..0ab2b880f 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -55,7 +55,7 @@ class TranslateBehavior extends ModelBehavior { $db = ConnectionManager::getDataSource($model->useDbConfig); if (!$db->connected) { trigger_error( - __('Datasource %s for TranslateBehavior of model %s is not connected', $model->useDbConfig, $model->alias), + __d('cake', 'Datasource %s for TranslateBehavior of model %s is not connected', $model->useDbConfig, $model->alias), E_USER_ERROR ); return false; @@ -426,7 +426,7 @@ class TranslateBehavior extends ModelBehavior { foreach (array('hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany') as $type) { if (isset($model->{$type}[$association]) || isset($model->__backAssociation[$type][$association])) { trigger_error( - __('Association %s is already binded to model %s', $association, $model->alias), + __d('cake', 'Association %s is already binded to model %s', $association, $model->alias), E_USER_ERROR ); return false; diff --git a/lib/Cake/Model/BehaviorCollection.php b/lib/Cake/Model/BehaviorCollection.php index 341e5ccc1..445688313 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -219,7 +219,7 @@ class BehaviorCollection extends ObjectCollection { $method = $this->hasMethod($method, true); if ($strict && empty($method)) { - trigger_error(__("BehaviorCollection::dispatchMethod() - Method %s not found in any attached behavior", $method), E_USER_WARNING); + trigger_error(__d('cake', "BehaviorCollection::dispatchMethod() - Method %s not found in any attached behavior", $method), E_USER_WARNING); return null; } if (empty($method)) { diff --git a/lib/Cake/Model/CakeSchema.php b/lib/Cake/Model/CakeSchema.php index 37208581a..e34a1393c 100644 --- a/lib/Cake/Model/CakeSchema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -592,7 +592,7 @@ class CakeSchema extends Object { $value['key'] = 'primary'; } if (!isset($db->columns[$value['type']])) { - trigger_error(__('Schema generation error: invalid column type %s does not exist in DBO', $value['type']), E_USER_NOTICE); + trigger_error(__d('cake', 'Schema generation error: invalid column type %s does not exist in DBO', $value['type']), E_USER_NOTICE); continue; } else { $defaultCol = $db->columns[$value['type']]; diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 45a70f69d..04118e428 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -254,7 +254,7 @@ class CakeSession { self::__overwrite($_SESSION, Set::remove($_SESSION, $name)); return (self::check($name) == false); } - self::__setError(2, __("%s doesn't exist", $name)); + self::__setError(2, __d('cake', "%s doesn't exist", $name)); return false; } @@ -480,7 +480,7 @@ class CakeSession { foreach ($sessionConfig['ini'] as $setting => $value) { if (ini_set($setting, $value) === false) { throw new CakeSessionException(sprintf( - __('Unable to configure the session, setting %s failed.'), + __d('cake', 'Unable to configure the session, setting %s failed.'), $setting )); } @@ -514,13 +514,13 @@ class CakeSession { list($plugin, $class) = pluginSplit($handler, true); App::uses($class, $plugin . 'Model/Datasource/Session'); if (!class_exists($class)) { - throw new CakeSessionException(__('Could not load %s to handle the session.', $class)); + throw new CakeSessionException(__d('cake', 'Could not load %s to handle the session.', $class)); } $handler = new $class(); if ($handler instanceof CakeSessionHandlerInterface) { return $handler; } - throw new CakeSessionException(__('Chosen SessionHandler does not implement CakeSessionHandlerInterface it cannot be used with an engine key.')); + throw new CakeSessionException(__d('cake', 'Chosen SessionHandler does not implement CakeSessionHandlerInterface it cannot be used with an engine key.')); } /** diff --git a/lib/Cake/Model/Datasource/Database/Mssql.php b/lib/Cake/Model/Datasource/Database/Mssql.php index 91db76c5f..e1cef1905 100644 --- a/lib/Cake/Model/Datasource/Database/Mssql.php +++ b/lib/Cake/Model/Datasource/Database/Mssql.php @@ -116,7 +116,7 @@ class DboMssql extends DboSource { function __construct($config, $autoConnect = true) { if ($autoConnect) { if (!function_exists('mssql_min_message_severity')) { - trigger_error(__("PHP SQL Server interface is not installed, cannot continue. For troubleshooting information, see http://php.net/mssql/"), E_USER_WARNING); + trigger_error(__d('cake', "PHP SQL Server interface is not installed, cannot continue. For troubleshooting information, see http://php.net/mssql/"), E_USER_WARNING); } mssql_min_message_severity(15); mssql_min_error_severity(2); diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 5c924c801..3eecf0261 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -298,7 +298,7 @@ class Mysql extends DboSource { $fields = false; $cols = $this->_execute('SHOW FULL COLUMNS FROM ' . $this->fullTableName($model)); if (!$cols) { - throw new CakeException(__('Could not describe table for %s', $model->name)); + throw new CakeException(__d('cake', 'Could not describe table for %s', $model->name)); } foreach ($cols as $column) { diff --git a/lib/Cake/Model/Datasource/Database/Oracle.php b/lib/Cake/Model/Datasource/Database/Oracle.php index 4b4444211..2edcab6dc 100644 --- a/lib/Cake/Model/Datasource/Database/Oracle.php +++ b/lib/Cake/Model/Datasource/Database/Oracle.php @@ -571,7 +571,7 @@ class DboOracle extends DboSource { */ function constraint($action, $table) { if (empty($table)) { - trigger_error(__('Must specify table to operate on constraints')); + trigger_error(__d('cake', 'Must specify table to operate on constraints')); } $table = strtoupper($table); @@ -629,7 +629,7 @@ class DboOracle extends DboSource { return $constraints; break; default: - trigger_error(__('DboOracle::constraint() accepts only enable, disable, or list')); + trigger_error(__d('cake', 'DboOracle::constraint() accepts only enable, disable, or list')); } } return true; @@ -976,7 +976,7 @@ class DboOracle extends DboSource { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { if (!isset($resultSet) || !is_array($resultSet)) { if (Configure::read('debug') > 0) { - echo '
    ' . __('SQL Error in model %s:', $model->alias) . ' '; + echo '
    ' . __d('cake', 'SQL Error in model %s:', $model->alias) . ' '; if (isset($this->error) && $this->error != null) { echo $this->error; } diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 0780622dd..e1176126c 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -392,7 +392,7 @@ class Sqlite extends DboSource { } if (!isset($this->columns[$type])) { - trigger_error(__('Column type %s does not exist', $type), E_USER_WARNING); + trigger_error(__d('cake', 'Column type %s does not exist', $type), E_USER_WARNING); return null; } diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php old mode 100755 new mode 100644 index 5e9b560d2..4142f0904 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -941,11 +941,11 @@ class DboSource extends DataSource { if (Configure::read('debug') > 0) { $out = null; if ($error) { - trigger_error('' . __('SQL Error:') . " {$this->error}", E_USER_WARNING); + trigger_error('' . __d('cake', 'SQL Error:') . " {$this->error}", E_USER_WARNING); } else { - $out = ('[' . __('Aff:%s Num:%s Took:%sms', $this->affected, $this->numRows, $this->took) . ']'); + $out = ('[' . __d('cake', 'Aff:%s Num:%s Took:%sms', $this->affected, $this->numRows, $this->took) . ']'); } - pr(sprintf('

    ' . __('Query:') . ' %s %s

    ', $sql, $out)); + pr(sprintf('

    ' . __d('cake', 'Query:') . ' %s %s

    ', $sql, $out)); } } @@ -1169,7 +1169,7 @@ class DboSource extends DataSource { if ($query = $this->generateAssociationQuery($model, $linkModel, $type, $association, $assocData, $queryData, $external, $resultSet)) { if (!is_array($resultSet)) { if (Configure::read('debug') > 0) { - echo '
    ' . __('SQL Error in model %s:', $model->alias) . ' '; + echo '
    ' . __d('cake', 'SQL Error in model %s:', $model->alias) . ' '; if (isset($this->error) && $this->error != null) { echo $this->error; } @@ -2725,7 +2725,7 @@ class DboSource extends DataSource { */ public function length($real) { if (!preg_match_all('/([\w\s]+)(?:\((\d+)(?:,(\d+))?\))?(\sunsigned)?(\szerofill)?/', $real, $result)) { - trigger_error(__("FIXME: Can't parse field: " . $real), E_USER_WARNING); + trigger_error(__d('cake', "FIXME: Can't parse field: " . $real), E_USER_WARNING); $col = str_replace(array(')', 'unsigned'), '', $real); $limit = null; @@ -2833,7 +2833,7 @@ class DboSource extends DataSource { */ public function createSchema($schema, $tableName = null) { if (!is_a($schema, 'CakeSchema')) { - trigger_error(__('Invalid schema object'), E_USER_WARNING); + trigger_error(__d('cake', 'Invalid schema object'), E_USER_WARNING); return null; } $out = ''; @@ -2915,12 +2915,12 @@ class DboSource extends DataSource { extract(array_merge(array('null' => true), $column)); if (empty($name) || empty($type)) { - trigger_error(__('Column name or type not defined in schema'), E_USER_WARNING); + trigger_error(__d('cake', 'Column name or type not defined in schema'), E_USER_WARNING); return null; } if (!isset($this->columns[$type])) { - trigger_error(__('Column type %s does not exist', $type), E_USER_WARNING); + trigger_error(__d('cake', 'Column type %s does not exist', $type), E_USER_WARNING); return null; } diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index fa20aa513..63e8051fe 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1005,7 +1005,7 @@ class Model extends Object { public function getColumnTypes() { $columns = $this->schema(); if (empty($columns)) { - trigger_error(__('(Model::getColumnTypes) Unable to build model field data. If you are using a model without a database table, try implementing schema()'), E_USER_WARNING); + trigger_error(__d('cake', '(Model::getColumnTypes) Unable to build model field data. If you are using a model without a database table, try implementing schema()'), E_USER_WARNING); } $cols = array(); foreach ($columns as $field => $values) { @@ -2602,7 +2602,7 @@ class Model extends Object { if (isset($validator['message'])) { $message = $validator['message']; } else { - $message = __('This field cannot be left blank'); + $message = __d('cake', 'This field cannot be left blank'); } if ( @@ -2650,7 +2650,7 @@ class Model extends Object { } elseif (!is_array($validator['rule'])) { $valid = preg_match($rule, $data[$fieldName]); } elseif (Configure::read('debug') > 0) { - trigger_error(__('Could not find validation handler %s for %s', $rule, $fieldName), E_USER_WARNING); + trigger_error(__d('cake', 'Could not find validation handler %s for %s', $rule, $fieldName), E_USER_WARNING); } if (!$valid || (is_string($valid) && strlen($valid) > 0)) { @@ -2957,7 +2957,7 @@ class Model extends Object { return array($with, array_unique(array_merge($assoc[$with], $keys))); } trigger_error( - __('Invalid join model settings in %s', $model->alias), + __d('cake', 'Invalid join model settings in %s', $model->alias), E_USER_WARNING ); } From 29b874e7399956758c7ee7e6dc7153aa05b5be1b Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 20:01:38 +0100 Subject: [PATCH 557/668] translation changes in the Network dir --- lib/Cake/Network/CakeRequest.php | 2 +- lib/Cake/Network/CakeResponse.php | 2 +- lib/Cake/Network/CakeSocket.php | 2 +- lib/Cake/Network/Http/HttpResponse.php | 6 +++--- lib/Cake/Network/Http/HttpSocket.php | 16 ++++++++-------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 8963f0e7a..e47f98049 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -380,7 +380,7 @@ class CakeRequest implements ArrayAccess { $type = strtolower(substr($name, 2)); return $this->is($type); } - throw new CakeException(__('Method %s does not exist', $name)); + throw new CakeException(__d('cake', 'Method %s does not exist', $name)); } /** diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 9c200cbcb..be58e46c8 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -459,7 +459,7 @@ class CakeResponse { return $this->_status; } if (!isset($this->_statusCodes[$code])) { - throw new CakeException(__('Unknown status code')); + throw new CakeException(__d('cake', 'Unknown status code')); } return $this->_status = $code; } diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 3be6984f5..0e135de89 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -221,7 +221,7 @@ class CakeSocket { $buffer = fread($this->connection, $length); $info = stream_get_meta_data($this->connection); if ($info['timed_out']) { - $this->setLastError(E_WARNING, __('Connection timed out')); + $this->setLastError(E_WARNING, __d('cake', 'Connection timed out')); return false; } return $buffer; diff --git a/lib/Cake/Network/Http/HttpResponse.php b/lib/Cake/Network/Http/HttpResponse.php index 51aff7a78..cff0bd08e 100644 --- a/lib/Cake/Network/Http/HttpResponse.php +++ b/lib/Cake/Network/Http/HttpResponse.php @@ -126,11 +126,11 @@ class HttpResponse implements ArrayAccess { */ public function parseResponse($message) { if (!is_string($message)) { - throw new SocketException(__('Invalid response.')); + throw new SocketException(__d('cake', 'Invalid response.')); } if (!preg_match("/^(.+\r\n)(.*)(?<=\r\n)\r\n/Us", $message, $match)) { - throw new SocketException(__('Invalid HTTP response.')); + throw new SocketException(__d('cake', 'Invalid HTTP response.')); } list(, $statusLine, $header) = $match; @@ -198,7 +198,7 @@ class HttpResponse implements ArrayAccess { while ($chunkLength !== 0) { if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) { - throw new SocketException(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk.')); + throw new SocketException(__d('cake', 'HttpSocket::_decodeChunkedBody - Could not parse malformed chunk.')); } $chunkSize = 0; diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index 1d5d1400d..275f76ddc 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -211,7 +211,7 @@ class HttpSocket extends CakeSocket { return; } if (!is_resource($resource)) { - throw new SocketException(__('Invalid resource.')); + throw new SocketException(__d('cake', 'Invalid resource.')); } $this->_contentResource = $resource; } @@ -364,7 +364,7 @@ class HttpSocket extends CakeSocket { } if (!App::import('Lib', $this->responseClass)) { - throw new SocketException(__('Class %s not found.', $this->responseClass)); + throw new SocketException(__d('cake', 'Class %s not found.', $this->responseClass)); } $responseClass = $this->responseClass; $this->response = new $responseClass($response); @@ -535,10 +535,10 @@ class HttpSocket extends CakeSocket { App::uses($authClass, $plugin . 'Network/Http'); if (!class_exists($authClass)) { - throw new SocketException(__('Unknown authentication method.')); + throw new SocketException(__d('cake', 'Unknown authentication method.')); } if (!method_exists($authClass, 'authentication')) { - throw new SocketException(sprintf(__('The %s do not support authentication.'), $authClass)); + throw new SocketException(sprintf(__d('cake', 'The %s do not support authentication.'), $authClass)); } call_user_func_array("$authClass::authentication", array($this, &$this->_auth[$method])); } @@ -564,10 +564,10 @@ class HttpSocket extends CakeSocket { App::uses($authClass, $plugin. 'Network/Http'); if (!class_exists($authClass)) { - throw new SocketException(__('Unknown authentication method for proxy.')); + throw new SocketException(__d('cake', 'Unknown authentication method for proxy.')); } if (!method_exists($authClass, 'proxyAuthentication')) { - throw new SocketException(sprintf(__('The %s do not support proxy authentication.'), $authClass)); + throw new SocketException(sprintf(__d('cake', 'The %s do not support proxy authentication.'), $authClass)); } call_user_func_array("$authClass::proxyAuthentication", array($this, &$this->_proxy)); } @@ -785,7 +785,7 @@ class HttpSocket extends CakeSocket { if (is_string($request)) { $isValid = preg_match("/(.+) (.+) (.+)\r\n/U", $request, $match); if (!$this->quirksMode && (!$isValid || ($match[2] == '*' && !in_array($match[3], $asteriskMethods)))) { - throw new SocketException(__('HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.')); + throw new SocketException(__d('cake', 'HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.')); } return $request; } elseif (!is_array($request)) { @@ -803,7 +803,7 @@ class HttpSocket extends CakeSocket { } if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) { - throw new SocketException(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', implode(',', $asteriskMethods))); + throw new SocketException(__d('cake', 'HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', implode(',', $asteriskMethods))); } return $request['method'] . ' ' . $request['uri'] . ' ' . $versionToken . "\r\n"; } From e7f39b456f9fcf4798d48610d30a43780a8de28e Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 20:01:53 +0100 Subject: [PATCH 558/668] translation changes in the Routing dir --- lib/Cake/Routing/Router.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 9261e7659..c4d13166f 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -263,7 +263,7 @@ class Router { if (isset($options['routeClass'])) { $routeClass = $options['routeClass']; if (!is_subclass_of($routeClass, 'CakeRoute')) { - throw new RouterException(__('Route classes must extend CakeRoute')); + throw new RouterException(__d('cake', 'Route classes must extend CakeRoute')); } unset($options['routeClass']); if ($routeClass == 'RedirectRoute' && isset($defaults['redirect'])) { From 26038b13e1937e9010942e61ec1f79b617a72754 Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 20:02:18 +0100 Subject: [PATCH 559/668] translation changes in the TestSuite dir --- lib/Cake/TestSuite/CakeTestCase.php | 2 +- lib/Cake/TestSuite/CakeTestRunner.php | 2 +- lib/Cake/TestSuite/Fixture/CakeFixtureManager.php | 2 +- lib/Cake/TestSuite/Reporter/CakeBaseReporter.php | 2 +- lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php | 10 +++++----- 5 files changed, 9 insertions(+), 9 deletions(-) mode change 100755 => 100644 lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 318a42458..3e80dc0a8 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -184,7 +184,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { */ function loadFixtures() { if (empty($this->fixtureManager)) { - throw new Exception(__('No fixture manager to load the test fixture')); + throw new Exception(__d('cake', 'No fixture manager to load the test fixture')); } $args = func_get_args(); foreach ($args as $class) { diff --git a/lib/Cake/TestSuite/CakeTestRunner.php b/lib/Cake/TestSuite/CakeTestRunner.php index c0eea1b56..21515886e 100644 --- a/lib/Cake/TestSuite/CakeTestRunner.php +++ b/lib/Cake/TestSuite/CakeTestRunner.php @@ -84,7 +84,7 @@ class CakeTestRunner extends PHPUnit_TextUI_TestRunner { if (class_exists($arguments['fixtureManager'])) { return new $arguments['fixtureManager']; } - throw new RuntimeException(__('Could not find fixture manager %s.', $arguments['fixtureManager'])); + throw new RuntimeException(__d('cake', 'Could not find fixture manager %s.', $arguments['fixtureManager'])); } App::uses('AppFixtureManager', 'TestSuite'); if (class_exists('AppFixtureManager')) { diff --git a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php index 7f2b307f0..ababd8629 100644 --- a/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php +++ b/lib/Cake/TestSuite/Fixture/CakeFixtureManager.php @@ -239,7 +239,7 @@ class CakeFixtureManager { $fixture->truncate($db); $fixture->insert($db); } else { - throw new UnexpectedValueException(__('Referenced fixture class %s not found', $name)); + throw new UnexpectedValueException(__d('cake', 'Referenced fixture class %s not found', $name)); } } diff --git a/lib/Cake/TestSuite/Reporter/CakeBaseReporter.php b/lib/Cake/TestSuite/Reporter/CakeBaseReporter.php index 8e48065c2..b79bd0d52 100644 --- a/lib/Cake/TestSuite/Reporter/CakeBaseReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeBaseReporter.php @@ -187,7 +187,7 @@ class CakeBaseReporter extends PHPUnit_TextUI_ResultPrinter { if (!$this->_headerSent) { echo $this->paintHeader(); } - echo __('Running %s', $suite->getName()) . "\n"; + echo __d('cake', 'Running %s', $suite->getName()) . "\n"; } /** diff --git a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php old mode 100755 new mode 100644 index e676c570d..d709a7c77 --- a/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php +++ b/lib/Cake/TestSuite/Reporter/CakeHtmlReporter.php @@ -234,8 +234,8 @@ class CakeHtmlReporter extends CakeBaseReporter { echo "
  • \n"; echo "Failed"; echo "
    " . $this->_htmlEntities($message->toString()) . "
    \n"; - echo "
    " . __('Test case: %s', $testName) . "
    \n"; - echo "
    " . __('Stack trace:') . '
    ' . $trace . "
    \n"; + echo "
    " . __d('cake', 'Test case: %s', $testName) . "
    \n"; + echo "
    " . __d('cake', 'Stack trace:') . '
    ' . $trace . "
    \n"; echo "
  • \n"; } @@ -272,8 +272,8 @@ class CakeHtmlReporter extends CakeBaseReporter { echo "" . get_class($message) . ""; echo "
    " . $this->_htmlEntities($message->getMessage()) . "
    \n"; - echo "
    " . __('Test case: %s', $testName) . "
    \n"; - echo "
    " . __('Stack trace:') . '
    ' . $trace . "
    \n"; + echo "
    " . __d('cake', 'Test case: %s', $testName) . "
    \n"; + echo "
    " . __d('cake', 'Stack trace:') . '
    ' . $trace . "
    \n"; echo "

  • \n"; } @@ -341,6 +341,6 @@ class CakeHtmlReporter extends CakeBaseReporter { if (!$this->_headerSent) { echo $this->paintHeader(); } - echo '

    ' . __('Running %s', $suite->getName()) . '

    '; + echo '

    ' . __d('cake', 'Running %s', $suite->getName()) . '

    '; } } From e2dfafddb2482f8a9fa259b878cd97ab3d9952ca Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 20:02:37 +0100 Subject: [PATCH 560/668] translation changes for the Utility dir --- lib/Cake/Utility/ClassRegistry.php | 4 ++-- lib/Cake/Utility/Debugger.php | 4 ++-- lib/Cake/Utility/Folder.php | 34 +++++++++++++-------------- lib/Cake/Utility/ObjectCollection.php | 2 +- lib/Cake/Utility/Security.php | 2 +- lib/Cake/Utility/Validation.php | 8 +++---- lib/Cake/Utility/Xml.php | 14 +++++------ 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/Cake/Utility/ClassRegistry.php b/lib/Cake/Utility/ClassRegistry.php index c0d4e6685..86d9f161b 100644 --- a/lib/Cake/Utility/ClassRegistry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -149,7 +149,7 @@ class ClassRegistry { } if (!isset(${$class})) { - trigger_error(__('(ClassRegistry::init() could not create instance of %1$s class %2$s ', $class, $type), E_USER_WARNING); + trigger_error(__d('cake', '(ClassRegistry::init() could not create instance of %1$s class %2$s ', $class, $type), E_USER_WARNING); return $false; } @@ -159,7 +159,7 @@ class ClassRegistry { $_this->map($alias, $class); } } elseif (is_numeric($settings)) { - trigger_error(__('(ClassRegistry::init() Attempted to create instance of a class with a numeric name'), E_USER_WARNING); + trigger_error(__d('cake', '(ClassRegistry::init() Attempted to create instance of a class with a numeric name'), E_USER_WARNING); return $false; } } diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index e92edb4bf..4b81b0f80 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -647,11 +647,11 @@ class Debugger { */ public static function checkSecurityKeys() { if (Configure::read('Security.salt') == 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi') { - trigger_error(__('Please change the value of \'Security.salt\' in app/config/core.php to a salt value specific to your application'), E_USER_NOTICE); + trigger_error(__d('cake', 'Please change the value of \'Security.salt\' in app/config/core.php to a salt value specific to your application'), E_USER_NOTICE); } if (Configure::read('Security.cipherSeed') === '76859309657453542496749683645') { - trigger_error(__('Please change the value of \'Security.cipherSeed\' in app/config/core.php to a numeric (digits only) seed value specific to your application'), E_USER_NOTICE); + trigger_error(__d('cake', 'Please change the value of \'Security.cipherSeed\' in app/config/core.php to a numeric (digits only) seed value specific to your application'), E_USER_NOTICE); } } diff --git a/lib/Cake/Utility/Folder.php b/lib/Cake/Utility/Folder.php index 02b097227..e38656bae 100644 --- a/lib/Cake/Utility/Folder.php +++ b/lib/Cake/Utility/Folder.php @@ -345,11 +345,11 @@ class Folder { if ($recursive === false && is_dir($path)) { if (@chmod($path, intval($mode, 8))) { - $this->__messages[] = __('%s changed to %s', $path, $mode); + $this->__messages[] = __d('cake', '%s changed to %s', $path, $mode); return true; } - $this->__errors[] = __('%s NOT changed to %s', $path, $mode); + $this->__errors[] = __d('cake', '%s NOT changed to %s', $path, $mode); return false; } @@ -366,9 +366,9 @@ class Folder { } if (@chmod($fullpath, intval($mode, 8))) { - $this->__messages[] = __('%s changed to %s', $fullpath, $mode); + $this->__messages[] = __d('cake', '%s changed to %s', $fullpath, $mode); } else { - $this->__errors[] = __('%s NOT changed to %s', $fullpath, $mode); + $this->__errors[] = __d('cake', '%s NOT changed to %s', $fullpath, $mode); } } } @@ -453,7 +453,7 @@ class Folder { } if (is_file($pathname)) { - $this->__errors[] = __('%s is a file', $pathname); + $this->__errors[] = __d('cake', '%s is a file', $pathname); return false; } $pathname = rtrim($pathname, DS); @@ -464,11 +464,11 @@ class Folder { $old = umask(0); if (mkdir($pathname, $mode)) { umask($old); - $this->__messages[] = __('%s created', $pathname); + $this->__messages[] = __d('cake', '%s created', $pathname); return true; } else { umask($old); - $this->__errors[] = __('%s NOT created', $pathname); + $this->__errors[] = __d('cake', '%s NOT created', $pathname); return false; } } @@ -541,9 +541,9 @@ class Folder { } if (is_file($file) === true) { if (@unlink($file)) { - $this->__messages[] = __('%s removed', $file); + $this->__messages[] = __d('cake', '%s removed', $file); } else { - $this->__errors[] = __('%s NOT removed', $file); + $this->__errors[] = __d('cake', '%s NOT removed', $file); } } elseif (is_dir($file) === true && $this->delete($file) === false) { return false; @@ -552,10 +552,10 @@ class Folder { } $path = substr($path, 0, strlen($path) - 1); if (rmdir($path) === false) { - $this->__errors[] = __('%s NOT removed', $path); + $this->__errors[] = __d('cake', '%s NOT removed', $path); return false; } else { - $this->__messages[] = __('%s removed', $path); + $this->__messages[] = __d('cake', '%s removed', $path); } } return true; @@ -590,7 +590,7 @@ class Folder { $mode = $options['mode']; if (!$this->cd($fromDir)) { - $this->__errors[] = __('%s not found', $fromDir); + $this->__errors[] = __d('cake', '%s not found', $fromDir); return false; } @@ -599,7 +599,7 @@ class Folder { } if (!is_writable($toDir)) { - $this->__errors[] = __('%s not writable', $toDir); + $this->__errors[] = __d('cake', '%s not writable', $toDir); return false; } @@ -613,9 +613,9 @@ class Folder { if (copy($from, $to)) { chmod($to, intval($mode, 8)); touch($to, filemtime($from)); - $this->__messages[] = __('%s copied to %s', $from, $to); + $this->__messages[] = __d('cake', '%s copied to %s', $from, $to); } else { - $this->__errors[] = __('%s NOT copied to %s', $from, $to); + $this->__errors[] = __d('cake', '%s NOT copied to %s', $from, $to); } } @@ -626,11 +626,11 @@ class Folder { $old = umask(0); chmod($to, $mode); umask($old); - $this->__messages[] = __('%s created', $to); + $this->__messages[] = __d('cake', '%s created', $to); $options = array_merge($options, array('to'=> $to, 'from'=> $from)); $this->copy($options); } else { - $this->__errors[] = __('%s not created', $to); + $this->__errors[] = __d('cake', '%s not created', $to); } } } diff --git a/lib/Cake/Utility/ObjectCollection.php b/lib/Cake/Utility/ObjectCollection.php index fbff40ee0..4ac2a246b 100644 --- a/lib/Cake/Utility/ObjectCollection.php +++ b/lib/Cake/Utility/ObjectCollection.php @@ -105,7 +105,7 @@ abstract class ObjectCollection { $list = array_keys($this->_loaded); } if ($options['modParams'] !== false && !isset($params[$options['modParams']])) { - throw new CakeException(__('Cannot use modParams with indexes that do not exist.')); + throw new CakeException(__d('cake', 'Cannot use modParams with indexes that do not exist.')); } foreach ($list as $name) { $result = call_user_func_array(array($this->_loaded[$name], $callback), $params); diff --git a/lib/Cake/Utility/Security.php b/lib/Cake/Utility/Security.php index fdb2dccb8..fba654e10 100644 --- a/lib/Cake/Utility/Security.php +++ b/lib/Cake/Utility/Security.php @@ -136,7 +136,7 @@ class Security { */ public static function cipher($text, $key) { if (empty($key)) { - trigger_error(__('You cannot use an empty key for Security::cipher()'), E_USER_WARNING); + trigger_error(__d('cake', 'You cannot use an empty key for Security::cipher()'), E_USER_WARNING); return ''; } diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 8d0871922..a28297ad0 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -246,7 +246,7 @@ class Validation { } break; default: - self::$errors[] = __('You must define the $operator parameter for Validation::comparison()'); + self::$errors[] = __d('cake', 'You must define the $operator parameter for Validation::comparison()'); break; } return false; @@ -265,7 +265,7 @@ class Validation { extract(self::_defaults($check)); } if ($regex === null) { - self::$errors[] = __('You must define a regular expression for Validation::custom()'); + self::$errors[] = __d('cake', 'You must define a regular expression for Validation::custom()'); return false; } return self::_check($check, $regex); @@ -724,11 +724,11 @@ class Validation { protected static function _pass($method, $check, $classPrefix) { $className = ucwords($classPrefix) . 'Validation'; if (!class_exists($className)) { - trigger_error(__('Could not find %s class, unable to complete validation.', $className), E_USER_WARNING); + trigger_error(__d('cake', 'Could not find %s class, unable to complete validation.', $className), E_USER_WARNING); return false; } if (!method_exists($className, $method)) { - trigger_error(__('Method %s does not exist on %s unable to complete validation.', $method, $className), E_USER_WARNING); + trigger_error(__d('cake', 'Method %s does not exist on %s unable to complete validation.', $method, $className), E_USER_WARNING); return false; } $check = (array)$check; diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index 1a90ddf94..bc9a8abbc 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -100,9 +100,9 @@ class Xml { $dom->load($input); return $dom; } elseif (!is_string($input)) { - throw new XmlException(__('Invalid input.')); + throw new XmlException(__d('cake', 'Invalid input.')); } - throw new XmlException(__('XML cannot be read.')); + throw new XmlException(__d('cake', 'XML cannot be read.')); } /** @@ -144,11 +144,11 @@ class Xml { */ public static function fromArray($input, $options = array()) { if (!is_array($input) || count($input) !== 1) { - throw new XmlException(__('Invalid input.')); + throw new XmlException(__d('cake', 'Invalid input.')); } $key = key($input); if (is_integer($key)) { - throw new XmlException(__('The key of input must be alphanumeric')); + throw new XmlException(__d('cake', 'The key of input must be alphanumeric')); } if (!is_array($options)) { @@ -212,7 +212,7 @@ class Xml { } } else { if ($key[0] === '@') { - throw new XmlException(__('Invalid array')); + throw new XmlException(__d('cake', 'Invalid array')); } if (array_keys($value) === range(0, count($value) - 1)) { // List foreach ($value as $item) { @@ -225,7 +225,7 @@ class Xml { } } } else { - throw new XmlException(__('Invalid array')); + throw new XmlException(__d('cake', 'Invalid array')); } } } @@ -277,7 +277,7 @@ class Xml { $obj = simplexml_import_dom($obj); } if (!($obj instanceof SimpleXMLElement)) { - throw new XmlException(__('The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.')); + throw new XmlException(__d('cake', 'The input is not instance of SimpleXMLElement, DOMDocument or DOMNode.')); } $result = array(); $namespaces = array_merge(array('' => ''), $obj->getNamespaces(true)); From 28eae99ecbe4fdfc26b0d67dce73c154bfa70fb5 Mon Sep 17 00:00:00 2001 From: AD7six Date: Sat, 12 Mar 2011 20:02:56 +0100 Subject: [PATCH 561/668] translation changes in the view folder --- lib/Cake/View/Helper.php | 2 +- lib/Cake/View/Helper/FormHelper.php | 42 ++++----- lib/Cake/View/Helper/HtmlHelper.php | 4 +- lib/Cake/View/Helper/JsHelper.php | 2 +- lib/Cake/View/Helper/MootoolsEngineHelper.php | 2 +- lib/Cake/View/Helper/NumberHelper.php | 10 +- lib/Cake/View/Helper/PaginatorHelper.php | 6 +- lib/Cake/View/Helper/TimeHelper.php | 58 ++++++------ lib/Cake/View/View.php | 4 +- lib/Cake/View/errors/error400.ctp | 4 +- lib/Cake/View/errors/error500.ctp | 4 +- lib/Cake/View/errors/missing_action.ctp | 14 +-- .../View/errors/missing_behavior_class.ctp | 14 +-- .../View/errors/missing_behavior_file.ctp | 14 +-- .../View/errors/missing_component_class.ctp | 14 +-- .../View/errors/missing_component_file.ctp | 14 +-- lib/Cake/View/errors/missing_connection.ctp | 14 +-- lib/Cake/View/errors/missing_controller.ctp | 14 +-- lib/Cake/View/errors/missing_database.ctp | 14 +-- .../View/errors/missing_datasource_config.ctp | 10 +- .../View/errors/missing_datasource_file.ctp | 10 +- lib/Cake/View/errors/missing_helper_class.ctp | 14 +-- lib/Cake/View/errors/missing_helper_file.ctp | 14 +-- lib/Cake/View/errors/missing_layout.ctp | 14 +-- lib/Cake/View/errors/missing_table.ctp | 10 +- lib/Cake/View/errors/missing_view.ctp | 14 +-- lib/Cake/View/errors/private_action.ctp | 10 +- lib/Cake/View/errors/scaffold_error.ctp | 10 +- lib/Cake/View/layouts/default.ctp | 6 +- lib/Cake/View/pages/home.ctp | 92 +++++++++---------- lib/Cake/View/scaffolds/form.ctp | 14 +-- lib/Cake/View/scaffolds/index.ctp | 24 ++--- lib/Cake/View/scaffolds/view.ctp | 30 +++--- 33 files changed, 261 insertions(+), 261 deletions(-) mode change 100755 => 100644 lib/Cake/View/Helper/PaginatorHelper.php diff --git a/lib/Cake/View/Helper.php b/lib/Cake/View/Helper.php index 448917f22..91b017ba1 100644 --- a/lib/Cake/View/Helper.php +++ b/lib/Cake/View/Helper.php @@ -124,7 +124,7 @@ class Helper extends Object { * @param array $params Array of params for the method. */ public function __call($method, $params) { - trigger_error(__('Method %1$s::%2$s does not exist', get_class($this), $method), E_USER_WARNING); + trigger_error(__d('cake', 'Method %1$s::%2$s does not exist', get_class($this), $method), E_USER_WARNING); } /** diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 17dd064c5..7a7ed9128 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -367,7 +367,7 @@ class FormHelper extends AppHelper { $submitOptions = $options; if (!$submit) { - $submit = __('Submit'); + $submit = __d('cake', 'Submit'); } } $out .= $this->submit($submit, $submitOptions); @@ -509,7 +509,7 @@ class FormHelper extends AppHelper { if ($text != null) { $error = $text; } elseif (is_numeric($error)) { - $error = __('Error in field %s', Inflector::humanize($this->field())); + $error = __d('cake', 'Error in field %s', Inflector::humanize($this->field())); } if ($options['escape']) { $error = h($error); @@ -552,7 +552,7 @@ class FormHelper extends AppHelper { if (substr($text, -3) == '_id') { $text = substr($text, 0, strlen($text) - 3); } - $text = __(Inflector::humanize(Inflector::underscore($text))); + $text = __d('cake', Inflector::humanize(Inflector::underscore($text))); } if (is_string($options)) { @@ -621,16 +621,16 @@ class FormHelper extends AppHelper { } if ($legend === true) { - $actionName = __('New %s'); + $actionName = __d('cake', 'New %s'); $isEdit = ( strpos($this->request->params['action'], 'update') !== false || strpos($this->request->params['action'], 'edit') !== false ); if ($isEdit) { - $actionName = __('Edit %s'); + $actionName = __d('cake', 'Edit %s'); } $modelName = Inflector::humanize(Inflector::underscore($model)); - $legend = sprintf($actionName, __($modelName)); + $legend = sprintf($actionName, __d('cake', $modelName)); } $out = null; @@ -1046,7 +1046,7 @@ class FormHelper extends AppHelper { $legend = $attributes['legend']; unset($attributes['legend']); } elseif (count($options) > 1) { - $legend = __(Inflector::humanize($this->field())); + $legend = __d('cake', Inflector::humanize($this->field())); } $label = true; @@ -1131,7 +1131,7 @@ class FormHelper extends AppHelper { public function __call($method, $params) { $options = array(); if (empty($params)) { - throw new CakeException(__('Missing field name for FormHelper::%s', $method)); + throw new CakeException(__d('cake', 'Missing field name for FormHelper::%s', $method)); } if (isset($params[1])) { $options = $params[1]; @@ -1347,7 +1347,7 @@ class FormHelper extends AppHelper { */ public function submit($caption = null, $options = array()) { if (!$caption) { - $caption = __('Submit'); + $caption = __d('cake', 'Submit'); } $out = null; $div = true; @@ -2139,18 +2139,18 @@ class FormHelper extends AppHelper { break; case 'month': if ($options['monthNames'] === true) { - $data['01'] = __('January'); - $data['02'] = __('February'); - $data['03'] = __('March'); - $data['04'] = __('April'); - $data['05'] = __('May'); - $data['06'] = __('June'); - $data['07'] = __('July'); - $data['08'] = __('August'); - $data['09'] = __('September'); - $data['10'] = __('October'); - $data['11'] = __('November'); - $data['12'] = __('December'); + $data['01'] = __d('cake', 'January'); + $data['02'] = __d('cake', 'February'); + $data['03'] = __d('cake', 'March'); + $data['04'] = __d('cake', 'April'); + $data['05'] = __d('cake', 'May'); + $data['06'] = __d('cake', 'June'); + $data['07'] = __d('cake', 'July'); + $data['08'] = __d('cake', 'August'); + $data['09'] = __d('cake', 'September'); + $data['10'] = __d('cake', 'October'); + $data['11'] = __d('cake', 'November'); + $data['12'] = __d('cake', 'December'); } else if (is_array($options['monthNames'])) { $data = $options['monthNames']; } else { diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index 1f098864f..4925ba16f 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -940,13 +940,13 @@ class HtmlHelper extends AppHelper { $reader = $configFile[1]; } } else { - throw new ConfigureException(__('Cannot load the configuration file. Wrong "configFile" configuration.')); + throw new ConfigureException(__d('cake', 'Cannot load the configuration file. Wrong "configFile" configuration.')); } $readerClass = Inflector::camelize($reader) . 'Reader'; App::uses($readerClass, 'Configure'); if (!class_exists($readerClass)) { - throw new ConfigureException(__('Cannot load the configuration file. Unknown reader.')); + throw new ConfigureException(__d('cake', 'Cannot load the configuration file. Unknown reader.')); } $readerObj = new $readerClass($path); diff --git a/lib/Cake/View/Helper/JsHelper.php b/lib/Cake/View/Helper/JsHelper.php index 1495b72a6..d705ea7ef 100644 --- a/lib/Cake/View/Helper/JsHelper.php +++ b/lib/Cake/View/Helper/JsHelper.php @@ -153,7 +153,7 @@ class JsHelper extends AppHelper { 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); + trigger_error(__d('cake', 'JsHelper:: Missing Method %s is undefined', $method), E_USER_WARNING); } /** diff --git a/lib/Cake/View/Helper/MootoolsEngineHelper.php b/lib/Cake/View/Helper/MootoolsEngineHelper.php index 37c61b6c9..13fb1bff4 100644 --- a/lib/Cake/View/Helper/MootoolsEngineHelper.php +++ b/lib/Cake/View/Helper/MootoolsEngineHelper.php @@ -307,7 +307,7 @@ class MootoolsEngineHelper extends JsBaseEngineHelper { function drop($options = array()) { if (empty($options['drag'])) { trigger_error( - __('MootoolsEngine::drop() requires a "drag" option to properly function'), E_USER_WARNING + __d('cake', 'MootoolsEngine::drop() requires a "drag" option to properly function'), E_USER_WARNING ); return false; } diff --git a/lib/Cake/View/Helper/NumberHelper.php b/lib/Cake/View/Helper/NumberHelper.php index f2449a4ea..fc5b35144 100644 --- a/lib/Cake/View/Helper/NumberHelper.php +++ b/lib/Cake/View/Helper/NumberHelper.php @@ -88,15 +88,15 @@ class NumberHelper extends AppHelper { public function toReadableSize($size) { switch (true) { case $size < 1024: - return __n('%d Byte', '%d Bytes', $size, $size); + return __dn('cake', '%d Byte', '%d Bytes', $size, $size); case round($size / 1024) < 1024: - return __('%d KB', $this->precision($size / 1024, 0)); + return __d('cake', '%d KB', $this->precision($size / 1024, 0)); case round($size / 1024 / 1024, 2) < 1024: - return __('%.2f MB', $this->precision($size / 1024 / 1024, 2)); + return __d('cake', '%.2f MB', $this->precision($size / 1024 / 1024, 2)); case round($size / 1024 / 1024 / 1024, 2) < 1024: - return __('%.2f GB', $this->precision($size / 1024 / 1024 / 1024, 2)); + return __d('cake', '%.2f GB', $this->precision($size / 1024 / 1024 / 1024, 2)); default: - return __('%.2f TB', $this->precision($size / 1024 / 1024 / 1024 / 1024, 2)); + return __d('cake', '%.2f TB', $this->precision($size / 1024 / 1024 / 1024 / 1024, 2)); } } diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php old mode 100755 new mode 100644 index eed163a95..495d6402b --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -102,7 +102,7 @@ class PaginatorHelper extends AppHelper { $classname = $ajaxProvider . 'Helper'; if (!method_exists($classname, 'link')) { throw new CakeException(sprintf( - __('%s does not implement a link() method, it is incompatible with PaginatorHelper'), $classname + __d('cake', '%s does not implement a link() method, it is incompatible with PaginatorHelper'), $classname )); } parent::__construct($View, $settings); @@ -306,7 +306,7 @@ class PaginatorHelper extends AppHelper { if (empty($title)) { $title = $key; - $title = __(Inflector::humanize(preg_replace('/_id$/', '', $title))); + $title = __d('cake', Inflector::humanize(preg_replace('/_id$/', '', $title))); } $dir = isset($options['direction']) ? $options['direction'] : 'asc'; unset($options['direction']); @@ -553,7 +553,7 @@ class PaginatorHelper extends AppHelper { array( 'model' => $this->defaultModel(), 'format' => 'pages', - 'separator' => __(' of ') + 'separator' => __d('cake', ' of ') ), $options); diff --git a/lib/Cake/View/Helper/TimeHelper.php b/lib/Cake/View/Helper/TimeHelper.php index 269c4b9f0..3f149add4 100644 --- a/lib/Cake/View/Helper/TimeHelper.php +++ b/lib/Cake/View/Helper/TimeHelper.php @@ -82,19 +82,19 @@ class TimeHelper extends AppHelper { private function __translateSpecifier($specifier) { switch ($specifier[1]) { case 'a': - $abday = __c('abday', 5); + $abday = __cn('cake', 'abday', 5); if (is_array($abday)) { return $abday[date('w', $this->__time)]; } break; case 'A': - $day = __c('day', 5); + $day = __cn('cake', 'day', 5); if (is_array($day)) { return $day[date('w', $this->__time)]; } break; case 'c': - $format = __c('d_t_fmt', 5); + $format = __cn('cake', 'd_t_fmt', 5); if ($format != 'd_t_fmt') { return $this->convertSpecifiers($format, $this->__time); } @@ -116,13 +116,13 @@ class TimeHelper extends AppHelper { return date('jS', $this->__time); case 'b': case 'h': - $months = __c('abmon', 5); + $months = __cn('cake', 'abmon', 5); if (is_array($months)) { return $months[date('n', $this->__time) -1]; } return '%b'; case 'B': - $months = __c('mon', 5); + $months = __cn('cake', 'mon', 5); if (is_array($months)) { return $months[date('n', $this->__time) -1]; } @@ -133,14 +133,14 @@ class TimeHelper extends AppHelper { case 'P': $default = array('am' => 0, 'pm' => 1); $meridiem = $default[date('a',$this->__time)]; - $format = __c('am_pm', 5); + $format = __cn('cake', 'am_pm', 5); if (is_array($format)) { $meridiem = $format[$meridiem]; return ($specifier[1] == 'P') ? strtolower($meridiem) : strtoupper($meridiem); } break; case 'r': - $complete = __c('t_fmt_ampm', 5); + $complete = __cn('cake', 't_fmt_ampm', 5); if ($complete != 't_fmt_ampm') { return str_replace('%p',$this->__translateSpecifier(array('%p', 'p')),$complete); } @@ -154,13 +154,13 @@ class TimeHelper extends AppHelper { case 'u': return ($weekDay = date('w', $this->__time)) ? $weekDay : 7; case 'x': - $format = __c('d_fmt', 5); + $format = __cn('cake', 'd_fmt', 5); if ($format != 'd_fmt') { return $this->convertSpecifiers($format, $this->__time); } break; case 'X': - $format = __c('t_fmt', 5); + $format = __cn('cake', 't_fmt', 5); if ($format != 't_fmt') { return $this->convertSpecifiers($format, $this->__time); } @@ -265,9 +265,9 @@ class TimeHelper extends AppHelper { $y = $this->isThisYear($date) ? '' : ' %Y'; if ($this->isToday($dateString, $userOffset)) { - $ret = __('Today, %s', strftime("%H:%M", $date)); + $ret = __d('cake', 'Today, %s', strftime("%H:%M", $date)); } elseif ($this->wasYesterday($dateString, $userOffset)) { - $ret = __('Yesterday, %s', strftime("%H:%M", $date)); + $ret = __d('cake', 'Yesterday, %s', strftime("%H:%M", $date)); } else { $format = $this->convertSpecifiers("%b %eS{$y}, %H:%M", $date); $ret = strftime($format, $date); @@ -614,41 +614,41 @@ class TimeHelper extends AppHelper { $diff = $futureTime - $pastTime; if ($diff > abs($now - $this->fromString($end))) { - $relativeDate = __('on %s', date($format, $inSeconds)); + $relativeDate = __d('cake', 'on %s', date($format, $inSeconds)); } else { if ($years > 0) { // years and months and days - $relativeDate .= ($relativeDate ? ', ' : '') . $years . ' ' . __n('year', 'years', $years); - $relativeDate .= $months > 0 ? ($relativeDate ? ', ' : '') . $months . ' ' . __n('month', 'months', $months) : ''; - $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks) : ''; - $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days) : ''; + $relativeDate .= ($relativeDate ? ', ' : '') . $years . ' ' . __dn('cake', 'year', 'years', $years); + $relativeDate .= $months > 0 ? ($relativeDate ? ', ' : '') . $months . ' ' . __dn('cake', 'month', 'months', $months) : ''; + $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . __dn('cake', 'week', 'weeks', $weeks) : ''; + $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __dn('cake', 'day', 'days', $days) : ''; } elseif (abs($months) > 0) { // months, weeks and days - $relativeDate .= ($relativeDate ? ', ' : '') . $months . ' ' . __n('month', 'months', $months); - $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks) : ''; - $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days) : ''; + $relativeDate .= ($relativeDate ? ', ' : '') . $months . ' ' . __dn('cake', 'month', 'months', $months); + $relativeDate .= $weeks > 0 ? ($relativeDate ? ', ' : '') . $weeks . ' ' . __dn('cake', 'week', 'weeks', $weeks) : ''; + $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __dn('cake', 'day', 'days', $days) : ''; } elseif (abs($weeks) > 0) { // weeks and days - $relativeDate .= ($relativeDate ? ', ' : '') . $weeks . ' ' . __n('week', 'weeks', $weeks); - $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days) : ''; + $relativeDate .= ($relativeDate ? ', ' : '') . $weeks . ' ' . __dn('cake', 'week', 'weeks', $weeks); + $relativeDate .= $days > 0 ? ($relativeDate ? ', ' : '') . $days . ' ' . __dn('cake', 'day', 'days', $days) : ''; } elseif (abs($days) > 0) { // days and hours - $relativeDate .= ($relativeDate ? ', ' : '') . $days . ' ' . __n('day', 'days', $days); - $relativeDate .= $hours > 0 ? ($relativeDate ? ', ' : '') . $hours . ' ' . __n('hour', 'hours', $hours) : ''; + $relativeDate .= ($relativeDate ? ', ' : '') . $days . ' ' . __dn('cake', 'day', 'days', $days); + $relativeDate .= $hours > 0 ? ($relativeDate ? ', ' : '') . $hours . ' ' . __dn('cake', 'hour', 'hours', $hours) : ''; } elseif (abs($hours) > 0) { // hours and minutes - $relativeDate .= ($relativeDate ? ', ' : '') . $hours . ' ' . __n('hour', 'hours', $hours); - $relativeDate .= $minutes > 0 ? ($relativeDate ? ', ' : '') . $minutes . ' ' . __n('minute', 'minutes', $minutes) : ''; + $relativeDate .= ($relativeDate ? ', ' : '') . $hours . ' ' . __dn('cake', 'hour', 'hours', $hours); + $relativeDate .= $minutes > 0 ? ($relativeDate ? ', ' : '') . $minutes . ' ' . __dn('cake', 'minute', 'minutes', $minutes) : ''; } elseif (abs($minutes) > 0) { // minutes only - $relativeDate .= ($relativeDate ? ', ' : '') . $minutes . ' ' . __n('minute', 'minutes', $minutes); + $relativeDate .= ($relativeDate ? ', ' : '') . $minutes . ' ' . __dn('cake', 'minute', 'minutes', $minutes); } else { // seconds only - $relativeDate .= ($relativeDate ? ', ' : '') . $seconds . ' ' . __n('second', 'seconds', $seconds); + $relativeDate .= ($relativeDate ? ', ' : '') . $seconds . ' ' . __dn('cake', 'second', 'seconds', $seconds); } if (!$backwards) { - $relativeDate = __('%s ago', $relativeDate); + $relativeDate = __d('cake', '%s ago', $relativeDate); } } return $relativeDate; @@ -668,7 +668,7 @@ class TimeHelper extends AppHelper { public function wasWithinLast($timeInterval, $dateString, $userOffset = null) { $tmp = str_replace(' ', '', $timeInterval); if (is_numeric($tmp)) { - $timeInterval = $tmp . ' ' . __('days'); + $timeInterval = $tmp . ' ' . __d('cake', 'days'); } $date = $this->fromString($dateString, $userOffset); diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index 26b9f2e35..2f22dbb54 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -396,7 +396,7 @@ class View extends Object { $layout = $this->layout; } if ($this->output === false) { - throw new CakeException(__("Error in view %s, got no content.", $viewFileName)); + throw new CakeException(__d('cake', "Error in view %s, got no content.", $viewFileName)); } if ($layout && $this->autoLayout) { $this->output = $this->renderLayout($this->output, $layout); @@ -439,7 +439,7 @@ class View extends Object { $this->output = $this->_render($layoutFileName); if ($this->output === false) { - throw new CakeException(__("Error in layout %s, got no content.", $layoutFileName)); + throw new CakeException(__d('cake', "Error in layout %s, got no content.", $layoutFileName)); } $this->Helpers->trigger('afterLayout', array($layoutFileName)); diff --git a/lib/Cake/View/errors/error400.ctp b/lib/Cake/View/errors/error400.ctp index b6487ee91..bc861ca49 100644 --- a/lib/Cake/View/errors/error400.ctp +++ b/lib/Cake/View/errors/error400.ctp @@ -18,9 +18,9 @@ ?>

    - : + : '{$url}'" ); ?>

    diff --git a/lib/Cake/View/errors/error500.ctp b/lib/Cake/View/errors/error500.ctp index f7b648ff6..ba0c41bea 100644 --- a/lib/Cake/View/errors/error500.ctp +++ b/lib/Cake/View/errors/error500.ctp @@ -18,8 +18,8 @@ ?>

    - : - + : +

    0 ): diff --git a/lib/Cake/View/errors/missing_action.ctp b/lib/Cake/View/errors/missing_action.ctp index 5b6fdb970..df8a7fc9f 100644 --- a/lib/Cake/View/errors/missing_action.ctp +++ b/lib/Cake/View/errors/missing_action.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - ' . $action . '', '' . $controller . ''); ?> + : + ' . $action . '', '' . $controller . ''); ?>

    - : - ' . $controller . '::', '' . $action . '()', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?> + : + ' . $controller . '::', '' . $action . '()', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?>

     <?php
    @@ -38,7 +38,7 @@ class  extends AppController {
     ?>
     

    - : - + : +

    element('exception_stack_trace'); ?> diff --git a/lib/Cake/View/errors/missing_behavior_class.ctp b/lib/Cake/View/errors/missing_behavior_class.ctp index e7c454069..cec3a107a 100644 --- a/lib/Cake/View/errors/missing_behavior_class.ctp +++ b/lib/Cake/View/errors/missing_behavior_class.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - %s can not be found or does not exist.', $class); ?> + : + %s can not be found or does not exist.', $class); ?>

    - : - + : +

     <?php
    @@ -33,8 +33,8 @@ class  extends ModelBehavior {
     ?>
     

    - : - + : +

    element('exception_stack_trace'); ?> diff --git a/lib/Cake/View/errors/missing_behavior_file.ctp b/lib/Cake/View/errors/missing_behavior_file.ctp index 09e90b350..ae04f123f 100644 --- a/lib/Cake/View/errors/missing_behavior_file.ctp +++ b/lib/Cake/View/errors/missing_behavior_file.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - + : +

    - : - + : +

     <?php
    @@ -33,8 +33,8 @@ class  extends ModelBehavior {
     ?>
     

    - : - + : +

    element('exception_stack_trace'); ?> diff --git a/lib/Cake/View/errors/missing_component_class.ctp b/lib/Cake/View/errors/missing_component_class.ctp index cf06671dc..674c04524 100644 --- a/lib/Cake/View/errors/missing_component_class.ctp +++ b/lib/Cake/View/errors/missing_component_class.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - ' . $class . ''); ?> + : + ' . $class . ''); ?>

    - : - ' . $class . '', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?> + : + ' . $class . '', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?>

     <?php
    @@ -33,8 +33,8 @@ class  extends Component {
    ?>

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_component_file.ctp b/lib/Cake/View/errors/missing_component_file.ctp index 527afc9c3..a39303ed0 100644 --- a/lib/Cake/View/errors/missing_component_file.ctp +++ b/lib/Cake/View/errors/missing_component_file.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - + : +

    - : - ' . $class . '', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?> + : + ' . $class . '', APP_DIR . DS . 'controllers' . DS . 'components' . DS . $file); ?>

     <?php
    @@ -33,8 +33,8 @@ class  extends Component {
    ?>

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_connection.ctp b/lib/Cake/View/errors/missing_connection.ctp index dfda66e3a..6f53202d7 100644 --- a/lib/Cake/View/errors/missing_connection.ctp +++ b/lib/Cake/View/errors/missing_connection.ctp @@ -16,18 +16,18 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - + : +

    - : - + : +

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_controller.ctp b/lib/Cake/View/errors/missing_controller.ctp index 7f9e7d27f..9919427ec 100644 --- a/lib/Cake/View/errors/missing_controller.ctp +++ b/lib/Cake/View/errors/missing_controller.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - ' . $controller . ''); ?> + : + ' . $controller . ''); ?>

    - : - ' . $controller . '', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?> + : + ' . $controller . '', APP_DIR . DS . 'controllers' . DS . Inflector::underscore($controller) . '.php'); ?>

     <?php
    @@ -33,8 +33,8 @@ class  extends AppController {
     ?>
     

    - : - + : +

    element('exception_stack_trace'); ?> diff --git a/lib/Cake/View/errors/missing_database.ctp b/lib/Cake/View/errors/missing_database.ctp index 7aa2d5e80..798bfa05d 100644 --- a/lib/Cake/View/errors/missing_database.ctp +++ b/lib/Cake/View/errors/missing_database.ctp @@ -16,18 +16,18 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - + : +

    - : - + : +

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_datasource_config.ctp b/lib/Cake/View/errors/missing_datasource_config.ctp index 64c7d4c13..51296083c 100644 --- a/lib/Cake/View/errors/missing_datasource_config.ctp +++ b/lib/Cake/View/errors/missing_datasource_config.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - ' . $config . ''); ?> + : + ' . $config . ''); ?>

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_datasource_file.ctp b/lib/Cake/View/errors/missing_datasource_file.ctp index 0d53072fb..452682655 100644 --- a/lib/Cake/View/errors/missing_datasource_file.ctp +++ b/lib/Cake/View/errors/missing_datasource_file.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - ' . $class . ''); ?> + : + ' . $class . ''); ?>

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_helper_class.ctp b/lib/Cake/View/errors/missing_helper_class.ctp index 842ded905..58d07eb3e 100644 --- a/lib/Cake/View/errors/missing_helper_class.ctp +++ b/lib/Cake/View/errors/missing_helper_class.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - %s can not be found or does not exist.', $class); ?> + : + %s can not be found or does not exist.', $class); ?>

    - : - + : +

     <?php
    @@ -33,8 +33,8 @@ class  extends AppHelper {
     ?>
     

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_helper_file.ctp b/lib/Cake/View/errors/missing_helper_file.ctp index 6ba0e9b6f..120cc3193 100644 --- a/lib/Cake/View/errors/missing_helper_file.ctp +++ b/lib/Cake/View/errors/missing_helper_file.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - + : +

    - : - + : +

     <?php
    @@ -33,8 +33,8 @@ class  extends AppHelper {
     ?>
     

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_layout.ctp b/lib/Cake/View/errors/missing_layout.ctp index 011e59a64..d822390f6 100644 --- a/lib/Cake/View/errors/missing_layout.ctp +++ b/lib/Cake/View/errors/missing_layout.ctp @@ -16,18 +16,18 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - ' . $file . ''); ?> + : + ' . $file . ''); ?>

    - : - ' . $file . ''); ?> + : + ' . $file . ''); ?>

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_table.ctp b/lib/Cake/View/errors/missing_table.ctp index 1288dd06a..ac61366f1 100644 --- a/lib/Cake/View/errors/missing_table.ctp +++ b/lib/Cake/View/errors/missing_table.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - ' . $table . '', '' . $class . ''); ?> + : + ' . $table . '', '' . $class . ''); ?>

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/missing_view.ctp b/lib/Cake/View/errors/missing_view.ctp index 9d8c7cb91..4a986b823 100644 --- a/lib/Cake/View/errors/missing_view.ctp +++ b/lib/Cake/View/errors/missing_view.ctp @@ -16,18 +16,18 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - ' . Inflector::camelize($this->request->controller) . 'Controller::', '' . $this->request->action . '()'); ?> + : + ' . Inflector::camelize($this->request->controller) . 'Controller::', '' . $this->request->action . '()'); ?>

    - : - + : +

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/private_action.ctp b/lib/Cake/View/errors/private_action.ctp index 833f42112..c194ebe58 100644 --- a/lib/Cake/View/errors/private_action.ctp +++ b/lib/Cake/View/errors/private_action.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - ' . $controller . '::', '' . $action . '()'); ?> + : + ' . $controller . '::', '' . $action . '()'); ?>

    - : - + : +

    element('exception_stack_trace'); ?> \ No newline at end of file diff --git a/lib/Cake/View/errors/scaffold_error.ctp b/lib/Cake/View/errors/scaffold_error.ctp index 40f09c90a..d2f9ae1e1 100644 --- a/lib/Cake/View/errors/scaffold_error.ctp +++ b/lib/Cake/View/errors/scaffold_error.ctp @@ -16,14 +16,14 @@ * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ ?> -

    +

    - : - + : +

    - : - + : +

     <?php
    diff --git a/lib/Cake/View/layouts/default.ctp b/lib/Cake/View/layouts/default.ctp
    index 5575c7329..f758b9551 100644
    --- a/lib/Cake/View/layouts/default.ctp
    +++ b/lib/Cake/View/layouts/default.ctp
    @@ -21,7 +21,7 @@
     
     	Html->charset(); ?>
     	
    -		<?php echo __('CakePHP: the rapid development php framework:'); ?>
    +		<?php echo __d('cake', 'CakePHP: the rapid development php framework:'); ?>
     		<?php echo $title_for_layout; ?>
     	
     	
     	
    @@ -46,7 +46,7 @@
    -

    +

      request->action != 'add'): ?>
    • Form->postLink( - __('Delete'), + __d('cake', 'Delete'), array('action' => 'delete', $this->Form->value($modelClass . '.' . $primaryKey)), null, - __('Are you sure you want to delete # %s?', $this->Form->value($modelClass . '.' . $primaryKey))); + __d('cake', 'Are you sure you want to delete # %s?', $this->Form->value($modelClass . '.' . $primaryKey))); ?>
    • -
    • Html->link(__('List') . ' ' . $pluralHumanName, array('action' => 'index'));?>
    • +
    • Html->link(__d('cake', 'List') . ' ' . $pluralHumanName, array('action' => 'index'));?>
    • $_data) { foreach ($_data as $_alias => $_details) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { - echo "\t\t
    • " . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "
    • \n"; - echo "\t\t
    • " . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "
    • \n"; + echo "\t\t
    • " . $this->Html->link(__d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' =>'index')) . "
    • \n"; + echo "\t\t
    • " . $this->Html->link(__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' =>'add')) . "
    • \n"; $done[] = $_details['controller']; } } diff --git a/lib/Cake/View/scaffolds/index.ctp b/lib/Cake/View/scaffolds/index.ctp index c3da1d4d8..d0def968e 100644 --- a/lib/Cake/View/scaffolds/index.ctp +++ b/lib/Cake/View/scaffolds/index.ctp @@ -23,7 +23,7 @@ Paginator->sort($_field);?> - + '; - echo $this->Html->link(__('View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])); - echo $this->Html->link(__('Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])); + echo $this->Html->link(__d('cake', 'View'), array('action' => 'view', ${$singularVar}[$modelClass][$primaryKey])); + echo $this->Html->link(__d('cake', 'Edit'), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])); echo $this->Form->postLink( - __('Delete'), + __d('cake', 'Delete'), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, - __('Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] + __d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] ); echo ''; echo ''; @@ -67,26 +67,26 @@ endforeach;

      Paginator->counter(array( - 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%') + 'format' => __d('cake', 'Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%') )); ?>

      - Paginator->prev('<< ' . __('previous'), array(), null, array('class' => 'disabled')); ?> + Paginator->prev('<< ' . __d('cake', 'previous'), array(), null, array('class' => 'disabled')); ?> | Paginator->numbers(); ?> - Paginator->next(__('next') .' >>', array(), null, array('class' => 'disabled')); ?> + Paginator->next(__d('cake', 'next') .' >>', array(), null, array('class' => 'disabled')); ?>
    -

    +

      -
    • Html->link(__('New %s', $singularHumanName), array('action' => 'add')); ?>
    • +
    • Html->link(__d('cake', 'New %s', $singularHumanName), array('action' => 'add')); ?>
    • $_data) { foreach ($_data as $_alias => $_details) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { - echo "
    • " . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
    • "; - echo "
    • " . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
    • "; + echo "
    • " . $this->Html->link(__d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
    • "; + echo "
    • " . $this->Html->link(__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
    • "; $done[] = $_details['controller']; } } diff --git a/lib/Cake/View/scaffolds/view.ctp b/lib/Cake/View/scaffolds/view.ctp index 010450a15..ef2fe7006 100644 --- a/lib/Cake/View/scaffolds/view.ctp +++ b/lib/Cake/View/scaffolds/view.ctp @@ -17,7 +17,7 @@ */ ?>
      -

      +

      -

      +

        " .$this->Html->link(__('Edit %s', $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). " \n"; - echo "\t\t
      • " .$this->Html->link(__('Delete %s', $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __('Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). "
      • \n"; - echo "\t\t
      • " .$this->Html->link(__('List %s', $pluralHumanName), array('action' => 'index')). "
      • \n"; - echo "\t\t
      • " .$this->Html->link(__('New %s', $singularHumanName), array('action' => 'add')). "
      • \n"; + echo "\t\t
      • " .$this->Html->link(__d('cake', 'Edit %s', $singularHumanName), array('action' => 'edit', ${$singularVar}[$modelClass][$primaryKey])). "
      • \n"; + echo "\t\t
      • " .$this->Html->link(__d('cake', 'Delete %s', $singularHumanName), array('action' => 'delete', ${$singularVar}[$modelClass][$primaryKey]), null, __d('cake', 'Are you sure you want to delete').' #' . ${$singularVar}[$modelClass][$primaryKey] . '?'). "
      • \n"; + echo "\t\t
      • " .$this->Html->link(__d('cake', 'List %s', $pluralHumanName), array('action' => 'index')). "
      • \n"; + echo "\t\t
      • " .$this->Html->link(__d('cake', 'New %s', $singularHumanName), array('action' => 'add')). "
      • \n"; $done = array(); foreach ($associations as $_type => $_data) { foreach ($_data as $_alias => $_details) { if ($_details['controller'] != $this->name && !in_array($_details['controller'], $done)) { - echo "\t\t
      • " . $this->Html->link(__('List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
      • \n"; - echo "\t\t
      • " . $this->Html->link(__('New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
      • \n"; + echo "\t\t
      • " . $this->Html->link(__d('cake', 'List %s', Inflector::humanize($_details['controller'])), array('controller' => $_details['controller'], 'action' => 'index')) . "
      • \n"; + echo "\t\t
      • " . $this->Html->link(__d('cake', 'New %s', Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add')) . "
      • \n"; $done[] = $_details['controller']; } } @@ -71,7 +71,7 @@ foreach ($scaffoldFields as $_field) { if (!empty($associations['hasOne'])) : foreach ($associations['hasOne'] as $_alias => $_details): ?> @@ -110,7 +110,7 @@ foreach ($relations as $_alias => $_details): $otherSingularVar = Inflector::variable($_alias); ?>