mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '1.3-misc' into 1.3-merger
Conflicts: cake/libs/view/helpers/html.php
This commit is contained in:
commit
8cdee90b4f
22 changed files with 418 additions and 372 deletions
|
@ -149,6 +149,9 @@ class ProjectTask extends Shell {
|
|||
$verbose = $this->in(__('Do you want verbose output?', true), array('y', 'n'), 'n');
|
||||
|
||||
$Folder = new Folder($skel);
|
||||
if (!empty($this->params['empty'])) {
|
||||
$skip = array();
|
||||
}
|
||||
if ($Folder->copy(array('to' => $path, 'skip' => $skip))) {
|
||||
$this->hr();
|
||||
$this->out(sprintf(__("Created: %s in %s", true), $app, $path));
|
||||
|
|
0
cake/console/templates/skel/libs/empty
Normal file
0
cake/console/templates/skel/libs/empty
Normal file
|
@ -27,16 +27,10 @@
|
|||
*/
|
||||
class Cache {
|
||||
|
||||
/**
|
||||
* Cache engine to use
|
||||
*
|
||||
* @var CacheEngine
|
||||
* @access protected
|
||||
*/
|
||||
var $_Engine = null;
|
||||
|
||||
/**
|
||||
* Cache configuration stack
|
||||
* Keeps the permanent/default settings for each cache engine.
|
||||
* These settings are used to reset the engines after temporary modification.
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
|
@ -44,7 +38,7 @@ class Cache {
|
|||
var $__config = array();
|
||||
|
||||
/**
|
||||
* Holds name of the current configuration being used
|
||||
* Holds name of the current configuration name being used.
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
|
@ -52,13 +46,20 @@ class Cache {
|
|||
var $__name = 'default';
|
||||
|
||||
/**
|
||||
* whether to reset the settings with the next call to self::set();
|
||||
* Whether to reset the settings with the next call to Cache::set();
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $__reset = false;
|
||||
|
||||
/**
|
||||
* Engine instances keyed by configuration name.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $_engines = array();
|
||||
|
||||
/**
|
||||
* Returns a singleton instance
|
||||
*
|
||||
|
@ -75,7 +76,18 @@ class Cache {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the cache configuration to use
|
||||
* Set the cache configuration to use. config() can
|
||||
* both create new configurations, return the settings for already configured
|
||||
* configurations. It also sets the 'default' configuration to use for subsequent
|
||||
* operations.
|
||||
*
|
||||
* To create a new configuration:
|
||||
*
|
||||
* `Cache::config('my_config', array('engine' => 'File', 'path' => TMP));`
|
||||
*
|
||||
* To get the settings for a configuration, and set it as the currently selected configuration
|
||||
*
|
||||
* `Cache::config('default');`
|
||||
*
|
||||
* @see app/config/core.php for configuration settings
|
||||
* @param string $name Name of the configuration
|
||||
|
@ -85,51 +97,74 @@ class Cache {
|
|||
* @static
|
||||
*/
|
||||
function config($name = null, $settings = array()) {
|
||||
$_this =& Cache::getInstance();
|
||||
$self =& Cache::getInstance();
|
||||
if (is_array($name)) {
|
||||
$settings = $name;
|
||||
}
|
||||
|
||||
if ($name === null || !is_string($name)) {
|
||||
$name = $_this->__name;
|
||||
$name = $self->__name;
|
||||
}
|
||||
|
||||
$current = array();
|
||||
if (isset($_this->__config[$name])) {
|
||||
$current = $_this->__config[$name];
|
||||
if (isset($self->__config[$name])) {
|
||||
$current = $self->__config[$name];
|
||||
}
|
||||
|
||||
if (!empty($settings)) {
|
||||
$_this->__name = null;
|
||||
$_this->__config[$name] = array_merge($current, $settings);
|
||||
$self->__config[$name] = array_merge($current, $settings);
|
||||
}
|
||||
|
||||
if (empty($_this->__config[$name]['engine'])) {
|
||||
if (empty($self->__config[$name]['engine'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$_this->__name = $name;
|
||||
$engine = $_this->__config[$name]['engine'];
|
||||
$self->__name = $name;
|
||||
$engine = $self->__config[$name]['engine'];
|
||||
|
||||
if (!$_this->isInitialized($engine)) {
|
||||
if ($_this->engine($engine, $_this->__config[$name]) === false) {
|
||||
return false;
|
||||
}
|
||||
$settings = $_this->__config[$name] = $_this->settings($engine);
|
||||
} else if ($settings = $_this->set($_this->__config[$name])) {
|
||||
$_this->__config[$name] = $settings;
|
||||
if (!isset($self->_engines[$name])) {
|
||||
$self->_buildEngine($name);
|
||||
$settings = $self->__config[$name] = $self->settings($name);
|
||||
} elseif ($settings = $self->set($self->__config[$name])) {
|
||||
$self->__config[$name] = $settings;
|
||||
}
|
||||
return compact('engine', 'settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and builds the instance of the required engine class.
|
||||
*
|
||||
* @param string $name Name of the config array that needs an engine instance built
|
||||
* @return void
|
||||
* @access protected
|
||||
*/
|
||||
function _buildEngine($name) {
|
||||
$config = $this->__config[$name];
|
||||
|
||||
list($plugin, $class) = pluginSplit($config['engine']);
|
||||
$cacheClass = $class . 'Engine';
|
||||
if (!class_exists($cacheClass) && $this->__loadEngine($class, $plugin) === false) {
|
||||
return false;
|
||||
}
|
||||
$cacheClass = $class . 'Engine';
|
||||
$this->_engines[$name] =& new $cacheClass();
|
||||
if ($this->_engines[$name]->init($config)) {
|
||||
if (time() % $this->_engines[$name]->settings['probability'] === 0) {
|
||||
$this->_engines[$name]->gc();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing the currently configured Cache settings.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function configured() {
|
||||
$_this = Cache::getInstance();
|
||||
return array_keys($_this->__config);
|
||||
$self = Cache::getInstance();
|
||||
return array_keys($self->__config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,56 +176,15 @@ class Cache {
|
|||
* @return boolen success of the removal, returns false when the config does not exist.
|
||||
*/
|
||||
function drop($name) {
|
||||
$_this = Cache::getInstance();
|
||||
if (!isset($_this->__config[$name])) {
|
||||
$self = Cache::getInstance();
|
||||
if (!isset($self->__config[$name])) {
|
||||
return false;
|
||||
}
|
||||
$last = true;
|
||||
$engine = $_this->__config[$name]['engine'];
|
||||
unset($_this->__config[$name]);
|
||||
foreach ($_this->__config as $name => $settings) {
|
||||
if ($settings['engine'] == $engine) {
|
||||
$last = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($last) {
|
||||
unset($_this->_Engine[$engine]);
|
||||
}
|
||||
unset($self->__config[$name]);
|
||||
unset($self->_engines[$name]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cache engine to use or modify settings for one instance
|
||||
*
|
||||
* @param string $name Name of the engine (without 'Engine')
|
||||
* @param array $settings Optional associative array of settings passed to the engine
|
||||
* @return boolean True on success, false on failure
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
function engine($name = 'File', $settings = array()) {
|
||||
$class = $name;
|
||||
list($plugin, $class) = pluginSplit($name);
|
||||
$cacheClass = $class . 'Engine';
|
||||
$_this =& Cache::getInstance();
|
||||
if (!isset($_this->_Engine[$name])) {
|
||||
if ($_this->__loadEngine($class, $plugin) === false) {
|
||||
return false;
|
||||
}
|
||||
$_this->_Engine[$name] =& new $cacheClass();
|
||||
}
|
||||
|
||||
if ($_this->_Engine[$name]->init($settings)) {
|
||||
if (time() % $_this->_Engine[$name]->settings['probability'] === 0) {
|
||||
$_this->_Engine[$name]->gc();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
$_this->_Engine[$name] = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to find and include a file for a cache engine and returns object instance
|
||||
*
|
||||
|
@ -200,17 +194,16 @@ class Cache {
|
|||
*/
|
||||
function __loadEngine($name, $plugin = null) {
|
||||
if ($plugin) {
|
||||
return App::import('Lib', $plugin . '.cache' . DS . $name);
|
||||
return App::import('Lib', $plugin . '.cache' . DS . $name, false);
|
||||
} else {
|
||||
$app = App::import('Lib', 'cache' . DS . $name);
|
||||
$app = App::import('Lib', 'cache' . DS . $name, false);
|
||||
if (!$app) {
|
||||
return App::import('Core', 'cache' . DS . $name);
|
||||
require LIBS . 'cache' . DS . strtolower($name) . '.php';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Temporarily change settings to current config options. if no params are passed, resets settings if needed
|
||||
* Cache::write() will reset the configuration changes made
|
||||
|
@ -222,30 +215,32 @@ class Cache {
|
|||
* @static
|
||||
*/
|
||||
function set($settings = array(), $value = null) {
|
||||
$_this =& Cache::getInstance();
|
||||
if (!isset($_this->__config[$_this->__name])) {
|
||||
$self =& Cache::getInstance();
|
||||
if (!isset($self->__config[$self->__name])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$engine = $_this->__config[$_this->__name]['engine'];
|
||||
$name = $self->__name;
|
||||
if (!empty($settings)) {
|
||||
$_this->__reset = true;
|
||||
$self->__reset = true;
|
||||
}
|
||||
|
||||
if ($_this->__reset === true) {
|
||||
if ($self->__reset === true) {
|
||||
if (empty($settings)) {
|
||||
$_this->__reset = false;
|
||||
$settings = $_this->__config[$_this->__name];
|
||||
$self->__reset = false;
|
||||
$settings = $self->__config[$name];
|
||||
} else {
|
||||
if (is_string($settings) && $value !== null) {
|
||||
$settings = array($settings => $value);
|
||||
}
|
||||
$settings = array_merge($_this->__config[$_this->__name], $settings);
|
||||
$settings = array_merge($self->__config[$self->__name], $settings);
|
||||
if (isset($settings['duration']) && !is_numeric($settings['duration'])) {
|
||||
$settings['duration'] = strtotime($settings['duration']) - time();
|
||||
}
|
||||
}
|
||||
$_this->engine($engine, $settings);
|
||||
$self->_engines[$name]->settings = $settings;
|
||||
}
|
||||
|
||||
return $_this->settings($engine);
|
||||
return $self->settings($name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,9 +253,8 @@ class Cache {
|
|||
* @static
|
||||
*/
|
||||
function gc() {
|
||||
$_this =& Cache::getInstance();
|
||||
$config = $_this->config();
|
||||
$_this->_Engine[$config['engine']]->gc();
|
||||
$self =& Cache::getInstance();
|
||||
$self->_engines[$self->__name]->gc();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -274,37 +268,27 @@ class Cache {
|
|||
* @static
|
||||
*/
|
||||
function write($key, $value, $config = null) {
|
||||
$_this =& Cache::getInstance();
|
||||
$self =& Cache::getInstance();
|
||||
|
||||
if ($config && isset($_this->__config[$config])) {
|
||||
$settings = $_this->set($_this->__config[$config]);
|
||||
} else {
|
||||
$settings = $_this->settings();
|
||||
if (!$config) {
|
||||
$config = $self->__name;
|
||||
}
|
||||
$settings = $self->settings($config);
|
||||
|
||||
if (empty($settings)) {
|
||||
return null;
|
||||
}
|
||||
extract($settings);
|
||||
if (!$self->isInitialized($config)) {
|
||||
return false;
|
||||
}
|
||||
$key = $self->_engines[$config]->key($key);
|
||||
|
||||
if (!$_this->isInitialized($engine)) {
|
||||
if (!$key || is_resource($value) || $settings['duration'] < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$key = $_this->_Engine[$engine]->key($key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_resource($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($duration < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$success = $_this->_Engine[$engine]->write($settings['prefix'] . $key, $value, $duration);
|
||||
$settings = $_this->set();
|
||||
$success = $self->_engines[$config]->write($settings['prefix'] . $key, $value, $settings['duration']);
|
||||
$self->set();
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
@ -318,29 +302,27 @@ class Cache {
|
|||
* @static
|
||||
*/
|
||||
function read($key, $config = null) {
|
||||
$_this =& Cache::getInstance();
|
||||
$self =& Cache::getInstance();
|
||||
|
||||
if (isset($_this->__config[$config])) {
|
||||
$settings = $_this->set($_this->__config[$config]);
|
||||
} else {
|
||||
$settings = $_this->settings();
|
||||
if (!$config) {
|
||||
$config = $self->__name;
|
||||
}
|
||||
$settings = $self->settings($config);
|
||||
|
||||
if (empty($settings)) {
|
||||
return null;
|
||||
}
|
||||
extract($settings);
|
||||
|
||||
if (!$_this->isInitialized($engine)) {
|
||||
if (!$self->isInitialized($config)) {
|
||||
return false;
|
||||
}
|
||||
if (!$key = $_this->_Engine[$engine]->key($key)) {
|
||||
$key = $self->_engines[$config]->key($key);
|
||||
if (!$key) {
|
||||
return false;
|
||||
}
|
||||
$success = $_this->_Engine[$engine]->read($settings['prefix'] . $key);
|
||||
$success = $self->_engines[$config]->read($settings['prefix'] . $key);
|
||||
|
||||
if ($config !== null && $config !== $_this->__name) {
|
||||
$settings = $_this->set();
|
||||
if ($config !== null && $config !== $self->__name) {
|
||||
$self->set();
|
||||
}
|
||||
return $success;
|
||||
}
|
||||
|
@ -355,28 +337,25 @@ class Cache {
|
|||
* @static
|
||||
*/
|
||||
function delete($key, $config = null) {
|
||||
$_this =& Cache::getInstance();
|
||||
if (isset($_this->__config[$config])) {
|
||||
$settings = $_this->set($_this->__config[$config]);
|
||||
} else {
|
||||
$settings = $_this->settings();
|
||||
$self =& Cache::getInstance();
|
||||
if (!$config) {
|
||||
$config = $self->__name;
|
||||
}
|
||||
$settings = $self->settings($config);
|
||||
|
||||
if (empty($settings)) {
|
||||
return null;
|
||||
}
|
||||
extract($settings);
|
||||
|
||||
if (!$_this->isInitialized($engine)) {
|
||||
if (!$self->isInitialized($config)) {
|
||||
return false;
|
||||
}
|
||||
$key = $self->_engines[$config]->key($key);
|
||||
if (!$key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$key = $_this->_Engine[$engine]->key($key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$success = $_this->_Engine[$engine]->delete($settings['prefix'] . $key);
|
||||
$settings = $_this->set();
|
||||
$success = $self->_engines[$config]->delete($settings['prefix'] . $key);
|
||||
$self->set();
|
||||
return $success;
|
||||
}
|
||||
|
||||
|
@ -390,28 +369,26 @@ class Cache {
|
|||
* @static
|
||||
*/
|
||||
function clear($check = false, $config = null) {
|
||||
$_this =& Cache::getInstance();
|
||||
if (isset($_this->__config[$config])) {
|
||||
$settings = $_this->set($_this->__config[$config]);
|
||||
} else {
|
||||
$settings = $_this->settings();
|
||||
$self =& Cache::getInstance();
|
||||
if (!$config) {
|
||||
$config = $self->__name;
|
||||
}
|
||||
$settings = $self->settings($config);
|
||||
|
||||
if (empty($settings)) {
|
||||
return null;
|
||||
}
|
||||
extract($settings);
|
||||
|
||||
if (isset($engine) && !$_this->isInitialized($engine)) {
|
||||
if (!$self->isInitialized($config)) {
|
||||
return false;
|
||||
}
|
||||
$success = $_this->_Engine[$engine]->clear($check);
|
||||
$settings = $_this->set();
|
||||
$success = $self->_engines[$config]->clear($check);
|
||||
$self->set();
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Cache has initialized a working storage engine
|
||||
* Check if Cache has initialized a working config for the given name.
|
||||
*
|
||||
* @param string $engine Name of the engine
|
||||
* @param string $config Name of the configuration setting
|
||||
|
@ -419,33 +396,35 @@ class Cache {
|
|||
* @access public
|
||||
* @static
|
||||
*/
|
||||
function isInitialized($engine = null) {
|
||||
function isInitialized($name = null) {
|
||||
if (Configure::read('Cache.disable')) {
|
||||
return false;
|
||||
}
|
||||
$_this =& Cache::getInstance();
|
||||
if (!$engine && isset($_this->__config[$_this->__name]['engine'])) {
|
||||
$engine = $_this->__config[$_this->__name]['engine'];
|
||||
$self =& Cache::getInstance();
|
||||
if (!$name && isset($self->__config[$self->__name])) {
|
||||
$name = $self->__name;
|
||||
}
|
||||
return isset($_this->_Engine[$engine]);
|
||||
return isset($self->_engines[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the settings for current cache engine
|
||||
* Return the settings for current cache engine. If no name is supplied the settings
|
||||
* for the 'active default' configuration will be returned. To set the 'active default'
|
||||
* configuration use `Cache::config()`
|
||||
*
|
||||
* @param string $engine Name of the engine
|
||||
* @param string $engine Name of the configuration to get settings for.
|
||||
* @return array list of settings for this engine
|
||||
* @see Cache::config()
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
function settings($engine = null) {
|
||||
$_this =& Cache::getInstance();
|
||||
if (!$engine && isset($_this->__config[$_this->__name]['engine'])) {
|
||||
$engine = $_this->__config[$_this->__name]['engine'];
|
||||
function settings($name = null) {
|
||||
$self =& Cache::getInstance();
|
||||
if (!$name && isset($self->__config[$self->__name])) {
|
||||
$name = $self->__name;
|
||||
}
|
||||
|
||||
if (isset($_this->_Engine[$engine]) && !is_null($_this->_Engine[$engine])) {
|
||||
return $_this->_Engine[$engine]->settings();
|
||||
if (!empty($self->_engines[$name])) {
|
||||
return $self->_engines[$name]->settings();
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
|
11
cake/libs/cache/file.php
vendored
11
cake/libs/cache/file.php
vendored
|
@ -37,11 +37,12 @@ class FileEngine extends CacheEngine {
|
|||
var $__File = null;
|
||||
|
||||
/**
|
||||
* settings
|
||||
* path = absolute path to cache directory, default => CACHE
|
||||
* prefix = string prefix for filename, default => cake_
|
||||
* lock = enable file locking on write, default => false
|
||||
* serialize = serialize the data, default => true
|
||||
* Settings
|
||||
*
|
||||
* - path = absolute path to cache directory, default => CACHE
|
||||
* - prefix = string prefix for filename, default => cake_
|
||||
* - lock = enable file locking on write, default => false
|
||||
* - serialize = serialize the data, default => true
|
||||
*
|
||||
* @var array
|
||||
* @see CacheEngine::__defaults
|
||||
|
|
5
cake/libs/cache/xcache.php
vendored
5
cake/libs/cache/xcache.php
vendored
|
@ -2,7 +2,6 @@
|
|||
/**
|
||||
* Xcache storage engine for cache.
|
||||
*
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
|
@ -68,7 +67,7 @@ class XcacheEngine extends CacheEngine {
|
|||
*/
|
||||
function write($key, &$value, $duration) {
|
||||
$expires = time() + $duration;
|
||||
xcache_set($key.'_expires', $expires, $duration);
|
||||
xcache_set($key . '_expires', $expires, $duration);
|
||||
return xcache_set($key, $value, $duration);
|
||||
}
|
||||
|
||||
|
@ -82,7 +81,7 @@ class XcacheEngine extends CacheEngine {
|
|||
function read($key) {
|
||||
if (xcache_isset($key)) {
|
||||
$time = time();
|
||||
$cachetime = intval(xcache_get($key.'_expires'));
|
||||
$cachetime = intval(xcache_get($key . '_expires'));
|
||||
if ($cachetime < $time || ($time + $this->settings['duration']) < $cachetime) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -212,11 +212,10 @@ class CakeSession extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function check($name) {
|
||||
$var = $this->__validateKeys($name);
|
||||
if (empty($var)) {
|
||||
if (empty($name)) {
|
||||
return false;
|
||||
}
|
||||
$result = Set::extract($_SESSION, $var);
|
||||
$result = Set::classicExtract($_SESSION, $name);
|
||||
return isset($result);
|
||||
}
|
||||
|
||||
|
@ -259,13 +258,11 @@ class CakeSession extends Object {
|
|||
*/
|
||||
function delete($name) {
|
||||
if ($this->check($name)) {
|
||||
if ($var = $this->__validateKeys($name)) {
|
||||
if (in_array($var, $this->watchKeys)) {
|
||||
trigger_error('Deleting session key {' . $var . '}', E_USER_NOTICE);
|
||||
}
|
||||
$this->__overwrite($_SESSION, Set::remove($_SESSION, $var));
|
||||
return ($this->check($var) == false);
|
||||
if (in_array($name, $this->watchKeys)) {
|
||||
trigger_error('Deleting session key {' . $name . '}', E_USER_NOTICE);
|
||||
}
|
||||
$this->__overwrite($_SESSION, Set::remove($_SESSION, $name));
|
||||
return ($this->check($name) == false);
|
||||
}
|
||||
$this->__setError(2, "$name doesn't exist");
|
||||
return false;
|
||||
|
@ -354,7 +351,7 @@ class CakeSession extends Object {
|
|||
if (empty($name)) {
|
||||
return false;
|
||||
}
|
||||
$result = Set::extract($_SESSION, $name);
|
||||
$result = Set::classicExtract($_SESSION, $name);
|
||||
|
||||
if (!is_null($result)) {
|
||||
return $result;
|
||||
|
@ -385,7 +382,6 @@ class CakeSession extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function watch($var) {
|
||||
$var = $this->__validateKeys($var);
|
||||
if (empty($var)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -402,7 +398,6 @@ class CakeSession extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function ignore($var) {
|
||||
$var = $this->__validateKeys($var);
|
||||
if (!in_array($var, $this->watchKeys)) {
|
||||
return;
|
||||
}
|
||||
|
@ -424,16 +419,14 @@ class CakeSession extends Object {
|
|||
* @access public
|
||||
*/
|
||||
function write($name, $value) {
|
||||
$var = $this->__validateKeys($name);
|
||||
|
||||
if (empty($var)) {
|
||||
if (empty($name)) {
|
||||
return false;
|
||||
}
|
||||
if (in_array($var, $this->watchKeys)) {
|
||||
trigger_error('Writing session key {' . $var . '}: ' . Debugger::exportVar($value), E_USER_NOTICE);
|
||||
if (in_array($name, $this->watchKeys)) {
|
||||
trigger_error('Writing session key {' . $name . '}: ' . Debugger::exportVar($value), E_USER_NOTICE);
|
||||
}
|
||||
$this->__overwrite($_SESSION, Set::insert($_SESSION, $var, $value));
|
||||
return (Set::extract($_SESSION, $var) === $value);
|
||||
$this->__overwrite($_SESSION, Set::insert($_SESSION, $name, $value));
|
||||
return (Set::classicExtract($_SESSION, $name) === $value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -676,22 +669,6 @@ class CakeSession extends Object {
|
|||
$this->__regenerateId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the $name is in correct dot notation
|
||||
* example: $name = 'ControllerName.key';
|
||||
*
|
||||
* @param string $name Session key names as string.
|
||||
* @return mixed false is $name is not correct format, or $name if it is correct
|
||||
* @access private
|
||||
*/
|
||||
function __validateKeys($name) {
|
||||
if (is_string($name) && preg_match("/^[ 0-9a-zA-Z._-]*$/", $name)) {
|
||||
return $name;
|
||||
}
|
||||
$this->__setError(3, "$name is not a string");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to set an internal error message.
|
||||
*
|
||||
|
|
|
@ -91,11 +91,21 @@ class Configure extends Object {
|
|||
if (strpos($name, '.') === false) {
|
||||
$_this->{$name} = $value;
|
||||
} else {
|
||||
$names = explode('.', $name, 2);
|
||||
if (!isset($_this->{$names[0]})) {
|
||||
$_this->{$names[0]} = array();
|
||||
$names = explode('.', $name, 4);
|
||||
switch (count($names)) {
|
||||
case 2:
|
||||
$_this->{$names[0]}[$names[1]] = $value;
|
||||
break;
|
||||
case 3:
|
||||
$_this->{$names[0]}[$names[1]][$names[2]] = $value;
|
||||
case 4:
|
||||
$names = explode('.', $name, 2);
|
||||
if (!isset($_this->{$names[0]})) {
|
||||
$_this->{$names[0]} = array();
|
||||
}
|
||||
$_this->{$names[0]} = Set::insert($_this->{$names[0]}, $names[1], $value);
|
||||
break;
|
||||
}
|
||||
$_this->{$names[0]} = Set::insert($_this->{$names[0]}, $names[1], $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,18 +159,32 @@ class Configure extends Object {
|
|||
}
|
||||
|
||||
if (strpos($var, '.') !== false) {
|
||||
$names = explode('.', $var, 2);
|
||||
$names = explode('.', $var, 3);
|
||||
$var = $names[0];
|
||||
}
|
||||
if (!isset($_this->{$var})) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!empty($names[1])) {
|
||||
return Set::extract($_this->{$var}, $names[1]);
|
||||
if (!isset($names[1])) {
|
||||
return $_this->{$var};
|
||||
}
|
||||
|
||||
return $_this->{$var};
|
||||
switch (count($names)) {
|
||||
case 2:
|
||||
if (isset($_this->{$var}[$names[1]])) {
|
||||
return $_this->{$var}[$names[1]];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (isset($_this->{$var}[$names[1]][$names[2]])) {
|
||||
return $_this->{$var}[$names[1]][$names[2]];
|
||||
}
|
||||
if (!isset($_this->{$var}[$names[1]])) {
|
||||
return null;
|
||||
}
|
||||
return Set::classicExtract($_this->{$var}[$names[1]], $names[2]);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -528,7 +528,7 @@ class AjaxHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
$attr = $this->_parseAttributes(array_merge($options, array('id' => $id)));
|
||||
return $this->output(sprintf($this->Html->tags['blockstart'], $attr));
|
||||
return sprintf($this->Html->tags['blockstart'], $attr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -547,7 +547,7 @@ class AjaxHelper extends AppHelper {
|
|||
return '';
|
||||
}
|
||||
}
|
||||
return $this->output($this->Html->tags['blockend']);
|
||||
return $this->Html->tags['blockend'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -294,7 +294,7 @@ class FormHelper extends AppHelper {
|
|||
|
||||
$this->setEntity($model . '.', true);
|
||||
$attributes = $this->_parseAttributes($htmlAttributes, null, '');
|
||||
return $this->output(sprintf($this->Html->tags['form'], $attributes)) . $append;
|
||||
return sprintf($this->Html->tags['form'], $attributes) . $append;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,7 +349,7 @@ class FormHelper extends AppHelper {
|
|||
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
$view->modelScope = false;
|
||||
return $this->output($out);
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -528,11 +528,11 @@ class FormHelper extends AppHelper {
|
|||
$labelFor = $this->domId($fieldName);
|
||||
}
|
||||
|
||||
return $this->output(sprintf(
|
||||
return sprintf(
|
||||
$this->Html->tags['label'],
|
||||
$labelFor,
|
||||
$this->_parseAttributes($options), $text
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -940,11 +940,11 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
unset($options['hiddenField']);
|
||||
|
||||
return $this->output($output . sprintf(
|
||||
return $output . sprintf(
|
||||
$this->Html->tags['checkbox'],
|
||||
$options['name'],
|
||||
$this->_parseAttributes($options, array('name'), null, ' ')
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1036,7 +1036,7 @@ class FormHelper extends AppHelper {
|
|||
sprintf($this->Html->tags['legend'], $legend) . $out
|
||||
);
|
||||
}
|
||||
return $this->output($out);
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1050,11 +1050,11 @@ class FormHelper extends AppHelper {
|
|||
$options = $this->_initInputField($fieldName, array_merge(
|
||||
array('type' => 'text'), $options
|
||||
));
|
||||
return $this->output(sprintf(
|
||||
return sprintf(
|
||||
$this->Html->tags['input'],
|
||||
$options['name'],
|
||||
$this->_parseAttributes($options, array('name'), null, ' ')
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1066,11 +1066,11 @@ class FormHelper extends AppHelper {
|
|||
*/
|
||||
function password($fieldName, $options = array()) {
|
||||
$options = $this->_initInputField($fieldName, $options);
|
||||
return $this->output(sprintf(
|
||||
return sprintf(
|
||||
$this->Html->tags['password'],
|
||||
$options['name'],
|
||||
$this->_parseAttributes($options, array('name'), null, ' ')
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1091,12 +1091,12 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
unset($options['value']);
|
||||
}
|
||||
return $this->output(sprintf(
|
||||
return sprintf(
|
||||
$this->Html->tags['textarea'],
|
||||
$options['name'],
|
||||
$this->_parseAttributes($options, array('type', 'name'), null, ' '),
|
||||
$value
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1123,11 +1123,11 @@ class FormHelper extends AppHelper {
|
|||
$this->__secure(null, '' . $options['value']);
|
||||
}
|
||||
|
||||
return $this->output(sprintf(
|
||||
return sprintf(
|
||||
$this->Html->tags['hidden'],
|
||||
$options['name'],
|
||||
$this->_parseAttributes($options, array('name', 'class'), '', ' ')
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1149,7 +1149,7 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
|
||||
$attributes = $this->_parseAttributes($options, array('name'), '', ' ');
|
||||
return $this->output(sprintf($this->Html->tags['file'], $options['name'], $attributes));
|
||||
return sprintf($this->Html->tags['file'], $options['name'], $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1169,12 +1169,12 @@ class FormHelper extends AppHelper {
|
|||
if ($options['escape']) {
|
||||
$title = h($title);
|
||||
}
|
||||
return $this->output(sprintf(
|
||||
return sprintf(
|
||||
$this->Html->tags['button'],
|
||||
$options['type'],
|
||||
$this->_parseAttributes($options, array('type'), '', ' '),
|
||||
$title
|
||||
));
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1217,11 +1217,11 @@ class FormHelper extends AppHelper {
|
|||
|
||||
if (strpos($caption, '://') !== false) {
|
||||
unset($options['type']);
|
||||
$out .= $this->output($before . sprintf(
|
||||
$out .= $before . sprintf(
|
||||
$this->Html->tags['submitimage'],
|
||||
$caption,
|
||||
$this->_parseAttributes($options, null, '', ' ')
|
||||
) . $after);
|
||||
) . $after;
|
||||
} elseif (preg_match('/\.(jpg|jpe|jpeg|gif|png|ico)$/', $caption)) {
|
||||
unset($options['type']);
|
||||
if ($caption{0} !== '/') {
|
||||
|
@ -1230,17 +1230,17 @@ class FormHelper extends AppHelper {
|
|||
$caption = trim($caption, '/');
|
||||
$url = $this->webroot($caption);
|
||||
}
|
||||
$out .= $this->output($before . sprintf(
|
||||
$out .= $before . sprintf(
|
||||
$this->Html->tags['submitimage'],
|
||||
$url,
|
||||
$this->_parseAttributes($options, null, '', ' ')
|
||||
) . $after);
|
||||
) . $after;
|
||||
} else {
|
||||
$options['value'] = $caption;
|
||||
$out .= $this->output($before . sprintf(
|
||||
$out .= $before . sprintf(
|
||||
$this->Html->tags['submit'],
|
||||
$this->_parseAttributes($options, null, '', ' ')
|
||||
). $after);
|
||||
). $after;
|
||||
}
|
||||
|
||||
if (isset($divOptions)) {
|
||||
|
@ -1347,7 +1347,7 @@ class FormHelper extends AppHelper {
|
|||
|
||||
$template = ($style == 'checkbox') ? 'checkboxmultipleend' : 'selectend';
|
||||
$select[] = $this->Html->tags[$template];
|
||||
return $this->output(implode("\n", $select));
|
||||
return implode("\n", $select);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -201,7 +201,7 @@ class HtmlHelper extends AppHelper {
|
|||
*/
|
||||
function docType($type = 'xhtml-strict') {
|
||||
if (isset($this->__docTypes[$type])) {
|
||||
return $this->output($this->__docTypes[$type]);
|
||||
return $this->__docTypes[$type];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ class HtmlHelper extends AppHelper {
|
|||
}
|
||||
|
||||
if ($inline) {
|
||||
return $this->output($out);
|
||||
return $out;
|
||||
} else {
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
$view->addScript($out);
|
||||
|
@ -288,7 +288,7 @@ class HtmlHelper extends AppHelper {
|
|||
if (empty($charset)) {
|
||||
$charset = strtolower(Configure::read('App.encoding'));
|
||||
}
|
||||
return $this->output(sprintf($this->tags['charset'], (!empty($charset) ? $charset : 'utf-8')));
|
||||
return sprintf($this->tags['charset'], (!empty($charset) ? $charset : 'utf-8'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -347,7 +347,7 @@ class HtmlHelper extends AppHelper {
|
|||
}
|
||||
unset($options['default']);
|
||||
}
|
||||
return $this->output(sprintf($this->tags['link'], $url, $this->_parseAttributes($options), $title));
|
||||
return sprintf($this->tags['link'], $url, $this->_parseAttributes($options), $title);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -408,7 +408,6 @@ class HtmlHelper extends AppHelper {
|
|||
}
|
||||
$out = sprintf($this->tags['css'], $rel, $url, $this->_parseAttributes($options, array('inline'), '', ' '));
|
||||
}
|
||||
$out = $this->output($out);
|
||||
|
||||
if ($options['inline']) {
|
||||
return $out;
|
||||
|
@ -472,7 +471,7 @@ class HtmlHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
$attributes = $this->_parseAttributes($options, array('inline', 'once'), ' ');
|
||||
$out = $this->output(sprintf($this->tags['javascriptlink'], $url, $attributes));
|
||||
$out = sprintf($this->tags['javascriptlink'], $url, $attributes);
|
||||
|
||||
if ($options['inline']) {
|
||||
return $out;
|
||||
|
@ -585,7 +584,7 @@ class HtmlHelper extends AppHelper {
|
|||
$out[] = $crumb[0];
|
||||
}
|
||||
}
|
||||
return $this->output(implode($separator, $out));
|
||||
return join($separator, $out);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -624,9 +623,9 @@ class HtmlHelper extends AppHelper {
|
|||
$image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' '));
|
||||
|
||||
if ($url) {
|
||||
return $this->output(sprintf($this->tags['link'], $this->url($url), null, $image));
|
||||
return sprintf($this->tags['link'], $this->url($url), null, $image);
|
||||
}
|
||||
return $this->output($image);
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -643,8 +642,7 @@ class HtmlHelper extends AppHelper {
|
|||
foreach ($names as $arg) {
|
||||
$out[] = sprintf($this->tags['tableheader'], $this->_parseAttributes($thOptions), $arg);
|
||||
}
|
||||
$data = sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), implode(' ', $out));
|
||||
return $this->output($data);
|
||||
return sprintf($this->tags['tablerow'], $this->_parseAttributes($trOptions), join(' ', $out));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -698,7 +696,7 @@ class HtmlHelper extends AppHelper {
|
|||
$options = $this->_parseAttributes($count % 2 ? $oddTrOptions : $evenTrOptions);
|
||||
$out[] = sprintf($this->tags['tablerow'], $options, implode(' ', $cellsOut));
|
||||
}
|
||||
return $this->output(implode("\n", $out));
|
||||
return implode("\n", $out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -729,7 +727,7 @@ class HtmlHelper extends AppHelper {
|
|||
} else {
|
||||
$tag = 'tag';
|
||||
}
|
||||
return $this->output(sprintf($this->tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name));
|
||||
return sprintf($this->tags[$tag], $name, $this->_parseAttributes($options, null, ' ', ''), $text, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -778,7 +776,7 @@ class HtmlHelper extends AppHelper {
|
|||
} else {
|
||||
$tag = 'para';
|
||||
}
|
||||
return $this->output(sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text));
|
||||
return sprintf($this->tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -273,7 +273,7 @@ class JavascriptHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
$out = $this->output(sprintf($this->tags['javascriptlink'], $url));
|
||||
$out = sprintf($this->tags['javascriptlink'], $url);
|
||||
|
||||
if ($inline) {
|
||||
return $out;
|
||||
|
|
|
@ -555,7 +555,7 @@ class PaginatorHelper extends AppHelper {
|
|||
$out = str_replace($newKeys, array_values($map), $out);
|
||||
break;
|
||||
}
|
||||
return $this->output($out);
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -676,7 +676,7 @@ class PaginatorHelper extends AppHelper {
|
|||
$out .= $after;
|
||||
}
|
||||
|
||||
return $this->output($out);
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -269,7 +269,7 @@ class RssHelper extends XmlHelper {
|
|||
if (!empty($elements)) {
|
||||
$content = implode('', $elements);
|
||||
}
|
||||
return $this->output($this->elem('item', $att, $content, !($content === null)));
|
||||
return $this->elem('item', $att, $content, !($content === null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -87,8 +87,7 @@ class TimeHelper extends AppHelper {
|
|||
$date = time();
|
||||
}
|
||||
|
||||
$ret = date("D, M jS Y, H:i", $date);
|
||||
return $this->output($ret);
|
||||
return date("D, M jS Y, H:i", $date);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,8 +114,7 @@ class TimeHelper extends AppHelper {
|
|||
} else {
|
||||
$ret = date("M jS{$y}, H:i", $date);
|
||||
}
|
||||
|
||||
return $this->output($ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,8 +132,7 @@ class TimeHelper extends AppHelper {
|
|||
$begin = date('Y-m-d', $begin) . ' 00:00:00';
|
||||
$end = date('Y-m-d', $end) . ' 23:59:59';
|
||||
|
||||
$ret ="($fieldName >= '$begin') AND ($fieldName <= '$end')";
|
||||
return $this->output($ret);
|
||||
return "($fieldName >= '$begin') AND ($fieldName <= '$end')";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,8 +146,7 @@ class TimeHelper extends AppHelper {
|
|||
*/
|
||||
function dayAsSql($dateString, $fieldName, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
$ret = $this->daysAsSql($dateString, $dateString, $fieldName);
|
||||
return $this->output($ret);
|
||||
return $this->daysAsSql($dateString, $dateString, $fieldName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,7 +250,7 @@ class TimeHelper extends AppHelper {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return $this->output($date);
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,8 +261,7 @@ class TimeHelper extends AppHelper {
|
|||
* @return integer Unix timestamp
|
||||
*/
|
||||
function toUnix($dateString, $userOffset = null) {
|
||||
$ret = $this->fromString($dateString, $userOffset);
|
||||
return $this->output($ret);
|
||||
return $this->fromString($dateString, $userOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -278,8 +273,7 @@ class TimeHelper extends AppHelper {
|
|||
*/
|
||||
function toAtom($dateString, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
$ret = date('Y-m-d\TH:i:s\Z', $date);
|
||||
return $this->output($ret);
|
||||
return date('Y-m-d\TH:i:s\Z', $date);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -291,8 +285,7 @@ class TimeHelper extends AppHelper {
|
|||
*/
|
||||
function toRSS($dateString, $userOffset = null) {
|
||||
$date = $this->fromString($dateString, $userOffset);
|
||||
$ret = date("r", $date);
|
||||
return $this->output($ret);
|
||||
return date("r", $date);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -472,7 +465,7 @@ class TimeHelper extends AppHelper {
|
|||
$relativeDate = sprintf(__('%s ago', true), $relativeDate);
|
||||
}
|
||||
}
|
||||
return $this->output($relativeDate);
|
||||
return $relativeDate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,7 +65,7 @@ class XmlHelper extends AppHelper {
|
|||
$attrib = 'xml ' . $attrib;
|
||||
}
|
||||
|
||||
return $this->output($this->Xml->header($attrib));
|
||||
return $this->Xml->header($attrib);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,7 +131,7 @@ class XmlHelper extends AppHelper {
|
|||
if (!$endTag) {
|
||||
$this->Xml =& $elem;
|
||||
}
|
||||
return $this->output($out);
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,7 +144,7 @@ class XmlHelper extends AppHelper {
|
|||
if ($parent =& $this->Xml->parent()) {
|
||||
$this->Xml =& $parent;
|
||||
}
|
||||
return $this->output('</' . $name . '>');
|
||||
return '</' . $name . '>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -115,6 +115,51 @@ class ProjectTaskTest extends CakeTestCase {
|
|||
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* test bake() method with -empty flag, directory creation and empty files.
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testBakeEmptyFlag() {
|
||||
$this->Task->params['empty'] = true;
|
||||
$this->_setupTestProject();
|
||||
$path = $this->Task->path . 'bake_test_app';
|
||||
$this->assertTrue(is_dir($path), 'No project dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'controllers'), 'No controllers dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'controllers' . DS .'components'), 'No components dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'models'), 'No models dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'views'), 'No views dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'views' . DS . 'helpers'), 'No helpers dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'tests'), 'No tests dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'cases'), 'No cases dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'groups'), 'No groups dir %s');
|
||||
$this->assertTrue(is_dir($path . DS . 'tests' . DS . 'fixtures'), 'No fixtures dir %s');
|
||||
|
||||
$this->assertTrue(is_file($path . DS . 'controllers' . DS .'components' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'locale' . DS . 'eng' . DS . 'LC_MESSAGES' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'models' . DS . 'behaviors' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'models' . DS . 'datasources' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'plugins' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'behaviors' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'components' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'controllers' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'datasources' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'models' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'shells' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'fixtures' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'groups' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'css' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'img' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'js' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'views' . DS . 'errors' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'views' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'views' . DS . 'scaffolds' . DS . 'empty'), 'No empty file in dir %s');
|
||||
$this->assertTrue(is_file($path . DS . 'webroot' . DS . 'js' . DS . 'empty'), 'No empty file in dir %s');
|
||||
}
|
||||
|
||||
/**
|
||||
* test generation of Security.salt
|
||||
*
|
||||
|
@ -141,7 +186,7 @@ class ProjectTaskTest extends CakeTestCase {
|
|||
*/
|
||||
function testIndexPhpGeneration() {
|
||||
$this->_setupTestProject();
|
||||
|
||||
|
||||
$path = $this->Task->path . 'bake_test_app' . DS;
|
||||
$this->Task->corePath($path);
|
||||
|
||||
|
|
|
@ -43,8 +43,6 @@ class CacheTest extends CakeTestCase {
|
|||
|
||||
$this->_defaultCacheConfig = Cache::config('default');
|
||||
Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
|
||||
|
||||
Cache::engine('File', array('path' => TMP . 'tests'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,7 +54,6 @@ class CacheTest extends CakeTestCase {
|
|||
function tearDown() {
|
||||
Configure::write('Cache.disable', $this->_cacheDisable);
|
||||
Cache::config('default', $this->_defaultCacheConfig['settings']);
|
||||
Cache::engine('File');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,15 +124,45 @@ class CacheTest extends CakeTestCase {
|
|||
$_cacheConfigTests = Cache::config('tests');
|
||||
|
||||
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
|
||||
$this->assertEqual($result['settings'], Cache::settings('File'));
|
||||
$this->assertEqual($result['settings'], Cache::settings('sessions'));
|
||||
|
||||
$result = Cache::config('tests', array('engine'=> 'File', 'path' => TMP . 'tests'));
|
||||
$this->assertEqual($result['settings'], Cache::settings('File'));
|
||||
$this->assertEqual($result['settings'], Cache::settings('tests'));
|
||||
|
||||
Cache::config('sessions', $_cacheConfigSessions['settings']);
|
||||
Cache::config('tests', $_cacheConfigTests['settings']);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that calling config() sets the 'default' configuration up.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testConfigSettingDefaultConfigKey() {
|
||||
Cache::config('test_name', array('engine' => 'File', 'prefix' => 'test_name_'));
|
||||
|
||||
Cache::config('test_name');
|
||||
Cache::write('value_one', 'I am cached');
|
||||
$result = Cache::read('value_one');
|
||||
$this->assertEqual($result, 'I am cached');
|
||||
|
||||
Cache::config('default');
|
||||
$result = Cache::read('value_one');
|
||||
$this->assertEqual($result, null);
|
||||
|
||||
Cache::write('value_one', 'I am in another cache config!');
|
||||
$result = Cache::read('value_one');
|
||||
$this->assertEqual($result, 'I am in another cache config!');
|
||||
|
||||
Cache::config('test_name');
|
||||
$result = Cache::read('value_one');
|
||||
$this->assertEqual($result, 'I am cached');
|
||||
|
||||
Cache::delete('value_one');
|
||||
Cache::config('default');
|
||||
Cache::delete('value_one');
|
||||
}
|
||||
|
||||
/**
|
||||
* testWritingWithConfig method
|
||||
*
|
||||
|
@ -157,7 +184,7 @@ class CacheTest extends CakeTestCase {
|
|||
'engine' => 'File',
|
||||
'isWindows' => DIRECTORY_SEPARATOR == '\\'
|
||||
);
|
||||
$this->assertEqual($expected, Cache::settings('File'));
|
||||
$this->assertEqual($expected, Cache::settings('sessions'));
|
||||
|
||||
Cache::config('sessions', $_cacheConfigSessions['settings']);
|
||||
}
|
||||
|
@ -181,7 +208,7 @@ class CacheTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testInitSettings() {
|
||||
Cache::engine('File', array('path' => TMP . 'tests'));
|
||||
Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
|
||||
|
||||
$settings = Cache::settings();
|
||||
$expecting = array(
|
||||
|
@ -195,17 +222,15 @@ class CacheTest extends CakeTestCase {
|
|||
'isWindows' => DIRECTORY_SEPARATOR == '\\'
|
||||
);
|
||||
$this->assertEqual($settings, $expecting);
|
||||
|
||||
Cache::engine('File');
|
||||
}
|
||||
|
||||
/**
|
||||
* test that unconfig removes cache configs, and that further attempts to use that config
|
||||
* test that drop removes cache configs, and that further attempts to use that config
|
||||
* do not work.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testUnconfig() {
|
||||
function testDrop() {
|
||||
App::build(array(
|
||||
'libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
|
||||
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||
|
@ -221,7 +246,7 @@ class CacheTest extends CakeTestCase {
|
|||
Cache::config('unconfigTest', array(
|
||||
'engine' => 'TestAppCache'
|
||||
));
|
||||
$this->assertTrue(Cache::isInitialized('TestAppCache'));
|
||||
$this->assertTrue(Cache::isInitialized('unconfigTest'));
|
||||
|
||||
$this->assertTrue(Cache::drop('unconfigTest'));
|
||||
$this->assertFalse(Cache::isInitialized('TestAppCache'));
|
||||
|
@ -324,5 +349,6 @@ class CacheTest extends CakeTestCase {
|
|||
|
||||
Cache::set($_cacheSet);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
5
cake/tests/cases/libs/cache/apc.test.php
vendored
5
cake/tests/cases/libs/cache/apc.test.php
vendored
|
@ -39,7 +39,7 @@ class ApcEngineTest extends UnitTestCase {
|
|||
*/
|
||||
function skip() {
|
||||
$skip = true;
|
||||
if (Cache::engine('Apc')) {
|
||||
if (function_exists('apc_store')) {
|
||||
$skip = false;
|
||||
}
|
||||
$this->skipIf($skip, '%s Apc is not installed or configured properly');
|
||||
|
@ -65,6 +65,7 @@ class ApcEngineTest extends UnitTestCase {
|
|||
*/
|
||||
function tearDown() {
|
||||
Configure::write('Cache.disable', $this->_cacheDisable);
|
||||
Cache::drop('apc');
|
||||
Cache::config('default');
|
||||
}
|
||||
|
||||
|
@ -112,7 +113,7 @@ class ApcEngineTest extends UnitTestCase {
|
|||
$result = Cache::read('other_test');
|
||||
$this->assertFalse($result);
|
||||
|
||||
Cache::set(array('duration' => "+1 second"));
|
||||
Cache::set(array('duration' => 1));
|
||||
|
||||
$data = 'this is a test of the emergency broadcasting system';
|
||||
$result = Cache::write('other_test', $data);
|
||||
|
|
95
cake/tests/cases/libs/cache/file.test.php
vendored
95
cake/tests/cases/libs/cache/file.test.php
vendored
|
@ -2,8 +2,6 @@
|
|||
/**
|
||||
* FileEngineTest file
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
|
@ -22,9 +20,6 @@
|
|||
if (!class_exists('Cache')) {
|
||||
require LIBS . 'cache.php';
|
||||
}
|
||||
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
||||
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* FileEngineTest class
|
||||
|
@ -74,12 +69,11 @@ class FileEngineTest extends CakeTestCase {
|
|||
*/
|
||||
function testCacheDirChange() {
|
||||
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
|
||||
$this->assertEqual($result['settings'], Cache::settings('File'));
|
||||
$this->assertNotEqual($result, Cache::settings('File'));
|
||||
$this->assertEqual($result['settings'], Cache::settings('sessions'));
|
||||
|
||||
$result = Cache::config('tests', array('engine'=> 'File', 'path' => TMP . 'tests'));
|
||||
$this->assertEqual($result['settings'], Cache::settings('File'));
|
||||
$this->assertNotEqual($result, Cache::settings('File'));
|
||||
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'tests'));
|
||||
$this->assertEqual($result['settings'], Cache::settings('sessions'));
|
||||
$this->assertNotEqual($result['settings'], Cache::settings('default'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,7 +153,6 @@ class FileEngineTest extends CakeTestCase {
|
|||
|
||||
$result = Cache::delete('delete_test');
|
||||
$this->assertFalse($result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,12 +162,12 @@ class FileEngineTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testSerialize() {
|
||||
Cache::engine('File', array('serialize' => true));
|
||||
Cache::config('default', array('engine' => 'File', 'serialize' => true));
|
||||
$data = 'this is a test of the emergency broadcasting system';
|
||||
$write = Cache::write('serialize_test', $data, 1);
|
||||
$write = Cache::write('serialize_test', $data);
|
||||
$this->assertTrue($write);
|
||||
|
||||
Cache::engine('File', array('serialize' => false));
|
||||
Cache::config('default', array('serialize' => false));
|
||||
$read = Cache::read('serialize_test');
|
||||
|
||||
$newread = Cache::read('serialize_test');
|
||||
|
@ -184,7 +177,6 @@ class FileEngineTest extends CakeTestCase {
|
|||
$this->assertIdentical($read, serialize($data));
|
||||
|
||||
$this->assertIdentical(unserialize($newread), $data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,7 +186,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testClear() {
|
||||
Cache::engine('File', array('duration' => 1));
|
||||
Cache::config('default', 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);
|
||||
|
@ -223,7 +215,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test2'));
|
||||
$this->assertFalse(file_exists(CACHE . 'cake_serialize_test3'));
|
||||
|
||||
$result = Cache::engine('File', array('path' => CACHE . 'views'));
|
||||
Cache::config('default', array('engine' => 'File', 'path' => CACHE . 'views'));
|
||||
|
||||
$data = 'this is a test of the emergency broadcasting system';
|
||||
$write = Cache::write('controller_view_1', $data);
|
||||
|
@ -278,7 +270,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
|
||||
clearCache('controller_view');
|
||||
|
||||
Cache::engine('File', array('path' => CACHE));
|
||||
Cache::config('default', array('engine' => 'File', 'path' => CACHE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -306,40 +298,43 @@ class FileEngineTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testRemoveWindowsSlashesFromCache() {
|
||||
Cache::engine('File', array('isWindows' => true, 'prefix' => null, 'path' => TMP));
|
||||
Cache::config('windows_test', array('engine' => 'File', 'isWindows' => true, 'prefix' => null, 'path' => TMP));
|
||||
|
||||
$expected = array (
|
||||
'C:\dev\prj2\sites\cake\libs' => array(
|
||||
0 => 'C:\dev\prj2\sites\cake\libs', 1 => 'C:\dev\prj2\sites\cake\libs\view',
|
||||
2 => 'C:\dev\prj2\sites\cake\libs\view\scaffolds', 3 => 'C:\dev\prj2\sites\cake\libs\view\pages',
|
||||
4 => 'C:\dev\prj2\sites\cake\libs\view\layouts', 5 => 'C:\dev\prj2\sites\cake\libs\view\layouts\xml',
|
||||
6 => 'C:\dev\prj2\sites\cake\libs\view\layouts\rss', 7 => 'C:\dev\prj2\sites\cake\libs\view\layouts\js',
|
||||
8 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email', 9 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\text',
|
||||
10 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\html', 11 => 'C:\dev\prj2\sites\cake\libs\view\helpers',
|
||||
12 => 'C:\dev\prj2\sites\cake\libs\view\errors', 13 => 'C:\dev\prj2\sites\cake\libs\view\elements',
|
||||
14 => 'C:\dev\prj2\sites\cake\libs\view\elements\email', 15 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\text',
|
||||
16 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\html', 17 => 'C:\dev\prj2\sites\cake\libs\model',
|
||||
18 => 'C:\dev\prj2\sites\cake\libs\model\datasources', 19 => 'C:\dev\prj2\sites\cake\libs\model\datasources\dbo',
|
||||
20 => 'C:\dev\prj2\sites\cake\libs\model\behaviors', 21 => 'C:\dev\prj2\sites\cake\libs\controller',
|
||||
22 => 'C:\dev\prj2\sites\cake\libs\controller\components', 23 => 'C:\dev\prj2\sites\cake\libs\cache'),
|
||||
'C:\dev\prj2\sites\main_site\vendors' => array(
|
||||
0 => 'C:\dev\prj2\sites\main_site\vendors', 1 => 'C:\dev\prj2\sites\main_site\vendors\shells',
|
||||
2 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates', 3 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates\cdc_project',
|
||||
4 => 'C:\dev\prj2\sites\main_site\vendors\shells\tasks', 5 => 'C:\dev\prj2\sites\main_site\vendors\js',
|
||||
6 => 'C:\dev\prj2\sites\main_site\vendors\css'),
|
||||
'C:\dev\prj2\sites\vendors' => array(
|
||||
0 => 'C:\dev\prj2\sites\vendors', 1 => 'C:\dev\prj2\sites\vendors\simpletest',
|
||||
2 => 'C:\dev\prj2\sites\vendors\simpletest\test', 3 => 'C:\dev\prj2\sites\vendors\simpletest\test\support',
|
||||
4 => 'C:\dev\prj2\sites\vendors\simpletest\test\support\collector', 5 => 'C:\dev\prj2\sites\vendors\simpletest\extensions',
|
||||
6 => 'C:\dev\prj2\sites\vendors\simpletest\extensions\testdox', 7 => 'C:\dev\prj2\sites\vendors\simpletest\docs',
|
||||
8 => 'C:\dev\prj2\sites\vendors\simpletest\docs\fr', 9 => 'C:\dev\prj2\sites\vendors\simpletest\docs\en'),
|
||||
'C:\dev\prj2\sites\main_site\views\helpers' => array(
|
||||
0 => 'C:\dev\prj2\sites\main_site\views\helpers'));
|
||||
'C:\dev\prj2\sites\cake\libs' => array(
|
||||
0 => 'C:\dev\prj2\sites\cake\libs', 1 => 'C:\dev\prj2\sites\cake\libs\view',
|
||||
2 => 'C:\dev\prj2\sites\cake\libs\view\scaffolds', 3 => 'C:\dev\prj2\sites\cake\libs\view\pages',
|
||||
4 => 'C:\dev\prj2\sites\cake\libs\view\layouts', 5 => 'C:\dev\prj2\sites\cake\libs\view\layouts\xml',
|
||||
6 => 'C:\dev\prj2\sites\cake\libs\view\layouts\rss', 7 => 'C:\dev\prj2\sites\cake\libs\view\layouts\js',
|
||||
8 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email', 9 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\text',
|
||||
10 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\html', 11 => 'C:\dev\prj2\sites\cake\libs\view\helpers',
|
||||
12 => 'C:\dev\prj2\sites\cake\libs\view\errors', 13 => 'C:\dev\prj2\sites\cake\libs\view\elements',
|
||||
14 => 'C:\dev\prj2\sites\cake\libs\view\elements\email', 15 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\text',
|
||||
16 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\html', 17 => 'C:\dev\prj2\sites\cake\libs\model',
|
||||
18 => 'C:\dev\prj2\sites\cake\libs\model\datasources', 19 => 'C:\dev\prj2\sites\cake\libs\model\datasources\dbo',
|
||||
20 => 'C:\dev\prj2\sites\cake\libs\model\behaviors', 21 => 'C:\dev\prj2\sites\cake\libs\controller',
|
||||
22 => 'C:\dev\prj2\sites\cake\libs\controller\components', 23 => 'C:\dev\prj2\sites\cake\libs\cache'),
|
||||
'C:\dev\prj2\sites\main_site\vendors' => array(
|
||||
0 => 'C:\dev\prj2\sites\main_site\vendors', 1 => 'C:\dev\prj2\sites\main_site\vendors\shells',
|
||||
2 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates', 3 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates\cdc_project',
|
||||
4 => 'C:\dev\prj2\sites\main_site\vendors\shells\tasks', 5 => 'C:\dev\prj2\sites\main_site\vendors\js',
|
||||
6 => 'C:\dev\prj2\sites\main_site\vendors\css'),
|
||||
'C:\dev\prj2\sites\vendors' => array(
|
||||
0 => 'C:\dev\prj2\sites\vendors', 1 => 'C:\dev\prj2\sites\vendors\simpletest',
|
||||
2 => 'C:\dev\prj2\sites\vendors\simpletest\test', 3 => 'C:\dev\prj2\sites\vendors\simpletest\test\support',
|
||||
4 => 'C:\dev\prj2\sites\vendors\simpletest\test\support\collector', 5 => 'C:\dev\prj2\sites\vendors\simpletest\extensions',
|
||||
6 => 'C:\dev\prj2\sites\vendors\simpletest\extensions\testdox', 7 => 'C:\dev\prj2\sites\vendors\simpletest\docs',
|
||||
8 => 'C:\dev\prj2\sites\vendors\simpletest\docs\fr', 9 => 'C:\dev\prj2\sites\vendors\simpletest\docs\en'),
|
||||
'C:\dev\prj2\sites\main_site\views\helpers' => array(
|
||||
0 => 'C:\dev\prj2\sites\main_site\views\helpers')
|
||||
);
|
||||
|
||||
$data = Cache::write('test_dir_map', $expected);
|
||||
$data = Cache::read('test_dir_map');
|
||||
Cache::delete('test_dir_map');
|
||||
Cache::write('test_dir_map', $expected, 'windows_test');
|
||||
$data = Cache::read('test_dir_map', 'windows_test');
|
||||
Cache::delete('test_dir_map', 'windows_test');
|
||||
$this->assertEqual($expected, $data);
|
||||
|
||||
Cache::drop('windows_test');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,13 +344,13 @@ class FileEngineTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testWriteQuotedString() {
|
||||
Cache::engine('File', array('path' => TMP . 'tests'));
|
||||
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::engine('File', array('isWindows' => true, 'path' => TMP . 'tests'));
|
||||
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'");
|
||||
|
|
43
cake/tests/cases/libs/cache/memcache.test.php
vendored
43
cake/tests/cases/libs/cache/memcache.test.php
vendored
|
@ -2,8 +2,6 @@
|
|||
/**
|
||||
* MemcacheEngineTest file
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
|
@ -23,13 +21,6 @@ if (!class_exists('Cache')) {
|
|||
require LIBS . 'cache.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* MemcacheEngineTest class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.cache
|
||||
*/
|
||||
|
||||
/**
|
||||
* MemcacheEngineTest class
|
||||
*
|
||||
|
@ -46,10 +37,10 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
*/
|
||||
function skip() {
|
||||
$skip = true;
|
||||
if (Cache::engine('Memcache')) {
|
||||
if (class_exists('Memcache')) {
|
||||
$skip = false;
|
||||
}
|
||||
$this->skipIf($skip, '%s Memcache is not installed or configured properly');
|
||||
$this->skipIf($skip, '%s Memcache is not installed or configured properly.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,6 +63,7 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
*/
|
||||
function tearDown() {
|
||||
Configure::write('Cache.disable', $this->_cacheDisable);
|
||||
Cache::drop('memcache');
|
||||
Cache::config('default');
|
||||
}
|
||||
|
||||
|
@ -103,14 +95,12 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
*/
|
||||
function testMultipleServers() {
|
||||
$servers = array('127.0.0.1:11211', '127.0.0.1:11222');
|
||||
|
||||
$Cache =& Cache::getInstance();
|
||||
$MemCache =& $Cache->_Engine['Memcache'];
|
||||
|
||||
$available = true;
|
||||
$Memcache =& new Memcache();
|
||||
|
||||
foreach($servers as $server) {
|
||||
list($host, $port) = explode(':', $server);
|
||||
if (!@$MemCache->__Memcache->connect($host, $port)) {
|
||||
if (!$Memcache->addServer($host, $port)) {
|
||||
$available = false;
|
||||
}
|
||||
}
|
||||
|
@ -118,13 +108,13 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
if ($this->skipIf(!$available, '%s Need memcache servers at ' . implode(', ', $servers) . ' to run this test')) {
|
||||
return;
|
||||
}
|
||||
$Memcache =& new MemcacheEngine();
|
||||
$Memcache->init(array('engine' => 'Memcache', 'servers' => $servers));
|
||||
|
||||
unset($MemCache->__Memcache);
|
||||
$MemCache->init(array('engine' => 'Memcache', 'servers' => $servers));
|
||||
|
||||
$servers = array_keys($MemCache->__Memcache->getExtendedStats());
|
||||
$settings = Cache::settings();
|
||||
$servers = array_keys($Memcache->__Memcache->getExtendedStats());
|
||||
$settings = $Memcache->settings();
|
||||
$this->assertEqual($servers, $settings['servers']);
|
||||
Cache::drop('dual_server');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,8 +124,9 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testConnect() {
|
||||
$Cache =& Cache::getInstance();
|
||||
$result = $Cache->_Engine['Memcache']->connect('127.0.0.1');
|
||||
$Memcache =& new MemcacheEngine();
|
||||
$Memcache->init(Cache::settings('memcache'));
|
||||
$result = $Memcache->connect('127.0.0.1');
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
|
@ -193,13 +184,13 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
$result = Cache::read('other_test');
|
||||
$this->assertFalse($result);
|
||||
|
||||
Cache::engine('Memcache', array('duration' => '+1 second'));
|
||||
Cache::config('memcache', array('duration' => '+1 second'));
|
||||
sleep(2);
|
||||
|
||||
$result = Cache::read('other_test');
|
||||
$this->assertFalse($result);
|
||||
|
||||
Cache::engine('Memcache', array('duration' => '+31 day'));
|
||||
Cache::config('memcache', array('duration' => '+31 day'));
|
||||
$data = 'this is a test of the emergency broadcasting system';
|
||||
$result = Cache::write('long_expiry_test', $data);
|
||||
$this->assertTrue($result);
|
||||
|
@ -212,7 +203,7 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
$result = Cache::read('long_expiry_test');
|
||||
$this->assertTrue($result);
|
||||
|
||||
Cache::engine('Memcache', array('duration' => 3600));
|
||||
Cache::config('memcache', array('duration' => 3600));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
2
cake/tests/cases/libs/cache/xcache.test.php
vendored
2
cake/tests/cases/libs/cache/xcache.test.php
vendored
|
@ -39,7 +39,7 @@ class XcacheEngineTest extends UnitTestCase {
|
|||
*/
|
||||
function skip() {
|
||||
$skip = true;
|
||||
if ($result = Cache::engine('Xcache')) {
|
||||
if (function_exists('xcache_set')) {
|
||||
$skip = false;
|
||||
}
|
||||
$this->skipIf($skip, '%s Xcache is not installed or configured properly');
|
||||
|
|
|
@ -289,6 +289,20 @@ class SessionTest extends CakeTestCase {
|
|||
$this->assertTrue($this->Session->check('Session Test.Test Case'));
|
||||
}
|
||||
|
||||
/**
|
||||
* test key exploitation
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testKeyExploit() {
|
||||
$key = "a'] = 1; phpinfo(); \$_SESSION['a";
|
||||
$result = $this->Session->write($key, 'haxored');
|
||||
$this->assertTrue($result);
|
||||
|
||||
$result = $this->Session->read($key);
|
||||
$this->assertEqual($result, 'haxored');
|
||||
}
|
||||
|
||||
/**
|
||||
* testReadingSavedEmpty method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue