Merge branch '2.0-class-loading' into 2.0-translations

Conflicts:
	lib/Cake/Console/Command/Task/ControllerTask.php
	lib/Cake/Console/Command/Task/ProjectTask.php
	lib/Cake/Core/Configure.php
	lib/Cake/View/pages/home.ctp
This commit is contained in:
AD7six 2011-03-16 12:29:39 +01:00
commit 39c7d03319
42 changed files with 388 additions and 307 deletions

View file

@ -1,9 +1,12 @@
<?php <?php
/** /**
* This file is loaded automatically by the app/webroot/index.php file after the core bootstrap.php * This file is loaded automatically by the app/webroot/index.php file after core.php
* *
* This is an application wide file to load any function that is not used within a class * This file should load/create any application wide configuration settings, such as
* define. You can also use this to include or require any files in your application. * Caching, Logging, loading additional configuration files.
*
* You should also use this file to include any files that provide global functions/constants
* that your application uses.
* *
* PHP 5 * PHP 5
* *
@ -20,6 +23,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
// Setup a 'default' cache configuration for use in the application.
Cache::config('default', array('engine' => 'File'));
/** /**
* The settings below can be used to set additional paths to models, views and controllers. * 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) * This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)

View file

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

View file

@ -28,15 +28,15 @@
* You can specify multiple configurations for production, development and testing. * You can specify multiple configurations for production, development and testing.
* *
* driver => The name of a supported driver; valid options are as follows: * driver => The name of a supported driver; valid options are as follows:
* mysql - MySQL 4 & 5, * Datasabe/Mysql - MySQL 4 & 5,
* sqlite - SQLite (PHP5 only), * Datasabe/Sqlite - SQLite (PHP5 only),
* postgres - PostgreSQL 7 and higher, * Datasabe/Postgres - PostgreSQL 7 and higher,
* mssql - Microsoft SQL Server 2000 and higher, * Datasabe/Mssql - Microsoft SQL Server 2000 and higher,
* oracle - Oracle 8 and higher * Datasabe/Oracle - Oracle 8 and higher
* *
* You can add custom database drivers (or override existing drivers) by adding the * 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', * appropriate file to app/models/datasources/database. Drivers should be named 'MyDriver.php',
* where 'x' is the name of the database. *
* *
* persistent => true / false * persistent => true / false
* Determines whether or not the database should use a persistent connection * Determines whether or not the database should use a persistent connection
@ -59,7 +59,7 @@
class DATABASE_CONFIG { class DATABASE_CONFIG {
public $default = array( public $default = array(
'driver' => 'mysql', 'datasource' => 'Database/Mysql',
'persistent' => false, 'persistent' => false,
'host' => 'localhost', 'host' => 'localhost',
'login' => 'user', 'login' => 'user',
@ -69,7 +69,7 @@ class DATABASE_CONFIG {
); );
public $test = array( public $test = array(
'driver' => 'mysql', 'datasource' => 'Database/Mysql',
'persistent' => false, 'persistent' => false,
'host' => 'localhost', 'host' => 'localhost',
'login' => 'user', 'login' => 'user',

View file

@ -75,6 +75,6 @@
return; return;
} }
require LIBS . 'Routing' . DS .'Dispatcher.php'; App::uses('Dispatcher', 'Routing');
$Dispatcher = new Dispatcher(); $Dispatcher = new Dispatcher();
$Dispatcher->dispatch(new CakeRequest()); $Dispatcher->dispatch(new CakeRequest());

View file

@ -73,14 +73,24 @@ class Cache {
* both create new configurations, return the settings for already configured * both create new configurations, return the settings for already configured
* configurations. * 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));` * `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');` * `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 * @see app/config/core.php for configuration settings
* @param string $name Name of the configuration * @param string $name Name of the configuration
* @param array $settings Optional associative array of settings passed to the engine * @param array $settings Optional associative array of settings passed to the engine

View file

@ -1,7 +1,10 @@
<?php <?php
/** /**
* File Storage engine for cache * File Storage engine for cache. Filestorage is the slowest cache storage
* to read and write. However, it is good for servers that don't have other storage
* engine available, or have content which is not performance sensitive.
* *
* You can configure a FileEngine cache, using Cache::config()
* *
* PHP 5 * PHP 5
* *
@ -13,7 +16,6 @@
* *
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org) * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project * @link http://cakephp.org CakePHP(tm) Project
* @package cake.libs.cache
* @since CakePHP(tm) v 1.2.0.4933 * @since CakePHP(tm) v 1.2.0.4933
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
@ -21,7 +23,6 @@
/** /**
* File Storage engine for cache * 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 * @package cake.libs.cache
*/ */
class FileEngine extends CacheEngine { class FileEngine extends CacheEngine {

View file

@ -19,7 +19,7 @@
/** /**
* This is a placeholder class. * This is a placeholder class.
* Create the same file in app/console/shells/app_shell.php * Create the same file in app/console/shells/AppShell.php
* *
* Add your application-wide methods in the class below, your shells * Add your application-wide methods in the class below, your shells
* will inherit them. * will inherit them.

View file

@ -143,10 +143,9 @@ class ControllerTask extends BakeTask {
$useDynamicScaffold = 'n'; $useDynamicScaffold = 'n';
$wannaBakeCrud = 'y'; $wannaBakeCrud = 'y';
$controllerFile = strtolower(Inflector::underscore($controllerName));
$question[] = __d('cake', "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')) { if (file_exists($this->path . $controllerName .'Controller.php')) {
$question[] = __d('cake', "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'); $doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y');
@ -288,7 +287,7 @@ class ControllerTask extends BakeTask {
$primaryKey = $modelObj->primaryKey; $primaryKey = $modelObj->primaryKey;
$this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName', $this->Template->set(compact('plugin', 'admin', 'controllerPath', 'pluralName', 'singularName',
'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName', 'singularHumanName', 'pluralHumanName', 'modelObj', 'wannaUseSession', 'currentModelName',
'displayField', 'primaryKey' 'displayField', 'primaryKey'
)); ));
$actions = $this->Template->generate('actions', 'controller_actions'); $actions = $this->Template->generate('actions', 'controller_actions');
@ -315,7 +314,7 @@ class ControllerTask extends BakeTask {
$contents = $this->Template->generate('classes', 'controller'); $contents = $this->Template->generate('classes', 'controller');
$path = $this->getPath(); $path = $this->getPath();
$filename = $path . $this->_controllerPath($controllerName) . '_controller.php'; $filename = $path . $this->_controllerNames($controllerName) . 'Controller.php';
if ($this->createFile($filename, $contents)) { if ($this->createFile($filename, $contents)) {
return $contents; return $contents;
} }
@ -500,4 +499,4 @@ class ControllerTask extends BakeTask {
$this->out(); $this->out();
$this->_stop(); $this->_stop();
} }
} }

View file

@ -741,7 +741,7 @@ class ModelTask extends BakeTask {
$out = $this->Template->generate('classes', 'model'); $out = $this->Template->generate('classes', 'model');
$path = $this->getPath(); $path = $this->getPath();
$filename = $path . Inflector::underscore($name) . '.php'; $filename = $path . $name . '.php';
$this->out("\nBaking model class for $name...", 1, Shell::QUIET); $this->out("\nBaking model class for $name...", 1, Shell::QUIET);
$this->createFile($filename, $out); $this->createFile($filename, $out);
ClassRegistry::flush(); ClassRegistry::flush();

View file

@ -52,14 +52,6 @@ class ProjectTask extends Shell {
$project = $_SERVER['PWD'] . DS . $project; $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) { while (!$project) {
$prompt = __d('cake', "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'; $default = APP_PATH . 'myapp';
@ -387,8 +379,9 @@ class ProjectTask extends Shell {
))->addOption('empty', array( ))->addOption('empty', array(
'help' => __d('cake', '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( ))->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.') '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.')
)); ));
} }
} }

View file

@ -663,7 +663,7 @@ class Shell extends Object {
* @return string Path to controller * @return string Path to controller
*/ */
protected function _controllerPath($name) { protected function _controllerPath($name) {
return strtolower(Inflector::underscore($name)); return Inflector::underscore($name);
} }
/** /**

View file

@ -105,7 +105,7 @@ class ShellDispatcher {
if (!isset($this->args[0]) || !isset($this->params['working'])) { if (!isset($this->args[0]) || !isset($this->params['working'])) {
$message = "This file has been loaded incorrectly and cannot continue.\n" . $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" . "and check the cookbook for the correct usage of this command.\n" .
"(http://book.cakephp.org/)"; "(http://book.cakephp.org/)";
throw new CakeException($message); throw new CakeException($message);
@ -127,14 +127,14 @@ class ShellDispatcher {
define('APP_PATH', $this->params['working'] . DS); define('APP_PATH', $this->params['working'] . DS);
define('WWW_ROOT', APP_PATH . $this->params['webroot'] . DS); define('WWW_ROOT', APP_PATH . $this->params['webroot'] . DS);
if (!is_dir(ROOT . DS . APP_DIR . DS . 'tmp')) { 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'); $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')) { 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(); App::build();
} }
require_once CONSOLE_LIBS . 'ConsoleErrorHandler.php'; require_once CONSOLE_LIBS . 'ConsoleErrorHandler.php';
@ -229,9 +229,9 @@ class ShellDispatcher {
$this->_parsePaths($args); $this->_parsePaths($args);
$defaults = array( $defaults = array(
'app' => 'app', 'app' => 'app',
'root' => dirname(dirname(dirname(__FILE__))), 'root' => dirname(dirname(dirname(__FILE__))),
'working' => null, 'working' => null,
'webroot' => 'webroot' 'webroot' => 'webroot'
); );
$params = array_merge($defaults, array_intersect_key($this->params, $defaults)); $params = array_merge($defaults, array_intersect_key($this->params, $defaults));

View file

@ -20,7 +20,7 @@
echo "<?php\n"; echo "<?php\n";
echo "/* ". $className ." Test cases generated on: " . date('Y-m-d H:i:s') . " : ". time() . "*/\n"; echo "/* ". $className ." Test cases generated on: " . date('Y-m-d H:i:s') . " : ". time() . "*/\n";
?> ?>
App::import('<?php echo $type; ?>', '<?php echo $plugin . $className;?>'); App::uses('<?php echo $fullClassName; ?>', '<?php echo $plugin . $type;?>');
<?php if ($mock and strtolower($type) == 'controller'): ?> <?php if ($mock and strtolower($type) == 'controller'): ?>
/** /**

View file

@ -2,7 +2,7 @@
$output = "<h2>Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!</h2>\n"; $output = "<h2>Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!</h2>\n";
$output .=" $output .="
<?php <?php
App::import('Core', 'Debugger'); App::uses('Debugger', 'Utility');
if (Configure::read() > 0): if (Configure::read() > 0):
Debugger::checkSecurityKeys(); Debugger::checkSecurityKeys();
endif; endif;
@ -52,27 +52,38 @@ endif;
?> ?>
</p> </p>
<?php <?php
if (!empty(\$filePresent)): if (isset(\$filePresent)):
if (!class_exists('ConnectionManager')) { App::uses('ConnectionManager', 'Model');
require LIBS . 'model' . DS . 'connection_manager.php'; try {
\$connected = ConnectionManager::getDataSource('default');
} catch (Exception \$e) {
\$connected = false;
} }
\$db = ConnectionManager::getInstance();
\$connected = \$db->getDataSource('default');
?> ?>
<p> <p>
<?php
if (\$connected && \$connected->isConnected()):
echo '<span class=\"notice success\">';
echo __('Cake is able to connect to the database.');
echo '</span>';
else:
echo '<span class=\"notice\">';
echo __('Cake is NOT able to connect to the database.');
echo '</span>';
endif;
?>
</p>
<?php endif;?>
<?php <?php
if (\$connected->isConnected()): App::uses('Validation', 'Utility');
echo '<span class=\"notice success\">'; if (!Validation::alphaNumeric('cakephp')) {
echo __('Cake is able to connect to the database.'); echo '<p><span class=\"notice\">';
echo '</span>'; __('PCRE has not been compiled with Unicode support.');
else: echo '<br/>';
echo '<span class=\"notice\">'; __('Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
echo __('Cake is NOT able to connect to the database.'); echo '</span></p>';
echo '</span>'; }
endif; ?>\n";
?>
</p>\n";
$output .= "<?php endif;?>\n";
$output .= "<h3><?php echo __('Editing this Page') ?></h3>\n"; $output .= "<h3><?php echo __('Editing this Page') ?></h3>\n";
$output .= "<p>\n"; $output .= "<p>\n";
$output .= "<?php\n"; $output .= "<?php\n";

View file

@ -1,9 +1,12 @@
<?php <?php
/** /**
* This file is loaded automatically by the app/webroot/index.php file after the core bootstrap.php * This file is loaded automatically by the app/webroot/index.php file after core.php
* *
* This is an application wide file to load any function that is not used within a class * This file should load/create any application wide configuration settings, such as
* define. You can also use this to include or require any files in your application. * Caching, Logging, loading additional configuration files.
*
* You should also use this file to include any files that provide global functions/constants
* that your application uses.
* *
* PHP 5 * PHP 5
* *
@ -20,6 +23,9 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
// Setup a 'default' cache configuration for use in the application.
Cache::config('default', array('engine' => 'File'));
/** /**
* The settings below can be used to set additional paths to models, views and controllers. * 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) * 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/'), * 'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),
* 'models' => array('/full/path/to/models/', '/next/full/path/to/models/'), * 'models' => array('/full/path/to/models/', '/next/full/path/to/models/'),
* 'views' => array('/full/path/to/views/', '/next/full/path/to/views/'), * '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/'), * 'datasources' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'),
* 'behaviors' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'), * 'behaviors' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'),
* 'components' => array('/full/path/to/components/', '/next/full/path/to/components/'), * 'components' => array('/full/path/to/components/', '/next/full/path/to/components/'),

View file

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

View file

@ -28,39 +28,38 @@
* You can specify multiple configurations for production, development and testing. * You can specify multiple configurations for production, development and testing.
* *
* driver => The name of a supported driver; valid options are as follows: * driver => The name of a supported driver; valid options are as follows:
* mysql - MySQL 4 & 5, * Datasabe/Mysql - MySQL 4 & 5,
* sqlite - SQLite (PHP5 only), * Datasabe/Sqlite - SQLite (PHP5 only),
* postgres - PostgreSQL 7 and higher, * Datasabe/Postgres - PostgreSQL 7 and higher,
* mssql - Microsoft SQL Server 2000 and higher, * Datasabe/Mssql - Microsoft SQL Server 2000 and higher,
* oracle - Oracle 8 and higher * Datasabe/Oracle - Oracle 8 and higher
* *
* You can add custom database drivers (or override existing drivers) by adding the * 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', * appropriate file to app/models/datasources/database. Drivers should be named 'MyDriver.php',
* where 'x' is the name of the database. *
* *
* persistent => true / false * persistent => true / false
* Determines whether or not the database should use a persistent connection * Determines whether or not the database should use a persistent connection
* *
* host => * 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 => * prefix =>
* Uses the given prefix for all the tables in this database. This setting can be overridden * 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. * on a per-table basis with the Model::$tablePrefix property.
* *
* schema => * schema =>
* For Postgresspecifies which schema you would like to use the tables in. Postgres defaults to * For Postgres specifies which schema you would like to use the tables in. Postgres defaults to 'public'.
* 'public', DB2 defaults to empty.
* *
* encoding => * encoding =>
* For MySQL, Postgres and Sqlite, specifies the character encoding to use when connecting to the * For MySQL, Postgres specifies the character encoding to use when connecting to the
* database. Uses database default. * database. Uses database default not specified.
* *
*/ */
class DATABASE_CONFIG { class DATABASE_CONFIG {
public $default = array( public $default = array(
'driver' => 'mysql', 'datasource' => 'Database/Mysql',
'persistent' => false, 'persistent' => false,
'host' => 'localhost', 'host' => 'localhost',
'login' => 'user', 'login' => 'user',
@ -70,7 +69,7 @@ class DATABASE_CONFIG {
); );
public $test = array( public $test = array(
'driver' => 'mysql', 'datasource' => 'Database/Mysql',
'persistent' => false, 'persistent' => false,
'host' => 'localhost', 'host' => 'localhost',
'login' => 'user', 'login' => 'user',

View file

@ -18,7 +18,7 @@
* @since CakePHP(tm) v 0.2.9 * @since CakePHP(tm) v 0.2.9
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/ */
App::uses('Helper', 'Helper'); App::uses('Helper', 'View');
/** /**
* This is a placeholder class. * This is a placeholder class.

View file

@ -49,7 +49,7 @@
* *
*/ */
if (!defined('CAKE_CORE_INCLUDE_PATH')) { 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('APP_PATH', ROOT . DS . APP_DIR . DS);
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . 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); 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; return;
} }
require LIBS . 'dispatcher.php'; require LIBS . 'Routing' . DS .'Dispatcher.php';
$Dispatcher = new Dispatcher(); $Dispatcher = new Dispatcher();
$Dispatcher->dispatch(new CakeRequest()); $Dispatcher->dispatch(new CakeRequest());

View file

@ -186,7 +186,7 @@ class SecurityComponent extends Component {
*/ */
public function startup($controller) { public function startup($controller) {
$this->request = $controller->request; $this->request = $controller->request;
$this->_action = strtolower($this->request->params['action']); $this->_action = $this->request->params['action'];
$this->_methodsRequired($controller); $this->_methodsRequired($controller);
$this->_secureRequired($controller); $this->_secureRequired($controller);
$this->_authRequired($controller); $this->_authRequired($controller);
@ -321,10 +321,10 @@ class SecurityComponent extends Component {
foreach (array('Post', 'Get', 'Put', 'Delete') as $method) { foreach (array('Post', 'Get', 'Put', 'Delete') as $method) {
$property = 'require' . $method; $property = 'require' . $method;
if (is_array($this->$property) && !empty($this->$property)) { 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 (in_array($this->_action, $require) || $this->$property == array('*')) {
if (!$this->request->is(strtolower($method))) { if (!$this->request->is($method)) {
if (!$this->blackHole($controller, strtolower($method))) { if (!$this->blackHole($controller, $method)) {
return null; return null;
} }
} }
@ -342,7 +342,7 @@ class SecurityComponent extends Component {
*/ */
protected function _secureRequired($controller) { protected function _secureRequired($controller) {
if (is_array($this->requireSecure) && !empty($this->requireSecure)) { 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 (in_array($this->_action, $requireSecure) || $this->requireSecure == array('*')) {
if (!$this->request->is('ssl')) { if (!$this->request->is('ssl')) {
@ -363,7 +363,7 @@ class SecurityComponent extends Component {
*/ */
protected function _authRequired($controller) { protected function _authRequired($controller) {
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) { 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 (in_array($this->request->params['action'], $requireAuth) || $this->requireAuth == array('*')) {
if (!isset($controller->request->data['_Token'] )) { if (!isset($controller->request->data['_Token'] )) {

View file

@ -236,14 +236,14 @@ class App {
'Model' => array('%s' . 'models' . DS), 'Model' => array('%s' . 'models' . DS),
'Model/Behavior' => array('%s' . 'models' . DS . 'behaviors' . DS), 'Model/Behavior' => array('%s' . 'models' . DS . 'behaviors' . DS),
'Model/Datasource' => array('%s' . 'models' . DS . 'datasources' . 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), 'Model/Datasource/Session' => array('%s' . 'models' . DS . 'datasources' . DS . 'session' . DS),
'Controller' => array('%s' . 'controllers' . DS), 'Controller' => array('%s' . 'controllers' . DS),
'Controller/Component' => array('%s' . 'controllers' . DS . 'components' . DS), 'Controller/Component' => array('%s' . 'controllers' . DS . 'components' . DS),
'View' => array('%s' . 'views' . DS), 'View' => array('%s' . 'views' . DS),
'View/Helper' => array('%s' . 'views' . DS . 'helpers' . DS), 'View/Helper' => array('%s' . 'views' . DS . 'helpers' . DS),
'Console' => array( 'Console' => array(
'%s' . 'console' . DS . 'shells' . DS, '%s' . 'console' . DS,
'%s' . 'vendors' . DS . 'shells' . DS, '%s' . 'vendors' . DS . 'shells' . DS,
VENDORS . 'shells' . DS VENDORS . 'shells' . DS
), ),

View file

@ -21,7 +21,7 @@
* Configuration class. Used for managing runtime configuration information. * Configuration class. Used for managing runtime configuration information.
* *
* Provides features for reading and writing to the runtime configuration, as well * 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. * for future use.
* *
* @package cake.libs * @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); 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::init();
App::build(); App::build();
if (!include(CONFIGS . 'bootstrap.php')) { 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 * 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. * 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());` * `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. * read values from a specific reader.
* @param ConfigReaderInterface $reader The reader to append. * @param ConfigReaderInterface $reader The reader to append.
* @return void * @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. * and make any future attempts to use it cause an Exception.
* *
* @param string $name Name of the reader to drop. * @param string $name Name of the reader to drop.
@ -313,7 +276,7 @@ class Configure {
* runtime configuration. You can load configuration files from plugins * runtime configuration. You can load configuration files from plugins
* by preceeding the filename with the plugin name. * 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 * 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. * 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 * These sources can either be static resources like files, or dynamic ones like
* a database, or other datasource. * a database, or other datasource.
* *
* @param string $key * @param string $key
* @return array An array of data to merge into the runtime configuration * @return array An array of data to merge into the runtime configuration
*/ */
function read($key); function read($key);

View file

@ -20,12 +20,14 @@
/** /**
* Parent class for all of the HTTP related exceptions in CakePHP. * 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. * catch blocks can be specifically typed.
* *
* @package cake.libs * @package cake.libs
*/ */
class HttpException extends RuntimeException { } if (!class_exists('HttpException')) {
class HttpException extends RuntimeException { }
}
/** /**
* Represents an HTTP 400 error. * 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. * cannot be found.
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingControllerException extends CakeException { class MissingControllerException extends CakeException {
protected $_messageTemplate = 'Controller class %s could not be found.'; protected $_messageTemplate = 'Controller class %s could not be found.';
public function __construct($message, $code = 404) { 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. * cannot be found.
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingActionException extends CakeException { class MissingActionException extends CakeException {
protected $_messageTemplate = 'Action %s::%s() could not be found.'; protected $_messageTemplate = 'Action %s::%s() could not be found.';
public function __construct($message, $code = 404) { 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 `_`. * is protected, or starts with a `_`.
* *
* @package cake.libs * @package cake.libs
*/ */
class PrivateActionException extends CakeException { class PrivateActionException extends CakeException {
protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.'; protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.';
public function __construct($message, $code = 404, Exception $previous = null) { public function __construct($message, $code = 404, Exception $previous = null) {
@ -243,7 +245,7 @@ class PrivateActionException extends CakeException {
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingComponentFileException extends CakeException { class MissingComponentFileException extends CakeException {
protected $_messageTemplate = 'Component File "%s" is missing.'; protected $_messageTemplate = 'Component File "%s" is missing.';
} }
@ -252,7 +254,7 @@ class MissingComponentFileException extends CakeException {
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingComponentClassException extends CakeException { class MissingComponentClassException extends CakeException {
protected $_messageTemplate = 'Component class "%s" is missing.'; protected $_messageTemplate = 'Component class "%s" is missing.';
} }
@ -275,7 +277,7 @@ class MissingBehaviorClassException extends CakeException { }
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingViewException extends CakeException { class MissingViewException extends CakeException {
protected $_messageTemplate = 'View file "%s" is missing.'; protected $_messageTemplate = 'View file "%s" is missing.';
} }
@ -284,7 +286,7 @@ class MissingViewException extends CakeException {
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingLayoutException extends CakeException { class MissingLayoutException extends CakeException {
protected $_messageTemplate = 'Layout file "%s" is missing.'; protected $_messageTemplate = 'Layout file "%s" is missing.';
} }
@ -293,7 +295,7 @@ class MissingLayoutException extends CakeException {
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingHelperFileException extends CakeException { class MissingHelperFileException extends CakeException {
protected $_messageTemplate = 'Helper File "%s" is missing.'; protected $_messageTemplate = 'Helper File "%s" is missing.';
} }
@ -302,7 +304,7 @@ class MissingHelperFileException extends CakeException {
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingHelperClassException extends CakeException { class MissingHelperClassException extends CakeException {
protected $_messageTemplate = 'Helper class "%s" is missing.'; protected $_messageTemplate = 'Helper class "%s" is missing.';
} }
@ -330,7 +332,7 @@ class MissingConnectionException extends CakeException {
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingTaskFileException extends CakeException { class MissingTaskFileException extends CakeException {
protected $_messageTemplate = 'Task file "%s" is missing.'; protected $_messageTemplate = 'Task file "%s" is missing.';
} }
@ -339,7 +341,7 @@ class MissingTaskFileException extends CakeException {
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingTaskClassException extends CakeException { class MissingTaskClassException extends CakeException {
protected $_messageTemplate = 'Task class "%s" is missing.'; protected $_messageTemplate = 'Task class "%s" is missing.';
} }
@ -348,7 +350,7 @@ class MissingTaskClassException extends CakeException {
* *
* @package cake.libs * @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`"; 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 * @package cake.libs
*/ */
class MissingShellClassException extends CakeException { class MissingShellClassException extends CakeException {
protected $_messageTemplate = "Shell class %s could not be loaded."; protected $_messageTemplate = "Shell class %s could not be loaded.";
} }
@ -366,7 +368,7 @@ class MissingShellClassException extends CakeException {
* *
* @package cake.libs * @package cake.libs
*/ */
class MissingShellFileException extends CakeException { class MissingShellFileException extends CakeException {
protected $_messageTemplate = "Shell file %s could not be loaded."; protected $_messageTemplate = "Shell file %s could not be loaded.";
} }
@ -479,4 +481,3 @@ class XmlException extends CakeException { }
* @package cake.libs * @package cake.libs
*/ */
class ConsoleException extends CakeException { } class ConsoleException extends CakeException { }

View file

@ -1041,6 +1041,7 @@ class FormHelper extends AppHelper {
public function radio($fieldName, $options = array(), $attributes = array()) { public function radio($fieldName, $options = array(), $attributes = array()) {
$attributes = $this->_initInputField($fieldName, $attributes); $attributes = $this->_initInputField($fieldName, $attributes);
$legend = false; $legend = false;
$disabled = array();
if (isset($attributes['legend'])) { if (isset($attributes['legend'])) {
$legend = $attributes['legend']; $legend = $attributes['legend'];
@ -1066,6 +1067,11 @@ class FormHelper extends AppHelper {
} else { } else {
$value = $this->value($fieldName); $value = $this->value($fieldName);
} }
if (isset($attributes['disabled'])) {
$disabled = $attributes['disabled'];
}
$out = array(); $out = array();
$hiddenField = isset($attributes['hiddenField']) ? $attributes['hiddenField'] : true; $hiddenField = isset($attributes['hiddenField']) ? $attributes['hiddenField'] : true;
@ -1077,6 +1083,9 @@ class FormHelper extends AppHelper {
if (isset($value) && $optValue == $value) { if (isset($value) && $optValue == $value) {
$optionsHere['checked'] = 'checked'; $optionsHere['checked'] = 'checked';
} }
if (!empty($disabled) && in_array($optValue, $disabled)) {
$optionsHere['disabled'] = true;
}
$tagName = Inflector::camelize( $tagName = Inflector::camelize(
$attributes['id'] . '_' . Inflector::slug($optValue) $attributes['id'] . '_' . Inflector::slug($optValue)
); );

View file

@ -18,7 +18,7 @@
if (Configure::read('debug') == 0): if (Configure::read('debug') == 0):
throw new NotFoundException(); throw new NotFoundException();
endif; endif;
App::import('Core', 'Debugger'); App::uses('Debugger', 'Utility');
?> ?>
<h2><?php echo __d('cake', 'Release Notes for CakePHP %s.', Configure::version()); ?></h2> <h2><?php echo __d('cake', 'Release Notes for CakePHP %s.', Configure::version()); ?></h2>
<a href="http://cakephp.org/changelogs/1.3.6"><?php __d('cake', 'Read the changelog'); ?> </a> <a href="http://cakephp.org/changelogs/1.3.6"><?php __d('cake', 'Read the changelog'); ?> </a>
@ -71,16 +71,6 @@ endif;
endif; endif;
?> ?>
</p> </p>
<?php
App::uses('Validation', 'Utility');
if (!Validation::alphaNumeric('cakephp')) {
echo '<p><span class="notice">';
__d('cake', 'PCRE has not been compiled with Unicode support.');
echo '<br/>';
__d('cake', 'Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
echo '</span></p>';
}
?>
<?php <?php
if (isset($filePresent)): if (isset($filePresent)):
App::uses('ConnectionManager', 'Model'); App::uses('ConnectionManager', 'Model');
@ -104,6 +94,16 @@ if (isset($filePresent)):
?> ?>
</p> </p>
<?php endif;?> <?php endif;?>
<?php
App::uses('Validation', 'Utility');
if (!Validation::alphaNumeric('cakephp')) {
echo '<p><span class="notice">';
__('PCRE has not been compiled with Unicode support.');
echo '<br/>';
__('Recompile PCRE with Unicode support by adding <code>--enable-unicode-properties</code> when configuring');
echo '</span></p>';
}
?>
<h3><?php echo __d('cake', 'Editing this Page'); ?></h3> <h3><?php echo __d('cake', 'Editing this Page'); ?></h3>
<p> <p>
<?php <?php
@ -168,4 +168,4 @@ You can also add some CSS styles for your pages at: APP/webroot/css.');
<ul><li><?php echo __d('cake', 'Recommended Software Books'); ?></li></ul></li> <ul><li><?php echo __d('cake', 'Recommended Software Books'); ?></li></ul></li>
<li><a href="http://www.cafepress.com/cakefoundation"><?php echo __d('cake', 'CakePHP gear'); ?> </a> <li><a href="http://www.cafepress.com/cakefoundation"><?php echo __d('cake', 'CakePHP gear'); ?> </a>
<ul><li><?php echo __d('cake', 'Get your own CakePHP gear - Doughnate to Cake'); ?></li></ul></li> <ul><li><?php echo __d('cake', 'Get your own CakePHP gear - Doughnate to Cake'); ?></li></ul></li>
</ul> </ul>

View file

@ -299,7 +299,7 @@ class ControllerTaskTest extends CakeTestCase {
$components = array('Acl', 'Auth'); $components = array('Acl', 'Auth');
$uses = array('Comment', 'User'); $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( $this->Task->expects($this->at(1))->method('createFile')->with(
$path, $path,
@ -313,7 +313,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->bake('Articles', '--actions--', array(), array(), array()); $this->Task->bake('Articles', '--actions--', array(), array(), array());
$this->Task->plugin = 'controllerTest'; $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->Task->bake('Articles', '--actions--', array(), array(), array());
$this->assertEqual($this->Task->Template->templateVars['plugin'], 'ControllerTest'); $this->assertEqual($this->Task->Template->templateVars['plugin'], 'ControllerTest');
@ -442,7 +442,7 @@ class ControllerTaskTest extends CakeTestCase {
'y' // looks good? 'y' // looks good?
)); ));
$filename = '/my/path/bake_articles_controller.php'; $filename = '/my/path/BakeArticlesController.php';
$this->Task->expects($this->once())->method('createFile')->with( $this->Task->expects($this->once())->method('createFile')->with(
$filename, $filename,
new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/') new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/')
@ -482,7 +482,7 @@ class ControllerTaskTest extends CakeTestCase {
->method('getPrefix') ->method('getPrefix')
->will($this->returnValue('admin_')); ->will($this->returnValue('admin_'));
$filename = '/my/path/bake_articles_controller.php'; $filename = '/my/path/BakeArticlesController.php';
$this->Task->expects($this->once())->method('createFile')->with( $this->Task->expects($this->once())->method('createFile')->with(
$filename, $filename,
new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/') 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->expects($this->any())->method('_checkUnitTest')->will($this->returnValue(true));
$this->Task->Test->expects($this->once())->method('bake'); $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( $this->Task->expects($this->once())->method('createFile')->with(
$filename, $filename,
new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/') new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesController/')
@ -534,7 +534,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->path = '/my/path/'; $this->Task->path = '/my/path/';
$this->Task->args = array('BakeArticles'); $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( $this->Task->expects($this->once())->method('createFile')->with(
$filename, $filename,
new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/') new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/')
@ -568,7 +568,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->path = '/my/path/'; $this->Task->path = '/my/path/';
$this->Task->args = array($name); $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( $this->Task->expects($this->once())->method('createFile')->with(
$filename, new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/') $filename, new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/')
); );
@ -589,7 +589,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->args = array('BakeArticles'); $this->Task->args = array('BakeArticles');
$this->Task->params = array('public' => true); $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/')); $expected = new PHPUnit_Framework_Constraint_Not(new PHPUnit_Framework_Constraint_PCREMatch('/\$scaffold/'));
$this->Task->expects($this->once())->method('createFile')->with( $this->Task->expects($this->once())->method('createFile')->with(
$filename, $expected $filename, $expected
@ -612,7 +612,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->args = array('BakeArticles'); $this->Task->args = array('BakeArticles');
$this->Task->params = array('public' => true, 'admin' => true); $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( $this->Task->expects($this->once())->method('createFile')->with(
$filename, new PHPUnit_Framework_Constraint_PCREMatch('/admin_index/') $filename, new PHPUnit_Framework_Constraint_PCREMatch('/admin_index/')
); );
@ -634,7 +634,7 @@ class ControllerTaskTest extends CakeTestCase {
$this->Task->args = array('BakeArticles'); $this->Task->args = array('BakeArticles');
$this->Task->params = array('admin' => true); $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( $this->Task->expects($this->once())->method('createFile')->with(
$filename, new PHPUnit_Framework_Constraint_PCREMatch('/admin_index/') $filename, new PHPUnit_Framework_Constraint_PCREMatch('/admin_index/')
); );

View file

@ -745,7 +745,7 @@ STRINGEND;
public function testBakeWithPlugin() { public function testBakeWithPlugin() {
$this->Task->plugin = 'controllerTest'; $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') $this->Task->expects($this->once())->method('createFile')
->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/BakeArticle extends ControllerTestAppModel/')); ->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/BakeArticle extends ControllerTestAppModel/'));
@ -763,8 +763,8 @@ STRINGEND;
public function testExecuteWithNamedModel() { public function testExecuteWithNamedModel() {
$this->Task->connection = 'test'; $this->Task->connection = 'test';
$this->Task->path = '/my/path/'; $this->Task->path = '/my/path/';
$this->Task->args = array('bake_article'); $this->Task->args = array('BakeArticle');
$filename = '/my/path/bake_article.php'; $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
$this->Task->expects($this->once())->method('createFile') $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->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
$this->Task->args = array($name); $this->Task->args = array($name);
$filename = '/my/path/bake_article.php'; $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->at(0))->method('createFile') $this->Task->expects($this->at(0))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle extends AppModel/')); ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle extends AppModel/'));
@ -814,8 +814,8 @@ STRINGEND;
public function testExecuteWithNamedModelHasManyCreated() { public function testExecuteWithNamedModelHasManyCreated() {
$this->Task->connection = 'test'; $this->Task->connection = 'test';
$this->Task->path = '/my/path/'; $this->Task->path = '/my/path/';
$this->Task->args = array('bake_article'); $this->Task->args = array('BakeArticle');
$filename = '/my/path/bake_article.php'; $filename = '/my/path/BakeArticle.php';
$this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1));
$this->Task->expects($this->at(0))->method('createFile') $this->Task->expects($this->at(0))->method('createFile')
@ -843,23 +843,23 @@ STRINGEND;
$this->Task->Fixture->expects($this->exactly(5))->method('bake'); $this->Task->Fixture->expects($this->exactly(5))->method('bake');
$this->Task->Test->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') $this->Task->expects($this->at(1))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/')); ->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') $this->Task->expects($this->at(2))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesBakeTag/')); ->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') $this->Task->expects($this->at(3))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeComment/')); ->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)) $this->Task->expects($this->at(4))
->method('createFile')->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeTag/')); ->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') $this->Task->expects($this->at(5))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/')); ->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->Fixture->expects($this->exactly(4))->method('bake');
$this->Task->Test->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') $this->Task->expects($this->at(1))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/')); ->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') $this->Task->expects($this->at(2))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticlesBakeTag/')); ->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') $this->Task->expects($this->at(3))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeComment/')); ->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') $this->Task->expects($this->at(4))->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/')); ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class CategoryThread/'));
@ -939,7 +939,7 @@ STRINGEND;
$this->Task->Test->expects($this->once())->method('bake'); $this->Task->Test->expects($this->once())->method('bake');
$this->Task->Fixture->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') $this->Task->expects($this->once())->method('createFile')
->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/')); ->with($filename, new PHPUnit_Framework_Constraint_PCREMatch('/class BakeArticle/'));

View file

@ -437,7 +437,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->bake('Model', 'TestTaskArticle'); $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('class TestTaskArticleTestCase extends CakeTestCase', $result);
$this->assertContains('function setUp()', $result); $this->assertContains('function setUp()', $result);
@ -468,7 +468,7 @@ class TestTaskTest extends CakeTestCase {
$result = $this->Task->bake('Controller', 'TestTaskComments'); $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 TestTaskCommentsControllerTestCase extends CakeTestCase', $result);
$this->assertContains('class TestTestTaskCommentsController extends TestTaskCommentsController', $result); $this->assertContains('class TestTestTaskCommentsController extends TestTaskCommentsController', $result);

View file

@ -307,7 +307,7 @@ class CacheTest extends CakeTestCase {
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS) 'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true); ), true);
Cache::config('test_trigger', array('engine' => 'TestAppCache')); Cache::config('test_trigger', array('engine' => 'TestAppCache', 'prefix' => ''));
try { try {
Cache::write('fail', 'value', 'test_trigger'); Cache::write('fail', 'value', 'test_trigger');
$this->fail('No exception thrown'); $this->fail('No exception thrown');

View file

@ -41,10 +41,9 @@ class FileEngineTest extends CakeTestCase {
* @return void * @return void
*/ */
function setUp() { function setUp() {
$this->_cacheDisable = Configure::read('Cache.disable'); parent::setUp();
$this->_cacheConfig = Cache::config('default');
Configure::write('Cache.disable', false); 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 * @return void
*/ */
function tearDown() { function tearDown() {
Cache::clear(false, 'default'); parent::tearDown();
Configure::write('Cache.disable', $this->_cacheDisable); Cache::clear(false, 'file_test');
Cache::config('default', $this->_cacheConfig['settings']); Cache::drop('file_test');
} }
/** /**
@ -83,24 +82,24 @@ class FileEngineTest extends CakeTestCase {
function testReadAndWriteCache() { function testReadAndWriteCache() {
Cache::config('default'); Cache::config('default');
$result = Cache::write(null, 'here'); $result = Cache::write(null, 'here', 'file_test');
$this->assertFalse($result); $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 = ''; $expecting = '';
$this->assertEqual($result, $expecting); $this->assertEqual($result, $expecting);
$data = 'this is a test of the emergency broadcasting system'; $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')); $this->assertTrue(file_exists(CACHE . 'cake_test'));
$result = Cache::read('test'); $result = Cache::read('test', 'file_test');
$expecting = $data; $expecting = $data;
$this->assertEqual($result, $expecting); $this->assertEqual($result, $expecting);
Cache::delete('test'); Cache::delete('test', 'file_test');
} }
/** /**
@ -110,27 +109,27 @@ class FileEngineTest extends CakeTestCase {
* @return void * @return void
*/ */
function testExpiry() { 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); $this->assertFalse($result);
$data = 'this is a test of the emergency broadcasting system'; $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); $this->assertTrue($result);
sleep(2); sleep(2);
$result = Cache::read('other_test'); $result = Cache::read('other_test', 'file_test');
$this->assertFalse($result); $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'; $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); $this->assertTrue($result);
sleep(2); sleep(2);
$result = Cache::read('other_test'); $result = Cache::read('other_test', 'file_test');
$this->assertFalse($result); $this->assertFalse($result);
} }
@ -142,14 +141,14 @@ class FileEngineTest extends CakeTestCase {
*/ */
function testDeleteCache() { function testDeleteCache() {
$data = 'this is a test of the emergency broadcasting system'; $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); $this->assertTrue($result);
$result = Cache::delete('delete_test'); $result = Cache::delete('delete_test', 'file_test');
$this->assertTrue($result); $this->assertTrue($result);
$this->assertFalse(file_exists(TMP . 'tests' . DS . 'delete_test')); $this->assertFalse(file_exists(TMP . 'tests' . DS . 'delete_test'));
$result = Cache::delete('delete_test'); $result = Cache::delete('delete_test', 'file_test');
$this->assertFalse($result); $this->assertFalse($result);
} }
@ -160,17 +159,17 @@ class FileEngineTest extends CakeTestCase {
* @return void * @return void
*/ */
function testSerialize() { 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'; $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); $this->assertTrue($write);
Cache::config('default', array('serialize' => false)); Cache::config('file_test', array('serialize' => false));
$read = Cache::read('serialize_test'); $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)); $this->assertIdentical($read, serialize($data));
@ -184,91 +183,35 @@ class FileEngineTest extends CakeTestCase {
* @return void * @return void
*/ */
function testClear() { 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'; $data = 'this is a test of the emergency broadcasting system';
$write = Cache::write('serialize_test1', $data); $write = Cache::write('serialize_test1', $data, 'file_test');
$write = Cache::write('serialize_test2', $data); $write = Cache::write('serialize_test2', $data, 'file_test');
$write = Cache::write('serialize_test3', $data); $write = Cache::write('serialize_test3', $data, 'file_test');
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test1')); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test1'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test2')); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test2'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test3')); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test3'));
sleep(2); sleep(2);
$result = Cache::clear(true); $result = Cache::clear(true, 'file_test');
$this->assertTrue($result); $this->assertTrue($result);
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test1')); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test1'));
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test2')); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test2'));
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test3')); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test3'));
$data = 'this is a test of the emergency broadcasting system'; $data = 'this is a test of the emergency broadcasting system';
$write = Cache::write('serialize_test1', $data); $write = Cache::write('serialize_test1', $data, 'file_test');
$write = Cache::write('serialize_test2', $data); $write = Cache::write('serialize_test2', $data, 'file_test');
$write = Cache::write('serialize_test3', $data); $write = Cache::write('serialize_test3', $data, 'file_test');
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test1')); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test1'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test2')); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test2'));
$this->assertTrue(file_exists(CACHE . 'cake_serialize_test3')); $this->assertTrue(file_exists(CACHE . 'cake_serialize_test3'));
$result = Cache::clear(); $result = Cache::clear(false, 'file_test');
$this->assertTrue($result); $this->assertTrue($result);
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test1')); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test1'));
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test2')); $this->assertFalse(file_exists(CACHE . 'cake_serialize_test2'));
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test3')); $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'; $data1 = $data2 = $expected = 'content to cache';
$FileOne->write('key_one', $data1, DAY); $FileOne->write('prefix_one_key_one', $data1, DAY);
$FileTwo->write('key_two', $data2, DAY); $FileTwo->write('prefix_two_key_two', $data2, DAY);
$this->assertEqual($FileOne->read('key_one'), $expected); $this->assertEqual($FileOne->read('prefix_one_key_one'), $expected);
$this->assertEqual($FileTwo->read('key_two'), $expected); $this->assertEqual($FileTwo->read('prefix_two_key_two'), $expected);
$FileOne->clear(false); $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 * @return void
*/ */
function testKeyPath() { function testKeyPath() {
$result = Cache::write('views.countries.something', 'here'); $result = Cache::write('views.countries.something', 'here', 'file_test');
$this->assertTrue($result); $this->assertTrue($result);
$this->assertTrue(file_exists(CACHE . 'cake_views_countries_something')); $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'); $this->assertEqual($result, 'here');
$result = Cache::clear(); $result = Cache::clear();
@ -370,16 +314,16 @@ class FileEngineTest extends CakeTestCase {
* @return void * @return void
*/ */
function testWriteQuotedString() { function testWriteQuotedString() {
Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests')); Cache::config('file_test', array('engine' => 'File', 'path' => TMP . 'tests'));
Cache::write('App.doubleQuoteTest', '"this is a quoted string"'); Cache::write('App.doubleQuoteTest', '"this is a quoted string"', 'file_test');
$this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"'); $this->assertIdentical(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"');
Cache::write('App.singleQuoteTest', "'this is a quoted string'"); Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test');
$this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'"); $this->assertIdentical(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'");
Cache::config('default', array('isWindows' => true, 'path' => TMP . 'tests')); Cache::config('file_test', array('isWindows' => true, 'path' => TMP . 'tests'));
$this->assertIdentical(Cache::read('App.doubleQuoteTest'), '"this is a quoted string"'); $this->assertIdentical(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"');
Cache::write('App.singleQuoteTest', "'this is a quoted string'"); Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test');
$this->assertIdentical(Cache::read('App.singleQuoteTest'), "'this is a quoted string'"); $this->assertIdentical(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'");
} }
/** /**

View file

@ -3018,6 +3018,35 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected); $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 * test disabling the hidden input for radio buttons
* *

View file

@ -19,7 +19,7 @@
class TestAppCacheEngine extends CacheEngine { class TestAppCacheEngine extends CacheEngine {
public function write($key, $value, $duration) { public function write($key, $value, $duration) {
if ($key = 'fail') { if ($key == 'fail') {
return false; return false;
} }
} }

View file

@ -0,0 +1,19 @@
<?php
/**
* Test Suite TestUtilityClass Library
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* 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 {}

View file

@ -0,0 +1,19 @@
<?php
/**
* Test Suite CustomLibClass Library
*
* PHP 5
*
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
* 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 {}