mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch 'master' into 2.4
Conflicts: lib/Cake/Console/Command/ConsoleShell.php
This commit is contained in:
commit
38b050a711
52 changed files with 407 additions and 122 deletions
|
@ -79,8 +79,7 @@ if (!defined('WWW_ROOT')) {
|
||||||
|
|
||||||
// for built-in server
|
// for built-in server
|
||||||
if (php_sapi_name() == 'cli-server') {
|
if (php_sapi_name() == 'cli-server') {
|
||||||
$uri = str_replace($_SERVER['SCRIPT_FILENAME'], WWW_ROOT, '');
|
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) {
|
||||||
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $uri)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
|
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
|
||||||
|
|
|
@ -223,40 +223,67 @@ class FileEngine extends CacheEngine {
|
||||||
if (!$this->_init) {
|
if (!$this->_init) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$dir = dir($this->settings['path']);
|
$threshold = $now = false;
|
||||||
if ($check) {
|
if ($check) {
|
||||||
$now = time();
|
$now = time();
|
||||||
$threshold = $now - $this->settings['duration'];
|
$threshold = $now - $this->settings['duration'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->_clearDirectory($this->settings['path'], $now, $threshold);
|
||||||
|
|
||||||
|
$directory = new RecursiveDirectoryIterator($this->settings['path']);
|
||||||
|
$contents = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST);
|
||||||
|
foreach ($contents as $path) {
|
||||||
|
if ($path->isFile()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$this->_clearDirectory($path->getRealPath() . DS, $now, $threshold);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to clear a directory of matching files.
|
||||||
|
*
|
||||||
|
* @param string $path The path to search.
|
||||||
|
* @param integer $now The current timestamp
|
||||||
|
* @param integer $threshold Any file not modified after this value will be deleted.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function _clearDirectory($path, $now, $threshold) {
|
||||||
$prefixLength = strlen($this->settings['prefix']);
|
$prefixLength = strlen($this->settings['prefix']);
|
||||||
|
|
||||||
|
if (!is_dir($path)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dir = dir($path);
|
||||||
while (($entry = $dir->read()) !== false) {
|
while (($entry = $dir->read()) !== false) {
|
||||||
if (substr($entry, 0, $prefixLength) !== $this->settings['prefix']) {
|
if (substr($entry, 0, $prefixLength) !== $this->settings['prefix']) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($this->_setKey($entry) === false) {
|
$filePath = $path . $entry;
|
||||||
|
if (is_dir($filePath)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($check) {
|
$file = new SplFileObject($path . $entry, 'r');
|
||||||
$mtime = $this->_File->getMTime();
|
|
||||||
|
if ($threshold) {
|
||||||
|
$mtime = $file->getMTime();
|
||||||
|
|
||||||
if ($mtime > $threshold) {
|
if ($mtime > $threshold) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$expires = (int)$file->current();
|
||||||
$expires = (int)$this->_File->current();
|
|
||||||
|
|
||||||
if ($expires > $now) {
|
if ($expires > $now) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$path = $this->_File->getRealPath();
|
if ($file->isFile()) {
|
||||||
$this->_File = null;
|
unlink($file->getRealPath());
|
||||||
if (file_exists($path)) {
|
|
||||||
unlink($path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$dir->close();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
|
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
|
||||||
<?php if ($wannaUseSession): ?>
|
<?php if ($wannaUseSession): ?>
|
||||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
|
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
|
||||||
$this->redirect(array('action' => 'index'));
|
return $this->redirect(array('action' => 'index'));
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
$this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.'), array('action' => 'index'));
|
$this->flash(__('<?php echo ucfirst(strtolower($currentModelName)); ?> saved.'), array('action' => 'index'));
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
|
if ($this-><?php echo $currentModelName; ?>->save($this->request->data)) {
|
||||||
<?php if ($wannaUseSession): ?>
|
<?php if ($wannaUseSession): ?>
|
||||||
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
|
$this->Session->setFlash(__('The <?php echo strtolower($singularHumanName); ?> has been saved'));
|
||||||
$this->redirect(array('action' => 'index'));
|
return $this->redirect(array('action' => 'index'));
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
$this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
|
$this->flash(__('The <?php echo strtolower($singularHumanName); ?> has been saved.'), array('action' => 'index'));
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -145,7 +145,7 @@
|
||||||
if ($this-><?php echo $currentModelName; ?>->delete()) {
|
if ($this-><?php echo $currentModelName; ?>->delete()) {
|
||||||
<?php if ($wannaUseSession): ?>
|
<?php if ($wannaUseSession): ?>
|
||||||
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'));
|
$this->Session->setFlash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'));
|
||||||
$this->redirect(array('action' => 'index'));
|
return $this->redirect(array('action' => 'index'));
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index'));
|
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> deleted'), array('action' => 'index'));
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -155,5 +155,5 @@
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'), array('action' => 'index'));
|
$this->flash(__('<?php echo ucfirst(strtolower($singularHumanName)); ?> was not deleted'), array('action' => 'index'));
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
$this->redirect(array('action' => 'index'));
|
return $this->redirect(array('action' => 'index'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,7 @@ if (!defined('WWW_ROOT')) {
|
||||||
|
|
||||||
// for built-in server
|
// for built-in server
|
||||||
if (php_sapi_name() === 'cli-server') {
|
if (php_sapi_name() === 'cli-server') {
|
||||||
$uri = str_replace($_SERVER['SCRIPT_FILENAME'], WWW_ROOT, '');
|
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $_SERVER['PHP_SELF'])) {
|
||||||
if ($_SERVER['REQUEST_URI'] !== '/' && file_exists(WWW_ROOT . $uri)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
|
$_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
|
||||||
|
|
|
@ -233,7 +233,7 @@ class SecurityComponent extends Component {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($this->_action == $this->blackHoleCallback) {
|
if ($this->_action == $this->blackHoleCallback) {
|
||||||
return $this->blackhole($controller, 'auth');
|
return $this->blackHole($controller, 'auth');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array($this->_action, (array)$this->unlockedActions) && $isPost && $isNotRequestAction) {
|
if (!in_array($this->_action, (array)$this->unlockedActions) && $isPost && $isNotRequestAction) {
|
||||||
|
|
|
@ -54,6 +54,16 @@ class ComponentCollection extends ObjectCollection implements CakeEventListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the controller associated with the collection.
|
||||||
|
*
|
||||||
|
* @param Controller $Controller Controller to set
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setController(Controller $Controller) {
|
||||||
|
$this->_Controller = $Controller;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the controller associated with the collection.
|
* Get the controller associated with the collection.
|
||||||
*
|
*
|
||||||
|
|
|
@ -347,7 +347,7 @@ class Controller extends Object implements CakeEventListener {
|
||||||
* Lazy loads models using the loadModel() method if declared in $uses
|
* Lazy loads models using the loadModel() method if declared in $uses
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return void
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function __isset($name) {
|
public function __isset($name) {
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
|
@ -384,8 +384,8 @@ class Controller extends Object implements CakeEventListener {
|
||||||
* Provides backwards compatibility access to the request object properties.
|
* Provides backwards compatibility access to the request object properties.
|
||||||
* Also provides the params alias.
|
* Also provides the params alias.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name The name of the requested value
|
||||||
* @return void
|
* @return mixed The requested value for valid variables/aliases else null
|
||||||
*/
|
*/
|
||||||
public function __get($name) {
|
public function __get($name) {
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
|
@ -422,15 +422,19 @@ class Controller extends Object implements CakeEventListener {
|
||||||
case 'here':
|
case 'here':
|
||||||
case 'webroot':
|
case 'webroot':
|
||||||
case 'data':
|
case 'data':
|
||||||
return $this->request->{$name} = $value;
|
$this->request->{$name} = $value;
|
||||||
|
return;
|
||||||
case 'action':
|
case 'action':
|
||||||
return $this->request->params['action'] = $value;
|
$this->request->params['action'] = $value;
|
||||||
|
return;
|
||||||
case 'params':
|
case 'params':
|
||||||
return $this->request->params = $value;
|
$this->request->params = $value;
|
||||||
|
return;
|
||||||
case 'paginate':
|
case 'paginate':
|
||||||
return $this->Components->load('Paginator')->settings = $value;
|
$this->Components->load('Paginator')->settings = $value;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return $this->{$name} = $value;
|
$this->{$name} = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -714,7 +718,7 @@ class Controller extends Object implements CakeEventListener {
|
||||||
*
|
*
|
||||||
* @param string $modelClass Name of model class to load
|
* @param string $modelClass Name of model class to load
|
||||||
* @param integer|string $id Initial ID the instanced model class should have
|
* @param integer|string $id Initial ID the instanced model class should have
|
||||||
* @return mixed true when single model found and instance created, error returned if model not found.
|
* @return bool True if the model was found
|
||||||
* @throws MissingModelException if the model class cannot be found.
|
* @throws MissingModelException if the model class cannot be found.
|
||||||
*/
|
*/
|
||||||
public function loadModel($modelClass = null, $id = null) {
|
public function loadModel($modelClass = null, $id = null) {
|
||||||
|
|
|
@ -72,8 +72,8 @@ class Configure {
|
||||||
if (!include APP . 'Config' . DS . 'core.php') {
|
if (!include APP . 'Config' . DS . 'core.php') {
|
||||||
trigger_error(__d('cake_dev', "Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", APP . 'Config' . DS), E_USER_ERROR);
|
trigger_error(__d('cake_dev', "Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", APP . 'Config' . DS), E_USER_ERROR);
|
||||||
}
|
}
|
||||||
App::$bootstrapping = false;
|
|
||||||
App::init();
|
App::init();
|
||||||
|
App::$bootstrapping = false;
|
||||||
App::build();
|
App::build();
|
||||||
|
|
||||||
$exception = array(
|
$exception = array(
|
||||||
|
|
|
@ -124,12 +124,14 @@ class I18n {
|
||||||
*
|
*
|
||||||
* @param string $singular String to translate
|
* @param string $singular String to translate
|
||||||
* @param string $plural Plural string (if any)
|
* @param string $plural Plural string (if any)
|
||||||
* @param string $domain Domain The domain of the translation. Domains are often used by plugin translations
|
* @param string $domain Domain The domain of the translation. Domains are often used by plugin translations.
|
||||||
|
* If null, the default domain will be used.
|
||||||
* @param string $category Category The integer value of the category to use.
|
* @param string $category Category The integer value of the category to use.
|
||||||
* @param integer $count Count Count is used with $plural to choose the correct plural form.
|
* @param integer $count Count Count is used with $plural to choose the correct plural form.
|
||||||
* @param string $language Language to translate string to.
|
* @param string $language Language to translate string to.
|
||||||
* If null it checks for language in session followed by Config.language configuration variable.
|
* If null it checks for language in session followed by Config.language configuration variable.
|
||||||
* @return string translated string.
|
* @return string translated string.
|
||||||
|
* @throws CakeException When '' is provided as a domain.
|
||||||
*/
|
*/
|
||||||
public static function translate($singular, $plural = null, $domain = null, $category = 6, $count = null, $language = null) {
|
public static function translate($singular, $plural = null, $domain = null, $category = 6, $count = null, $language = null) {
|
||||||
$_this = I18n::getInstance();
|
$_this = I18n::getInstance();
|
||||||
|
@ -162,6 +164,9 @@ class I18n {
|
||||||
if (is_null($domain)) {
|
if (is_null($domain)) {
|
||||||
$domain = self::$defaultDomain;
|
$domain = self::$defaultDomain;
|
||||||
}
|
}
|
||||||
|
if ($domain === '') {
|
||||||
|
throw new CakeException(__d('cake_dev', 'You cannot use "" as a domain.'));
|
||||||
|
}
|
||||||
|
|
||||||
$_this->domain = $domain . '_' . $_this->l10n->lang;
|
$_this->domain = $domain . '_' . $_this->l10n->lang;
|
||||||
|
|
||||||
|
|
|
@ -1637,9 +1637,10 @@ class Model extends Object implements CakeEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($options['fieldList'])) {
|
if (!empty($options['fieldList'])) {
|
||||||
$this->whitelist = $options['fieldList'];
|
|
||||||
if (!empty($options['fieldList'][$this->alias]) && is_array($options['fieldList'][$this->alias])) {
|
if (!empty($options['fieldList'][$this->alias]) && is_array($options['fieldList'][$this->alias])) {
|
||||||
$this->whitelist = $options['fieldList'][$this->alias];
|
$this->whitelist = $options['fieldList'][$this->alias];
|
||||||
|
} elseif (Hash::dimensions($options['fieldList']) < 2) {
|
||||||
|
$this->whitelist = $options['fieldList'];
|
||||||
}
|
}
|
||||||
} elseif ($options['fieldList'] === null) {
|
} elseif ($options['fieldList'] === null) {
|
||||||
$this->whitelist = array();
|
$this->whitelist = array();
|
||||||
|
@ -2360,7 +2361,10 @@ class Model extends Object implements CakeEventListener {
|
||||||
$options['fieldList'][$this->alias][] = $key;
|
$options['fieldList'][$this->alias][] = $key;
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
if (!empty($options['fieldList']) && is_array($options['fieldList'])) {
|
if (!empty($options['fieldList']) &&
|
||||||
|
is_array($options['fieldList']) &&
|
||||||
|
Hash::dimensions($options['fieldList']) < 2
|
||||||
|
) {
|
||||||
$options['fieldList'][] = $key;
|
$options['fieldList'][] = $key;
|
||||||
}
|
}
|
||||||
return $options;
|
return $options;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
App::uses('CakeValidationSet', 'Model/Validator');
|
App::uses('CakeValidationSet', 'Model/Validator');
|
||||||
|
App::uses('Hash', 'Utility');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ModelValidator object encapsulates all methods related to data validations for a model
|
* ModelValidator object encapsulates all methods related to data validations for a model
|
||||||
|
@ -394,11 +395,11 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
|
||||||
}
|
}
|
||||||
unset($fieldList);
|
unset($fieldList);
|
||||||
|
|
||||||
$validateList = array();
|
if (empty($whitelist) || Hash::dimensions($whitelist) > 1) {
|
||||||
if (empty($whitelist)) {
|
|
||||||
return $this->_fields;
|
return $this->_fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$validateList = array();
|
||||||
$this->validationErrors = array();
|
$this->validationErrors = array();
|
||||||
foreach ((array)$whitelist as $f) {
|
foreach ((array)$whitelist as $f) {
|
||||||
if (!empty($this->_fields[$f])) {
|
if (!empty($this->_fields[$f])) {
|
||||||
|
|
|
@ -378,6 +378,9 @@ class CakeRoute {
|
||||||
* @return array An array with persistent parameters applied.
|
* @return array An array with persistent parameters applied.
|
||||||
*/
|
*/
|
||||||
public function persistParams($url, $params) {
|
public function persistParams($url, $params) {
|
||||||
|
if (empty($this->options['persist']) || !is_array($this->options['persist'])) {
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
foreach ($this->options['persist'] as $persistKey) {
|
foreach ($this->options['persist'] as $persistKey) {
|
||||||
if (array_key_exists($persistKey, $params) && !isset($url[$persistKey])) {
|
if (array_key_exists($persistKey, $params) && !isset($url[$persistKey])) {
|
||||||
$url[$persistKey] = $params[$persistKey];
|
$url[$persistKey] = $params[$persistKey];
|
||||||
|
|
|
@ -856,9 +856,7 @@ class Router {
|
||||||
for ($i = 0, $len = count(self::$routes); $i < $len; $i++) {
|
for ($i = 0, $len = count(self::$routes); $i < $len; $i++) {
|
||||||
$originalUrl = $url;
|
$originalUrl = $url;
|
||||||
|
|
||||||
if (isset(self::$routes[$i]->options['persist'], $params)) {
|
|
||||||
$url = self::$routes[$i]->persistParams($url, $params);
|
$url = self::$routes[$i]->persistParams($url, $params);
|
||||||
}
|
|
||||||
|
|
||||||
if ($match = self::$routes[$i]->match($url)) {
|
if ($match = self::$routes[$i]->match($url)) {
|
||||||
$output = trim($match, '/');
|
$output = trim($match, '/');
|
||||||
|
|
|
@ -52,7 +52,7 @@ class FileEngineTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
Cache::clear(false, 'file_test');
|
// Cache::clear(false, 'file_test');
|
||||||
Cache::drop('file_test');
|
Cache::drop('file_test');
|
||||||
Cache::drop('file_groups');
|
Cache::drop('file_groups');
|
||||||
Cache::drop('file_groups2');
|
Cache::drop('file_groups2');
|
||||||
|
@ -255,6 +255,41 @@ class FileEngineTest extends CakeTestCase {
|
||||||
$FileTwo->clear(false);
|
$FileTwo->clear(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that clear() also removes files with group tags.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testClearWithGroups() {
|
||||||
|
$engine = new FileEngine();
|
||||||
|
$engine->init(array(
|
||||||
|
'prefix' => 'cake_test_',
|
||||||
|
'duration' => DAY,
|
||||||
|
'groups' => array('short', 'round')
|
||||||
|
));
|
||||||
|
$key = 'cake_test_test_key';
|
||||||
|
$engine->write($key, 'it works', DAY);
|
||||||
|
$engine->clear(false);
|
||||||
|
$this->assertFalse($engine->read($key), 'Key should have been removed');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that clear() also removes files with group tags.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testClearWithNoKeys() {
|
||||||
|
$engine = new FileEngine();
|
||||||
|
$engine->init(array(
|
||||||
|
'prefix' => 'cake_test_',
|
||||||
|
'duration' => DAY,
|
||||||
|
'groups' => array('one', 'two')
|
||||||
|
));
|
||||||
|
$key = 'cake_test_test_key';
|
||||||
|
$engine->clear(false);
|
||||||
|
$this->assertFalse($engine->read($key), 'No errors should be found');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testKeyPath method
|
* testKeyPath method
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,6 +34,7 @@ class RedisEngineTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->skipIf(!class_exists('Redis'), 'Redis is not installed or configured properly.');
|
$this->skipIf(!class_exists('Redis'), 'Redis is not installed or configured properly.');
|
||||||
|
|
||||||
$this->_cacheDisable = Configure::read('Cache.disable');
|
$this->_cacheDisable = Configure::read('Cache.disable');
|
||||||
|
@ -51,6 +52,7 @@ class RedisEngineTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
Configure::write('Cache.disable', $this->_cacheDisable);
|
Configure::write('Cache.disable', $this->_cacheDisable);
|
||||||
Cache::drop('');
|
Cache::drop('');
|
||||||
Cache::drop('redis_groups');
|
Cache::drop('redis_groups');
|
||||||
|
|
|
@ -72,6 +72,7 @@ class CookieComponentTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$_COOKIE = array();
|
$_COOKIE = array();
|
||||||
$this->Controller = new CookieComponentTestController(new CakeRequest(), new CakeResponse());
|
$this->Controller = new CookieComponentTestController(new CakeRequest(), new CakeResponse());
|
||||||
$this->Controller->constructClasses();
|
$this->Controller->constructClasses();
|
||||||
|
@ -93,6 +94,7 @@ class CookieComponentTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
$this->Cookie->destroy();
|
$this->Cookie->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -320,6 +320,8 @@ class PaginatorComponentTest extends CakeTestCase {
|
||||||
$Controller->request->query = array();
|
$Controller->request->query = array();
|
||||||
$Controller->constructClasses();
|
$Controller->constructClasses();
|
||||||
|
|
||||||
|
$Controller->PaginatorControllerPost->order = null;
|
||||||
|
|
||||||
$Controller->Paginator->settings = array(
|
$Controller->Paginator->settings = array(
|
||||||
'order' => array('PaginatorControllerComment.id' => 'ASC')
|
'order' => array('PaginatorControllerComment.id' => 'ASC')
|
||||||
);
|
);
|
||||||
|
|
|
@ -1854,6 +1854,16 @@ class I18nTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the '' domain causes exceptions.
|
||||||
|
*
|
||||||
|
* @expectedException CakeException
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testTranslateEmptyDomain() {
|
||||||
|
I18n::translate('Plural Rule 1', null, '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Singular method
|
* Singular method
|
||||||
*
|
*
|
||||||
|
|
|
@ -226,6 +226,7 @@ class AclBehaviorTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetup() {
|
public function testSetup() {
|
||||||
|
parent::setUp();
|
||||||
$User = new AclUser();
|
$User = new AclUser();
|
||||||
$this->assertTrue(isset($User->Behaviors->Acl->settings['User']));
|
$this->assertTrue(isset($User->Behaviors->Acl->settings['User']));
|
||||||
$this->assertEquals('requester', $User->Behaviors->Acl->settings['User']['type']);
|
$this->assertEquals('requester', $User->Behaviors->Acl->settings['User']['type']);
|
||||||
|
|
|
@ -62,6 +62,7 @@ class TreeBehaviorAfterTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testAftersaveCallback() {
|
public function testAftersaveCallback() {
|
||||||
$this->Tree = new AfterTree();
|
$this->Tree = new AfterTree();
|
||||||
|
$this->Tree->order = null;
|
||||||
|
|
||||||
$expected = array('AfterTree' => array('name' => 'Six and One Half Changed in AfterTree::afterSave() but not in database', 'parent_id' => 6, 'lft' => 11, 'rght' => 12));
|
$expected = array('AfterTree' => array('name' => 'Six and One Half Changed in AfterTree::afterSave() but not in database', 'parent_id' => 6, 'lft' => 11, 'rght' => 12));
|
||||||
$result = $this->Tree->save(array('AfterTree' => array('name' => 'Six and One Half', 'parent_id' => 6)));
|
$result = $this->Tree->save(array('AfterTree' => array('name' => 'Six and One Half', 'parent_id' => 6)));
|
||||||
|
|
|
@ -65,6 +65,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testInitialize() {
|
public function testInitialize() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$result = $this->Tree->find('count');
|
$result = $this->Tree->find('count');
|
||||||
|
@ -82,6 +83,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testDetectInvalidLeft() {
|
public function testDetectInvalidLeft() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$result = $this->Tree->findByName('1.1');
|
$result = $this->Tree->findByName('1.1');
|
||||||
|
@ -108,6 +110,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testDetectInvalidRight() {
|
public function testDetectInvalidRight() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$result = $this->Tree->findByName('1.1');
|
$result = $this->Tree->findByName('1.1');
|
||||||
|
@ -134,6 +137,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testDetectInvalidParent() {
|
public function testDetectInvalidParent() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$result = $this->Tree->findByName('1.1');
|
$result = $this->Tree->findByName('1.1');
|
||||||
|
@ -159,6 +163,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testDetectNoneExistentParent() {
|
public function testDetectNoneExistentParent() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$result = $this->Tree->findByName('1.1');
|
$result = $this->Tree->findByName('1.1');
|
||||||
|
@ -182,6 +187,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testRecoverUsingParentMode() {
|
public function testRecoverUsingParentMode() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->Behaviors->disable('Tree');
|
$this->Tree->Behaviors->disable('Tree');
|
||||||
|
|
||||||
$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
|
$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
|
||||||
|
@ -233,6 +239,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testRecoverUsingParentModeAndDelete() {
|
public function testRecoverUsingParentModeAndDelete() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->Behaviors->disable('Tree');
|
$this->Tree->Behaviors->disable('Tree');
|
||||||
|
|
||||||
$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
|
$this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0));
|
||||||
|
@ -301,6 +308,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testRecoverFromMissingParent() {
|
public function testRecoverFromMissingParent() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$result = $this->Tree->findByName('1.1');
|
$result = $this->Tree->findByName('1.1');
|
||||||
|
@ -324,6 +332,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testDetectInvalidParents() {
|
public function testDetectInvalidParents() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$this->Tree->updateAll(array($parentField => null));
|
$this->Tree->updateAll(array($parentField => null));
|
||||||
|
@ -346,6 +355,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testDetectInvalidLftsRghts() {
|
public function testDetectInvalidLftsRghts() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$this->Tree->updateAll(array($leftField => 0, $rightField => 0));
|
$this->Tree->updateAll(array($leftField => 0, $rightField => 0));
|
||||||
|
@ -367,6 +377,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testDetectEqualLftsRghts() {
|
public function testDetectEqualLftsRghts() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(1, 3);
|
$this->Tree->initialize(1, 3);
|
||||||
|
|
||||||
$result = $this->Tree->findByName('1.1');
|
$result = $this->Tree->findByName('1.1');
|
||||||
|
@ -394,6 +405,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testAddOrphan() {
|
public function testAddOrphan() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null)));
|
$this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null)));
|
||||||
|
@ -413,6 +425,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testAddMiddle() {
|
public function testAddMiddle() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
|
@ -444,6 +457,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testAddWithPreSpecifiedId() {
|
public function testAddWithPreSpecifiedId() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array(
|
$data = $this->Tree->find('first', array(
|
||||||
|
@ -474,6 +488,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testAddInvalid() {
|
public function testAddInvalid() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
|
@ -498,6 +513,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testAddNotIndexedByModel() {
|
public function testAddNotIndexedByModel() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null));
|
$this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null));
|
||||||
|
@ -517,6 +533,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMovePromote() {
|
public function testMovePromote() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
|
@ -543,6 +560,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveWithWhitelist() {
|
public function testMoveWithWhitelist() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
|
@ -570,6 +588,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testInsertWithWhitelist() {
|
public function testInsertWithWhitelist() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$this->Tree->whitelist = array('name', $parentField);
|
$this->Tree->whitelist = array('name', $parentField);
|
||||||
|
@ -588,6 +607,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveBefore() {
|
public function testMoveBefore() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
|
@ -616,6 +636,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveAfter() {
|
public function testMoveAfter() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
|
@ -644,6 +665,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveDemoteInvalid() {
|
public function testMoveDemoteInvalid() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
|
@ -676,6 +698,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveInvalid() {
|
public function testMoveInvalid() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
|
@ -700,6 +723,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveSelfInvalid() {
|
public function testMoveSelfInvalid() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
|
@ -725,6 +749,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveUpSuccess() {
|
public function testMoveUpSuccess() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2')));
|
||||||
|
@ -746,6 +771,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveUpFail() {
|
public function testMoveUpFail() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
|
@ -768,6 +794,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveUp2() {
|
public function testMoveUp2() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(1, 10);
|
$this->Tree->initialize(1, 10);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
||||||
|
@ -798,6 +825,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveUpFirst() {
|
public function testMoveUpFirst() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(1, 10);
|
$this->Tree->initialize(1, 10);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
||||||
|
@ -828,6 +856,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveDownSuccess() {
|
public function testMoveDownSuccess() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
|
@ -849,6 +878,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveDownFail() {
|
public function testMoveDownFail() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2')));
|
||||||
|
@ -870,6 +900,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveDownLast() {
|
public function testMoveDownLast() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(1, 10);
|
$this->Tree->initialize(1, 10);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
||||||
|
@ -900,6 +931,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveDown2() {
|
public function testMoveDown2() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(1, 10);
|
$this->Tree->initialize(1, 10);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
||||||
|
@ -930,6 +962,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testSaveNoMove() {
|
public function testSaveNoMove() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(1, 10);
|
$this->Tree->initialize(1, 10);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5')));
|
||||||
|
@ -960,6 +993,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testMoveToRootAndMoveUp() {
|
public function testMoveToRootAndMoveUp() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(1, 1);
|
$this->Tree->initialize(1, 1);
|
||||||
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
$data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1')));
|
||||||
$this->Tree->id = $data[$modelClass]['id'];
|
$this->Tree->id = $data[$modelClass]['id'];
|
||||||
|
@ -984,6 +1018,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testDelete() {
|
public function testDelete() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
|
@ -1019,6 +1054,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testDeleteDoesNotExist() {
|
public function testDeleteDoesNotExist() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->delete(99999);
|
$this->Tree->delete(99999);
|
||||||
}
|
}
|
||||||
|
@ -1031,6 +1067,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testRemove() {
|
public function testRemove() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
$result = $this->Tree->findByName('1.1');
|
$result = $this->Tree->findByName('1.1');
|
||||||
|
@ -1063,6 +1100,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testRemoveLastTopParent() {
|
public function testRemoveLastTopParent() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
|
@ -1096,6 +1134,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testRemoveNoChildren() {
|
public function testRemoveNoChildren() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
|
|
||||||
|
@ -1130,6 +1169,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testRemoveAndDelete() {
|
public function testRemoveAndDelete() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
|
@ -1164,6 +1204,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testRemoveAndDeleteNoChildren() {
|
public function testRemoveAndDeleteNoChildren() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
|
|
||||||
|
@ -1196,6 +1237,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testChildren() {
|
public function testChildren() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
|
@ -1226,6 +1268,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testCountChildren() {
|
public function testCountChildren() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
|
@ -1251,6 +1294,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testGetParentNode() {
|
public function testGetParentNode() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
|
||||||
|
@ -1269,6 +1313,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testGetPath() {
|
public function testGetPath() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2')));
|
||||||
|
@ -1289,6 +1334,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testNoAmbiguousColumn() {
|
public function testNoAmbiguousColumn() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
||||||
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
@ -1321,6 +1367,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testReorderTree() {
|
public function testReorderTree() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(3, 3);
|
$this->Tree->initialize(3, 3);
|
||||||
$nodes = $this->Tree->find('list', array('order' => $leftField));
|
$nodes = $this->Tree->find('list', array('order' => $leftField));
|
||||||
|
|
||||||
|
@ -1352,6 +1399,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testReorderBigTreeWithQueryCaching() {
|
public function testReorderBigTreeWithQueryCaching() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 10);
|
$this->Tree->initialize(2, 10);
|
||||||
|
|
||||||
$original = $this->Tree->cacheQueries;
|
$original = $this->Tree->cacheQueries;
|
||||||
|
@ -1369,6 +1417,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testGenerateTreeListWithSelfJoin() {
|
public function testGenerateTreeListWithSelfJoin() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
||||||
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
@ -1386,6 +1435,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testGenerateTreeListFormatting() {
|
public function testGenerateTreeListFormatting() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$result = $this->Tree->generateTreeList(
|
$result = $this->Tree->generateTreeList(
|
||||||
|
@ -1406,6 +1456,7 @@ class TreeBehaviorNumberTest extends CakeTestCase {
|
||||||
public function testArraySyntax() {
|
public function testArraySyntax() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(3, 3);
|
$this->Tree->initialize(3, 3);
|
||||||
$this->assertSame($this->Tree->childCount(2), $this->Tree->childCount(array('id' => 2)));
|
$this->assertSame($this->Tree->childCount(2), $this->Tree->childCount(array('id' => 2)));
|
||||||
$this->assertSame($this->Tree->getParentNode(2), $this->Tree->getParentNode(array('id' => 2)));
|
$this->assertSame($this->Tree->getParentNode(2), $this->Tree->getParentNode(array('id' => 2)));
|
||||||
|
|
|
@ -64,6 +64,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testStringScope() {
|
public function testStringScope() {
|
||||||
$this->Tree = new FlagTree();
|
$this->Tree = new FlagTree();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 3);
|
$this->Tree->initialize(2, 3);
|
||||||
|
|
||||||
$this->Tree->id = 1;
|
$this->Tree->id = 1;
|
||||||
|
@ -100,6 +101,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testArrayScope() {
|
public function testArrayScope() {
|
||||||
$this->Tree = new FlagTree();
|
$this->Tree = new FlagTree();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 3);
|
$this->Tree->initialize(2, 3);
|
||||||
|
|
||||||
$this->Tree->id = 1;
|
$this->Tree->id = 1;
|
||||||
|
@ -136,6 +138,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testMoveUpWithScope() {
|
public function testMoveUpWithScope() {
|
||||||
$this->Ad = new Ad();
|
$this->Ad = new Ad();
|
||||||
|
$this->Ad->order = null;
|
||||||
$this->Ad->Behaviors->attach('Tree', array('scope' => 'Campaign'));
|
$this->Ad->Behaviors->attach('Tree', array('scope' => 'Campaign'));
|
||||||
$this->Ad->moveUp(6);
|
$this->Ad->moveUp(6);
|
||||||
|
|
||||||
|
@ -152,6 +155,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testMoveDownWithScope() {
|
public function testMoveDownWithScope() {
|
||||||
$this->Ad = new Ad();
|
$this->Ad = new Ad();
|
||||||
|
$this->Ad->order = null;
|
||||||
$this->Ad->Behaviors->attach('Tree', array('scope' => 'Campaign'));
|
$this->Ad->Behaviors->attach('Tree', array('scope' => 'Campaign'));
|
||||||
$this->Ad->moveDown(6);
|
$this->Ad->moveDown(6);
|
||||||
|
|
||||||
|
@ -169,6 +173,7 @@ class TreeBehaviorScopedTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testTranslatingTree() {
|
public function testTranslatingTree() {
|
||||||
$this->Tree = new FlagTree();
|
$this->Tree = new FlagTree();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->cacheQueries = false;
|
$this->Tree->cacheQueries = false;
|
||||||
$this->Tree->Behaviors->attach('Translate', array('title'));
|
$this->Tree->Behaviors->attach('Translate', array('title'));
|
||||||
|
|
||||||
|
@ -286,9 +291,11 @@ class TreeBehaviorScopedTest extends CakeTestCase {
|
||||||
public function testAliasesWithScopeInTwoTreeAssociations() {
|
public function testAliasesWithScopeInTwoTreeAssociations() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$this->TreeTwo = new NumberTreeTwo();
|
$this->TreeTwo = new NumberTreeTwo();
|
||||||
|
$this->TreeTwo->order = null;
|
||||||
|
|
||||||
$record = $this->Tree->find('first');
|
$record = $this->Tree->find('first');
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,7 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
||||||
public function testAddWithPreSpecifiedId() {
|
public function testAddWithPreSpecifiedId() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array(
|
$data = $this->Tree->find('first', array(
|
||||||
|
@ -97,6 +98,7 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
||||||
public function testMovePromote() {
|
public function testMovePromote() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
|
@ -123,6 +125,7 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
||||||
public function testMoveWithWhitelist() {
|
public function testMoveWithWhitelist() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$this->Tree->id = null;
|
$this->Tree->id = null;
|
||||||
|
|
||||||
|
@ -150,6 +153,7 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
||||||
public function testRemoveNoChildren() {
|
public function testRemoveNoChildren() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
|
|
||||||
|
@ -184,6 +188,7 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
||||||
public function testRemoveAndDeleteNoChildren() {
|
public function testRemoveAndDeleteNoChildren() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
$initialCount = $this->Tree->find('count');
|
$initialCount = $this->Tree->find('count');
|
||||||
|
|
||||||
|
@ -216,6 +221,7 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
||||||
public function testChildren() {
|
public function testChildren() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
$data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root')));
|
||||||
|
@ -244,6 +250,7 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
||||||
public function testNoAmbiguousColumn() {
|
public function testNoAmbiguousColumn() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
||||||
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
||||||
|
@ -280,6 +287,7 @@ class TreeBehaviorUuidTest extends CakeTestCase {
|
||||||
public function testGenerateTreeListWithSelfJoin() {
|
public function testGenerateTreeListWithSelfJoin() {
|
||||||
extract($this->settings);
|
extract($this->settings);
|
||||||
$this->Tree = new $modelClass();
|
$this->Tree = new $modelClass();
|
||||||
|
$this->Tree->order = null;
|
||||||
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
$this->Tree->bindModel(array('belongsTo' => array('Dummy' =>
|
||||||
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false);
|
||||||
$this->Tree->initialize(2, 2);
|
$this->Tree->initialize(2, 2);
|
||||||
|
|
|
@ -77,24 +77,6 @@ class MyAppSchema extends CakeSchema {
|
||||||
*/
|
*/
|
||||||
protected $_foo = array('bar');
|
protected $_foo = array('bar');
|
||||||
|
|
||||||
/**
|
|
||||||
* setup method
|
|
||||||
*
|
|
||||||
* @param mixed $version
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function setup($version) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* teardown method
|
|
||||||
*
|
|
||||||
* @param mixed $version
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function teardown($version) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getVar method
|
* getVar method
|
||||||
*
|
*
|
||||||
|
|
|
@ -62,6 +62,7 @@ class MysqlTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->Dbo = ConnectionManager::getDataSource('test');
|
$this->Dbo = ConnectionManager::getDataSource('test');
|
||||||
if (!($this->Dbo instanceof Mysql)) {
|
if (!($this->Dbo instanceof Mysql)) {
|
||||||
$this->markTestSkipped('The MySQL extension is not available.');
|
$this->markTestSkipped('The MySQL extension is not available.');
|
||||||
|
@ -76,6 +77,7 @@ class MysqlTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->model);
|
unset($this->model);
|
||||||
ClassRegistry::flush();
|
ClassRegistry::flush();
|
||||||
Configure::write('debug', $this->_debug);
|
Configure::write('debug', $this->_debug);
|
||||||
|
|
|
@ -215,6 +215,7 @@ class PostgresTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
Configure::write('Cache.disable', true);
|
Configure::write('Cache.disable', true);
|
||||||
$this->Dbo = ConnectionManager::getDataSource('test');
|
$this->Dbo = ConnectionManager::getDataSource('test');
|
||||||
$this->skipIf(!($this->Dbo instanceof Postgres));
|
$this->skipIf(!($this->Dbo instanceof Postgres));
|
||||||
|
@ -227,6 +228,7 @@ class PostgresTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
Configure::write('Cache.disable', false);
|
Configure::write('Cache.disable', false);
|
||||||
unset($this->Dbo2);
|
unset($this->Dbo2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,6 +266,7 @@ class SqlserverTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->Dbo = ConnectionManager::getDataSource('test');
|
$this->Dbo = ConnectionManager::getDataSource('test');
|
||||||
if (!($this->Dbo instanceof Sqlserver)) {
|
if (!($this->Dbo instanceof Sqlserver)) {
|
||||||
$this->markTestSkipped('Please configure the test datasource to use SQL Server.');
|
$this->markTestSkipped('Please configure the test datasource to use SQL Server.');
|
||||||
|
@ -280,6 +281,7 @@ class SqlserverTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->Dbo);
|
unset($this->Dbo);
|
||||||
unset($this->model);
|
unset($this->model);
|
||||||
}
|
}
|
||||||
|
|
|
@ -570,6 +570,7 @@ class ModelDeleteTest extends BaseModelTest {
|
||||||
'Tag' => array('with' => 'TestPlugin.ArticlesTag')
|
'Tag' => array('with' => 'TestPlugin.ArticlesTag')
|
||||||
)), false);
|
)), false);
|
||||||
|
|
||||||
|
$Article->ArticlesTag->order = null;
|
||||||
$this->assertTrue($Article->delete(1));
|
$this->assertTrue($Article->delete(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6302,6 +6302,7 @@ class ModelReadTest extends BaseModelTest {
|
||||||
$this->loadFixtures('User');
|
$this->loadFixtures('User');
|
||||||
$TestModel = new User();
|
$TestModel = new User();
|
||||||
$TestModel->cacheQueries = false;
|
$TestModel->cacheQueries = false;
|
||||||
|
$TestModel->order = null;
|
||||||
|
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'conditions' => array(
|
'conditions' => array(
|
||||||
|
@ -6849,6 +6850,8 @@ class ModelReadTest extends BaseModelTest {
|
||||||
));
|
));
|
||||||
$this->assertEquals('mariano', $result);
|
$this->assertEquals('mariano', $result);
|
||||||
|
|
||||||
|
$TestModel->order = null;
|
||||||
|
|
||||||
$result = $TestModel->field('COUNT(*) AS count', true);
|
$result = $TestModel->field('COUNT(*) AS count', true);
|
||||||
$this->assertEquals(4, $result);
|
$this->assertEquals(4, $result);
|
||||||
|
|
||||||
|
@ -6904,7 +6907,9 @@ class ModelReadTest extends BaseModelTest {
|
||||||
$this->assertNotRegExp('/ORDER\s+BY/', $log['log'][0]['query']);
|
$this->assertNotRegExp('/ORDER\s+BY/', $log['log'][0]['query']);
|
||||||
|
|
||||||
$Article = new Article();
|
$Article = new Article();
|
||||||
|
$Article->order = null;
|
||||||
$Article->recursive = -1;
|
$Article->recursive = -1;
|
||||||
|
|
||||||
$expected = count($Article->find('all', array(
|
$expected = count($Article->find('all', array(
|
||||||
'fields' => array('Article.user_id'),
|
'fields' => array('Article.user_id'),
|
||||||
'group' => 'Article.user_id')
|
'group' => 'Article.user_id')
|
||||||
|
@ -7761,6 +7766,8 @@ class ModelReadTest extends BaseModelTest {
|
||||||
));
|
));
|
||||||
$this->assertEquals(2, $result['Post']['id']);
|
$this->assertEquals(2, $result['Post']['id']);
|
||||||
|
|
||||||
|
$Post->order = null;
|
||||||
|
|
||||||
$Post->virtualFields = array('other_field' => 'Post.id + 1');
|
$Post->virtualFields = array('other_field' => 'Post.id + 1');
|
||||||
$result = $Post->find('all', array(
|
$result = $Post->find('all', array(
|
||||||
'fields' => array($dbo->calculate($Post, 'max', array('other_field')))
|
'fields' => array($dbo->calculate($Post, 'max', array('other_field')))
|
||||||
|
|
|
@ -1522,7 +1522,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testValidateAssociated() {
|
public function testValidateAssociated() {
|
||||||
$this->loadFixtures('Comment', 'Attachment');
|
$this->loadFixtures('Comment', 'Attachment', 'Article', 'User');
|
||||||
$TestModel = new Comment();
|
$TestModel = new Comment();
|
||||||
$TestModel->Attachment->validate = array('attachment' => 'notEmpty');
|
$TestModel->Attachment->validate = array('attachment' => 'notEmpty');
|
||||||
|
|
||||||
|
@ -1539,6 +1539,18 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$result = $TestModel->validateAssociated($data);
|
$result = $TestModel->validateAssociated($data);
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
|
$fieldList = array(
|
||||||
|
'Attachment' => array('comment_id')
|
||||||
|
);
|
||||||
|
$result = $TestModel->saveAll($data, array(
|
||||||
|
'fieldList' => $fieldList, 'validate' => 'only'
|
||||||
|
));
|
||||||
|
$this->assertTrue($result);
|
||||||
|
$this->assertEmpty($TestModel->validationErrors);
|
||||||
|
$result = $TestModel->validateAssociated($data, array('fieldList' => $fieldList));
|
||||||
|
$this->assertTrue($result);
|
||||||
|
$this->assertEmpty($TestModel->validationErrors);
|
||||||
|
|
||||||
$TestModel->validate = array('comment' => 'notEmpty');
|
$TestModel->validate = array('comment' => 'notEmpty');
|
||||||
$record = array(
|
$record = array(
|
||||||
'Comment' => array(
|
'Comment' => array(
|
||||||
|
|
|
@ -2520,6 +2520,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
public function testHabtmSavingWithNoPrimaryKeyUuidJoinTable() {
|
public function testHabtmSavingWithNoPrimaryKeyUuidJoinTable() {
|
||||||
$this->loadFixtures('UuidTag', 'Fruit', 'FruitsUuidTag');
|
$this->loadFixtures('UuidTag', 'Fruit', 'FruitsUuidTag');
|
||||||
$Fruit = new Fruit();
|
$Fruit = new Fruit();
|
||||||
|
$Fruit->FruitsUuidTag->order = null;
|
||||||
$data = array(
|
$data = array(
|
||||||
'Fruit' => array(
|
'Fruit' => array(
|
||||||
'color' => 'Red',
|
'color' => 'Red',
|
||||||
|
@ -6580,6 +6581,66 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->assertEquals('', $result[3]['Post']['body']);
|
$this->assertEquals('', $result[3]['Post']['body']);
|
||||||
$this->assertEquals('working', $result[3]['Author']['test']);
|
$this->assertEquals('working', $result[3]['Author']['test']);
|
||||||
|
|
||||||
|
$fieldList = array(
|
||||||
|
'Post' => array('title')
|
||||||
|
);
|
||||||
|
$data = array(
|
||||||
|
'Post' => array(
|
||||||
|
'title' => 'Post without body 2',
|
||||||
|
'body' => 'This will not be saved'
|
||||||
|
),
|
||||||
|
'Author' => array(
|
||||||
|
'user' => 'jack'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$TestModel->saveAll($data, array('fieldList' => $fieldList));
|
||||||
|
$result = $TestModel->find('all', array(
|
||||||
|
'order' => 'Post.id ASC',
|
||||||
|
));
|
||||||
|
$this->assertNull($result[4]['Post']['body']);
|
||||||
|
|
||||||
|
$fieldList = array(
|
||||||
|
'Author' => array('password')
|
||||||
|
);
|
||||||
|
$data = array(
|
||||||
|
'Post' => array(
|
||||||
|
'id' => '5',
|
||||||
|
'title' => 'Post title',
|
||||||
|
'body' => 'Post body'
|
||||||
|
),
|
||||||
|
'Author' => array(
|
||||||
|
'id' => '6',
|
||||||
|
'user' => 'will not change',
|
||||||
|
'password' => 'foobar'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$result = $TestModel->saveAll($data, array('fieldList' => $fieldList));
|
||||||
|
$this->assertTrue($result);
|
||||||
|
|
||||||
|
$result = $TestModel->find('all', array(
|
||||||
|
'order' => 'Post.id ASC',
|
||||||
|
));
|
||||||
|
$expected = array(
|
||||||
|
'Post' => array(
|
||||||
|
'id' => '5',
|
||||||
|
'author_id' => '6',
|
||||||
|
'title' => 'Post title',
|
||||||
|
'body' => 'Post body',
|
||||||
|
'published' => 'N',
|
||||||
|
'created' => self::date(),
|
||||||
|
'updated' => self::date()
|
||||||
|
),
|
||||||
|
'Author' => array(
|
||||||
|
'id' => '6',
|
||||||
|
'user' => 'jack',
|
||||||
|
'password' => 'foobar',
|
||||||
|
'created' => self::date(),
|
||||||
|
'updated' => self::date(),
|
||||||
|
'test' => 'working'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$this->assertEquals($expected, $result[4]);
|
||||||
|
|
||||||
// test multirecord
|
// test multirecord
|
||||||
$this->db->truncate($TestModel);
|
$this->db->truncate($TestModel);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ class DebugTransportTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->DebugTransport = new DebugTransport();
|
$this->DebugTransport = new DebugTransport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ class MailTransportTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->MailTransport = $this->getMock('MailTransport', array('_mail'));
|
$this->MailTransport = $this->getMock('MailTransport', array('_mail'));
|
||||||
$this->MailTransport->config(array('additionalParameters' => '-f'));
|
$this->MailTransport->config(array('additionalParameters' => '-f'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ class SmtpTransportTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
if (!class_exists('MockSocket')) {
|
if (!class_exists('MockSocket')) {
|
||||||
$this->getMock('CakeSocket', array('read', 'write', 'connect', 'enableCrypto'), array(), 'MockSocket');
|
$this->getMock('CakeSocket', array('read', 'write', 'connect', 'enableCrypto'), array(), 'MockSocket');
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ class DigestAuthenticationTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->HttpSocket = new DigestHttpSocket();
|
$this->HttpSocket = new DigestHttpSocket();
|
||||||
$this->HttpSocket->request['method'] = 'GET';
|
$this->HttpSocket->request['method'] = 'GET';
|
||||||
$this->HttpSocket->request['uri']['path'] = '/';
|
$this->HttpSocket->request['uri']['path'] = '/';
|
||||||
|
@ -84,6 +85,7 @@ class DigestAuthenticationTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->HttpSocket);
|
unset($this->HttpSocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ class HttpResponseTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->HttpResponse = new TestHttpResponse();
|
$this->HttpResponse = new TestHttpResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,6 +193,7 @@ class HttpSocketTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
if (!class_exists('MockHttpSocket')) {
|
if (!class_exists('MockHttpSocket')) {
|
||||||
$this->getMock('TestHttpSocket', array('read', 'write', 'connect'), array(), 'MockHttpSocket');
|
$this->getMock('TestHttpSocket', array('read', 'write', 'connect'), array(), 'MockHttpSocket');
|
||||||
$this->getMock('TestHttpSocket', array('read', 'write', 'connect', 'request'), array(), 'MockHttpSocketRequests');
|
$this->getMock('TestHttpSocket', array('read', 'write', 'connect', 'request'), array(), 'MockHttpSocketRequests');
|
||||||
|
@ -208,6 +209,7 @@ class HttpSocketTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->Socket, $this->RequestSocket);
|
unset($this->Socket, $this->RequestSocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -511,6 +511,7 @@ class DispatcherTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$this->_get = $_GET;
|
$this->_get = $_GET;
|
||||||
$_GET = array();
|
$_GET = array();
|
||||||
$this->_post = $_POST;
|
$this->_post = $_POST;
|
||||||
|
@ -538,6 +539,7 @@ class DispatcherTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
$_GET = $this->_get;
|
$_GET = $this->_get;
|
||||||
$_POST = $this->_post;
|
$_POST = $this->_post;
|
||||||
$_FILES = $this->_files;
|
$_FILES = $this->_files;
|
||||||
|
|
|
@ -30,6 +30,7 @@ class AssetDispatcherTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
Configure::write('Dispatcher.filters', array());
|
Configure::write('Dispatcher.filters', array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -484,6 +484,40 @@ class CakeRouteTest extends CakeTestCase {
|
||||||
$this->assertEquals('red', $result['color']);
|
$this->assertEquals('red', $result['color']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test persist with a non array value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testPersistParamsNonArray() {
|
||||||
|
$url = array('controller' => 'posts', 'action' => 'index');
|
||||||
|
$params = array('lang' => 'en', 'color' => 'blue');
|
||||||
|
|
||||||
|
$route = new CakeRoute(
|
||||||
|
'/:lang/:color/blog/:action',
|
||||||
|
array('controller' => 'posts')
|
||||||
|
// No persist options
|
||||||
|
);
|
||||||
|
$result = $route->persistParams($url, $params);
|
||||||
|
$this->assertEquals($url, $result);
|
||||||
|
|
||||||
|
$route = new CakeRoute(
|
||||||
|
'/:lang/:color/blog/:action',
|
||||||
|
array('controller' => 'posts'),
|
||||||
|
array('persist' => false)
|
||||||
|
);
|
||||||
|
$result = $route->persistParams($url, $params);
|
||||||
|
$this->assertEquals($url, $result);
|
||||||
|
|
||||||
|
$route = new CakeRoute(
|
||||||
|
'/:lang/:color/blog/:action',
|
||||||
|
array('controller' => 'posts'),
|
||||||
|
array('persist' => 'derp')
|
||||||
|
);
|
||||||
|
$result = $route->persistParams($url, $params);
|
||||||
|
$this->assertEquals($url, $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test the parse method of CakeRoute.
|
* test the parse method of CakeRoute.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1078,13 +1078,13 @@ class RouterTest extends CakeTestCase {
|
||||||
Router::connect(
|
Router::connect(
|
||||||
'/:lang/:color/posts/view/*',
|
'/:lang/:color/posts/view/*',
|
||||||
array('controller' => 'posts', 'action' => 'view'),
|
array('controller' => 'posts', 'action' => 'view'),
|
||||||
array('persist' => array('lang', 'color')
|
array('persist' => array('lang', 'color'))
|
||||||
));
|
);
|
||||||
Router::connect(
|
Router::connect(
|
||||||
'/:lang/:color/posts/index',
|
'/:lang/:color/posts/index',
|
||||||
array('controller' => 'posts', 'action' => 'index'),
|
array('controller' => 'posts', 'action' => 'index'),
|
||||||
array('persist' => array('lang')
|
array('persist' => array('lang'))
|
||||||
));
|
);
|
||||||
Router::connect('/:lang/:color/posts/edit/*', array('controller' => 'posts', 'action' => 'edit'));
|
Router::connect('/:lang/:color/posts/edit/*', array('controller' => 'posts', 'action' => 'edit'));
|
||||||
Router::connect('/about', array('controller' => 'pages', 'action' => 'view', 'about'));
|
Router::connect('/about', array('controller' => 'pages', 'action' => 'view', 'about'));
|
||||||
Router::parse('/en/red/posts/view/5');
|
Router::parse('/en/red/posts/view/5');
|
||||||
|
|
|
@ -189,6 +189,7 @@ class CakeTestFixtureTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
|
parent::setUp();
|
||||||
$methods = array_diff(get_class_methods('DboSource'), array('enabled'));
|
$methods = array_diff(get_class_methods('DboSource'), array('enabled'));
|
||||||
$methods[] = 'connect';
|
$methods[] = 'connect';
|
||||||
|
|
||||||
|
@ -204,6 +205,7 @@ class CakeTestFixtureTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->criticDb);
|
unset($this->criticDb);
|
||||||
$this->db->config = $this->_backupConfig;
|
$this->db->config = $this->_backupConfig;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ class CakeTimeTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->Time);
|
unset($this->Time);
|
||||||
$this->_restoreSystemTimezone();
|
$this->_restoreSystemTimezone();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8054,6 +8054,32 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that required fields are created when only using ModelValidator::add().
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testFormInputRequiredDetectionModelValidator() {
|
||||||
|
ClassRegistry::getObject('ContactTag')->validator()->add('iwillberequired', 'required', array('rule' => 'notEmpty'));
|
||||||
|
|
||||||
|
$this->Form->create('ContactTag');
|
||||||
|
$result = $this->Form->input('ContactTag.iwillberequired');
|
||||||
|
$expected = array(
|
||||||
|
'div' => array('class' => 'input text required'),
|
||||||
|
'label' => array('for' => 'ContactTagIwillberequired'),
|
||||||
|
'Iwillberequired',
|
||||||
|
'/label',
|
||||||
|
'input' => array(
|
||||||
|
'name' => 'data[ContactTag][iwillberequired]',
|
||||||
|
'type' => 'text',
|
||||||
|
'id' => 'ContactTagIwillberequired',
|
||||||
|
'required' => 'required'
|
||||||
|
),
|
||||||
|
'/div'
|
||||||
|
);
|
||||||
|
$this->assertTags($result, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testFormMagicInput method
|
* testFormMagicInput method
|
||||||
*
|
*
|
||||||
|
|
|
@ -79,6 +79,7 @@ class PaginatorHelperTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
|
parent::tearDown();
|
||||||
unset($this->View, $this->Paginator);
|
unset($this->View, $this->Paginator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,24 +75,6 @@ class CakeTestSuiteCommand extends PHPUnit_TextUI_Command {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!count($suite)) {
|
|
||||||
$skeleton = new PHPUnit_Util_Skeleton_Test(
|
|
||||||
$suite->getName(),
|
|
||||||
$this->arguments['testFile']
|
|
||||||
);
|
|
||||||
|
|
||||||
$result = $skeleton->generate(true);
|
|
||||||
|
|
||||||
if (!$result['incomplete']) {
|
|
||||||
//@codingStandardsIgnoreStart
|
|
||||||
eval(str_replace(array('<?php', '?>'), '', $result['code']));
|
|
||||||
//@codingStandardsIgnoreEnd
|
|
||||||
$suite = new PHPUnit_Framework_TestSuite(
|
|
||||||
$this->arguments['test'] . 'Test'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->arguments['listGroups']) {
|
if ($this->arguments['listGroups']) {
|
||||||
PHPUnit_TextUI_TestRunner::printVersionString();
|
PHPUnit_TextUI_TestRunner::printVersionString();
|
||||||
|
|
||||||
|
|
|
@ -334,6 +334,7 @@ abstract class ControllerTestCase extends CakeTestCase {
|
||||||
$request = $this->getMock('CakeRequest');
|
$request = $this->getMock('CakeRequest');
|
||||||
$response = $this->getMock('CakeResponse', array('_sendHeader'));
|
$response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||||
$controllerObj->__construct($request, $response);
|
$controllerObj->__construct($request, $response);
|
||||||
|
$controllerObj->Components->setController($controllerObj);
|
||||||
|
|
||||||
$config = ClassRegistry::config('Model');
|
$config = ClassRegistry::config('Model');
|
||||||
foreach ($mocks['models'] as $model => $methods) {
|
foreach ($mocks['models'] as $model => $methods) {
|
||||||
|
|
|
@ -32,27 +32,15 @@ class CakeTestModel extends Model {
|
||||||
* incorrect order when no order has been defined in the finds.
|
* incorrect order when no order has been defined in the finds.
|
||||||
* Postgres can return the results in any order it considers appropriate if none is specified
|
* Postgres can return the results in any order it considers appropriate if none is specified
|
||||||
*
|
*
|
||||||
* @param array $queryData
|
* @param integer|string|array $id Set this ID for this model on startup, can also be an array of options, see above.
|
||||||
* @return array $queryData
|
* @param string $table Name of database table to use.
|
||||||
|
* @param string $ds DataSource connection name.
|
||||||
*/
|
*/
|
||||||
public function beforeFind($queryData) {
|
public function __construct($id = false, $table = null, $ds = null) {
|
||||||
$pk = $this->primaryKey;
|
parent::__construct($id, $table, $ds);
|
||||||
$aliasedPk = $this->alias . '.' . $this->primaryKey;
|
$this->order = array($this->alias . '.' . $this->primaryKey => 'ASC');
|
||||||
switch (true) {
|
|
||||||
case !$pk:
|
|
||||||
case !$this->useTable:
|
|
||||||
case !$this->schema('id'):
|
|
||||||
case !empty($queryData['order'][0]):
|
|
||||||
case !empty($queryData['group']):
|
|
||||||
case
|
|
||||||
(is_string($queryData['fields']) && !($queryData['fields'] == $pk || $queryData['fields'] == $aliasedPk)) ||
|
|
||||||
(is_array($queryData['fields']) && !(array_key_exists($pk, $queryData['fields']) || array_key_exists($aliasedPk, $queryData['fields']))):
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$queryData['order'] = array($this->alias . '.' . $this->primaryKey => 'ASC');
|
|
||||||
}
|
|
||||||
return $queryData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overriding save() to set CakeTestSuiteDispatcher::date() as formatter for created, modified and updated fields
|
* Overriding save() to set CakeTestSuiteDispatcher::date() as formatter for created, modified and updated fields
|
||||||
*
|
*
|
||||||
|
|
|
@ -223,7 +223,7 @@ class Helper extends Object {
|
||||||
*
|
*
|
||||||
* @param string $name Name of the property being accessed.
|
* @param string $name Name of the property being accessed.
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return mixed Return the $value
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __set($name, $value) {
|
public function __set($name, $value) {
|
||||||
switch ($name) {
|
switch ($name) {
|
||||||
|
@ -231,11 +231,13 @@ class Helper extends Object {
|
||||||
case 'here':
|
case 'here':
|
||||||
case 'webroot':
|
case 'webroot':
|
||||||
case 'data':
|
case 'data':
|
||||||
return $this->request->{$name} = $value;
|
$this->request->{$name} = $value;
|
||||||
|
return;
|
||||||
case 'action':
|
case 'action':
|
||||||
return $this->request->params['action'] = $value;
|
$this->request->params['action'] = $value;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return $this->{$name} = $value;
|
$this->{$name} = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -834,7 +836,7 @@ class Helper extends Object {
|
||||||
* @param string $viewFile The file about to be rendered.
|
* @param string $viewFile The file about to be rendered.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function beforeRenderFile($viewfile) {
|
public function beforeRenderFile($viewFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -847,7 +849,7 @@ class Helper extends Object {
|
||||||
* @param string $content The content that was rendered.
|
* @param string $content The content that was rendered.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function afterRenderFile($viewfile, $content) {
|
public function afterRenderFile($viewFile, $content) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,7 +67,8 @@ class CacheHelper extends AppHelper {
|
||||||
* Parses the view file and stores content for cache file building.
|
* Parses the view file and stores content for cache file building.
|
||||||
*
|
*
|
||||||
* @param string $viewFile
|
* @param string $viewFile
|
||||||
* @return void
|
* @param string $output The output for the file.
|
||||||
|
* @return string Updated content.
|
||||||
*/
|
*/
|
||||||
public function afterRenderFile($viewFile, $output) {
|
public function afterRenderFile($viewFile, $output) {
|
||||||
if ($this->_enabled()) {
|
if ($this->_enabled()) {
|
||||||
|
|
|
@ -218,13 +218,11 @@ class FormHelper extends AppHelper {
|
||||||
|
|
||||||
if ($key === 'validates' && !isset($this->fieldset[$model]['validates'])) {
|
if ($key === 'validates' && !isset($this->fieldset[$model]['validates'])) {
|
||||||
$validates = array();
|
$validates = array();
|
||||||
if (!empty($object->validate)) {
|
|
||||||
foreach ($object->validator() as $validateField => $validateProperties) {
|
foreach ($object->validator() as $validateField => $validateProperties) {
|
||||||
if ($this->_isRequiredField($validateProperties)) {
|
if ($this->_isRequiredField($validateProperties)) {
|
||||||
$validates[$validateField] = true;
|
$validates[$validateField] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$this->fieldset[$model]['validates'] = $validates;
|
$this->fieldset[$model]['validates'] = $validates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -621,7 +621,7 @@ class View extends Object {
|
||||||
* @see ViewBlock::start()
|
* @see ViewBlock::start()
|
||||||
*/
|
*/
|
||||||
public function start($name) {
|
public function start($name) {
|
||||||
return $this->Blocks->start($name);
|
$this->Blocks->start($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -632,7 +632,7 @@ class View extends Object {
|
||||||
* @see ViewBlock::startIfEmpty()
|
* @see ViewBlock::startIfEmpty()
|
||||||
*/
|
*/
|
||||||
public function startIfEmpty($name) {
|
public function startIfEmpty($name) {
|
||||||
return $this->Blocks->startIfEmpty($name);
|
$this->Blocks->startIfEmpty($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -646,7 +646,7 @@ class View extends Object {
|
||||||
* @see ViewBlock::concat()
|
* @see ViewBlock::concat()
|
||||||
*/
|
*/
|
||||||
public function append($name, $value = null) {
|
public function append($name, $value = null) {
|
||||||
return $this->Blocks->concat($name, $value);
|
$this->Blocks->concat($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -660,7 +660,7 @@ class View extends Object {
|
||||||
* @see ViewBlock::concat()
|
* @see ViewBlock::concat()
|
||||||
*/
|
*/
|
||||||
public function prepend($name, $value = null) {
|
public function prepend($name, $value = null) {
|
||||||
return $this->Blocks->concat($name, $value, ViewBlock::PREPEND);
|
$this->Blocks->concat($name, $value, ViewBlock::PREPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -674,7 +674,7 @@ class View extends Object {
|
||||||
* @see ViewBlock::set()
|
* @see ViewBlock::set()
|
||||||
*/
|
*/
|
||||||
public function assign($name, $value) {
|
public function assign($name, $value) {
|
||||||
return $this->Blocks->set($name, $value);
|
$this->Blocks->set($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -697,7 +697,7 @@ class View extends Object {
|
||||||
* @see ViewBlock::end()
|
* @see ViewBlock::end()
|
||||||
*/
|
*/
|
||||||
public function end() {
|
public function end() {
|
||||||
return $this->Blocks->end();
|
$this->Blocks->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue