Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '1.3-misc' into 1.3-merger

Conflicts:
	cake/libs/view/helpers/html.php
  • Loading branch information...
commit 8cdee90b4fd95051d9d4cffe3e0bebf04de404cd 2 parents 6fdaa82 + 33ef318
@markstory markstory authored
View
3  cake/console/libs/tasks/project.php
@@ -149,6 +149,9 @@ function bake($path, $skel = null, $skip = array('empty')) {
$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));
View
0  cake/console/templates/skel/libs/empty
No changes.
View
297 cake/libs/cache.php
@@ -28,15 +28,9 @@
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,7 +46,7 @@ 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
@@ -60,6 +54,13 @@ class Cache {
var $__reset = false;
/**
+ * Engine instances keyed by configuration name.
+ *
+ * @var array
+ */
+ var $_engines = array();
+
+/**
* Returns a singleton instance
*
* @return object
@@ -75,7 +76,18 @@ function &getInstance() {
}
/**
- * 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 @@ function &getInstance() {
* @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,57 +176,16 @@ function configured() {
* @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
*
* @param $name Name of the engine (without 'Engine')
@@ -200,17 +194,16 @@ function engine($name = 'File', $settings = array()) {
*/
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 @@ function __loadEngine($name, $plugin = null) {
* @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 @@ function set($settings = array(), $value = null) {
* @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 @@ function gc() {
* @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 (!$_this->isInitialized($engine)) {
- return false;
- }
-
- if (!$key = $_this->_Engine[$engine]->key($key)) {
- return false;
- }
-
- if (is_resource($value)) {
+ if (!$self->isInitialized($config)) {
return false;
}
+ $key = $self->_engines[$config]->key($key);
- if ($duration < 1) {
+ if (!$key || is_resource($value) || $settings['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 @@ function write($key, $value, $config = null) {
* @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 @@ function read($key, $config = null) {
* @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;
}
-
- if (!$key = $_this->_Engine[$engine]->key($key)) {
+ $key = $self->_engines[$config]->key($key);
+ if (!$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 @@ function delete($key, $config = null) {
* @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 @@ function clear($check = false, $config = null) {
* @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();
}
View
11 cake/libs/cache/file.php
@@ -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
View
5 cake/libs/cache/xcache.php
@@ -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 @@ function init($settings) {
*/
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 @@ function write($key, &$value, $duration) {
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;
}
View
47 cake/libs/cake_session.php
@@ -212,11 +212,10 @@ function started() {
* @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 @@ function del($name) {
*/
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 @@ function read($name = null) {
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 @@ function __returnSessionVars() {
* @access public
*/
function watch($var) {
- $var = $this->__validateKeys($var);
if (empty($var)) {
return false;
}
@@ -402,7 +398,6 @@ function watch($var) {
* @access public
*/
function ignore($var) {
- $var = $this->__validateKeys($var);
if (!in_array($var, $this->watchKeys)) {
return;
}
@@ -424,16 +419,14 @@ function ignore($var) {
* @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);
}
/**
@@ -677,22 +670,6 @@ function renew() {
}
/**
- * 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.
*
* @param integer $errorNumber Number of the error
View
44 cake/libs/configure.php
@@ -91,11 +91,21 @@ function write($config, $value = null) {
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 @@ function read($var = 'debug') {
}
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;
}
/**
View
4 cake/libs/view/helpers/ajax.php
@@ -528,7 +528,7 @@ function div($id, $options = array()) {
}
}
$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 @@ function divEnd($id) {
return '';
}
}
- return $this->output($this->Html->tags['blockend']);
+ return $this->Html->tags['blockend'];
}
/**
View
50 cake/libs/view/helpers/form.php
@@ -294,7 +294,7 @@ function create($model = null, $options = array()) {
$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 @@ function end($options = null) {
$view =& ClassRegistry::getObject('view');
$view->modelScope = false;
- return $this->output($out);
+ return $out;
}
/**
@@ -528,11 +528,11 @@ function label($fieldName = null, $text = null, $options = array()) {
$labelFor = $this->domId($fieldName);
}
- return $this->output(sprintf(
+ return sprintf(
$this->Html->tags['label'],
$labelFor,
$this->_parseAttributes($options), $text
- ));
+ );
}
/**
@@ -940,11 +940,11 @@ function checkbox($fieldName, $options = array()) {
}
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 @@ function radio($fieldName, $options = array(), $attributes = array()) {
sprintf($this->Html->tags['legend'], $legend) . $out
);
}
- return $this->output($out);
+ return $out;
}
/**
@@ -1050,11 +1050,11 @@ function text($fieldName, $options = array()) {
$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 @@ function text($fieldName, $options = array()) {
*/
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 @@ function textarea($fieldName, $options = array()) {
}
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 @@ function hidden($fieldName, $options = array()) {
$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 @@ function file($fieldName, $options = array()) {
}
$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 @@ function button($title, $options = array()) {
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 @@ function submit($caption = null, $options = array()) {
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 @@ function submit($caption = null, $options = array()) {
$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 @@ function select($fieldName, $options = array(), $selected = null, $attributes =
$template = ($style == 'checkbox') ? 'checkboxmultipleend' : 'selectend';
$select[] = $this->Html->tags[$template];
- return $this->output(implode("\n", $select));
+ return implode("\n", $select);
}
/**
View
26 cake/libs/view/helpers/html.php
@@ -201,7 +201,7 @@ function addCrumb($name, $link = null, $options = null) {
*/
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 @@ function meta($type, $url = null, $options = array()) {
}
if ($inline) {
- return $this->output($out);
+ return $out;
} else {
$view =& ClassRegistry::getObject('view');
$view->addScript($out);
@@ -288,7 +288,7 @@ function charset($charset = null) {
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 @@ function link($title, $url = null, $options = array(), $confirmMessage = false)
}
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 @@ function css($path, $rel = null, $options = array()) {
}
$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 @@ function script($url, $options = array()) {
}
}
$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 @@ function getCrumbs($separator = '&raquo;', $startText = false) {
$out[] = $crumb[0];
}
}
- return $this->output(implode($separator, $out));
+ return join($separator, $out);
} else {
return null;
}
@@ -624,9 +623,9 @@ function image($path, $options = array()) {
$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 @@ function tableHeaders($names, $trOptions = null, $thOptions = null) {
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 @@ function tableCells($data, $oddTrOptions = null, $evenTrOptions = null, $useCoun
$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 @@ function tag($name, $text = null, $options = array()) {
} 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 @@ function para($class, $text, $options = array()) {
} 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);
}
/**
View
2  cake/libs/view/helpers/javascript.php
@@ -273,7 +273,7 @@ function link($url, $inline = true) {
}
}
}
- $out = $this->output(sprintf($this->tags['javascriptlink'], $url));
+ $out = sprintf($this->tags['javascriptlink'], $url);
if ($inline) {
return $out;
View
4 cake/libs/view/helpers/paginator.php
@@ -555,7 +555,7 @@ function counter($options = array()) {
$out = str_replace($newKeys, array_values($map), $out);
break;
}
- return $this->output($out);
+ return $out;
}
/**
@@ -676,7 +676,7 @@ function numbers($options = array()) {
$out .= $after;
}
- return $this->output($out);
+ return $out;
}
/**
View
2  cake/libs/view/helpers/rss.php
@@ -269,7 +269,7 @@ function item($att = array(), $elements = array()) {
if (!empty($elements)) {
$content = implode('', $elements);
}
- return $this->output($this->elem('item', $att, $content, !($content === null)));
+ return $this->elem('item', $att, $content, !($content === null));
}
/**
View
25 cake/libs/view/helpers/time.php
@@ -87,8 +87,7 @@ function nice($dateString = null, $userOffset = null) {
$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 @@ function niceShort($dateString = null, $userOffset = null) {
} else {
$ret = date("M jS{$y}, H:i", $date);
}
-
- return $this->output($ret);
+ return $ret;
}
/**
@@ -134,8 +132,7 @@ function daysAsSql($begin, $end, $fieldName, $userOffset = null) {
$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 @@ function daysAsSql($begin, $end, $fieldName, $userOffset = null) {
*/
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 @@ function toQuarter($dateString, $range = false) {
break;
}
}
- return $this->output($date);
+ return $date;
}
/**
@@ -265,8 +261,7 @@ function toQuarter($dateString, $range = false) {
* @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 @@ function toUnix($dateString, $userOffset = null) {
*/
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 @@ function toAtom($dateString, $userOffset = null) {
*/
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 @@ function timeAgoInWords($dateTime, $options = array()) {
$relativeDate = sprintf(__('%s ago', true), $relativeDate);
}
}
- return $this->output($relativeDate);
+ return $relativeDate;
}
/**
View
6 cake/libs/view/helpers/xml.php
@@ -65,7 +65,7 @@ function header($attrib = array()) {
$attrib = 'xml ' . $attrib;
}
- return $this->output($this->Xml->header($attrib));
+ return $this->Xml->header($attrib);
}
/**
@@ -131,7 +131,7 @@ function elem($name, $attrib = array(), $content = null, $endTag = true) {
if (!$endTag) {
$this->Xml =& $elem;
}
- return $this->output($out);
+ return $out;
}
/**
@@ -144,7 +144,7 @@ function closeElem() {
if ($parent =& $this->Xml->parent()) {
$this->Xml =& $parent;
}
- return $this->output('</' . $name . '>');
+ return '</' . $name . '>';
}
/**
View
47 cake/tests/cases/console/libs/tasks/project.test.php
@@ -116,6 +116,51 @@ function testBake() {
}
/**
+ * 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
*
* @return void
@@ -141,7 +186,7 @@ function testSecuritySaltGeneration() {
*/
function testIndexPhpGeneration() {
$this->_setupTestProject();
-
+
$path = $this->Task->path . 'bake_test_app' . DS;
$this->Task->corePath($path);
View
50 cake/tests/cases/libs/cache.test.php
@@ -43,8 +43,6 @@ function setUp() {
$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 @@ function setUp() {
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default', $this->_defaultCacheConfig['settings']);
- Cache::engine('File');
}
/**
@@ -127,16 +124,46 @@ function testConfigChange() {
$_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
*
* @access public
@@ -157,7 +184,7 @@ function testWritingWithConfig() {
'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 @@ function testConfigured() {
* @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 @@ function testInitSettings() {
'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 @@ function testUnconfig() {
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 @@ function testSet() {
Cache::set($_cacheSet);
}
+
}
?>
View
5 cake/tests/cases/libs/cache/apc.test.php
@@ -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 @@ function setUp() {
*/
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
+ Cache::drop('apc');
Cache::config('default');
}
@@ -112,7 +113,7 @@ function testExpiry() {
$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);
View
97 cake/tests/cases/libs/cache/file.test.php
@@ -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 @@ function endCase() {
*/
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 @@ function testDeleteCache() {
$result = Cache::delete('delete_test');
$this->assertFalse($result);
-
}
/**
@@ -169,12 +162,12 @@ function testDeleteCache() {
* @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 @@ function testSerialize() {
$this->assertIdentical($read, serialize($data));
$this->assertIdentical(unserialize($newread), $data);
-
}
/**
@@ -194,7 +186,7 @@ function testSerialize() {
* @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 @@ function testClear() {
$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 @@ function testClear() {
clearCache('controller_view');
- Cache::engine('File', array('path' => CACHE));
+ Cache::config('default', array('engine' => 'File', 'path' => CACHE));
}
/**
@@ -306,40 +298,43 @@ function testKeyPath() {
* @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'));
-
- $data = Cache::write('test_dir_map', $expected);
- $data = Cache::read('test_dir_map');
- Cache::delete('test_dir_map');
+ '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')
+ );
+
+ 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 @@ function testRemoveWindowsSlashesFromCache() {
* @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'");
View
43 cake/tests/cases/libs/cache/memcache.test.php
@@ -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>
@@ -29,13 +27,6 @@
* @package cake
* @subpackage cake.tests.cases.libs.cache
*/
-
-/**
- * MemcacheEngineTest class
- *
- * @package cake
- * @subpackage cake.tests.cases.libs.cache
- */
class MemcacheEngineTest extends CakeTestCase {
/**
@@ -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 @@ function setUp() {
*/
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
+ Cache::drop('memcache');
Cache::config('default');
}
@@ -103,14 +95,12 @@ function testSettings() {
*/
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 @@ function testMultipleServers() {
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');
}
/**