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 9744da06c..3a7613b85 100644 --- a/app/config/core.php +++ b/app/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 +)); + diff --git a/app/config/database.php.default b/app/config/database.php.default index 9fb8e9e98..b7eb4bba2 100644 --- a/app/config/database.php.default +++ b/app/config/database.php.default @@ -28,15 +28,15 @@ * You can specify multiple configurations for production, development and testing. * * driver => The name of a supported driver; valid options are as follows: - * mysql - MySQL 4 & 5, - * sqlite - SQLite (PHP5 only), - * postgres - PostgreSQL 7 and higher, - * mssql - Microsoft SQL Server 2000 and higher, - * oracle - Oracle 8 and higher + * Datasabe/Mysql - MySQL 4 & 5, + * Datasabe/Sqlite - SQLite (PHP5 only), + * Datasabe/Postgres - PostgreSQL 7 and higher, + * Datasabe/Mssql - Microsoft SQL Server 2000 and higher, + * Datasabe/Oracle - Oracle 8 and higher * * You can add custom database drivers (or override existing drivers) by adding the - * appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php', - * where 'x' is the name of the database. + * appropriate file to app/models/datasources/database. Drivers should be named 'MyDriver.php', + * * * persistent => true / false * Determines whether or not the database should use a persistent connection @@ -59,7 +59,7 @@ class DATABASE_CONFIG { public $default = array( - 'driver' => 'mysql', + 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', @@ -69,7 +69,7 @@ class DATABASE_CONFIG { ); public $test = array( - 'driver' => 'mysql', + 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', diff --git a/app/webroot/index.php b/app/webroot/index.php index 77b9db786..3c5e71589 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -75,6 +75,6 @@ return; } - require LIBS . 'Routing' . DS .'Dispatcher.php'; + App::uses('Dispatcher', 'Routing'); $Dispatcher = new Dispatcher(); $Dispatcher->dispatch(new CakeRequest()); diff --git a/lib/Cake/Cache/Cache.php b/lib/Cake/Cache/Cache.php index 00cd64c52..32e5e5cb3 100644 --- a/lib/Cake/Cache/Cache.php +++ b/lib/Cake/Cache/Cache.php @@ -73,14 +73,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/lib/Cake/Cache/Engine/FileEngine.php b/lib/Cake/Cache/Engine/FileEngine.php index f7c55e7e8..c1cf8da68 100644 --- a/lib/Cake/Cache/Engine/FileEngine.php +++ b/lib/Cake/Cache/Engine/FileEngine.php @@ -1,7 +1,10 @@ path . $controllerFile .'_controller.php')) { + if (file_exists($this->path . $controllerName .'Controller.php')) { $question[] = __d('cake', "Warning: Choosing no will overwrite the %sController.", $controllerName); } $doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y'); @@ -288,7 +287,7 @@ class ControllerTask extends BakeTask { $primaryKey = $modelObj->primaryKey; $this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName', - 'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName', + 'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName', 'displayField', 'primaryKey' )); $actions = $this->Template->generate('actions', 'controller_actions'); @@ -315,7 +314,7 @@ class ControllerTask extends BakeTask { $contents = $this->Template->generate('classes', 'controller'); $path = $this->getPath(); - $filename = $path . $this->_controllerPath($controllerName) . '_controller.php'; + $filename = $path . $this->_controllerNames($controllerName) . 'Controller.php'; if ($this->createFile($filename, $contents)) { return $contents; } @@ -500,4 +499,4 @@ class ControllerTask extends BakeTask { $this->out(); $this->_stop(); } -} +} \ No newline at end of file diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 349997dda..7804e491c 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -741,7 +741,7 @@ class ModelTask extends BakeTask { $out = $this->Template->generate('classes', 'model'); $path = $this->getPath(); - $filename = $path . Inflector::underscore($name) . '.php'; + $filename = $path . $name . '.php'; $this->out("\nBaking model class for $name...", 1, Shell::QUIET); $this->createFile($filename, $out); ClassRegistry::flush(); diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index 862b7f83a..3223cf54a 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -52,14 +52,6 @@ class ProjectTask extends Shell { $project = $_SERVER['PWD'] . DS . $project; } - if (empty($this->params['skel'])) { - $core = App::core('Console'); - $skelPath = dirname($core[0]) . DS . 'templates' . DS . 'skel'; - if (is_dir($skelPath) === true) { - $this->params['skel'] = $skelPath; - } - } - while (!$project) { $prompt = __d('cake', "What is the full path for this app including the app directory name?\n Example:"); $default = APP_PATH . 'myapp'; @@ -387,8 +379,9 @@ class ProjectTask extends Shell { ))->addOption('empty', array( 'help' => __d('cake', 'Create empty files in each of the directories. Good if you are using git') ))->addOption('skel', array( + 'default' => current(App::core('Console')) . DS . 'templates' . DS . 'skel', 'help' => __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.') )); } -} +} \ No newline at end of file diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 9660e0cc9..aa7739aea 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -663,7 +663,7 @@ class Shell extends Object { * @return string Path to controller */ protected function _controllerPath($name) { - return strtolower(Inflector::underscore($name)); + return Inflector::underscore($name); } /** diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index 6198bc338..2bc41e66c 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -105,7 +105,7 @@ class ShellDispatcher { if (!isset($this->args[0]) || !isset($this->params['working'])) { $message = "This file has been loaded incorrectly and cannot continue.\n" . - "Please make sure that " . DIRECTORY_SEPARATOR . "cake" . DIRECTORY_SEPARATOR . "console is in your system path,\n" . + "Please make sure that " . DIRECTORY_SEPARATOR . "cake" . DIRECTORY_SEPARATOR . "console is in your system path,\n" . "and check the cookbook for the correct usage of this command.\n" . "(http://book.cakephp.org/)"; throw new CakeException($message); @@ -127,14 +127,14 @@ class ShellDispatcher { define('APP_PATH', $this->params['working'] . DS); define('WWW_ROOT', APP_PATH . $this->params['webroot'] . DS); if (!is_dir(ROOT . DS . APP_DIR . DS . 'tmp')) { - define('TMP', CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS . 'console' . DS . 'templates' . DS . 'skel' . DS . 'tmp' . DS); + define('TMP', CAKE_CORE_INCLUDE_PATH . DS . 'Cake' . DS . 'Console' . DS . 'templates' . DS . 'skel' . DS . 'tmp' . DS); } $boot = file_exists(ROOT . DS . APP_DIR . DS . 'config' . 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'; + 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 . 'ConsoleErrorHandler.php'; @@ -229,9 +229,9 @@ class ShellDispatcher { $this->_parsePaths($args); $defaults = array( - 'app' => 'app', + 'app' => 'app', 'root' => dirname(dirname(dirname(__FILE__))), - 'working' => null, + 'working' => null, 'webroot' => 'webroot' ); $params = array_merge($defaults, array_intersect_key($this->params, $defaults)); diff --git a/lib/Cake/Console/templates/default/classes/test.ctp b/lib/Cake/Console/templates/default/classes/test.ctp index 2bcce902b..331347099 100644 --- a/lib/Cake/Console/templates/default/classes/test.ctp +++ b/lib/Cake/Console/templates/default/classes/test.ctp @@ -20,7 +20,7 @@ echo " -App::import('', ''); +App::uses('', ''); /** diff --git a/lib/Cake/Console/templates/default/views/home.ctp b/lib/Cake/Console/templates/default/views/home.ctp index 22217b2fb..b707e5eb3 100644 --- a/lib/Cake/Console/templates/default/views/home.ctp +++ b/lib/Cake/Console/templates/default/views/home.ctp @@ -2,7 +2,7 @@ $output = "

Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!

\n"; $output .=" 0): Debugger::checkSecurityKeys(); endif; @@ -52,27 +52,38 @@ endif; ?>

getDataSource('default'); ?>

+ isConnected()): + echo ''; + echo __('Cake is able to connect to the database.'); + echo ''; + else: + echo ''; + echo __('Cake is NOT able to connect to the database.'); + echo ''; + endif; + ?> +

+ isConnected()): - echo ''; - echo __('Cake is able to connect to the database.'); - echo ''; - else: - echo ''; - echo __('Cake is NOT able to connect to the database.'); - echo ''; - endif; -?> -

\n"; -$output .= "\n"; + App::uses('Validation', 'Utility'); + if (!Validation::alphaNumeric('cakephp')) { + echo '

'; + __('PCRE has not been compiled with Unicode support.'); + echo '
'; + __('Recompile PCRE with Unicode support by adding --enable-unicode-properties when configuring'); + echo '

'; + } +?>\n"; $output .= "

\n"; $output .= "

\n"; $output .= " '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/lib/Cake/Console/templates/skel/config/core.php b/lib/Cake/Console/templates/skel/config/core.php index 9744da06c..3a7613b85 100644 --- a/lib/Cake/Console/templates/skel/config/core.php +++ b/lib/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 +)); + diff --git a/lib/Cake/Console/templates/skel/config/database.php.default b/lib/Cake/Console/templates/skel/config/database.php.default index 0952dac47..b7eb4bba2 100644 --- a/lib/Cake/Console/templates/skel/config/database.php.default +++ b/lib/Cake/Console/templates/skel/config/database.php.default @@ -28,39 +28,38 @@ * You can specify multiple configurations for production, development and testing. * * driver => The name of a supported driver; valid options are as follows: - * mysql - MySQL 4 & 5, - * sqlite - SQLite (PHP5 only), - * postgres - PostgreSQL 7 and higher, - * mssql - Microsoft SQL Server 2000 and higher, - * oracle - Oracle 8 and higher + * Datasabe/Mysql - MySQL 4 & 5, + * Datasabe/Sqlite - SQLite (PHP5 only), + * Datasabe/Postgres - PostgreSQL 7 and higher, + * Datasabe/Mssql - Microsoft SQL Server 2000 and higher, + * Datasabe/Oracle - Oracle 8 and higher * * You can add custom database drivers (or override existing drivers) by adding the - * appropriate file to app/models/datasources/dbo. Drivers should be named 'dbo_x.php', - * where 'x' is the name of the database. + * appropriate file to app/models/datasources/database. Drivers should be named 'MyDriver.php', + * * * persistent => true / false * Determines whether or not the database should use a persistent connection * * host => - * the host you connect to the database. To add a socket or port number, use 'port' => # + * the host you connect to the database. To add a socket or port number, use 'port' => # * * prefix => * Uses the given prefix for all the tables in this database. This setting can be overridden * on a per-table basis with the Model::$tablePrefix property. * * schema => - * For Postgresspecifies which schema you would like to use the tables in. Postgres defaults to - * 'public', DB2 defaults to empty. + * For Postgres specifies which schema you would like to use the tables in. Postgres defaults to 'public'. * * encoding => - * For MySQL, Postgres and Sqlite, specifies the character encoding to use when connecting to the - * database. Uses database default. + * For MySQL, Postgres specifies the character encoding to use when connecting to the + * database. Uses database default not specified. * */ class DATABASE_CONFIG { public $default = array( - 'driver' => 'mysql', + 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', @@ -70,7 +69,7 @@ class DATABASE_CONFIG { ); public $test = array( - 'driver' => 'mysql', + 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'user', diff --git a/lib/Cake/Console/templates/skel/app_controller.php b/lib/Cake/Console/templates/skel/controllers/AppController.php similarity index 100% rename from lib/Cake/Console/templates/skel/app_controller.php rename to lib/Cake/Console/templates/skel/controllers/AppController.php diff --git a/lib/Cake/Console/templates/skel/controllers/pages_controller.php b/lib/Cake/Console/templates/skel/controllers/PagesController.php similarity index 100% rename from lib/Cake/Console/templates/skel/controllers/pages_controller.php rename to lib/Cake/Console/templates/skel/controllers/PagesController.php diff --git a/lib/Cake/Console/templates/skel/app_model.php b/lib/Cake/Console/templates/skel/models/AppModel.php similarity index 100% rename from lib/Cake/Console/templates/skel/app_model.php rename to lib/Cake/Console/templates/skel/models/AppModel.php diff --git a/lib/Cake/Console/templates/skel/app_helper.php b/lib/Cake/Console/templates/skel/views/helpers/AppHelper.php similarity index 96% rename from lib/Cake/Console/templates/skel/app_helper.php rename to lib/Cake/Console/templates/skel/views/helpers/AppHelper.php index 8bb93af44..6689abcba 100644 --- a/lib/Cake/Console/templates/skel/app_helper.php +++ b/lib/Cake/Console/templates/skel/views/helpers/AppHelper.php @@ -18,7 +18,7 @@ * @since CakePHP(tm) v 0.2.9 * @license MIT License (http://www.opensource.org/licenses/mit-license.php) */ -App::uses('Helper', 'Helper'); +App::uses('Helper', 'View'); /** * This is a placeholder class. diff --git a/lib/Cake/Console/templates/skel/webroot/index.php b/lib/Cake/Console/templates/skel/webroot/index.php index f1ff8d197..77b9db786 100644 --- a/lib/Cake/Console/templates/skel/webroot/index.php +++ b/lib/Cake/Console/templates/skel/webroot/index.php @@ -49,7 +49,7 @@ * */ if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', ROOT); + define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'lib'); } /** @@ -67,7 +67,7 @@ define('APP_PATH', ROOT . DS . APP_DIR . DS); define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS); } - if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) { + if (!include(CORE_PATH . 'Cake' . DS . 'bootstrap.php')) { trigger_error("CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR); } @@ -75,6 +75,6 @@ return; } - require LIBS . 'dispatcher.php'; + require LIBS . 'Routing' . DS .'Dispatcher.php'; $Dispatcher = new Dispatcher(); $Dispatcher->dispatch(new CakeRequest()); diff --git a/lib/Cake/Controller/Component/SecurityComponent.php b/lib/Cake/Controller/Component/SecurityComponent.php index 5f73edc78..16cdc6413 100644 --- a/lib/Cake/Controller/Component/SecurityComponent.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -186,7 +186,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); @@ -321,10 +321,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; } } @@ -342,7 +342,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')) { @@ -363,7 +363,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'] )) { diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 07aea99ef..a257b051f 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -236,14 +236,14 @@ 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/Session' => array('%s' . 'models' . DS . 'datasources' . DS . 'Session' . DS), + 'Model/Datasource/Database' => array('%s' . 'models' . DS . 'datasources' . DS . 'database' . DS), + 'Model/Datasource/Session' => array('%s' . 'models' . DS . 'datasources' . DS . 'session' . DS), 'Controller' => array('%s' . 'controllers' . DS), 'Controller/Component' => array('%s' . 'controllers' . DS . 'components' . DS), 'View' => array('%s' . 'views' . DS), 'View/Helper' => array('%s' . 'views' . DS . 'helpers' . DS), 'Console' => array( - '%s' . 'console' . DS . 'shells' . DS, + '%s' . 'console' . DS, '%s' . 'vendors' . DS . 'shells' . DS, VENDORS . 'shells' . DS ), diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 096de5da7..2ec08964c 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -21,7 +21,7 @@ * Configuration class. Used for managing runtime configuration information. * * Provides features for reading and writing to the runtime configuration, as well - * as methods for loading additional configuration files or storing runtime configuration + * as methods for loading additional configuration files or storing runtime configuration * for future use. * * @package cake.libs @@ -73,43 +73,6 @@ class Configure { 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(__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; - - 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')) { @@ -261,7 +224,7 @@ class Configure { } /** - * Add a new reader to Configure. Readers allow you to read configuration + * Add a new reader to Configure. Readers allow you to read configuration * files in various formats/storage locations. CakePHP comes with two built-in readers * PhpReader and IniReader. You can also implement your own reader classes in your application. * @@ -269,7 +232,7 @@ class Configure { * * `Configure::config('ini', new IniReader());` * - * @param string $name The name of the reader being configured. This alias is used later to + * @param string $name The name of the reader being configured. This alias is used later to * read values from a specific reader. * @param ConfigReaderInterface $reader The reader to append. * @return void @@ -291,7 +254,7 @@ class Configure { } /** - * Remove a configured reader. This will unset the reader + * Remove a configured reader. This will unset the reader * and make any future attempts to use it cause an Exception. * * @param string $name Name of the reader to drop. @@ -313,7 +276,7 @@ class Configure { * runtime configuration. You can load configuration files from plugins * by preceeding the filename with the plugin name. * - * `Configure::load('Users.user', 'default')` + * `Configure::load('Users.user', 'default')` * * Would load the 'user' config file using the default config reader. You can load * app config files by giving the name of the resource you want loaded. @@ -395,7 +358,7 @@ interface ConfigReaderInterface { * These sources can either be static resources like files, or dynamic ones like * a database, or other datasource. * - * @param string $key + * @param string $key * @return array An array of data to merge into the runtime configuration */ function read($key); diff --git a/lib/Cake/Error/exceptions.php b/lib/Cake/Error/exceptions.php index 8c5a80b86..31f01f361 100644 --- a/lib/Cake/Error/exceptions.php +++ b/lib/Cake/Error/exceptions.php @@ -20,12 +20,14 @@ /** * Parent class for all of the HTTP related exceptions in CakePHP. - * All HTTP status/error related exceptions should extend this class so + * All HTTP status/error related exceptions should extend this class so * catch blocks can be specifically typed. * * @package cake.libs */ -class HttpException extends RuntimeException { } +if (!class_exists('HttpException')) { + class HttpException extends RuntimeException { } +} /** * Represents an HTTP 400 error. @@ -198,12 +200,12 @@ class CakeException extends RuntimeException { } /** - * Missing Controller exception - used when a controller + * Missing Controller exception - used when a controller * cannot be found. * * @package cake.libs */ -class MissingControllerException extends CakeException { +class MissingControllerException extends CakeException { protected $_messageTemplate = 'Controller class %s could not be found.'; public function __construct($message, $code = 404) { @@ -212,12 +214,12 @@ class MissingControllerException extends CakeException { } /** - * Missing Action exception - used when a controller action + * Missing Action exception - used when a controller action * cannot be found. * * @package cake.libs */ -class MissingActionException extends CakeException { +class MissingActionException extends CakeException { protected $_messageTemplate = 'Action %s::%s() could not be found.'; public function __construct($message, $code = 404) { @@ -225,12 +227,12 @@ class MissingActionException extends CakeException { } } /** - * Private Action exception - used when a controller action + * Private Action exception - used when a controller action * is protected, or starts with a `_`. * * @package cake.libs */ -class PrivateActionException extends CakeException { +class PrivateActionException extends CakeException { protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.'; public function __construct($message, $code = 404, Exception $previous = null) { @@ -243,7 +245,7 @@ class PrivateActionException extends CakeException { * * @package cake.libs */ -class MissingComponentFileException extends CakeException { +class MissingComponentFileException extends CakeException { protected $_messageTemplate = 'Component File "%s" is missing.'; } @@ -252,7 +254,7 @@ class MissingComponentFileException extends CakeException { * * @package cake.libs */ -class MissingComponentClassException extends CakeException { +class MissingComponentClassException extends CakeException { protected $_messageTemplate = 'Component class "%s" is missing.'; } @@ -275,7 +277,7 @@ class MissingBehaviorClassException extends CakeException { } * * @package cake.libs */ -class MissingViewException extends CakeException { +class MissingViewException extends CakeException { protected $_messageTemplate = 'View file "%s" is missing.'; } @@ -284,7 +286,7 @@ class MissingViewException extends CakeException { * * @package cake.libs */ -class MissingLayoutException extends CakeException { +class MissingLayoutException extends CakeException { protected $_messageTemplate = 'Layout file "%s" is missing.'; } @@ -293,7 +295,7 @@ class MissingLayoutException extends CakeException { * * @package cake.libs */ -class MissingHelperFileException extends CakeException { +class MissingHelperFileException extends CakeException { protected $_messageTemplate = 'Helper File "%s" is missing.'; } @@ -302,7 +304,7 @@ class MissingHelperFileException extends CakeException { * * @package cake.libs */ -class MissingHelperClassException extends CakeException { +class MissingHelperClassException extends CakeException { protected $_messageTemplate = 'Helper class "%s" is missing.'; } @@ -330,7 +332,7 @@ class MissingConnectionException extends CakeException { * * @package cake.libs */ -class MissingTaskFileException extends CakeException { +class MissingTaskFileException extends CakeException { protected $_messageTemplate = 'Task file "%s" is missing.'; } @@ -339,7 +341,7 @@ class MissingTaskFileException extends CakeException { * * @package cake.libs */ -class MissingTaskClassException extends CakeException { +class MissingTaskClassException extends CakeException { protected $_messageTemplate = 'Task class "%s" is missing.'; } @@ -348,7 +350,7 @@ class MissingTaskClassException extends CakeException { * * @package cake.libs */ -class MissingShellMethodException extends CakeException { +class MissingShellMethodException extends CakeException { protected $_messageTemplate = "Unknown command %1\$s %2\$s.\nFor usage try `cake %1\$s --help`"; } @@ -357,7 +359,7 @@ class MissingShellMethodException extends CakeException { * * @package cake.libs */ -class MissingShellClassException extends CakeException { +class MissingShellClassException extends CakeException { protected $_messageTemplate = "Shell class %s could not be loaded."; } @@ -366,7 +368,7 @@ class MissingShellClassException extends CakeException { * * @package cake.libs */ -class MissingShellFileException extends CakeException { +class MissingShellFileException extends CakeException { protected $_messageTemplate = "Shell file %s could not be loaded."; } @@ -479,4 +481,3 @@ class XmlException extends CakeException { } * @package cake.libs */ class ConsoleException extends CakeException { } - diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 7a7ed9128..ff4d77e59 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1041,6 +1041,7 @@ class FormHelper extends AppHelper { public function radio($fieldName, $options = array(), $attributes = array()) { $attributes = $this->_initInputField($fieldName, $attributes); $legend = false; + $disabled = array(); if (isset($attributes['legend'])) { $legend = $attributes['legend']; @@ -1066,6 +1067,11 @@ class FormHelper extends AppHelper { } else { $value = $this->value($fieldName); } + + if (isset($attributes['disabled'])) { + $disabled = $attributes['disabled']; + } + $out = array(); $hiddenField = isset($attributes['hiddenField']) ? $attributes['hiddenField'] : true; @@ -1077,6 +1083,9 @@ class FormHelper extends AppHelper { if (isset($value) && $optValue == $value) { $optionsHere['checked'] = 'checked'; } + if (!empty($disabled) && in_array($optValue, $disabled)) { + $optionsHere['disabled'] = true; + } $tagName = Inflector::camelize( $attributes['id'] . '_' . Inflector::slug($optValue) ); diff --git a/lib/Cake/View/pages/home.ctp b/lib/Cake/View/pages/home.ctp index 57a7e1cc1..61912ad75 100644 --- a/lib/Cake/View/pages/home.ctp +++ b/lib/Cake/View/pages/home.ctp @@ -18,7 +18,7 @@ if (Configure::read('debug') == 0): throw new NotFoundException(); endif; -App::import('Core', 'Debugger'); +App::uses('Debugger', 'Utility'); ?>

@@ -71,16 +71,6 @@ endif; endif; ?>

-'; - __d('cake', 'PCRE has not been compiled with Unicode support.'); - echo '
'; - __d('cake', 'Recompile PCRE with Unicode support by adding --enable-unicode-properties when configuring'); - echo '

'; - } -?>

+'; + __('PCRE has not been compiled with Unicode support.'); + echo '
'; + __('Recompile PCRE with Unicode support by adding --enable-unicode-properties when configuring'); + echo '

'; + } +?>

  • - + \ No newline at end of file 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 1ec00d43e..e9be0a9d2 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/controller.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/controller.test.php @@ -299,7 +299,7 @@ class ControllerTaskTest extends CakeTestCase { $components = array('Acl', 'Auth'); $uses = array('Comment', 'User'); - $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'articles_controller.php'; + $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'ArticlesController.php'; $this->Task->expects($this->at(1))->method('createFile')->with( $path, @@ -313,7 +313,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->bake('Articles', '--actions--', array(), array(), array()); $this->Task->plugin = 'controllerTest'; - $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'articles_controller.php'; + $path = APP . 'plugins' . DS . 'controller_test' . DS . 'controllers' . DS . 'ArticlesController.php'; $this->Task->bake('Articles', '--actions--', array(), array(), array()); $this->assertEqual($this->Task->Template->templateVars['plugin'], 'ControllerTest'); @@ -442,7 +442,7 @@ class ControllerTaskTest extends CakeTestCase { 'y' // looks good? )); - $filename = '/my/path/bake_articles_controller.php'; + $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( $filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/') @@ -482,7 +482,7 @@ class ControllerTaskTest extends CakeTestCase { ->method('getPrefix') ->will($this->returnValue('admin_')); - $filename = '/my/path/bake_articles_controller.php'; + $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( $filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/') @@ -512,7 +512,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->expects($this->any())->method('_checkUnitTest')->will($this->returnValue(true)); $this->Task->Test->expects($this->once())->method('bake'); - $filename = '/my/path/bake_articles_controller.php'; + $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( $filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/') @@ -534,7 +534,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->path = '/my/path/'; $this->Task->args = array('BakeArticles'); - $filename = '/my/path/bake_articles_controller.php'; + $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( $filename, new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/') @@ -568,7 +568,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->path = '/my/path/'; $this->Task->args = array($name); - $filename = '/my/path/bake_articles_controller.php'; + $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( $filename, new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/') ); @@ -589,7 +589,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->args = array('BakeArticles'); $this->Task->params = array('public' => true); - $filename = '/my/path/bake_articles_controller.php'; + $filename = '/my/path/BakeArticlesController.php'; $expected = new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/')); $this->Task->expects($this->once())->method('createFile')->with( $filename, $expected @@ -612,7 +612,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->args = array('BakeArticles'); $this->Task->params = array('public' => true, 'admin' => true); - $filename = '/my/path/bake_articles_controller.php'; + $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( $filename, new PHPUnit_Framework_Constraint_PCREMatch('/admin_index/') ); @@ -634,7 +634,7 @@ class ControllerTaskTest extends CakeTestCase { $this->Task->args = array('BakeArticles'); $this->Task->params = array('admin' => true); - $filename = '/my/path/bake_articles_controller.php'; + $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( $filename, new PHPUnit_Framework_Constraint_PCREMatch('/admin_index/') ); diff --git a/lib/Cake/tests/cases/console/shells/tasks/model.test.php b/lib/Cake/tests/cases/console/shells/tasks/model.test.php index 470496e06..5ebf1367b 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/model.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/model.test.php @@ -745,7 +745,7 @@ STRINGEND; public function testBakeWithPlugin() { $this->Task->plugin = 'controllerTest'; - $path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'bake_article.php'; + $path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'BakeArticle.php'; $this->Task->expects($this->once())->method('createFile') ->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/BakeArticle extends ControllerTestAppModel/')); @@ -763,8 +763,8 @@ STRINGEND; public function testExecuteWithNamedModel() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('bake_article'); - $filename = '/my/path/bake_article.php'; + $this->Task->args = array('BakeArticle'); + $filename = '/my/path/BakeArticle.php'; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); $this->Task->expects($this->once())->method('createFile') @@ -799,7 +799,7 @@ STRINGEND; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); $this->Task->args = array($name); - $filename = '/my/path/bake_article.php'; + $filename = '/my/path/BakeArticle.php'; $this->Task->expects($this->at(0))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle extends AppModel/')); @@ -814,8 +814,8 @@ STRINGEND; public function testExecuteWithNamedModelHasManyCreated() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('bake_article'); - $filename = '/my/path/bake_article.php'; + $this->Task->args = array('BakeArticle'); + $filename = '/my/path/BakeArticle.php'; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); $this->Task->expects($this->at(0))->method('createFile') @@ -843,23 +843,23 @@ STRINGEND; $this->Task->Fixture->expects($this->exactly(5))->method('bake'); $this->Task->Test->expects($this->exactly(5))->method('bake'); - $filename = '/my/path/bake_article.php'; + $filename = '/my/path/BakeArticle.php'; $this->Task->expects($this->at(1))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/')); - $filename = '/my/path/bake_articles_bake_tag.php'; + $filename = '/my/path/BakeArticlesBakeTag.php'; $this->Task->expects($this->at(2))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesBakeTag/')); - $filename = '/my/path/bake_comment.php'; + $filename = '/my/path/BakeComment.php'; $this->Task->expects($this->at(3))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeComment/')); - $filename = '/my/path/bake_tag.php'; + $filename = '/my/path/BakeTag.php'; $this->Task->expects($this->at(4)) ->method('createFile')->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeTag/')); - $filename = '/my/path/category_thread.php'; + $filename = '/my/path/CategoryThread.php'; $this->Task->expects($this->at(5))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/')); @@ -889,19 +889,19 @@ STRINGEND; $this->Task->Fixture->expects($this->exactly(4))->method('bake'); $this->Task->Test->expects($this->exactly(4))->method('bake'); - $filename = '/my/path/bake_article.php'; + $filename = '/my/path/BakeArticle.php'; $this->Task->expects($this->at(1))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/')); - $filename = '/my/path/bake_articles_bake_tag.php'; + $filename = '/my/path/BakeArticlesBakeTag.php'; $this->Task->expects($this->at(2))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesBakeTag/')); - $filename = '/my/path/bake_comment.php'; + $filename = '/my/path/BakeComment.php'; $this->Task->expects($this->at(3))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeComment/')); - $filename = '/my/path/category_thread.php'; + $filename = '/my/path/CategoryThread.php'; $this->Task->expects($this->at(4))->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/')); @@ -939,7 +939,7 @@ STRINGEND; $this->Task->Test->expects($this->once())->method('bake'); $this->Task->Fixture->expects($this->once())->method('bake'); - $filename = '/my/path/bake_article.php'; + $filename = '/my/path/BakeArticle.php'; $this->Task->expects($this->once())->method('createFile') ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/')); diff --git a/lib/Cake/tests/cases/console/shells/tasks/test.test.php b/lib/Cake/tests/cases/console/shells/tasks/test.test.php index 3de416b8e..f6e8376e1 100644 --- a/lib/Cake/tests/cases/console/shells/tasks/test.test.php +++ b/lib/Cake/tests/cases/console/shells/tasks/test.test.php @@ -437,7 +437,7 @@ class TestTaskTest extends CakeTestCase { $result = $this->Task->bake('Model', 'TestTaskArticle'); - $this->assertContains("App::import('Model', 'TestTaskArticle')", $result); + $this->assertContains("App::uses('TestTaskArticle', 'Model')", $result); $this->assertContains('class TestTaskArticleTestCase extends CakeTestCase', $result); $this->assertContains('function setUp()', $result); @@ -468,7 +468,7 @@ class TestTaskTest extends CakeTestCase { $result = $this->Task->bake('Controller', 'TestTaskComments'); - $this->assertContains("App::import('Controller', 'TestTaskComments')", $result); + $this->assertContains("App::uses('TestTaskCommentsController', 'Controller')", $result); $this->assertContains('class TestTaskCommentsControllerTestCase extends CakeTestCase', $result); $this->assertContains('class TestTestTaskCommentsController extends TestTaskCommentsController', $result); diff --git a/lib/Cake/tests/cases/libs/cache.test.php b/lib/Cake/tests/cases/libs/cache.test.php index 5476f837a..ce5150e8b 100644 --- a/lib/Cake/tests/cases/libs/cache.test.php +++ b/lib/Cake/tests/cases/libs/cache.test.php @@ -307,7 +307,7 @@ class CacheTest extends CakeTestCase { 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) ), true); - Cache::config('test_trigger', array('engine' => 'TestAppCache')); + Cache::config('test_trigger', array('engine' => 'TestAppCache', 'prefix' => '')); try { Cache::write('fail', 'value', 'test_trigger'); $this->fail('No exception thrown'); diff --git a/lib/Cake/tests/cases/libs/cache/file.test.php b/lib/Cake/tests/cases/libs/cache/file.test.php index 50d20181e..5395ac025 100644 --- a/lib/Cake/tests/cases/libs/cache/file.test.php +++ b/lib/Cake/tests/cases/libs/cache/file.test.php @@ -41,10 +41,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)); } /** @@ -54,9 +53,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'); } /** @@ -83,24 +82,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'); } /** @@ -110,27 +109,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); } @@ -142,14 +141,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); } @@ -160,17 +159,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)); @@ -184,91 +183,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)); } /** @@ -289,14 +232,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); } /** @@ -306,11 +250,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(); @@ -370,16 +314,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'"); } /** diff --git a/lib/Cake/tests/cases/libs/view/helpers/form.test.php b/lib/Cake/tests/cases/libs/view/helpers/form.test.php index 51e09d85d..9764c70ff 100644 --- a/lib/Cake/tests/cases/libs/view/helpers/form.test.php +++ b/lib/Cake/tests/cases/libs/view/helpers/form.test.php @@ -3018,6 +3018,35 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * test disabled radio options + * + * @return void + */ + function testRadioDisabled() { + $result = $this->Form->radio( + 'Model.field', + array('option A', 'option B'), + array('disabled' => array('option A'), 'value' => 'option A') + ); + $expected = array( + 'fieldset' => array(), + 'legend' => array(), + 'Field', + '/legend', + array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField0', 'disabled' => 'disabled', 'checked' => 'checked')), + array('label' => array('for' => 'ModelField0')), + 'option A', + '/label', + array('input' => array('type' => 'radio', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField1')), + array('label' => array('for' => 'ModelField1')), + 'option B', + '/label', + '/fieldset' + ); + $this->assertTags($result, $expected); + } + /** * test disabling the hidden input for radio buttons * diff --git a/lib/Cake/tests/test_app/libs/Cache/Engine/TestAppCacheEngine.php b/lib/Cake/tests/test_app/libs/Cache/Engine/TestAppCacheEngine.php index 1a8a47ac0..86b7688fb 100644 --- a/lib/Cake/tests/test_app/libs/Cache/Engine/TestAppCacheEngine.php +++ b/lib/Cake/tests/test_app/libs/Cache/Engine/TestAppCacheEngine.php @@ -19,7 +19,7 @@ class TestAppCacheEngine extends CacheEngine { public function write($key, $value, $duration) { - if ($key = 'fail') { + if ($key == 'fail') { return false; } } diff --git a/lib/Cake/tests/test_app/libs/Utility/TestUtilityClass.php b/lib/Cake/tests/test_app/libs/Utility/TestUtilityClass.php new file mode 100644 index 000000000..6d4e021f6 --- /dev/null +++ b/lib/Cake/tests/test_app/libs/Utility/TestUtilityClass.php @@ -0,0 +1,19 @@ + + * 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.cases.libs + * @since CakePHP(tm) v 1.3 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + */ +class TestUtilityClass {} diff --git a/lib/Cake/tests/test_app/models/datasources/Database/TestLocalDriver.php b/lib/Cake/tests/test_app/models/datasources/database/TestLocalDriver.php similarity index 100% rename from lib/Cake/tests/test_app/models/datasources/Database/TestLocalDriver.php rename to lib/Cake/tests/test_app/models/datasources/database/TestLocalDriver.php diff --git a/lib/Cake/tests/test_app/models/datasources/Session/TestAppLibSession.php b/lib/Cake/tests/test_app/models/datasources/session/TestAppLibSession.php similarity index 100% rename from lib/Cake/tests/test_app/models/datasources/Session/TestAppLibSession.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/Custom/Package/CustomLibClass.php b/lib/Cake/tests/test_app/plugins/test_plugin/libs/Custom/Package/CustomLibClass.php new file mode 100644 index 000000000..70c86ff40 --- /dev/null +++ b/lib/Cake/tests/test_app/plugins/test_plugin/libs/Custom/Package/CustomLibClass.php @@ -0,0 +1,19 @@ + + * 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.cases.libs + * @since CakePHP(tm) v 1.2.0.5432 + * @license MIT License (http://www.opensource.org/licenses/mit-license.php) + */ +class CustomLibClass {} diff --git a/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/Database/DboDummy.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/database/DboDummy.php similarity index 100% rename from lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/Database/DboDummy.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/database/DboDummy.php diff --git a/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/Database/TestDriver.php b/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/database/TestDriver.php similarity index 100% rename from lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/Database/TestDriver.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/database/TestDriver.php diff --git a/lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/Session/TestPluginSession.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/models/datasources/Session/TestPluginSession.php rename to lib/Cake/tests/test_app/plugins/test_plugin/models/datasources/session/TestPluginSession.php