mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 02:26:17 +00:00
Merge remote branch 'upstream/2.0' into 2.0
This commit is contained in:
commit
46d14c51a0
26 changed files with 281 additions and 89 deletions
|
@ -282,7 +282,7 @@ if (!function_exists('sortByKey')) {
|
||||||
if (defined('SERVER_IIS') && SERVER_IIS === true) {
|
if (defined('SERVER_IIS') && SERVER_IIS === true) {
|
||||||
return str_replace('\\\\', '\\', env('PATH_TRANSLATED'));
|
return str_replace('\\\\', '\\', env('PATH_TRANSLATED'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'DOCUMENT_ROOT':
|
case 'DOCUMENT_ROOT':
|
||||||
$name = env('SCRIPT_NAME');
|
$name = env('SCRIPT_NAME');
|
||||||
$filename = env('SCRIPT_FILENAME');
|
$filename = env('SCRIPT_FILENAME');
|
||||||
|
@ -291,20 +291,31 @@ if (!function_exists('sortByKey')) {
|
||||||
$offset = 4;
|
$offset = 4;
|
||||||
}
|
}
|
||||||
return substr($filename, 0, strlen($filename) - (strlen($name) + $offset));
|
return substr($filename, 0, strlen($filename) - (strlen($name) + $offset));
|
||||||
break;
|
break;
|
||||||
case 'PHP_SELF':
|
case 'PHP_SELF':
|
||||||
return str_replace(env('DOCUMENT_ROOT'), '', env('SCRIPT_FILENAME'));
|
return str_replace(env('DOCUMENT_ROOT'), '', env('SCRIPT_FILENAME'));
|
||||||
break;
|
break;
|
||||||
case 'CGI_MODE':
|
case 'CGI_MODE':
|
||||||
return (PHP_SAPI === 'cgi');
|
return (PHP_SAPI === 'cgi');
|
||||||
break;
|
break;
|
||||||
case 'HTTP_BASE':
|
case 'HTTP_BASE':
|
||||||
$host = env('HTTP_HOST');
|
$host = env('HTTP_HOST');
|
||||||
if (substr_count($host, '.') !== 1) {
|
$parts = explode('.', $host);
|
||||||
return preg_replace('/^([^.])*/i', null, env('HTTP_HOST'));
|
$count = count($parts);
|
||||||
|
|
||||||
|
if ($count === 1) {
|
||||||
|
return '.' . $host;
|
||||||
|
} elseif ($count === 2) {
|
||||||
|
return '.' . $host;
|
||||||
|
} elseif ($count === 3) {
|
||||||
|
$gTLD = array('aero', 'asia', 'biz', 'cat', 'com', 'coop', 'edu', 'gov', 'info', 'int', 'jobs', 'mil', 'mobi', 'museum', 'name', 'net', 'org', 'pro', 'tel', 'travel', 'xxx');
|
||||||
|
if (in_array($parts[1], $gTLD)) {
|
||||||
|
return '.' . $host;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return '.' . $host;
|
array_shift($parts);
|
||||||
break;
|
return '.' . implode('.', $parts);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,11 +48,10 @@ class TaskCollection extends ObjectCollection {
|
||||||
*
|
*
|
||||||
* @param string $task Task name to load
|
* @param string $task Task name to load
|
||||||
* @param array $settings Settings for the task.
|
* @param array $settings Settings for the task.
|
||||||
* @param boolean $enable Whether or not this task should be enabled by default
|
|
||||||
* @return Task A task object, Either the existing loaded task or a new one.
|
* @return Task A task object, Either the existing loaded task or a new one.
|
||||||
* @throws MissingTaskFileException, MissingTaskClassException when the task could not be found
|
* @throws MissingTaskFileException, MissingTaskClassException when the task could not be found
|
||||||
*/
|
*/
|
||||||
public function load($task, $settings = array(), $enable = true) {
|
public function load($task, $settings = array()) {
|
||||||
list($plugin, $name) = pluginSplit($task, true);
|
list($plugin, $name) = pluginSplit($task, true);
|
||||||
|
|
||||||
if (isset($this->_loaded[$name])) {
|
if (isset($this->_loaded[$name])) {
|
||||||
|
@ -72,6 +71,7 @@ class TaskCollection extends ObjectCollection {
|
||||||
$this->_loaded[$name] = new $taskClass(
|
$this->_loaded[$name] = new $taskClass(
|
||||||
$this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin
|
$this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin
|
||||||
);
|
);
|
||||||
|
$enable = isset($settings['enabled']) ? $settings['enabled'] : true;
|
||||||
if ($enable === true) {
|
if ($enable === true) {
|
||||||
$this->_enabled[] = $name;
|
$this->_enabled[] = $name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<?php echo '<?php' . "\n"; ?>
|
<?php echo '<?php' . "\n"; ?>
|
||||||
/* <?php echo $model; ?> Fixture generated on: <?php echo date('Y-m-d H:m:s') . " : ". time(); ?> */
|
/* <?php echo $model; ?> Fixture generated on: <?php echo date('Y-m-d H:i:s') . " : ". time(); ?> */
|
||||||
class <?php echo $model; ?>Fixture extends CakeTestFixture {
|
class <?php echo $model; ?>Fixture extends CakeTestFixture {
|
||||||
public $name = '<?php echo $model; ?>';
|
public $name = '<?php echo $model; ?>';
|
||||||
<?php if ($table): ?>
|
<?php if ($table): ?>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||||
*/
|
*/
|
||||||
echo "<?php\n";
|
echo "<?php\n";
|
||||||
echo "/* ". $className ." Test cases generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n";
|
echo "/* ". $className ." Test cases generated on: " . date('Y-m-d H:i:s') . " : ". time() . "*/\n";
|
||||||
?>
|
?>
|
||||||
App::import('<?php echo $type; ?>', '<?php echo $plugin . $className;?>');
|
App::import('<?php echo $type; ?>', '<?php echo $plugin . $className;?>');
|
||||||
|
|
||||||
|
|
30
cake/libs/cache/memcache.php
vendored
30
cake/libs/cache/memcache.php
vendored
|
@ -33,7 +33,7 @@ class MemcacheEngine extends CacheEngine {
|
||||||
* @var Memcache
|
* @var Memcache
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private $__Memcache = null;
|
protected $_Memcache = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings
|
* Settings
|
||||||
|
@ -74,12 +74,12 @@ class MemcacheEngine extends CacheEngine {
|
||||||
if (!is_array($this->settings['servers'])) {
|
if (!is_array($this->settings['servers'])) {
|
||||||
$this->settings['servers'] = array($this->settings['servers']);
|
$this->settings['servers'] = array($this->settings['servers']);
|
||||||
}
|
}
|
||||||
if (!isset($this->__Memcache)) {
|
if (!isset($this->_Memcache)) {
|
||||||
$return = false;
|
$return = false;
|
||||||
$this->__Memcache = new Memcache();
|
$this->_Memcache = new Memcache();
|
||||||
foreach ($this->settings['servers'] as $server) {
|
foreach ($this->settings['servers'] as $server) {
|
||||||
list($host, $port) = $this->_parseServerString($server);
|
list($host, $port) = $this->_parseServerString($server);
|
||||||
if ($this->__Memcache->addServer($host, $port)) {
|
if ($this->_Memcache->addServer($host, $port)) {
|
||||||
$return = true;
|
$return = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,8 +116,7 @@ class MemcacheEngine extends CacheEngine {
|
||||||
/**
|
/**
|
||||||
* Write data for key into cache. When using memcache as your cache engine
|
* Write data for key into cache. When using memcache as your cache engine
|
||||||
* remember that the Memcache pecl extension does not support cache expiry times greater
|
* remember that the Memcache pecl extension does not support cache expiry times greater
|
||||||
* than 30 days in the future. If you wish to create cache entries that do not expire, set the duration
|
* than 30 days in the future. Any duration greater than 30 days will be treated as never expiring.
|
||||||
* to `0` in your cache configuration.
|
|
||||||
*
|
*
|
||||||
* @param string $key Identifier for the data
|
* @param string $key Identifier for the data
|
||||||
* @param mixed $value Data to be cached
|
* @param mixed $value Data to be cached
|
||||||
|
@ -126,7 +125,10 @@ class MemcacheEngine extends CacheEngine {
|
||||||
* @see http://php.net/manual/en/memcache.set.php
|
* @see http://php.net/manual/en/memcache.set.php
|
||||||
*/
|
*/
|
||||||
public function write($key, $value, $duration) {
|
public function write($key, $value, $duration) {
|
||||||
return $this->__Memcache->set($key, $value, $this->settings['compress'], $duration);
|
if ($duration > 30 * DAY) {
|
||||||
|
$duration = 0;
|
||||||
|
}
|
||||||
|
return $this->_Memcache->set($key, $value, $this->settings['compress'], $duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +138,7 @@ class MemcacheEngine extends CacheEngine {
|
||||||
* @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
|
* @return mixed The cached data, or false if the data doesn't exist, has expired, or if there was an error fetching it
|
||||||
*/
|
*/
|
||||||
public function read($key) {
|
public function read($key) {
|
||||||
return $this->__Memcache->get($key);
|
return $this->_Memcache->get($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -154,7 +156,7 @@ class MemcacheEngine extends CacheEngine {
|
||||||
__('Method increment() not implemented for compressed cache in %s', __CLASS__)
|
__('Method increment() not implemented for compressed cache in %s', __CLASS__)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $this->__Memcache->increment($key, $offset);
|
return $this->_Memcache->increment($key, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,7 +174,7 @@ class MemcacheEngine extends CacheEngine {
|
||||||
__('Method decrement() not implemented for compressed cache in %s', __CLASS__)
|
__('Method decrement() not implemented for compressed cache in %s', __CLASS__)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $this->__Memcache->decrement($key, $offset);
|
return $this->_Memcache->decrement($key, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -182,7 +184,7 @@ class MemcacheEngine extends CacheEngine {
|
||||||
* @return boolean True if the value was succesfully deleted, false if it didn't exist or couldn't be removed
|
* @return boolean True if the value was succesfully deleted, false if it didn't exist or couldn't be removed
|
||||||
*/
|
*/
|
||||||
public function delete($key) {
|
public function delete($key) {
|
||||||
return $this->__Memcache->delete($key);
|
return $this->_Memcache->delete($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -191,7 +193,7 @@ class MemcacheEngine extends CacheEngine {
|
||||||
* @return boolean True if the cache was succesfully cleared, false otherwise
|
* @return boolean True if the cache was succesfully cleared, false otherwise
|
||||||
*/
|
*/
|
||||||
public function clear($check) {
|
public function clear($check) {
|
||||||
return $this->__Memcache->flush();
|
return $this->_Memcache->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,8 +204,8 @@ class MemcacheEngine extends CacheEngine {
|
||||||
* @return boolean True if memcache server was connected
|
* @return boolean True if memcache server was connected
|
||||||
*/
|
*/
|
||||||
public function connect($host, $port = 11211) {
|
public function connect($host, $port = 11211) {
|
||||||
if ($this->__Memcache->getServerStatus($host, $port) === 0) {
|
if ($this->_Memcache->getServerStatus($host, $port) === 0) {
|
||||||
if ($this->__Memcache->connect($host, $port)) {
|
if ($this->_Memcache->connect($host, $port)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -74,7 +74,7 @@ class ComponentCollection extends ObjectCollection {
|
||||||
* @throws MissingComponentFileException, MissingComponentClassException when the component could not be found
|
* @throws MissingComponentFileException, MissingComponentClassException when the component could not be found
|
||||||
*/
|
*/
|
||||||
public function load($component, $settings = array()) {
|
public function load($component, $settings = array()) {
|
||||||
if (isset($settings['className'])) {
|
if (is_array($settings) && isset($settings['className'])) {
|
||||||
$alias = $component;
|
$alias = $component;
|
||||||
$component = $settings['className'];
|
$component = $settings['className'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,6 +132,7 @@ class RequestHandlerComponent extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->params = $controller->params;
|
||||||
$this->_set($settings);
|
$this->_set($settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,7 +586,9 @@ class RequestHandlerComponent extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cType != null) {
|
if ($cType != null) {
|
||||||
$this->response->type($cType);
|
if (empty($this->request->params['requested'])) {
|
||||||
|
$this->response->type($cType);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($options['charset'])) {
|
if (!empty($options['charset'])) {
|
||||||
$this->response->charset($options['charset']);
|
$this->response->charset($options['charset']);
|
||||||
|
|
|
@ -99,7 +99,7 @@ class BehaviorCollection extends ObjectCollection {
|
||||||
* @throws MissingBehaviorFileException or MissingBehaviorClassException when a behavior could not be found.
|
* @throws MissingBehaviorFileException or MissingBehaviorClassException when a behavior could not be found.
|
||||||
*/
|
*/
|
||||||
public function load($behavior, $config = array()) {
|
public function load($behavior, $config = array()) {
|
||||||
if (isset($config['className'])) {
|
if (is_array($config) && isset($config['className'])) {
|
||||||
$alias = $behavior;
|
$alias = $behavior;
|
||||||
$behavior = $config['className'];
|
$behavior = $config['className'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -365,7 +365,7 @@ class CakeSchema extends Object {
|
||||||
$out .= "}\n";
|
$out .= "}\n";
|
||||||
|
|
||||||
$file = new SplFileObject($path . DS . $file, 'w+');
|
$file = new SplFileObject($path . DS . $file, 'w+');
|
||||||
$content = "<?php \n/* {$name} schema generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
|
$content = "<?php \n/* {$name} schema generated on: " . date('Y-m-d H:i:s') . " : ". time() . "*/\n{$out}?>";
|
||||||
if ($file->fwrite($content)) {
|
if ($file->fwrite($content)) {
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class AclNode extends AppModel {
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
public $actsAs = array('Tree' => 'nested');
|
public $actsAs = array('Tree' => array('nested'));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
|
|
@ -173,7 +173,7 @@ class CakeRoute {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the given URL can be parsed by this route.
|
* Checks to see if the given URL can be parsed by this route.
|
||||||
* If the route can be parsed an array of parameters will be returned if not
|
* If the route can be parsed an array of parameters will be returned; if not
|
||||||
* false will be returned. String urls are parsed if they match a routes regular expression.
|
* false will be returned. String urls are parsed if they match a routes regular expression.
|
||||||
*
|
*
|
||||||
* @param string $url The url to attempt to parse.
|
* @param string $url The url to attempt to parse.
|
||||||
|
@ -245,8 +245,8 @@ class CakeRoute {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to match a url array. If the url matches the route parameters + settings, then
|
* Attempt to match a url array. If the url matches the route parameters and settings, then
|
||||||
* return a generated string url. If the url doesn't match the route parameters false will be returned.
|
* return a generated string url. If the url doesn't match the route parameters, false will be returned.
|
||||||
* This method handles the reverse routing or conversion of url arrays into string urls.
|
* This method handles the reverse routing or conversion of url arrays into string urls.
|
||||||
*
|
*
|
||||||
* @param array $url An array of parameters to check matching with.
|
* @param array $url An array of parameters to check matching with.
|
||||||
|
|
|
@ -221,21 +221,25 @@ class Router {
|
||||||
* Shows connecting a route with custom route parameters as well as providing patterns for those parameters.
|
* Shows connecting a route with custom route parameters as well as providing patterns for those parameters.
|
||||||
* Patterns for routing parameters do not need capturing groups, as one will be added for each route params.
|
* Patterns for routing parameters do not need capturing groups, as one will be added for each route params.
|
||||||
*
|
*
|
||||||
* $options offers two 'special' keys. `pass` and `persist` have special meaning in the $options array.
|
* $options offers three 'special' keys. `pass`, `persist` and `routeClass` have special meaning in the $options array.
|
||||||
*
|
*
|
||||||
* `pass` is used to define which of the routed parameters should be shifted into the pass array. Adding a
|
* `pass` is used to define which of the routed parameters should be shifted into the pass array. Adding a
|
||||||
* parameter to pass will remove it from the regular route array. Ex. `'pass' => array('slug')`
|
* parameter to pass will remove it from the regular route array. Ex. `'pass' => array('slug')`
|
||||||
*
|
*
|
||||||
* `persist` is used to define which route parameters should be automatically included when generating
|
* `persist` is used to define which route parameters should be automatically included when generating
|
||||||
* new urls. You can override peristent parameters by redifining them in a url or remove them by
|
* new urls. You can override persistent parameters by redefining them in a url or remove them by
|
||||||
* setting the parameter to `false`. Ex. `'persist' => array('lang')`
|
* setting the parameter to `false`. Ex. `'persist' => array('lang')`
|
||||||
*
|
*
|
||||||
|
* `routeClass` is used to extend and change how individual routes parse requests and handle reverse routing,
|
||||||
|
* via a custom routing class. Ex. `'routeClass' => 'SlugRoute'`
|
||||||
|
*
|
||||||
* @param string $route A string describing the template of the route
|
* @param string $route A string describing the template of the route
|
||||||
* @param array $defaults An array describing the default route parameters. These parameters will be used by default
|
* @param array $defaults An array describing the default route parameters. These parameters will be used by default
|
||||||
* and can supply routing parameters that are not dynamic. See above.
|
* and can supply routing parameters that are not dynamic. See above.
|
||||||
* @param array $options An array matching the named elements in the route to regular expressions which that
|
* @param array $options An array matching the named elements in the route to regular expressions which that
|
||||||
* element should match. Also contains additional parameters such as which routed parameters should be
|
* element should match. Also contains additional parameters such as which routed parameters should be
|
||||||
* shifted into the passed arguments. As well as supplying patterns for routing parameters.
|
* shifted into the passed arguments, supplying patterns for routing parameters and supplying the name of a
|
||||||
|
* custom routing class.
|
||||||
* @see routes
|
* @see routes
|
||||||
* @return array Array of routes
|
* @return array Array of routes
|
||||||
* @throws RouterException
|
* @throws RouterException
|
||||||
|
@ -731,7 +735,7 @@ class Router {
|
||||||
*
|
*
|
||||||
* @param $which A zero-based array index representing the route to move. For example,
|
* @param $which A zero-based array index representing the route to move. For example,
|
||||||
* if 3 routes have been added, the last route would be 2.
|
* if 3 routes have been added, the last route would be 2.
|
||||||
* @return boolean Retuns false if no route exists at the position specified by $which.
|
* @return boolean Returns false if no route exists at the position specified by $which.
|
||||||
*/
|
*/
|
||||||
public static function promote($which = null) {
|
public static function promote($which = null) {
|
||||||
if ($which === null) {
|
if ($which === null) {
|
||||||
|
@ -752,7 +756,7 @@ class Router {
|
||||||
* Returns an URL pointing to a combination of controller and action. Param
|
* Returns an URL pointing to a combination of controller and action. Param
|
||||||
* $url can be:
|
* $url can be:
|
||||||
*
|
*
|
||||||
* - Empty - the method will find address to actuall controller/action.
|
* - Empty - the method will find address to actual controller/action.
|
||||||
* - '/' - the method will find base URL of application.
|
* - '/' - the method will find base URL of application.
|
||||||
* - A combination of controller/action - the method will find url for it.
|
* - A combination of controller/action - the method will find url for it.
|
||||||
*
|
*
|
||||||
|
@ -1068,7 +1072,7 @@ class Router {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverses a parsed parameter array into a string. Works similarily to Router::url(), but
|
* Reverses a parsed parameter array into a string. Works similarly to Router::url(), but
|
||||||
* Since parsed URL's contain additional 'pass' and 'named' as well as 'url.url' keys.
|
* Since parsed URL's contain additional 'pass' and 'named' as well as 'url.url' keys.
|
||||||
* Those keys need to be specially handled in order to reverse a params array into a string url.
|
* Those keys need to be specially handled in order to reverse a params array into a string url.
|
||||||
*
|
*
|
||||||
|
@ -1199,7 +1203,7 @@ class Router {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes an passed params and converts it to args
|
* Takes a passed params and converts it to args
|
||||||
*
|
*
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @return array Array containing passed and named parameters
|
* @return array Array containing passed and named parameters
|
||||||
|
@ -1263,5 +1267,6 @@ class Router {
|
||||||
return compact('pass', 'named');
|
return compact('pass', 'named');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Save the initial state
|
//Save the initial state
|
||||||
Router::reload();
|
Router::reload();
|
||||||
|
|
|
@ -106,6 +106,9 @@ class DatabaseSession implements CakeSessionHandlerInterface {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
public function write($id, $data) {
|
public function write($id, $data) {
|
||||||
|
if (!$id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$expires = time() + (Configure::read('Session.timeout') * 60);
|
$expires = time() + (Configure::read('Session.timeout') * 60);
|
||||||
return ClassRegistry::getObject('Session')->save(compact('id', 'data', 'expires'));
|
return ClassRegistry::getObject('Session')->save(compact('id', 'data', 'expires'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ class HelperCollection extends ObjectCollection {
|
||||||
* @throws MissingHelperFileException, MissingHelperClassException when the helper could not be found
|
* @throws MissingHelperFileException, MissingHelperClassException when the helper could not be found
|
||||||
*/
|
*/
|
||||||
public function load($helper, $settings = array()) {
|
public function load($helper, $settings = array()) {
|
||||||
if (isset($settings['className'])) {
|
if (is_array($settings) && isset($settings['className'])) {
|
||||||
$alias = $helper;
|
$alias = $helper;
|
||||||
$helper = $settings['className'];
|
$helper = $settings['className'];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1001,7 +1001,10 @@ class FormHelper extends AppHelper {
|
||||||
|
|
||||||
if (empty($options['value'])) {
|
if (empty($options['value'])) {
|
||||||
$options['value'] = 1;
|
$options['value'] = 1;
|
||||||
} elseif (!empty($value) && $value === $options['value']) {
|
} elseif (
|
||||||
|
(!isset($options['checked']) && !empty($value) && $value === $options['value']) ||
|
||||||
|
!empty($options['checked'])
|
||||||
|
) {
|
||||||
$options['checked'] = 'checked';
|
$options['checked'] = 'checked';
|
||||||
}
|
}
|
||||||
if ($options['hiddenField']) {
|
if ($options['hiddenField']) {
|
||||||
|
@ -1322,7 +1325,6 @@ class FormHelper extends AppHelper {
|
||||||
unset($options['confirm']);
|
unset($options['confirm']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = $this->url($url);
|
|
||||||
$formName = uniqid('post_');
|
$formName = uniqid('post_');
|
||||||
$out = $this->create(false, array('url' => $url, 'name' => $formName, 'id' => $formName, 'style' => 'display:none;'));
|
$out = $this->create(false, array('url' => $url, 'name' => $formName, 'id' => $formName, 'style' => 'display:none;'));
|
||||||
if (isset($options['data']) && is_array($options['data'])) {
|
if (isset($options['data']) && is_array($options['data'])) {
|
||||||
|
@ -2021,7 +2023,7 @@ class FormHelper extends AppHelper {
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = $this->_View->field;
|
$name = !empty($this->_View->field) ? $this->_View->field : $this->_View->model;
|
||||||
if (!empty($this->_View->fieldSuffix)) {
|
if (!empty($this->_View->fieldSuffix)) {
|
||||||
$name .= '[' . $this->_View->fieldSuffix . ']';
|
$name .= '[' . $this->_View->fieldSuffix . ']';
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,8 +180,9 @@ class TextHelper extends AppHelper {
|
||||||
*/
|
*/
|
||||||
public function autoLinkEmails($text, $options = array()) {
|
public function autoLinkEmails($text, $options = array()) {
|
||||||
$this->_linkOptions = $options;
|
$this->_linkOptions = $options;
|
||||||
|
$atom = '[a-z0-9!#$%&\'*+\/=?^_`{|}~-]';
|
||||||
return preg_replace_callback(
|
return preg_replace_callback(
|
||||||
'#([_A-Za-z0-9+-]+(?:\.[_A-Za-z0-9+-]+)*@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)#',
|
'/(' . $atom . '+(?:\.' . $atom . '+)*@[a-z0-9-]+(?:\.[a-z0-9-]+)*)/i',
|
||||||
array(&$this, '_linkEmails'),
|
array(&$this, '_linkEmails'),
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
|
|
@ -326,6 +326,7 @@ class View extends Object {
|
||||||
return $contents;
|
return $contents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $this->_getElementFilename($name, $plugin);
|
$file = $this->_getElementFilename($name, $plugin);
|
||||||
|
|
||||||
if ($file) {
|
if ($file) {
|
||||||
|
@ -623,7 +624,7 @@ class View extends Object {
|
||||||
public function loadHelpers() {
|
public function loadHelpers() {
|
||||||
$helpers = HelperCollection::normalizeObjectArray($this->helpers);
|
$helpers = HelperCollection::normalizeObjectArray($this->helpers);
|
||||||
foreach ($helpers as $name => $properties) {
|
foreach ($helpers as $name => $properties) {
|
||||||
$this->Helpers->load($properties['class'], $properties['settings'], true);
|
$this->Helpers->load($properties['class'], $properties['settings']);
|
||||||
}
|
}
|
||||||
$this->_helpersLoaded = true;
|
$this->_helpersLoaded = true;
|
||||||
}
|
}
|
||||||
|
@ -698,10 +699,7 @@ class View extends Object {
|
||||||
}
|
}
|
||||||
$paths = $this->_paths($this->plugin);
|
$paths = $this->_paths($this->plugin);
|
||||||
|
|
||||||
$exts = array($this->ext);
|
$exts = $this->_getExtensions();
|
||||||
if ($this->ext !== '.ctp') {
|
|
||||||
array_push($exts, '.ctp');
|
|
||||||
}
|
|
||||||
foreach ($exts as $ext) {
|
foreach ($exts as $ext) {
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
if (file_exists($path . $name . $ext)) {
|
if (file_exists($path . $name . $ext)) {
|
||||||
|
@ -741,11 +739,8 @@ class View extends Object {
|
||||||
}
|
}
|
||||||
$paths = $this->_paths($this->plugin);
|
$paths = $this->_paths($this->plugin);
|
||||||
$file = 'layouts' . DS . $subDir . $name;
|
$file = 'layouts' . DS . $subDir . $name;
|
||||||
|
|
||||||
$exts = array($this->ext);
|
$exts = $this->_getExtensions();
|
||||||
if ($this->ext !== '.ctp') {
|
|
||||||
array_push($exts, '.ctp');
|
|
||||||
}
|
|
||||||
foreach ($exts as $ext) {
|
foreach ($exts as $ext) {
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
if (file_exists($path . $file . $ext)) {
|
if (file_exists($path . $file . $ext)) {
|
||||||
|
@ -756,6 +751,21 @@ class View extends Object {
|
||||||
throw new MissingLayoutException(array('file' => $paths[0] . $file . $this->ext));
|
throw new MissingLayoutException(array('file' => $paths[0] . $file . $this->ext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the extensions that view files can use.
|
||||||
|
*
|
||||||
|
* @return array Array of extensions view files use.
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function _getExtensions() {
|
||||||
|
$exts = array($this->ext);
|
||||||
|
if ($this->ext !== '.ctp') {
|
||||||
|
array_push($exts, '.ctp');
|
||||||
|
}
|
||||||
|
return $exts;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds an element filename, returns false on failure.
|
* Finds an element filename, returns false on failure.
|
||||||
*
|
*
|
||||||
|
@ -765,9 +775,12 @@ class View extends Object {
|
||||||
*/
|
*/
|
||||||
protected function _getElementFileName($name, $plugin = null) {
|
protected function _getElementFileName($name, $plugin = null) {
|
||||||
$paths = $this->_paths($plugin);
|
$paths = $this->_paths($plugin);
|
||||||
foreach ($paths as $path) {
|
$exts = $this->_getExtensions();
|
||||||
if (file_exists($path . 'elements' . DS . $name . $this->ext)) {
|
foreach ($exts as $ext) {
|
||||||
return $path . 'elements' . DS . $name . $this->ext;
|
foreach ($paths as $path) {
|
||||||
|
if (file_exists($path . 'elements' . DS . $name . $ext)) {
|
||||||
|
return $path . 'elements' . DS . $name . $ext;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -90,7 +90,13 @@ class BasicsTest extends CakeTestCase {
|
||||||
$__ENV = $_ENV;
|
$__ENV = $_ENV;
|
||||||
|
|
||||||
$_SERVER['HTTP_HOST'] = 'localhost';
|
$_SERVER['HTTP_HOST'] = 'localhost';
|
||||||
$this->assertEqual(env('HTTP_BASE'), '');
|
$this->assertEqual(env('HTTP_BASE'), '.localhost');
|
||||||
|
|
||||||
|
$_SERVER['HTTP_HOST'] = 'com.ar';
|
||||||
|
$this->assertEqual(env('HTTP_BASE'), '.com.ar');
|
||||||
|
|
||||||
|
$_SERVER['HTTP_HOST'] = 'example.ar';
|
||||||
|
$this->assertEqual(env('HTTP_BASE'), '.example.ar');
|
||||||
|
|
||||||
$_SERVER['HTTP_HOST'] = 'example.com';
|
$_SERVER['HTTP_HOST'] = 'example.com';
|
||||||
$this->assertEqual(env('HTTP_BASE'), '.example.com');
|
$this->assertEqual(env('HTTP_BASE'), '.example.com');
|
||||||
|
@ -101,9 +107,21 @@ class BasicsTest extends CakeTestCase {
|
||||||
$_SERVER['HTTP_HOST'] = 'subdomain.example.com';
|
$_SERVER['HTTP_HOST'] = 'subdomain.example.com';
|
||||||
$this->assertEqual(env('HTTP_BASE'), '.example.com');
|
$this->assertEqual(env('HTTP_BASE'), '.example.com');
|
||||||
|
|
||||||
|
$_SERVER['HTTP_HOST'] = 'example.com.ar';
|
||||||
|
$this->assertEqual(env('HTTP_BASE'), '.example.com.ar');
|
||||||
|
|
||||||
|
$_SERVER['HTTP_HOST'] = 'www.example.com.ar';
|
||||||
|
$this->assertEqual(env('HTTP_BASE'), '.example.com.ar');
|
||||||
|
|
||||||
|
$_SERVER['HTTP_HOST'] = 'subdomain.example.com.ar';
|
||||||
|
$this->assertEqual(env('HTTP_BASE'), '.example.com.ar');
|
||||||
|
|
||||||
$_SERVER['HTTP_HOST'] = 'double.subdomain.example.com';
|
$_SERVER['HTTP_HOST'] = 'double.subdomain.example.com';
|
||||||
$this->assertEqual(env('HTTP_BASE'), '.subdomain.example.com');
|
$this->assertEqual(env('HTTP_BASE'), '.subdomain.example.com');
|
||||||
|
|
||||||
|
$_SERVER['HTTP_HOST'] = 'double.subdomain.example.com.ar';
|
||||||
|
$this->assertEqual(env('HTTP_BASE'), '.subdomain.example.com.ar');
|
||||||
|
|
||||||
$_SERVER = $_ENV = array();
|
$_SERVER = $_ENV = array();
|
||||||
|
|
||||||
$_SERVER['SCRIPT_NAME'] = '/a/test/test.php';
|
$_SERVER['SCRIPT_NAME'] = '/a/test/test.php';
|
||||||
|
|
|
@ -63,7 +63,7 @@ class TaskCollectionTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testLoadWithEnableFalse() {
|
function testLoadWithEnableFalse() {
|
||||||
$result = $this->Tasks->load('DbConfig', array(), false);
|
$result = $this->Tasks->load('DbConfig', array('enabled' => false));
|
||||||
$this->assertInstanceOf('DbConfigTask', $result);
|
$this->assertInstanceOf('DbConfigTask', $result);
|
||||||
$this->assertInstanceOf('DbConfigTask', $this->Tasks->DbConfig);
|
$this->assertInstanceOf('DbConfigTask', $this->Tasks->DbConfig);
|
||||||
|
|
||||||
|
|
24
cake/tests/cases/libs/cache/memcache.test.php
vendored
24
cake/tests/cases/libs/cache/memcache.test.php
vendored
|
@ -31,6 +31,10 @@ class TestMemcacheEngine extends MemcacheEngine {
|
||||||
function parseServerString($server) {
|
function parseServerString($server) {
|
||||||
return $this->_parseServerString($server);
|
return $this->_parseServerString($server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setMemcache($memcache) {
|
||||||
|
$this->_Memcache = $memcache;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -357,7 +361,25 @@ class MemcacheEngineTest extends CakeTestCase {
|
||||||
$this->assertTrue($result, 'Could not write with duration 0');
|
$this->assertTrue($result, 'Could not write with duration 0');
|
||||||
$result = Cache::read('test_key', 'memcache');
|
$result = Cache::read('test_key', 'memcache');
|
||||||
$this->assertEqual($result, 'written!');
|
$this->assertEqual($result, 'written!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that durations greater than 30 days never expire
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testLongDurationEqualToZero() {
|
||||||
|
$memcache =& new TestMemcacheEngine();
|
||||||
|
$memcache->settings['compress'] = false;
|
||||||
|
|
||||||
|
$mock = $this->getMock('Memcache');
|
||||||
|
$memcache->setMemcache($mock);
|
||||||
|
$mock->expects($this->once())
|
||||||
|
->method('set')
|
||||||
|
->with('key', 'value', false, 0);
|
||||||
|
|
||||||
|
$value = 'value';
|
||||||
|
$memcache->write('key', $value, 50 * DAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1505,7 +1505,6 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
);
|
);
|
||||||
$TestModel->save($data);
|
$TestModel->save($data);
|
||||||
$result = $TestModel->read(null, 1);
|
$result = $TestModel->read(null, 1);
|
||||||
$time = date('Y-M-D H:i:s');
|
|
||||||
$expected = array(4, 5);
|
$expected = array(4, 5);
|
||||||
$this->assertEqual(Set::extract('/JoinC/JoinAsJoinC/id', $result), $expected);
|
$this->assertEqual(Set::extract('/JoinC/JoinAsJoinC/id', $result), $expected);
|
||||||
$expected = array('new record', 'new record');
|
$expected = array('new record', 'new record');
|
||||||
|
|
|
@ -54,16 +54,16 @@ class GenericObjectCollection extends ObjectCollection {
|
||||||
*
|
*
|
||||||
* @param string $object Object name
|
* @param string $object Object name
|
||||||
* @param array $settings Settings array
|
* @param array $settings Settings array
|
||||||
* @param boolean $enable Start object as enabled
|
|
||||||
* @return array List of loaded objects
|
* @return array List of loaded objects
|
||||||
*/
|
*/
|
||||||
public function load($object, $settings = array(), $enable = true) {
|
public function load($object, $settings = array()) {
|
||||||
list($plugin, $name) = pluginSplit($object);
|
list($plugin, $name) = pluginSplit($object);
|
||||||
if (isset($this->_loaded[$name])) {
|
if (isset($this->_loaded[$name])) {
|
||||||
return $this->_loaded[$name];
|
return $this->_loaded[$name];
|
||||||
}
|
}
|
||||||
$objectClass = $name . 'GenericObject';
|
$objectClass = $name . 'GenericObject';
|
||||||
$this->_loaded[$name] = new $objectClass($this, $settings);
|
$this->_loaded[$name] = new $objectClass($this, $settings);
|
||||||
|
$enable = isset($settings['enabled']) ? $settings['enabled'] : true;
|
||||||
if ($enable === true) {
|
if ($enable === true) {
|
||||||
$this->_enabled[] = $name;
|
$this->_enabled[] = $name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,16 @@ class DatabaseSessionTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testReadAndWriteWithDatabaseStorage method
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testWriteEmptySessionId() {
|
||||||
|
$result = $this->storage->write('', 'This is a Test');
|
||||||
|
$this->assertFalse($result);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* test read()
|
* test read()
|
||||||
*
|
*
|
||||||
|
|
|
@ -2168,6 +2168,35 @@ class FormHelperTest extends CakeTestCase {
|
||||||
'/div'
|
'/div'
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$this->Form->data = array();
|
||||||
|
$result = $this->Form->input('Publisher.id', array(
|
||||||
|
'label' => 'Publisher',
|
||||||
|
'type' => 'select',
|
||||||
|
'multiple' => 'checkbox',
|
||||||
|
'options' => array('Value 1' => 'Label 1', 'Value 2' => 'Label 2')
|
||||||
|
));
|
||||||
|
$expected = array(
|
||||||
|
array('div' => array('class' => 'input select')),
|
||||||
|
array('label' => array('for' => 'PublisherId')),
|
||||||
|
'Publisher',
|
||||||
|
'/label',
|
||||||
|
'input' => array('type' => 'hidden', 'name' => 'data[Publisher][id]', 'value' => '', 'id' => 'PublisherId'),
|
||||||
|
array('div' => array('class' => 'checkbox')),
|
||||||
|
array('input' => array('type' => 'checkbox', 'name' => 'data[Publisher][id][]', 'value' => 'Value 1', 'id' => 'PublisherIdValue1')),
|
||||||
|
array('label' => array('for' => 'PublisherIdValue1')),
|
||||||
|
'Label 1',
|
||||||
|
'/label',
|
||||||
|
'/div',
|
||||||
|
array('div' => array('class' => 'checkbox')),
|
||||||
|
array('input' => array('type' => 'checkbox', 'name' => 'data[Publisher][id][]', 'value' => 'Value 2', 'id' => 'PublisherIdValue2')),
|
||||||
|
array('label' => array('for' => 'PublisherIdValue2')),
|
||||||
|
'Label 2',
|
||||||
|
'/label',
|
||||||
|
'/div',
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3123,7 +3152,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
'/select'
|
'/select'
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$options = array(
|
$options = array(
|
||||||
'>< Key' => array(
|
'>< Key' => array(
|
||||||
1 => 'One',
|
1 => 'One',
|
||||||
|
@ -3500,7 +3529,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testSelectMultipleCheckboxDiv() {
|
function testSelectMultipleCheckboxDiv() {
|
||||||
$result = $this->Form->select(
|
$result = $this->Form->select(
|
||||||
'Model.tags',
|
'Model.tags',
|
||||||
array('first', 'second'),
|
array('first', 'second'),
|
||||||
array('multiple' => 'checkbox', 'class' => 'my-class')
|
array('multiple' => 'checkbox', 'class' => 'my-class')
|
||||||
);
|
);
|
||||||
|
@ -3528,7 +3557,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
|
|
||||||
$result = $this->Form->input('Model.tags', array(
|
$result = $this->Form->input('Model.tags', array(
|
||||||
'options' => array('first', 'second'),
|
'options' => array('first', 'second'),
|
||||||
'multiple' => 'checkbox',
|
'multiple' => 'checkbox',
|
||||||
'class' => 'my-class',
|
'class' => 'my-class',
|
||||||
'div' => false,
|
'div' => false,
|
||||||
'label' => false
|
'label' => false
|
||||||
|
@ -3762,27 +3791,6 @@ class FormHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$result = $this->Form->checkbox('Model.field', array('checked' => 'checked'));
|
|
||||||
$expected = array(
|
|
||||||
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
|
|
||||||
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
|
|
||||||
);
|
|
||||||
$this->assertTags($result, $expected);
|
|
||||||
|
|
||||||
$result = $this->Form->checkbox('Model.field', array('checked' => 1));
|
|
||||||
$expected = array(
|
|
||||||
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
|
|
||||||
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
|
|
||||||
);
|
|
||||||
$this->assertTags($result, $expected);
|
|
||||||
|
|
||||||
$result = $this->Form->checkbox('Model.field', array('checked' => true));
|
|
||||||
$expected = array(
|
|
||||||
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
|
|
||||||
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
|
|
||||||
);
|
|
||||||
$this->assertTags($result, $expected);
|
|
||||||
|
|
||||||
$this->Form->validationErrors['Model']['field'] = 1;
|
$this->Form->validationErrors['Model']['field'] = 1;
|
||||||
$this->Form->request->data['Contact']['published'] = 1;
|
$this->Form->request->data['Contact']['published'] = 1;
|
||||||
$result = $this->Form->checkbox('Contact.published', array('id' => 'theID'));
|
$result = $this->Form->checkbox('Contact.published', array('id' => 'theID'));
|
||||||
|
@ -3823,6 +3831,49 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test the checked option for checkboxes.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testCheckboxCheckedOption() {
|
||||||
|
$result = $this->Form->checkbox('Model.field', array('checked' => 'checked'));
|
||||||
|
$expected = array(
|
||||||
|
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
|
||||||
|
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->Form->checkbox('Model.field', array('checked' => 1));
|
||||||
|
$expected = array(
|
||||||
|
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
|
||||||
|
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->Form->checkbox('Model.field', array('checked' => true));
|
||||||
|
$expected = array(
|
||||||
|
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
|
||||||
|
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField', 'checked' => 'checked'))
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->Form->checkbox('Model.field', array('checked' => false));
|
||||||
|
$expected = array(
|
||||||
|
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
|
||||||
|
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField'))
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$this->Form->request->data['Model']['field'] = 1;
|
||||||
|
$result = $this->Form->checkbox('Model.field', array('checked' => false));
|
||||||
|
$expected = array(
|
||||||
|
'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'),
|
||||||
|
array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'ModelField'))
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that disabling a checkbox also disables the hidden input so no value is submitted
|
* Test that disabling a checkbox also disables the hidden input so no value is submitted
|
||||||
*
|
*
|
||||||
|
@ -5751,6 +5802,28 @@ class FormHelperTest extends CakeTestCase {
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test get form, and inputs when the model param is false
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testGetFormWithFalseModel() {
|
||||||
|
$encoding = strtolower(Configure::read('App.encoding'));
|
||||||
|
$result = $this->Form->create(false, array('type' => 'get'));
|
||||||
|
|
||||||
|
$expected = array('form' => array(
|
||||||
|
'id' => 'addForm', 'method' => 'get', 'action' => '/contact_test/add',
|
||||||
|
'accept-charset' => $encoding
|
||||||
|
));
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
|
$result = $this->Form->text('reason');
|
||||||
|
$expected = array(
|
||||||
|
'input' => array('type' => 'text', 'name' => 'reason', 'id' => 'reason')
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test that datetime() works with GET style forms.
|
* test that datetime() works with GET style forms.
|
||||||
*
|
*
|
||||||
|
|
|
@ -273,6 +273,16 @@ class TextHelperTest extends CakeTestCase {
|
||||||
$expected = 'Text with a url <a href="http://www.cot.ag/cuIb2Q">www.cot.ag/cuIb2Q</a> and more';
|
$expected = 'Text with a url <a href="http://www.cot.ag/cuIb2Q">www.cot.ag/cuIb2Q</a> and more';
|
||||||
$result = $this->Text->autoLinkUrls($text);
|
$result = $this->Text->autoLinkUrls($text);
|
||||||
$this->assertEqual($expected, $result);
|
$this->assertEqual($expected, $result);
|
||||||
|
|
||||||
|
$text = 'Text with a url http://www.does--not--work.com and more';
|
||||||
|
$expected = 'Text with a url <a href="http://www.does--not--work.com">http://www.does--not--work.com</a> and more';
|
||||||
|
$result = $this->Text->autoLinkUrls($text);
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
|
||||||
|
$text = 'Text with a url http://www.not--work.com and more';
|
||||||
|
$expected = 'Text with a url <a href="http://www.not--work.com">http://www.not--work.com</a> and more';
|
||||||
|
$result = $this->Text->autoLinkUrls($text);
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -291,6 +301,11 @@ class TextHelperTest extends CakeTestCase {
|
||||||
$expected = 'Text with <a href="mailto:email@example.com"\s*>email@example.com</a> address';
|
$expected = 'Text with <a href="mailto:email@example.com"\s*>email@example.com</a> address';
|
||||||
$result = $this->Text->autoLinkEmails($text);
|
$result = $this->Text->autoLinkEmails($text);
|
||||||
$this->assertPattern('#^' . $expected . '$#', $result);
|
$this->assertPattern('#^' . $expected . '$#', $result);
|
||||||
|
|
||||||
|
$text = "Text with o'hare._-bob@example.com address";
|
||||||
|
$expected = 'Text with <a href="mailto:o'hare._-bob@example.com">o'hare._-bob@example.com</a> address';
|
||||||
|
$result = $this->Text->autoLinkEmails($text);
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
|
||||||
$text = 'Text with email@example.com address';
|
$text = 'Text with email@example.com address';
|
||||||
$expected = 'Text with <a href="mailto:email@example.com" \s*class="link">email@example.com</a> address';
|
$expected = 'Text with <a href="mailto:email@example.com" \s*class="link">email@example.com</a> address';
|
||||||
|
|
|
@ -544,6 +544,21 @@ class ViewTest extends CakeTestCase {
|
||||||
$this->assertInstanceOf('HtmlHelper', $View->Html);
|
$this->assertInstanceOf('HtmlHelper', $View->Html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that ctp is used as a fallback file extension for elements
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testElementCtpFallback() {
|
||||||
|
$View = new TestView($this->PostsController);
|
||||||
|
$View->ext = '.missing';
|
||||||
|
$element = 'test_element';
|
||||||
|
$expected = 'this is the test element';
|
||||||
|
$result = $View->element($element);
|
||||||
|
|
||||||
|
$this->assertEqual($expected, $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testLoadHelpers method
|
* testLoadHelpers method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue