mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
commit
39c7d03319
42 changed files with 388 additions and 307 deletions
|
@ -1,9 +1,12 @@
|
|||
<?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
|
||||
* define. You can also use this to include or require any files in your application.
|
||||
* This file should load/create any application wide configuration settings, such as
|
||||
* 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
|
||||
*
|
||||
|
@ -20,6 +23,9 @@
|
|||
* @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.
|
||||
* This is related to Ticket #470 (https://trac.cakephp.org/ticket/470)
|
||||
|
|
|
@ -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
|
||||
));
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -75,6 +75,6 @@
|
|||
return;
|
||||
}
|
||||
|
||||
require LIBS . 'Routing' . DS .'Dispatcher.php';
|
||||
App::uses('Dispatcher', 'Routing');
|
||||
$Dispatcher = new Dispatcher();
|
||||
$Dispatcher->dispatch(new CakeRequest());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<?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
|
||||
*
|
||||
|
@ -13,7 +16,6 @@
|
|||
*
|
||||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake.libs.cache
|
||||
* @since CakePHP(tm) v 1.2.0.4933
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
@ -21,7 +23,6 @@
|
|||
/**
|
||||
* File Storage engine for cache
|
||||
*
|
||||
* @todo use the File and Folder classes (if it's not a too big performance hit)
|
||||
* @package cake.libs.cache
|
||||
*/
|
||||
class FileEngine extends CacheEngine {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
/**
|
||||
* 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
|
||||
* will inherit them.
|
||||
|
|
|
@ -143,10 +143,9 @@ class ControllerTask extends BakeTask {
|
|||
$useDynamicScaffold = 'n';
|
||||
$wannaBakeCrud = 'y';
|
||||
|
||||
$controllerFile = strtolower(Inflector::underscore($controllerName));
|
||||
|
||||
$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);
|
||||
}
|
||||
$doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y');
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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,6 +379,7 @@ 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.')
|
||||
));
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
echo "<?php\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'): ?>
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
$output = "<h2>Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP!</h2>\n";
|
||||
$output .="
|
||||
<?php
|
||||
App::import('Core', 'Debugger');
|
||||
App::uses('Debugger', 'Utility');
|
||||
if (Configure::read() > 0):
|
||||
Debugger::checkSecurityKeys();
|
||||
endif;
|
||||
|
@ -52,27 +52,38 @@ endif;
|
|||
?>
|
||||
</p>
|
||||
<?php
|
||||
if (!empty(\$filePresent)):
|
||||
if (!class_exists('ConnectionManager')) {
|
||||
require LIBS . 'model' . DS . 'connection_manager.php';
|
||||
if (isset(\$filePresent)):
|
||||
App::uses('ConnectionManager', 'Model');
|
||||
try {
|
||||
\$connected = ConnectionManager::getDataSource('default');
|
||||
} catch (Exception \$e) {
|
||||
\$connected = false;
|
||||
}
|
||||
\$db = ConnectionManager::getInstance();
|
||||
\$connected = \$db->getDataSource('default');
|
||||
?>
|
||||
<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
|
||||
if (\$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>\n";
|
||||
$output .= "<?php endif;?>\n";
|
||||
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>';
|
||||
}
|
||||
?>\n";
|
||||
$output .= "<h3><?php echo __('Editing this Page') ?></h3>\n";
|
||||
$output .= "<p>\n";
|
||||
$output .= "<?php\n";
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<?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
|
||||
* define. You can also use this to include or require any files in your application.
|
||||
* This file should load/create any application wide configuration settings, such as
|
||||
* 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
|
||||
*
|
||||
|
@ -20,6 +23,9 @@
|
|||
* @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.
|
||||
* 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/'),
|
||||
|
|
|
@ -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
|
||||
));
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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.
|
|
@ -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());
|
||||
|
|
|
@ -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'] )) {
|
||||
|
|
|
@ -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
|
||||
),
|
||||
|
|
|
@ -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')) {
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
*
|
||||
* @package cake.libs
|
||||
*/
|
||||
class HttpException extends RuntimeException { }
|
||||
if (!class_exists('HttpException')) {
|
||||
class HttpException extends RuntimeException { }
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an HTTP 400 error.
|
||||
|
@ -479,4 +481,3 @@ class XmlException extends CakeException { }
|
|||
* @package cake.libs
|
||||
*/
|
||||
class ConsoleException extends CakeException { }
|
||||
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
if (Configure::read('debug') == 0):
|
||||
throw new NotFoundException();
|
||||
endif;
|
||||
App::import('Core', 'Debugger');
|
||||
App::uses('Debugger', 'Utility');
|
||||
?>
|
||||
<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>
|
||||
|
@ -71,16 +71,6 @@ endif;
|
|||
endif;
|
||||
?>
|
||||
</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
|
||||
if (isset($filePresent)):
|
||||
App::uses('ConnectionManager', 'Model');
|
||||
|
@ -104,6 +94,16 @@ if (isset($filePresent)):
|
|||
?>
|
||||
</p>
|
||||
<?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>
|
||||
<p>
|
||||
<?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/')
|
||||
);
|
||||
|
|
|
@ -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/'));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
|
|
164
lib/Cake/tests/cases/libs/cache/file.test.php
vendored
164
lib/Cake/tests/cases/libs/cache/file.test.php
vendored
|
@ -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'");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
class TestAppCacheEngine extends CacheEngine {
|
||||
|
||||
public function write($key, $value, $duration) {
|
||||
if ($key = 'fail') {
|
||||
if ($key == 'fail') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
19
lib/Cake/tests/test_app/libs/Utility/TestUtilityClass.php
Normal file
19
lib/Cake/tests/test_app/libs/Utility/TestUtilityClass.php
Normal 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 {}
|
|
@ -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 {}
|
Loading…
Reference in a new issue