Merge branch '1.3' into 1.3-inflector

This commit is contained in:
gwoo 2009-05-01 11:09:34 -07:00
commit d4003c17c4
270 changed files with 4292 additions and 2412 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
app/tmp
vendors

View file

@ -6,4 +6,4 @@
// +---------------------------------------------------------------------------------------------------+ //
///////////////////////////////////////////////////////////////////////////////////////////////////////////
1.2.1.8004
1.2.2.8120

View file

@ -198,10 +198,14 @@ class ShellDispatcher {
*/
function __buildPaths() {
$paths = array();
$pluginPaths = Configure::read('pluginPaths');
if (!class_exists('Folder')) {
require LIBS . 'folder.php';
}
foreach ($pluginPaths as $pluginPath) {
$plugins = Configure::listObjects('plugin', $pluginPath);
$Folder =& new Folder($pluginPath);
list($plugins,) = $Folder->read(false, true);
foreach ((array)$plugins as $plugin) {
$path = $pluginPath . Inflector::underscore($plugin) . DS . 'vendors' . DS . 'shells' . DS;
if (file_exists($path)) {
@ -262,7 +266,6 @@ class ShellDispatcher {
Configure::write('debug', 1);
return true;
}
/**
* Dispatches a CLI request
*
@ -542,16 +545,19 @@ class ShellDispatcher {
$this->stdout("\nAvailable Shells:");
$_shells = array();
foreach ($this->shellPaths as $path) {
if (is_dir($path)) {
$shells = Configure::listObjects('file', $path);
$path = str_replace(CORE_PATH, 'CORE/', $path);
$path = str_replace(CAKE_CORE_INCLUDE_PATH . DS . 'cake' . DS, 'CORE' . DS, $path);
$path = str_replace(APP, 'APP' . DS, $path);
$path = str_replace(ROOT, 'ROOT', $path);
$path = rtrim($path, DS);
$this->stdout("\n " . $path . ":");
if (empty($shells)) {
$this->stdout("\t - none");
} else {
sort($shells);
foreach ($shells as $shell) {
if ($shell !== 'shell.php') {
$this->stdout("\t " . str_replace('.php', '', $shell));

View file

@ -36,7 +36,7 @@ class AclShell extends Shell {
/**
* Contains instance of AclComponent
*
* @var object
* @var AclComponent
* @access public
*/
var $Acl;

View file

@ -34,7 +34,7 @@ class Shell extends Object {
/**
* An instance of the ShellDispatcher object that loaded this script
*
* @var object
* @var ShellDispatcher
* @access public
*/
var $Dispatch = null;
@ -49,7 +49,7 @@ class Shell extends Object {
* Holds the DATABASE_CONFIG object for the app. Null if database.php could not be found,
* or the app does not exist.
*
* @var object
* @var DATABASE_CONFIG
* @access public
*/
var $DbConfig = null;

View file

@ -465,11 +465,11 @@ class ControllerTask extends Shell {
$out .= "\tvar \$autoRender = false;\n}\n\n";
$out .= "class {$className}ControllerTest extends CakeTestCase {\n";
$out .= "\tvar \${$className} = null;\n\n";
$out .= "\tfunction setUp() {\n\t\t\$this->{$className} = new Test{$className}();";
$out .= "\tfunction startTest() {\n\t\t\$this->{$className} = new Test{$className}();";
$out .= "\n\t\t\$this->{$className}->constructClasses();\n\t}\n\n";
$out .= "\tfunction test{$className}ControllerInstance() {\n";
$out .= "\t\t\$this->assertTrue(is_a(\$this->{$className}, '{$className}Controller'));\n\t}\n\n";
$out .= "\tfunction tearDown() {\n\t\tunset(\$this->{$className});\n\t}\n}\n";
$out .= "\tfunction endTest() {\n\t\tunset(\$this->{$className});\n\t}\n}\n";
$path = CONTROLLER_TESTS;
if (isset($this->plugin)) {

View file

@ -135,7 +135,7 @@ class ExtractTask extends Shell{
} else {
$response = '';
while ($response == '') {
$response = $this->in("What is the full path you would like to extract?\nExample: " . $this->params['root'] . DS . "myapp\n[Q]uit", null, 'Q');
$response = $this->in("What is the full path you would like to extract?\nExample: " . $this->params['root'] . DS . "myapp\n[Q]uit", null, $this->params['working']);
if (strtoupper($response) === 'Q') {
$this->out('Extract Aborted');
$this->_stop();

View file

@ -156,30 +156,30 @@ class TestSuiteShell extends Shell {
function help() {
$this->out('Usage: ');
$this->out("\tcake testsuite category test_type file");
$this->out("\t\t - category - \"app\", \"core\" or name of a plugin");
$this->out("\t\t - test_type - \"case\", \"group\" or \"all\"");
$this->out("\t\t - test_file - file name with folder prefix and without the (test|group).php suffix");
$this->out("\t\t- category - \"app\", \"core\" or name of a plugin");
$this->out("\t\t- test_type - \"case\", \"group\" or \"all\"");
$this->out("\t\t- test_file - file name with folder prefix and without the (test|group).php suffix");
$this->out('');
$this->out('Examples: ');
$this->out("\t\t cake testsuite app all");
$this->out("\t\t cake testsuite core all");
$this->out("\t\tcake testsuite app all");
$this->out("\t\tcake testsuite core all");
$this->out('');
$this->out("\t\t cake testsuite app case behaviors/debuggable");
$this->out("\t\t cake testsuite app case models/my_model");
$this->out("\t\t cake testsuite app case controllers/my_controller");
$this->out("\t\tcake testsuite app case behaviors/debuggable");
$this->out("\t\tcake testsuite app case models/my_model");
$this->out("\t\tcake testsuite app case controllers/my_controller");
$this->out('');
$this->out("\t\t cake testsuite core case file");
$this->out("\t\t cake testsuite core case router");
$this->out("\t\t cake testsuite core case set");
$this->out("\t\tcake testsuite core case file");
$this->out("\t\tcake testsuite core case router");
$this->out("\t\tcake testsuite core case set");
$this->out('');
$this->out("\t\t cake testsuite app group mygroup");
$this->out("\t\t cake testsuite core group acl");
$this->out("\t\t cake testsuite core group socket");
$this->out("\t\tcake testsuite app group mygroup");
$this->out("\t\tcake testsuite core group acl");
$this->out("\t\tcake testsuite core group socket");
$this->out('');
$this->out("\t\t cake testsuite bugs case models/bug // for the plugin 'bugs' and its test case 'bug'");
$this->out("\t\t cake testsuite bugs group bug // for the plugin bugs and its test group 'bug'");
$this->out("\t\t cake testsuite bugs_me case models/bug // for the plugin 'bugs_me' and its test case 'bug'");
$this->out("\t\t cake testsuite bugs_me group bug // for the plugin bugs_me and its test group 'bug'");
$this->out("\t\tcake testsuite bugs case models/bug");
$this->out("\t\t // for the plugin 'bugs' and its test case 'models/bug'");
$this->out("\t\tcake testsuite bugs group bug");
$this->out("\t\t // for the plugin bugs and its test group 'bug'");
$this->out('');
$this->out('Code Coverage Analysis: ');
$this->out("\n\nAppend 'cov' to any of the above in order to enable code coverage analysis");
@ -312,11 +312,19 @@ class TestSuiteShell extends Shell {
);
if (array_key_exists($category, $paths)) {
$folder = $paths[$category];
$folder = $paths[$category] . 'tests';
} else {
$folder = APP.'plugins'.DS.Inflector::underscore($category).DS;
$scoredCategory = Inflector::underscore($category);
$folder = APP . 'plugins' . DS . $scoredCategory . DS;
$pluginPaths = Configure::read('pluginPaths');
foreach ($pluginPaths as $path) {
if (file_exists($path . $scoredCategory . DS . 'tests')) {
$folder = $path . $scoredCategory . DS . 'tests';
break;
}
}
}
return $folder.'tests';
return $folder;
}
/**
* Sets some get vars needed for TestManager

View file

@ -33,7 +33,7 @@ class Cache extends Object {
/**
* Cache engine to use
*
* @var object
* @var CacheEngine
* @access protected
*/
var $_Engine = null;

View file

@ -34,7 +34,7 @@ class FileEngine extends CacheEngine {
/**
* Instance of File class
*
* @var object
* @var File
* @access private
*/
var $__File = null;

View file

@ -33,7 +33,7 @@ class MemcacheEngine extends CacheEngine {
/**
* Memcache wrapper.
*
* @var object
* @var Memcache
* @access private
*/
var $__Memcache = null;

View file

@ -337,6 +337,11 @@ class AuthComponent extends Object {
if (!$this->user()) {
if (!$this->RequestHandler->isAjax()) {
$this->Session->setFlash($this->authError, 'default', array(), 'auth');
if (!empty($controller->params['url']) && count($controller->params['url']) >= 2) {
$query = $controller->params['url'];
unset($query['url']);
$url .= Router::queryString($query, array());
}
$this->Session->write('Auth.redirect', $url);
$controller->redirect($loginAction);
return false;

View file

@ -345,6 +345,7 @@ class EmailComponent extends Object{
$this->bcc = array();
$this->subject = null;
$this->additionalParams = null;
$this->smtpError = null;
$this->__header = array();
$this->__boundary = null;
$this->__message = array();
@ -673,7 +674,13 @@ class EmailComponent extends Object{
return false;
}
if (!$this->__smtpSend('HELO cake', '250')) {
if (isset($this->smtpOptions['host'])) {
$host = $this->smtpOptions['host'];
} else {
$host = env('HTTP_HOST');
}
if (!$this->__smtpSend("HELO {$host}", '250')) {
return false;
}

View file

@ -524,6 +524,7 @@ class RequestHandlerComponent extends Object {
return $this->ext;
}
$types = $type;
if (is_string($type)) {
$types = array($type);
}
@ -550,7 +551,11 @@ class RequestHandlerComponent extends Object {
return $accepts[0];
}
$accepts = array_intersect($this->__acceptTypes, $accepts);
$acceptedTypes = array();
foreach ($this->__acceptTypes as $type) {
$acceptedTypes[] = $this->mapType($type);
}
$accepts = array_intersect($acceptedTypes, $accepts);
return $accepts[0];
}
/**

View file

@ -291,6 +291,32 @@ class Controller extends Object {
* @link
*/
var $methods = array();
/**
* This controller's primary model class name, the Inflector::classify()'ed version of
* the controller's $name property.
*
* Example: For a controller named 'Comments', the modelClass would be 'Comment'
*
* @var string
* @access public
*/
var $modelClass = null;
/**
* This controller's model key name, an underscored version of the controller's $modelClass property.
*
* Example: For a controller named 'ArticleComments', the modelKey would be 'article_comment'
*
* @var string
* @access public
*/
var $modelKey = null;
/**
* Holds any validation errors produced by the last call of the validateErrors() method/
*
* @var array Validation errors, or false if none
* @access public
*/
var $validationErrors = null;
/**
* Constructor.
*
@ -367,7 +393,7 @@ class Controller extends Object {
if ($var === 'components') {
$normal = Set::normalize($this->{$var});
$app = Set::normalize($appVars[$var]);
$this->{$var} = Set::merge($normal, $app);
$this->{$var} = Set::merge($app, $normal);
} else {
$this->{$var} = Set::merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
}
@ -1000,6 +1026,14 @@ class Controller extends Object {
if (!isset($defaults['conditions'])) {
$defaults['conditions'] = array();
}
$type = 'all';
if (isset($defaults[0])) {
$type = $defaults[0];
unset($defaults[0]);
}
extract($options = array_merge(array('page' => 1, 'limit' => 20), $defaults, $options));
if (is_array($scope) && !empty($scope)) {
@ -1010,12 +1044,7 @@ class Controller extends Object {
if ($recursive === null) {
$recursive = $object->recursive;
}
$type = 'all';
if (isset($defaults[0])) {
$type = $defaults[0];
unset($defaults[0]);
}
$extra = array_diff_key($defaults, compact(
'conditions', 'fields', 'order', 'limit', 'page', 'recursive'
));

View file

@ -39,7 +39,7 @@ class Scaffold extends Object {
/**
* Controller object
*
* @var object
* @var Controller
* @access public
*/
var $controller = null;

View file

@ -144,7 +144,8 @@ class Debugger extends Object {
if (is_object($trace[0]['object']) && isset($trace[0]['object']->_reporter->_test_stack)) {
$stack = $trace[0]['object']->_reporter->_test_stack;
$source = "[". $stack[0].", ". $stack[2] ."::" . $stack[3] ."()]\n";
$source = sprintf('[%1$s, %3$s::%2$s()]' . "\n",
array_shift($stack), array_pop($stack), array_pop($stack));
}
CakeLog::write($level, $source . $_this->exportVar($var));

View file

@ -70,7 +70,7 @@ class ErrorHandler extends Object {
/**
* Controller instance.
*
* @var object
* @var Controller
* @access public
*/
var $controller = null;

View file

@ -42,7 +42,7 @@ class File extends Object {
/**
* Folder object of the File
*
* @var object
* @var Folder
* @access public
*/
var $Folder = null;
@ -376,7 +376,7 @@ class File extends Object {
}
/**
* Returns the full path of the File.
*
*
* @return string Full path to file
* @access public
*/

View file

@ -212,17 +212,18 @@ class Folder extends Object {
*/
function _findRecursive($pattern, $sort = false) {
list($dirs, $files) = $this->read($sort);
$found = array();
foreach ($files as $file) {
if (preg_match('/^' . $pattern . '$/i', $file)) {
$found[] = Folder::addPathElement($this->path, $file);
}
}
$start = $this->path;
foreach ($dirs as $dir) {
$this->cd(Folder::addPathElement($start, $dir));
$found = array_merge($found, $this->findRecursive($pattern));
$found = array_merge($found, $this->findRecursive($pattern, $sort));
}
return $found;
}

View file

@ -40,7 +40,7 @@ class I18n extends Object {
/**
* Instance of the I10n class for localization
*
* @var object
* @var I10n
* @access public
*/
var $l10n = null;

View file

@ -205,11 +205,11 @@ class ModelBehavior extends Object {
* @subpackage cake.cake.libs.model
*/
class BehaviorCollection extends Object {
/**
* Stores a reference to the attached name
*
* @var object
* @var string
* @access public
*/
var $modelName = null;
/**

View file

@ -1,9 +1,9 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* Datasource connection manager
*
* Long description for file
* Provides an interface for loading and enumerating connections defined in app/config/database.php
*
* PHP versions 4 and 5
*
@ -39,7 +39,7 @@ class ConnectionManager extends Object {
/**
* Holds a loaded instance of the Connections object
*
* @var object
* @var DATABASE_CONFIG
* @access public
*/
var $config = null;
@ -85,7 +85,7 @@ class ConnectionManager extends Object {
/**
* Gets a reference to a DataSource object
*
* @param string $name The name of the DataSource, as defined in app/config/connections
* @param string $name The name of the DataSource, as defined in app/config/database.php
* @return object Instance
* @access public
* @static
@ -145,8 +145,9 @@ class ConnectionManager extends Object {
/**
* Loads the DataSource class for the given connection name
*
* @param mixed $connName A string name of the connection, as defined in Connections config,
* or an array containing the file and class name of the object.
* @param mixed $connName A string name of the connection, as defined in app/config/database.php,
* or an array containing the filename (without extension) and class name of the object,
* to be found in app/models/datasources/ or cake/libs/model/datasources/.
* @return boolean True on success, null on failure or false if the class is already loaded
* @access public
* @static
@ -259,4 +260,4 @@ class ConnectionManager extends Object {
}
}
}
?>
?>

View file

@ -241,13 +241,14 @@ class DataSource extends Object {
if ($this->cacheSources === false) {
return null;
}
if (isset($this->__descriptions[$model->tablePrefix . $model->table])) {
return $this->__descriptions[$model->tablePrefix . $model->table];
$table = $this->fullTableName($model, false);
if (isset($this->__descriptions[$table])) {
return $this->__descriptions[$table];
}
$cache = $this->__cacheDescription($model->tablePrefix . $model->table);
$cache = $this->__cacheDescription($table);
if ($cache !== null) {
$this->__descriptions[$model->tablePrefix . $model->table] =& $cache;
$this->__descriptions[$table] =& $cache;
return $cache;
}
return null;

View file

@ -221,7 +221,7 @@ class DboMssql extends DboSource {
'null' => (strtoupper($column[0]['Null']) == 'YES'),
'default' => preg_replace("/^[(]{1,2}'?([^')]*)?'?[)]{1,2}$/", "$1", $column[0]['Default']),
'length' => intval($column[0]['Length']),
'key' => ($column[0]['Key'] == '1')
'key' => ($column[0]['Key'] == '1') ? 'primary' : false
);
if ($fields[$field]['default'] === 'null') {
$fields[$field]['default'] = null;
@ -341,17 +341,18 @@ class DboMssql extends DboSource {
if (!empty($values)) {
$fields = array_combine($fields, $values);
}
$primaryKey = $this->_getPrimaryKey($model);
if (array_key_exists($model->primaryKey, $fields)) {
if (empty($fields[$model->primaryKey])) {
unset($fields[$model->primaryKey]);
if (array_key_exists($primaryKey, $fields)) {
if (empty($fields[$primaryKey])) {
unset($fields[$primaryKey]);
} else {
$this->_execute("SET IDENTITY_INSERT " . $this->fullTableName($model) . " ON");
$this->_execute('SET IDENTITY_INSERT ' . $this->fullTableName($model) . ' ON');
}
}
$result = parent::create($model, array_keys($fields), array_values($fields));
if (array_key_exists($model->primaryKey, $fields) && !empty($fields[$model->primaryKey])) {
$this->_execute("SET IDENTITY_INSERT " . $this->fullTableName($model) . " OFF");
if (array_key_exists($primaryKey, $fields) && !empty($fields[$primaryKey])) {
$this->_execute('SET IDENTITY_INSERT ' . $this->fullTableName($model) . ' OFF');
}
return $result;
}
@ -631,6 +632,29 @@ class DboMssql extends DboSource {
return false;
}
}
/**
* Inserts multiple values into a table
*
* @param string $table
* @param string $fields
* @param array $values
* @access protected
*/
function insertMulti($table, $fields, $values) {
$primaryKey = $this->_getPrimaryKey($table);
$hasPrimaryKey = $primaryKey != null && (
(is_array($fields) && in_array($primaryKey, $fields)
|| (is_string($fields) && strpos($fields, $this->startQuote . $primaryKey . $this->endQuote) !== false))
);
if ($hasPrimaryKey) {
$this->_execute('SET IDENTITY_INSERT ' . $this->fullTableName($table) . ' ON');
}
parent::insertMulti($table, $fields, $values);
if ($hasPrimaryKey) {
$this->_execute('SET IDENTITY_INSERT ' . $this->fullTableName($table) . ' OFF');
}
}
/**
* Generate a database-native column schema string
*
@ -680,5 +704,27 @@ class DboMssql extends DboSource {
}
return $join;
}
/**
* Makes sure it will return the primary key
*
* @param mixed $model
* @access protected
* @return string
*/
function _getPrimaryKey($model) {
if (is_object($model)) {
$schema = $model->schema();
} else {
$schema = $this->describe($model);
}
foreach ($schema as $field => $props) {
if (isset($props['key']) && $props['key'] == 'primary') {
return $field;
}
}
return null;
}
}
?>

View file

@ -454,6 +454,7 @@ class DboOracle extends DboSource {
while($r = $this->fetchRow()) {
$sources[] = strtolower($r[0]['name']);
}
parent::listSources($sources);
return $sources;
}
/**
@ -834,8 +835,7 @@ class DboOracle extends DboSource {
switch($column) {
case 'date':
$date = new DateTime($data);
$data = $date->format('Y-m-d H:i:s');
$data = date('Y-m-d H:i:s', strtotime($data));
$data = "TO_DATE('$data', 'YYYY-MM-DD HH24:MI:SS')";
break;
case 'integer' :

View file

@ -221,7 +221,7 @@ class Model extends Overloadable {
/**
* Holds the Behavior objects currently bound to this model.
*
* @var object
* @var BehaviorCollection
* @access public
*/
var $Behaviors = null;
@ -1210,7 +1210,7 @@ class Model extends Overloadable {
foreach ($this->_schema as $field => $properties) {
if ($this->primaryKey === $field) {
$fInfo = $this->_schema[$field];
$isUUID = ($fInfo['length'] === 36 &&
$isUUID = ($fInfo['length'] == 36 &&
($fInfo['type'] === 'string' || $fInfo['type'] === 'binary')
);
if (empty($this->data[$this->alias][$this->primaryKey]) && $isUUID) {
@ -1279,7 +1279,7 @@ class Model extends Overloadable {
));
$isUUID = !empty($this->{$join}->primaryKey) && (
$this->{$join}->_schema[$this->{$join}->primaryKey]['length'] === 36 && (
$this->{$join}->_schema[$this->{$join}->primaryKey]['length'] == 36 && (
$this->{$join}->_schema[$this->{$join}->primaryKey]['type'] === 'string' ||
$this->{$join}->_schema[$this->{$join}->primaryKey]['type'] === 'binary'
)
@ -1374,16 +1374,15 @@ class Model extends Overloadable {
$conditions = ($recursive == 1) ? (array)$assoc['counterScope'] : array();
if (isset($keys['old'][$foreignKey])) {
if ($keys['old'][$foreignKey] == $keys[$foreignKey]) {
continue;
if ($keys['old'][$foreignKey] != $keys[$foreignKey]) {
$conditions[$fkQuoted] = $keys['old'][$foreignKey];
$count = intval($this->find('count', compact('conditions', 'recursive')));
$this->{$parent}->updateAll(
array($assoc['counterCache'] => $count),
array($this->{$parent}->escapeField() => $keys['old'][$foreignKey])
);
}
$conditions[$fkQuoted] = $keys['old'][$foreignKey];
$count = intval($this->find('count', compact('conditions', 'recursive')));
$this->{$parent}->updateAll(
array($assoc['counterCache'] => $count),
array($this->{$parent}->escapeField() => $keys['old'][$foreignKey])
);
}
$conditions[$fkQuoted] = $keys[$foreignKey];
@ -1420,7 +1419,7 @@ class Model extends Overloadable {
return array();
}
$old = $this->find('first', array(
'conditions' => array('id' => $this->id),
'conditions' => array($this->primaryKey => $this->id),
'fields' => array_values($included),
'recursive' => -1
));
@ -1853,7 +1852,7 @@ class Model extends Overloadable {
if ($this->getID() === false || $this->useTable === false) {
return false;
}
if ($this->__exists !== null && $reset !== true) {
if (!empty($this->__exists) && $reset !== true) {
return $this->__exists;
}
$conditions = array($this->alias . '.' . $this->primaryKey => $this->getID());
@ -2343,9 +2342,15 @@ class Model extends Overloadable {
$this->exists();
$_validate = $this->validate;
if (array_key_exists('fieldList', $options) && is_array($options['fieldList']) && !empty($options['fieldList'])) {
$whitelist = $this->whitelist;
if (array_key_exists('fieldList', $options)) {
$whitelist = $options['fieldList'];
}
if (!empty($whitelist)) {
$validate = array();
foreach ($options['fieldList'] as $f) {
foreach ((array)$whitelist as $f) {
if (!empty($this->validate[$f])) {
$validate[$f] = $this->validate[$f];
}

View file

@ -38,7 +38,7 @@ class Object {
/**
* Log object
*
* @var object
* @var CakeLog
* @access protected
*/
var $_log = null;
@ -248,7 +248,11 @@ class Object {
$objectArray = array(&$object);
$data = str_replace('\\', '\\\\', serialize($objectArray));
$data = '<?php $' . $name . ' = \'' . str_replace('\'', '\\\'', $data) . '\' ?>';
cache($file, $data, '+1 day');
$duration = '+999 days';
if (Configure::read() >= 1) {
$duration = '+10 seconds';
}
cache($file, $data, $duration);
}
/**
* Open the persistent class file for reading
@ -267,14 +271,16 @@ class Object {
case 'registry':
$vars = unserialize(${$name});
foreach ($vars['0'] as $key => $value) {
App::import('Model', Inflector::classify($key));
if (strpos($key, '_behavior') !== false) {
App::import('Behavior', Inflector::classify(substr($key, 0, -9)));
} else {
App::import('Model', Inflector::classify($key));
}
unset ($value);
}
unset($vars);
$vars = unserialize(${$name});
foreach ($vars['0'] as $key => $value) {
foreach ($vars['0'][$key]->Behaviors->_attached as $behavior) {
App::import('Behavior', $behavior);
}
ClassRegistry::addObject($key, $value);
unset ($value);
}

View file

@ -349,7 +349,9 @@ class CakeSession extends Object {
if (empty($var)) {
return false;
}
$this->watchKeys[] = $var;
if (!in_array($var, $this->watchKeys, true)) {
$this->watchKeys[] = $var;
}
}
/**
* Tells Session to stop watching a given key path
@ -508,7 +510,7 @@ class CakeSession extends Object {
array('Cache', 'read'),
array('Cache', 'write'),
array('Cache', 'delete'),
array('CakeSession', '__gc'));
array('Cache', 'gc'));
break;
default:
if (empty($_SESSION)) {
@ -571,10 +573,8 @@ class CakeSession extends Object {
$this->__setError(1, 'Session Highjacking Attempted !!!');
}
} else {
srand ((double)microtime() * 1000000);
$this->write('Config.userAgent', $this->_userAgent);
$this->write('Config.time', $this->sessionTime);
$this->write('Config.rand', mt_rand());
$this->write('Config.timeout', 10);
$this->valid = true;
$this->__setError(1, 'Session is valid');

View file

@ -374,12 +374,12 @@ class Set extends Object {
$data = $path;
$path = $tmp;
}
if (empty($data)) {
return array();
}
if (strpos($path, '/') === false) {
return Set::classicExtract($data, $path);
}
if (empty($data)) {
return array();
}
if ($path === '/') {
return $data;
}

View file

@ -237,6 +237,8 @@ class String extends Object {
$str = substr_replace($str, $val, $pos, 1);
}
} else {
asort($data);
$hashKeys = array_map('md5', array_keys($data));
$tempData = array_combine(array_keys($data), array_values($hashKeys));
foreach ($tempData as $key => $hashVal) {

View file

@ -798,6 +798,7 @@ class Validation extends Object {
* an optional fragment (anchor tag)
*
* @param string $check Value to check
* @param boolean $strict Require URL to be prefixed by a valid scheme (one of http(s)/ftp(s)/file/news/gopher)
* @return boolean Success
* @access public
*/
@ -925,4 +926,4 @@ class Validation extends Object {
$this->errors = array();
}
}
?>
?>

View file

@ -591,7 +591,7 @@ class Helper extends Overloadable {
if (is_array($result)) {
$view =& ClassRegistry::getObject('view');
if (isset($result[$view->fieldSuffix])) {
if (array_key_exists($view->fieldSuffix, $result)) {
$result = $result[$view->fieldSuffix];
}
}

View file

@ -42,14 +42,14 @@ class AjaxHelper extends AppHelper {
/**
* HtmlHelper instance
*
* @var object
* @var HtmlHelper
* @access public
*/
var $Html = null;
/**
* JavaScriptHelper instance
*
* @var object
* @var JavaScriptHelper
* @access public
*/
var $Javascript = null;
@ -81,7 +81,8 @@ class AjaxHelper extends AppHelper {
*/
var $dragOptions = array(
'handle', 'revert', 'snap', 'zindex', 'constraint', 'change', 'ghosting',
'starteffect', 'reverteffect', 'endeffect'
'starteffect', 'reverteffect', 'endeffect', 'scroll', 'scrollSensitivity',
'onStart', 'onDrag', 'onEnd'
);
/**
* Options for droppable.
@ -901,7 +902,7 @@ class AjaxHelper extends AppHelper {
}
if (isset($options['bind'])) {
$bind = $options['bind'];
$hasBinding = (
(is_array($bind) && in_array($callback, $bind)) ||
(is_string($bind) && strpos($bind, $callback) !== false)

View file

@ -52,7 +52,7 @@ class CacheHelper extends AppHelper {
/**
* holds the View object passed in final call to CacheHelper::cache()
*
* @var object
* @var View
* @access public
*/
var $view;

View file

@ -563,7 +563,8 @@ class FormHelper extends AppHelper {
/**
* Generates a form input element complete with label and wrapper div
*
* Options - See each field type method for more information.
* Options - See each field type method for more information. Any options that are part of
* $attributes or $options for the different type methods can be included in $options for input().
*
* - 'type' - Force the type of widget you want. e.g. ```type => 'select'```
* - 'label' - control the label
@ -852,11 +853,14 @@ class FormHelper extends AppHelper {
} elseif (!empty($value) && $value === $options['value']) {
$options['checked'] = 'checked';
}
$output = $this->hidden($fieldName, array(
$hiddenOptions = array(
'id' => $options['id'] . '_', 'name' => $options['name'],
'value' => '0', 'secure' => false
));
);
if (isset($options['disabled'])) {
$hiddenOptions['disabled'] = 'disabled';
}
$output = $this->hidden($fieldName, $hiddenOptions);
return $this->output($output . sprintf(
$this->Html->tags['checkbox'],
@ -935,7 +939,7 @@ class FormHelper extends AppHelper {
if (!isset($value) || $value === '') {
$hidden = $this->hidden($fieldName, array(
'id' => $attributes['id'] . '_', 'value' => ''
'id' => $attributes['id'] . '_', 'value' => '', 'name' => $attributes['name']
));
}
$out = $hidden . join($inbetween, $out);

View file

@ -319,7 +319,7 @@ class JavascriptHelper extends AppHelper {
* @return string Escaped string.
*/
function escapeString($string) {
$escape = array("\r\n" => '\n', "\r" => '\n', "\n" => '\n', '"' => '\"', "'" => "\\'");
$escape = array('\n' => '\\\n', "\r\n" => '\n', "\r" => '\n', "\n" => '\n', '"' => '\"', "'" => "\\'");
return str_replace(array_keys($escape), array_values($escape), $string);
}
/**

View file

@ -222,8 +222,16 @@ class PaginatorHelper extends AppHelper {
$title = __(Inflector::humanize(preg_replace('/_id$/', '', $title)), true);
}
$dir = 'asc';
$sortKey = $this->sortKey($options['model']);
$defaultModel = $this->defaultModel();
if ($this->sortKey($options['model']) == $key && $this->sortDir($options['model']) == 'asc') {
if (strpos($sortKey, $defaultModel) !== false && strpos($key, $defaultModel) === false) {
$isSorted = ($sortKey === $defaultModel . '.' . $key);
} else {
$isSorted = ($sortKey === $key);
}
if ($isSorted && $this->sortDir($options['model']) === 'asc') {
$dir = 'desc';
}
if (is_array($title) && array_key_exists($dir, $title)) {

View file

@ -79,6 +79,13 @@ class MediaView extends View {
'iges' => 'model/iges', 'igs' => 'model/iges', 'mesh' => 'model/mesh', 'msh' => 'model/mesh',
'silo' => 'model/mesh', 'vrml' => 'model/vrml', 'wrl' => 'model/vrml',
'mime' => 'www/mime', 'pdb' => 'chemical/x-pdb', 'xyz' => 'chemical/x-pdb');
/**
* Holds headers sent to browser before rendering media
*
* @var array
* @access protected
*/
var $_headers = array();
/**
* Constructor
*
@ -105,7 +112,7 @@ class MediaView extends View {
} else {
$path = APP . $path . $id;
}
if (!file_exists($path)) {
header('Content-Type: text/html');
$this->cakeError('error404');
@ -118,7 +125,7 @@ class MediaView extends View {
if (is_array($mimeType)) {
$this->mimeType = array_merge($this->mimeType, $mimeType);
}
if (isset($extension) && isset($this->mimeType[$extension]) && connection_status() == 0) {
$chunkSize = 8192;
$buffer = '';
@ -148,13 +155,14 @@ class MediaView extends View {
));
}
foreach($contentTypes as $contentType) {
header('Content-Type: ' . $contentType);
$this->_header('Content-Type: ' . $contentType);
}
header('Content-Disposition: attachment; filename="' . $name . '.' . $extension . '";');
header('Expires: 0');
header('Accept-Ranges: bytes');
header('Cache-Control: private', false);
header('Pragma: private');
$this->_header(array(
'Content-Disposition: attachment; filename="' . $name . '.' . $extension . '";',
'Expires: 0',
'Accept-Ranges: bytes',
'Cache-Control: private' => false,
'Pragma: private'));
$httpRange = env('HTTP_RANGE');
if (isset($httpRange)) {
@ -163,30 +171,36 @@ class MediaView extends View {
$size = $fileSize - 1;
$length = $fileSize - $range;
header('HTTP/1.1 206 Partial Content');
header('Content-Length: ' . $length);
header('Content-Range: bytes ' . $range . $size . '/' . $fileSize);
$this->_header(array(
'HTTP/1.1 206 Partial Content',
'Content-Length: ' . $length,
'Content-Range: bytes ' . $range . $size . '/' . $fileSize));
fseek($handle, $range);
} else {
header('Content-Length: ' . $fileSize);
$this->_header('Content-Length: ' . $fileSize);
}
} else {
header('Date: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
$this->_header('Date: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
if ($cache) {
if (!is_numeric($cache)) {
$cache = strtotime($cache) - time();
}
header('Cache-Control: max-age=' . $cache);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $cache) . ' GMT');
header('Pragma: cache');
$this->_header(array(
'Cache-Control: max-age=' . $cache,
'Expires: ' . gmdate('D, d M Y H:i:s', time() + $cache) . ' GMT',
'Pragma: cache'));
} else {
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');
$this->_header(array(
'Cache-Control: must-revalidate, post-check=0, pre-check=0',
'Pragma: no-cache'));
}
header('Last-Modified: ' . $modified);
header('Content-Type: ' . $this->mimeType[$extension]);
header('Content-Length: ' . $fileSize);
$this->_header(array(
'Last-Modified: ' . $modified,
'Content-Type: ' . $this->mimeType[$extension],
'Content-Length: ' . $fileSize));
}
$this->_output();
@ob_end_clean();
while (!feof($handle) && connection_status() == 0 && !connection_aborted()) {
@ -201,5 +215,35 @@ class MediaView extends View {
}
return false;
}
/**
* Method to set headers
* @param mixed $header
* @param boolean $boolean
* @access protected
*/
function _header($header, $boolean = true) {
if (is_array($header)) {
foreach ($header as $string => $boolean) {
if (is_numeric($string)) {
$this->_headers[] = array($boolean => true);
} else {
$this->_headers[] = array($string => $boolean);
}
}
return;
}
$this->_headers[] = array($header => $boolean);
return;
}
/**
* Method to output headers
* @access protected
*/
function _output() {
foreach ($this->_headers as $key => $value) {
$header = key($value);
header($header, $value[$header]);
}
}
}
?>
?>

View file

@ -823,13 +823,19 @@ class Xml extends XmlNode {
$this->{$key} = $options[$key];
}
$this->__tags = $options['tags'];
parent::__construct($options['root']);
parent::__construct('#document');
if ($options['root'] !== '#document') {
$Root = $this->createNode($options['root']);
} else {
$Root =& $this;
}
if (!empty($input)) {
if (is_string($input)) {
$this->load($input);
$Root->load($input);
} elseif (is_array($input) || is_object($input)) {
$this->append($input, $options);
$Root->append($input, $options);
}
}
// if (Configure::read('App.encoding') !== null) {
@ -874,10 +880,11 @@ class Xml extends XmlNode {
*/
function parse() {
$this->__initParser();
$this->__rawData = trim($this->__rawData);
$this->__header = trim(str_replace(
a('<' . '?', '?' . '>'),
a('', ''),
substr(trim($this->__rawData), 0, strpos($this->__rawData, "\n"))
substr($this->__rawData, 0, strpos($this->__rawData, '?' . '>'))
));
xml_parse_into_struct($this->__parser, $this->__rawData, $vals);

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* BasicsTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -29,7 +29,7 @@ App::import('Core', 'Folder');
/**
* BasicsTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases
*/
class BasicsTest extends CakeTestCase {
@ -40,7 +40,19 @@ class BasicsTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->_localePaths = Configure::read('localePaths');
Configure::write('localePaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale'));
$this->_language = Configure::read('Config.language');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('localePaths', $this->_localePaths);
Configure::write('Config.language', $this->_language);
}
/**
* testHttpBase method
@ -119,6 +131,8 @@ class BasicsTest extends CakeTestCase {
* @return void
*/
function testUses() {
$this->skipIf(class_exists('Security') || class_exists('Sanitize'), '%s Security and/or Sanitize class already loaded');
$this->assertFalse(class_exists('Security'));
$this->assertFalse(class_exists('Sanitize'));
@ -532,15 +546,17 @@ class BasicsTest extends CakeTestCase {
ob_start();
debug('this-is-a-test');
$result = ob_get_clean();
$pattern = '/.*' . preg_quote(substr(__FILE__, 1), '/')
. '.*line.*' . (__LINE__ - 3) . '.*this-is-a-test.*/s';
$pattern = '/.*\>(cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
$pattern .= preg_quote(substr(__FILE__, 1), '/') . ')';
$pattern .= '.*line.*' . (__LINE__ - 4) . '.*this-is-a-test.*/s';
$this->assertPattern($pattern, $result);
ob_start();
debug('<div>this-is-a-test</div>', true);
$result = ob_get_clean();
$pattern = '/.*' . preg_quote(substr(__FILE__, 1), '/')
. '.*line.*' . (__LINE__ - 3) . '.*&lt;div&gt;this-is-a-test&lt;\/div&gt;.*/s';
$pattern = '/.*\>(cake(\/|\\\)tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
$pattern .= preg_quote(substr(__FILE__, 1), '/') . ')';
$pattern .= '.*line.*' . (__LINE__ - 4) . '.*&lt;div&gt;this-is-a-test&lt;\/div&gt;.*/s';
$this->assertPattern($pattern, $result);
}
/**

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ShellDispatcherTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.console
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -76,7 +76,6 @@ class TestShellDispatcher extends ShellDispatcher {
* @return void
*/
function _initEnvironment() {
//
}
/**
* stderr method
@ -111,9 +110,9 @@ class TestShellDispatcher extends ShellDispatcher {
}
}
/**
* Short description for class.
* ShellDispatcherTest
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class ShellDispatcherTest extends UnitTestCase {
@ -124,14 +123,14 @@ class ShellDispatcherTest extends UnitTestCase {
* @return void
*/
function setUp() {
if (!isset($this->pluginPaths)) {
$this->pluginPaths = Configure::read('pluginPaths');
$this->shellPaths = Configure::read('shellPaths');
}
$this->_pluginPaths = Configure::read('pluginPaths');
$this->_shellPaths = Configure::read('shellPaths');
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
Configure::write('pluginPaths', array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
));
Configure::write('shellPaths', array(
ROOT . DS . CONSOLE_LIBS,
CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS,
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS
));
}
@ -142,8 +141,8 @@ class ShellDispatcherTest extends UnitTestCase {
* @return void
*/
function tearDown() {
Configure::write('pluginPaths', $this->pluginPaths);
Configure::write('shellPaths', $this->shellPaths);
Configure::write('pluginPaths', $this->_pluginPaths);
Configure::write('shellPaths', $this->_shellPaths);
}
/**
* testParseParams method
@ -406,14 +405,18 @@ class ShellDispatcherTest extends UnitTestCase {
*/
function testBuildPaths() {
$Dispatcher =& new TestShellDispatcher();
$this->assertEqual($Dispatcher->shellPaths, array(
$result = $Dispatcher->shellPaths;
$expected = array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'vendors' . DS . 'shells' . DS,
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS . 'vendors' . DS . 'shells' . DS,
APP . 'vendors' . DS . 'shells' . DS,
VENDORS . 'shells' . DS,
ROOT . DS . CONSOLE_LIBS,
CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS,
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS,
));
);
$this->assertIdentical(array_diff($result, $expected), array());
$this->assertIdentical(array_diff($expected, $result), array());
}
/**
* testDispatch method
@ -440,32 +443,26 @@ class ShellDispatcherTest extends UnitTestCase {
function testHelpCommand() {
$Dispatcher =& new TestShellDispatcher();
$expected = "/ ROOT(\\\|\/)cake(\\\|\/)tests(\\\|\/)test_app(\\\|\/)plugins(\\\|\/)test_plugin(\\\|\/)vendors(\\\|\/)shells:";
$expected = "/ CORE(\\\|\/)tests(\\\|\/)test_app(\\\|\/)plugins(\\\|\/)test_plugin(\\\|\/)vendors(\\\|\/)shells:";
$expected .= "\n\t example";
$expected .= "\n/";
$this->assertPattern($expected, $Dispatcher->stdout);
// Shells need to be returned ordered
// See Configure::__list/Folder::read
$expected = "/ ROOT(\\\|\/)cake(\\\|\/)tests(\\\|\/)test_app(\\\|\/)plugins(\\\|\/)test_plugin_two(\\\|\/)vendors(\\\|\/)shells:";
$expected = "/ CORE(\\\|\/)tests(\\\|\/)test_app(\\\|\/)plugins(\\\|\/)test_plugin_two(\\\|\/)vendors(\\\|\/)shells:";
$expected .= "\n\t example";
$expected .= "\n\t welcome";
$expected .= "\n/";
$this->assertPattern($expected, $Dispatcher->stdout);
$expected = "/ ROOT(\\\|\/)app(\\\|\/)vendors(\\\|\/)shells:";
$expected .= "\n\t - none";
$expected = "/ APP(\\\|\/)vendors(\\\|\/)shells:";
$expected .= "\n/";
$this->assertPattern($expected, $Dispatcher->stdout);
$expected = "/ ROOT(\\\|\/)vendors(\\\|\/)shells:";
$expected .= "\n\t - none";
$expected .= "\n/";
$this->assertPattern($expected, $Dispatcher->stdout);
// Shells need to be returned ordered
// See Configure::__list/Folder::read
$expected = "/ ROOT(\\\|\/)cake(\\\|\/)console(\\\|\/)libs:";
$expected = "/ CORE(\\\|\/)console(\\\|\/)libs:";
$expected .= "\n\t acl";
$expected .= "\n\t api";
$expected .= "\n\t bake";
@ -476,7 +473,7 @@ class ShellDispatcherTest extends UnitTestCase {
$expected .= "\n/";
$this->assertPattern($expected, $Dispatcher->stdout);
$expected = "/ ROOT(\\\|\/)cake(\\\|\/)tests(\\\|\/)test_app(\\\|\/)vendors(\\\|\/)shells:";
$expected = "/ CORE(\\\|\/)tests(\\\|\/)test_app(\\\|\/)vendors(\\\|\/)shells:";
$expected .= "\n\t sample";
$expected .= "\n/";
$this->assertPattern($expected, $Dispatcher->stdout);

View file

@ -1,9 +1,9 @@
<?php
/* SVN FILE: $Id$ */
/**
* Test Case for Shell
* ShellTest file
*
* Long description for file
* Test Case for Shell
*
* PHP versions 4 and 5
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.console.libs
* @since CakePHP v 1.2.0.7726
* @version $Revision$
@ -44,7 +44,7 @@ Mock::generatePartial(
/**
* TestShell class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.console.libs
*/
class TestShell extends Shell {
@ -52,7 +52,7 @@ class TestShell extends Shell {
/**
* TestAppleTask class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.console.libs
*/
class TestAppleTask extends Shell {
@ -60,7 +60,7 @@ class TestAppleTask extends Shell {
/**
* TestBananaTask class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.console.libs
*/
class TestBananaTask extends Shell {
@ -68,7 +68,7 @@ class TestBananaTask extends Shell {
/**
* ShellTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.console.libs
*/
class ShellTest extends CakeTestCase {
@ -78,7 +78,10 @@ class ShellTest extends CakeTestCase {
* @var array
* @access public
*/
var $fixtures = array('core.post', 'core.comment');
var $fixtures = array(
'core.post', 'core.comment', 'core.article', 'core.user',
'core.tag', 'core.articles_tag', 'core.attachment'
);
/**
* setUp method
*

View file

@ -1,9 +1,9 @@
<?php
/* SVN FILE: $Id: extract.test.php 7838 2008-11-07 10:41:52Z nate $ */
/* SVN FILE: $Id$ */
/**
* Test Case for i18n extraction shell task
* ExtractTaskTest file
*
* Long description for file
* Test Case for i18n extraction shell task
*
* PHP versions 4 and 5
*
@ -16,12 +16,12 @@
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.console.libs.tasks
* @since CakePHP v 1.2.0.7726
* @version $Revision: 7838 $
* @modifiedby $LastChangedBy: DarkAngelBGE $
* @lastmodified $Date: 2008-11-07 05:41:52 -0500 (Fri, 07 Nov 2008) $
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
App::import('Core', array('Shell', 'Folder'));
@ -45,11 +45,10 @@ Mock::generatePartial(
'ShellDispatcher', 'TestExtractTaskMockShellDispatcher',
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
);
/**
* ExtractTaskTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.console.libs.tasks
*/
class ExtractTaskTest extends CakeTestCase {

View file

@ -1,9 +1,9 @@
<?php
/* SVN FILE: $Id$ */
/**
* Test Case for test generation shell task
* TestTaskTest file
*
* Long description for file
* Test Case for test generation shell task
*
* PHP versions 4 and 5
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.console.libs.tasks
* @since CakePHP v 1.2.0.7726
* @version $Revision$
@ -52,7 +52,7 @@ Mock::generatePartial(
/**
* TestTaskTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.console.libs.tasks
*/
class TestTaskTest extends CakeTestCase {

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* DispatcherTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -24,8 +24,13 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
require_once CAKE.'dispatcher.php';
App::import('Core', 'AppController');
require_once CAKE . 'dispatcher.php';
if (!class_exists('AppController')) {
require_once LIBS . 'controller' . DS . 'app_controller.php';
} elseif (!defined('APP_CONTROLLER_EXISTS')){
define('APP_CONTROLLER_EXISTS', true);
}
/**
* TestDispatcher class
*
@ -72,7 +77,6 @@ class TestDispatcher extends Dispatcher {
function _stop() {
return true;
}
}
/**
* MyPluginAppController class
@ -81,7 +85,6 @@ class TestDispatcher extends Dispatcher {
* @subpackage cake.tests.cases
*/
class MyPluginAppController extends AppController {
}
/**
* MyPluginController class
@ -182,7 +185,6 @@ class SomePagesController extends AppController {
function _protected() {
return true;
}
/**
* redirect method overriding
*
@ -264,7 +266,6 @@ class TestDispatchPagesController extends AppController {
function admin_index() {
return true;
}
/**
* camelCased method
*
@ -282,7 +283,6 @@ class TestDispatchPagesController extends AppController {
* @subpackage cake.tests.cases
*/
class ArticlesTestAppController extends AppController {
}
/**
* ArticlesTestController class
@ -481,9 +481,9 @@ class TimesheetsController extends AppController {
}
}
/**
* Short description for class.
* DispatcherTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases
*/
class DispatcherTest extends CakeTestCase {
@ -496,11 +496,50 @@ class DispatcherTest extends CakeTestCase {
function setUp() {
$this->_get = $_GET;
$_GET = array();
$this->_post = $_POST;
$this->_files = $_FILES;
$this->_server = $_SERVER;
$this->_app = Configure::read('App');
Configure::write('App.base', false);
Configure::write('App.baseUrl', false);
Configure::write('App.dir', 'app');
Configure::write('App.webroot', 'webroot');
$this->_cache = Configure::read('Cache');
Configure::write('Cache.disable', true);
$this->_vendorPaths = Configure::read('vendorPaths');
$this->_pluginPaths = Configure::read('pluginPaths');
$this->_viewPaths = Configure::read('viewPaths');
$this->_debug = Configure::read('debug');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
$_GET = $this->_get;
$_POST = $this->_post;
$_FILES = $this->_files;
$_SERVER = $this->_server;
Configure::write('App', $this->_app);
Configure::write('Cache', $this->_cache);
Configure::write('vendorPaths', $this->_vendorPaths);
Configure::write('pluginPaths', $this->_pluginPaths);
Configure::write('viewPaths', $this->_viewPaths);
Configure::write('debug', $this->_debug);
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
$_GET = $this->_get;
}
/**
* testParseParamsWithoutZerosAndEmptyPost method
@ -622,8 +661,6 @@ class DispatcherTest extends CakeTestCase {
$this->assertTrue(isset($result['url']['sleep']));
$this->assertTrue(isset($result['url']['coffee']));
$this->assertEqual($result['url']['coffee'], 'life');
$_GET = $this->_get;
}
/**
* testFileUploadArrayStructure method
@ -850,8 +887,6 @@ class DispatcherTest extends CakeTestCase {
)
);
$this->assertEqual($result['data'], $expected);
$_FILES = array();
}
/**
* testGetUrl method
@ -1610,6 +1645,7 @@ class DispatcherTest extends CakeTestCase {
* @return void
*/
function testChangingParamsFromBeforeFilter() {
$_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php';
$Dispatcher =& new TestDispatcher();
$url = 'some_posts/index/param:value/param2:value2';
$controller = $Dispatcher->dispatch($url, array('return' => 1));
@ -2088,14 +2124,5 @@ class DispatcherTest extends CakeTestCase {
}
return $filename;
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
$_GET = $this->_get;
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* CacheTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -28,9 +28,9 @@ if (!class_exists('Cache')) {
require LIBS . 'cache.php';
}
/**
* Short description for class.
* CacheTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class CacheTest extends CakeTestCase {
@ -41,20 +41,24 @@ class CacheTest extends CakeTestCase {
* @return void
*/
function setUp() {
if (!isset($this->config)) {
$this->config = Cache::config('default');
}
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('default', array('engine'=> 'File', 'path' => CACHE));
$this->_defaultCacheConfig = Cache::config('default');
Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests'));
Cache::engine('File', array('path' => TMP . 'tests'));
}
/**
* end method
* tearDown method
*
* @access public
* @return void
*/
function end() {
Cache::config('default', $this->config['settings']);
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default', $this->_defaultCacheConfig['settings']);
Cache::engine('File');
}
/**
* testConfig method
@ -74,11 +78,17 @@ class CacheTest extends CakeTestCase {
* @return void
*/
function testConfigChange() {
$_cacheConfigSessions = Cache::config('sessions');
$_cacheConfigTests = Cache::config('tests');
$result = Cache::config('sessions', array('engine'=> 'File', 'path' => TMP . 'sessions'));
$this->assertEqual($result['settings'], Cache::settings('File'));
$result = Cache::config('tests', array('engine'=> 'File', 'path' => TMP . 'tests'));
$this->assertEqual($result['settings'], Cache::settings('File'));
Cache::config('sessions', $_cacheConfigSessions['settings']);
Cache::config('tests', $_cacheConfigTests['settings']);
}
/**
* testWritingWithConfig method
@ -87,7 +97,8 @@ class CacheTest extends CakeTestCase {
* @return void
*/
function testWritingWithConfig() {
Cache::config('sessions');
$_cacheConfigSessions = Cache::config('sessions');
Cache::write('test_somthing', 'this is the test data', 'tests');
$expected = array(
@ -101,6 +112,8 @@ class CacheTest extends CakeTestCase {
'isWindows' => DIRECTORY_SEPARATOR == '\\'
);
$this->assertEqual($expected, Cache::settings('File'));
Cache::config('sessions', $_cacheConfigSessions['settings']);
}
/**
* testInitSettings method
@ -110,6 +123,7 @@ class CacheTest extends CakeTestCase {
*/
function testInitSettings() {
Cache::engine('File', array('path' => TMP . 'tests'));
$settings = Cache::settings();
$expecting = array(
'engine' => 'File',
@ -122,6 +136,8 @@ class CacheTest extends CakeTestCase {
'isWindows' => DIRECTORY_SEPARATOR == '\\'
);
$this->assertEqual($settings, $expecting);
Cache::engine('File');
}
/**
* testWriteEmptyValues method
@ -130,8 +146,6 @@ class CacheTest extends CakeTestCase {
* @return void
*/
function testWriteEmptyValues() {
return;
Cache::engine('File', array('path' => TMP . 'tests'));
Cache::write('App.falseTest', false);
$this->assertIdentical(Cache::read('App.falseTest'), false);
@ -147,6 +161,49 @@ class CacheTest extends CakeTestCase {
Cache::write('App.zeroTest2', '0');
$this->assertIdentical(Cache::read('App.zeroTest2'), '0');
}
/**
* testCacheDisable method
*
* Check that the "Cache.disable" configuration and a change to it
* (even after a cache config has been setup) is taken into account.
*
* @link https://trac.cakephp.org/ticket/6236
* @access public
* @return void
*/
function testCacheDisable() {
Configure::write('Cache.disable', false);
Cache::config('test_cache_disable_1', array('engine'=> 'File', 'path' => TMP . 'tests'));
$this->assertTrue(Cache::write('key_1', 'hello'));
$this->assertIdentical(Cache::read('key_1'), 'hello');
Configure::write('Cache.disable', true);
$this->assertFalse(Cache::write('key_2', 'hello'));
$this->assertFalse(Cache::read('key_2'));
Configure::write('Cache.disable', false);
$this->assertTrue(Cache::write('key_3', 'hello'));
$this->assertIdentical(Cache::read('key_3'), 'hello');
Configure::write('Cache.disable', true);
Cache::config('test_cache_disable_2', array('engine'=> 'File', 'path' => TMP . 'tests'));
$this->assertFalse(Cache::write('key_4', 'hello'));
$this->assertFalse(Cache::read('key_4'));
Configure::write('Cache.disable', false);
$this->assertTrue(Cache::write('key_5', 'hello'));
$this->assertIdentical(Cache::read('key_5'), 'hello');
Configure::write('Cache.disable', true);
$this->assertFalse(Cache::write('key_6', 'hello'));
$this->assertFalse(Cache::read('key_6'));
}
/**
* testSet method
*
@ -154,7 +211,7 @@ class CacheTest extends CakeTestCase {
* @return void
*/
function testSet() {
$write = false;
$_cacheSet = Cache::set();
Cache::set(array('duration' => '+1 year'));
$data = Cache::read('test_cache');
@ -162,17 +219,17 @@ class CacheTest extends CakeTestCase {
$data = 'this is just a simple test of the cache system';
$write = Cache::write('test_cache', $data);
$this->assertTrue($write);
Cache::set(array('duration' => '+1 year'));
$data = Cache::read('test_cache');
$this->assertEqual($data, 'this is just a simple test of the cache system');
Cache::delete('test_cache');
$global = Cache::settings();
Cache::set($_cacheSet);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ApcEngineTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
* @since CakePHP(tm) v 1.2.0.5434
* @version $Revision$
@ -28,9 +28,9 @@ if (!class_exists('Cache')) {
require LIBS . 'cache.php';
}
/**
* Short description for class.
* ApcEngineTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
*/
class ApcEngineTest extends UnitTestCase {
@ -45,7 +45,7 @@ class ApcEngineTest extends UnitTestCase {
if (Cache::engine('Apc')) {
$skip = false;
}
$this->skipif($skip, 'Apc is not installed or configured properly');
$this->skipIf($skip, '%s Apc is not installed or configured properly');
}
/**
* setUp method
@ -54,7 +54,28 @@ class ApcEngineTest extends UnitTestCase {
* @return void
*/
function setUp() {
Cache::config('apc', array('engine'=>'Apc', 'prefix' => 'cake_'));
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('apc', array('engine' => 'Apc', 'prefix' => 'cake_'));
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Cache::config('default');
}
/**
* testReadAndWriteCache method
@ -127,14 +148,5 @@ class ApcEngineTest extends UnitTestCase {
$result = Cache::delete('delete_test');
$this->assertTrue($result);
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Cache::config('default');
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* FileEngineTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
* @since CakePHP(tm) v 1.2.0.5434
* @version $Revision$
@ -31,9 +31,9 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
/**
* Short description for class.
* FileEngineTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
*/
class FileEngineTest extends CakeTestCase {
@ -45,23 +45,26 @@ class FileEngineTest extends CakeTestCase {
*/
var $config = array();
/**
* start method
* startCase method
*
* @access public
* @return void
*/
function start() {
$this->config = Cache::config('default');
$settings = Cache::config('default', array('engine'=> 'File', 'path' => CACHE));
function startCase() {
$this->_cacheDisable = Configure::read('Cache.disable');
$this->_cacheConfig = Cache::config('default');
Configure::write('Cache.disable', false);
Cache::config('default', array('engine' => 'File', 'path' => CACHE));
}
/**
* end method
* endCase method
*
* @access public
* @return void
*/
function end() {
Cache::config('default', $this->config['settings']);
function endCase() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default', $this->_cacheConfig['settings']);
}
/**
* testCacheDirChange method
@ -103,7 +106,7 @@ class FileEngineTest extends CakeTestCase {
$result = Cache::read('test');
$expecting = $data;
$this->assertEqual($result, $expecting);
Cache::delete('test');
}
/**
@ -331,7 +334,12 @@ class FileEngineTest extends CakeTestCase {
Cache::delete('test_dir_map');
$this->assertEqual($expected, $data);
}
/**
* testWriteQuotedString method
*
* @access public
* @return void
*/
function testWriteQuotedString() {
Cache::engine('File', array('path' => TMP . 'tests'));
Cache::write('App.doubleQuoteTest', '"this is a quoted string"');

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* MemcacheEngineTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
* @since CakePHP(tm) v 1.2.0.5434
* @version $Revision$
@ -26,10 +26,11 @@
*/
if (!class_exists('Cache')) {
require LIBS . 'cache.php';
}/**
* Short description for class.
}
/**
* MemcacheEngineTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
*/
/**
@ -50,7 +51,7 @@ class MemcacheEngineTest extends CakeTestCase {
if (Cache::engine('Memcache')) {
$skip = false;
}
$this->skipIf($skip, 'Memcache is not installed or configured properly');
$this->skipIf($skip, '%s Memcache is not installed or configured properly');
}
/**
* setUp method
@ -59,7 +60,9 @@ class MemcacheEngineTest extends CakeTestCase {
* @return void
*/
function setUp() {
Cache::config('memcache', array('engine'=>'Memcache', 'prefix' => 'cake_'));
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('memcache', array('engine' => 'Memcache', 'prefix' => 'cake_'));
}
/**
* tearDown method
@ -68,6 +71,7 @@ class MemcacheEngineTest extends CakeTestCase {
* @return void
*/
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default');
}
/**
@ -107,7 +111,7 @@ class MemcacheEngineTest extends CakeTestCase {
}
}
if ($this->skipIf(!$available, 'Need memcache servers at ' . implode(', ', $servers) . ' to run this test')) {
if ($this->skipIf(!$available, '%s Need memcache servers at ' . implode(', ', $servers) . ' to run this test')) {
return;
}
@ -129,7 +133,6 @@ class MemcacheEngineTest extends CakeTestCase {
$result = $Cache->_Engine['Memcache']->connect('127.0.0.1');
$this->assertTrue($result);
}
/**
* testReadAndWriteCache method
*

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* XcacheEngineTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
* @since CakePHP(tm) v 1.2.0.5434
* @version $Revision$
@ -28,9 +28,9 @@ if (!class_exists('Cache')) {
require LIBS . 'cache.php';
}
/**
* Short description for class.
* XcacheEngineTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.cache
*/
class XcacheEngineTest extends UnitTestCase {
@ -45,7 +45,7 @@ class XcacheEngineTest extends UnitTestCase {
if ($result = Cache::engine('Xcache')) {
$skip = false;
}
$this->skipif($skip, 'Xcache is not installed or configured properly');
$this->skipIf($skip, '%s Xcache is not installed or configured properly');
}
/**
* setUp method
@ -54,7 +54,28 @@ class XcacheEngineTest extends UnitTestCase {
* @return void
*/
function setUp() {
Cache::config('xcache', array('engine'=>'Xcache', 'prefix' => 'cake_'));
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Cache::config('xcache', array('engine' => 'Xcache', 'prefix' => 'cake_'));
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('Cache.disable', $this->_cacheDisable);
Cache::config('default');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Cache::config('default');
}
/**
* testSettings method
@ -156,14 +177,5 @@ class XcacheEngineTest extends UnitTestCase {
$result = Cache::clear();
$this->assertTrue($result);
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Cache::config('default');
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* CakeLogTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -26,9 +26,9 @@
*/
App::import('Core', 'Log');
/**
* Short description for class.
* CakeLogTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class CakeLogTest extends CakeTestCase {
@ -52,5 +52,4 @@ class CakeLogTest extends CakeTestCase {
unlink(LOGS . 'error.log');
}
}
?>

View file

@ -1,9 +1,9 @@
<?php
/* SVN FILE: $Id$ */
/**
* CakeTestCase TestCase
* CakeTestCaseTest file
*
* Test Case for CakeTestCase Class
* Test Case for CakeTestCase class
*
* PHP versions 4 and 5
*
@ -25,20 +25,24 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
App::import('Core', 'CakeTestCase');
App::import('Core', 'AppController');
if (!class_exists('AppController')) {
require_once LIBS . 'controller' . DS . 'app_controller.php';
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
define('APP_CONTROLLER_EXISTS', true);
}
Mock::generate('CakeHtmlReporter');
Mock::generate('CakeTestCase', 'CakeDispatcherMockTestCase');
SimpleTest::ignore('SubjectCakeTestCase');
SimpleTest::ignore('CakeDispatcherMockTestCase');
/**
* SubjectCakeTestCase
*
* @package cake.tests
* @subpackage cake.tests.cases.libs
*/
* SubjectCakeTestCase
*
* @package cake
* @subpackage cake.tests.cases.libs
*/
class SubjectCakeTestCase extends CakeTestCase {
/**
* Feed a Mocked Reporter to the subject case
@ -51,18 +55,21 @@ class SubjectCakeTestCase extends CakeTestCase {
function setReporter(&$reporter) {
$this->_reporter = &$reporter;
}
/**
* testDummy method
*
* @return void
* @access public
*/
function testDummy() {
}
}
/**
* CakeTestCaseTest
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
**/
*/
class CakeTestCaseTest extends CakeTestCase {
/**
* setUp
@ -76,6 +83,16 @@ class CakeTestCaseTest extends CakeTestCase {
$this->Case->setReporter($reporter);
$this->Reporter = $reporter;
}
/**
* tearDown
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Case);
unset($this->Reporter);
}
/**
* testAssertGoodTags
*
@ -214,7 +231,6 @@ class CakeTestCaseTest extends CakeTestCase {
$this->assertEqual(array_slice($result, 0, 2), array('start', 'startCase'));
$this->assertEqual(array_slice($result, -2), array('endCase', 'end'));
}
/**
* TestTestAction
*
@ -303,7 +319,7 @@ class CakeTestCaseTest extends CakeTestCase {
$fixture =& new PostFixture($db);
$fixture->create($db);
$fixture->insert($db);
$result = $this->Case->testAction('/tests_apps_posts/fixtured', array(
'return' => 'vars',
'fixturize' => true,
@ -334,17 +350,17 @@ class CakeTestCaseTest extends CakeTestCase {
$fixture =& new PostFixture($db);
$fixture->create($db);
$fixture->insert($db);
$this->Case->dropTables = false;
$result = $this->Case->testAction('/tests_apps_posts/fixtured', array(
'return' => 'vars',
'fixturize' => true,
'connection' => 'cake_test_case',
));
$tables = $db->listSources();
$this->assertTrue(in_array('cake_testaction_test_suite_posts', $tables));
$fixture->drop($db);
$db =& ConnectionManager::getDataSource('test_suite');
$db->config['prefix'] = $_backPrefix;
@ -396,15 +412,5 @@ class CakeTestCaseTest extends CakeTestCase {
Configure::write('viewPaths', $_back['view']);
Configure::write('pluginPaths', $_back['plugin']);
}
/**
* tearDown
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Case);
unset($this->Reporter);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* CakeTestFixture file
*
* Long description for file
*
@ -25,9 +25,8 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Core', 'DboSource');
/**
* CakeFixture Test Fixture
* CakeTestFixtureTestFixture class
*
* @package cake
* @subpackage cake.cake.tests.cases.libs
@ -52,8 +51,8 @@ class CakeTestFixtureTestFixture extends CakeTestFixture {
*/
var $fields = array(
'id' => array('type' => 'integer', 'key' => 'primary'),
'name' => array('type' => 'text', 'length' => '255'),
'created' => array('type' => 'datetime'),
'name' => array('type' => 'string', 'length' => '255'),
'created' => array('type' => 'datetime')
);
/**
* Records property
@ -66,10 +65,8 @@ class CakeTestFixtureTestFixture extends CakeTestFixture {
array('name' => 'Chewbacca')
);
}
/**
* Import Fixture Test Fixture
* CakeTestFixtureImportFixture class
*
* @package cake
* @subpackage cake.cake.tests.cases.libs
@ -88,9 +85,8 @@ class CakeTestFixtureImportFixture extends CakeTestFixture {
*/
var $import = array('table' => 'fixture_tests', 'connection' => 'test_suite');
}
/**
* Import Fixture Test Fixture
* CakeTestFixtureDefaultImportFixture class
*
* @package cake
* @subpackage cake.cake.tests.cases.libs
@ -103,9 +99,8 @@ class CakeTestFixtureDefaultImportFixture extends CakeTestFixture {
*/
var $name = 'ImportFixture';
}
/**
* Fixture Test Case Model
* FixtureImportTestModel class
*
* @package default
* @subpackage cake.cake.tests.cases.libs.
@ -115,9 +110,7 @@ class FixtureImportTestModel extends Model {
var $useTable = 'fixture_tests';
var $useDbConfig = 'test_suite';
}
Mock::generate('DboSource', 'FixtureMockDboSource');
/**
* Test case for CakeTestFixture
*
@ -125,10 +118,25 @@ Mock::generate('DboSource', 'FixtureMockDboSource');
* @subpackage cake.cake.tests.cases.libs
*/
class CakeTestFixtureTest extends CakeTestCase {
/**
* setUp method
*
* @access public
* @return void
*/
function setUp() {
$this->criticDb =& new FixtureMockDboSource();
$this->criticDb->fullDebug = true;
}
/**
* tearDown
*
* @access public
* @return void
*/
function tearDown() {
unset($this->criticDb);
}
/**
* testInit
*
@ -215,8 +223,9 @@ class CakeTestFixtureTest extends CakeTestCase {
/**
* test create method
*
* @access public
* @return void
**/
*/
function testCreate() {
$Fixture =& new CakeTestFixtureTestFixture();
$this->criticDb->expectAtLeastOnce('execute');
@ -229,12 +238,12 @@ class CakeTestFixtureTest extends CakeTestCase {
$return = $Fixture->create($this->criticDb);
$this->assertFalse($return);
}
/**
* test the insert method
*
* @access public
* @return void
**/
*/
function testInsert() {
$Fixture =& new CakeTestFixtureTestFixture();
$this->criticDb->setReturnValue('insertMulti', true);
@ -244,12 +253,12 @@ class CakeTestFixtureTest extends CakeTestCase {
$this->assertTrue($this->criticDb->fullDebug);
$this->assertTrue($return);
}
/**
* Test the drop method
*
* @access public
* @return void
**/
*/
function testDrop() {
$Fixture =& new CakeTestFixtureTestFixture();
$this->criticDb->setReturnValueAt(0, 'execute', true);
@ -267,22 +276,14 @@ class CakeTestFixtureTest extends CakeTestCase {
/**
* Test the truncate method.
*
* @access public
* @return void
**/
*/
function testTruncate() {
$Fixture =& new CakeTestFixtureTestFixture();
$this->criticDb->expectAtLeastOnce('truncate');
$Fixture->truncate($this->criticDb);
$this->assertTrue($this->criticDb->fullDebug);
}
/**
* tearDown
*
* @access public
* @return void
*/
function tearDown() {
unset($this->criticDb);
}
}
?>
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ClassRegistryTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -28,7 +28,7 @@ App::import('Core', 'ClassRegistry');
/**
* ClassRegisterModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class ClassRegisterModel extends CakeTestModel {
@ -43,7 +43,7 @@ class ClassRegisterModel extends CakeTestModel {
/**
* RegisterArticle class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class RegisterArticle extends ClassRegisterModel {
@ -58,7 +58,7 @@ class RegisterArticle extends ClassRegisterModel {
/**
* RegisterArticleFeatured class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class RegisterArticleFeatured extends ClassRegisterModel {
@ -73,7 +73,7 @@ class RegisterArticleFeatured extends ClassRegisterModel {
/**
* RegisterArticleTag class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class RegisterArticleTag extends ClassRegisterModel {
@ -88,7 +88,7 @@ class RegisterArticleTag extends ClassRegisterModel {
/**
* RegistryPluginAppModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class RegistryPluginAppModel extends ClassRegisterModel {
@ -103,7 +103,7 @@ class RegistryPluginAppModel extends ClassRegisterModel {
/**
* TestRegistryPluginModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class TestRegistryPluginModel extends RegistryPluginAppModel {
@ -118,7 +118,7 @@ class TestRegistryPluginModel extends RegistryPluginAppModel {
/**
* RegisterCategory class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class RegisterCategory extends ClassRegisterModel {
@ -133,7 +133,7 @@ class RegisterCategory extends ClassRegisterModel {
/**
* ClassRegistryTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class ClassRegistryTest extends CakeTestCase {

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* CodeCoverageManagerTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -28,13 +28,20 @@ App::import('Core', 'CodeCoverageManager');
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cli_reporter.php';
require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_reporter.php';
/**
* Short description for class.
* CodeCoverageManagerTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class CodeCoverageManagerTest extends CakeTestCase {
/**
* Skip if XDebug not installed
*
* @access public
*/
function skip() {
$this->skipIf(!extension_loaded('xdebug'), '%s XDebug not installed');
}
/**
* startTest Method
* Store reference of $_GET to restore later.
@ -44,7 +51,6 @@ class CodeCoverageManagerTest extends CakeTestCase {
function startCase() {
$this->_get = $_GET;
}
/**
* End Case - restore GET vars.
*
@ -53,14 +59,6 @@ class CodeCoverageManagerTest extends CakeTestCase {
function endCase() {
$_GET = $this->_get;
}
/**
* Skip if XDebug not installed
*
* @access public
*/
function skip() {
$this->skipif (!extension_loaded('xdebug'), 'XDebug not installed');
}
/**
* testNoTestCaseSupplied method
*

View file

@ -1,9 +1,9 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ConfigureTest file
*
* Long description for file
* Holds several tests
*
* PHP versions 4 and 5
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -24,12 +24,11 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Core', 'Configure');
/**
* Short description for class.
* ConfigureTest
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class ConfigureTest extends CakeTestCase {
@ -40,8 +39,10 @@ class ConfigureTest extends CakeTestCase {
* @return void
*/
function setUp() {
parent::setUp();
$this->_cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', true);
$this->_debug = Configure::read('debug');
}
/**
* tearDown method
@ -68,8 +69,8 @@ class ConfigureTest extends CakeTestCase {
if (file_exists(TMP . 'cache' . DS . 'persistent' . DS . 'test.php')) {
unlink(TMP . 'cache' . DS . 'persistent' . DS . 'test.php');
}
Configure::write('debug', 2);
parent::tearDown();
Configure::write('debug', $this->_debug);
Configure::write('Cache.disable', $this->_cacheDisable);
}
/**
* testListObjects method
@ -149,7 +150,6 @@ class ConfigureTest extends CakeTestCase {
$result = Configure::read('SomeName.someKey');
$this->assertEqual($result, null);
}
/**
* testSetErrorReporting Level
*
@ -537,5 +537,4 @@ class AppImportTest extends UnitTestCase {
$this->assertEqual($text, 'This is the welcome.php file in test_plugin/vendors directory');
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ComponentTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
* @since CakePHP(tm) v 1.2.0.5436
* @version $Revision$
@ -62,15 +62,15 @@ if (!class_exists('AppController')) {
* @access public
*/
var $components = array('Orange' => array('colour' => 'blood orange'));
}
} else if (!defined('APP_CONTROLLER_EXISTS')){
} elseif (!defined('APP_CONTROLLER_EXISTS')){
define('APP_CONTROLLER_EXISTS', true);
}
/**
* ParamTestComponent
*
* @package cake.tests.cases.libs.controller
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class ParamTestComponent extends Object {
/**
@ -106,9 +106,9 @@ class ParamTestComponent extends Object {
}
}
/**
* Short description for class.
* ComponentTestController class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class ComponentTestController extends AppController {
@ -185,7 +185,13 @@ class OrangeComponent extends Object {
$this->Banana->testField = 'OrangeField';
$this->settings = $settings;
}
/**
* startup method
*
* @param Controller $controller
* @return string
* @access public
*/
function startup(&$controller) {
$controller->foo = 'pass';
}
@ -204,7 +210,13 @@ class BananaComponent extends Object {
* @access public
*/
var $testField = 'BananaField';
/**
* startup method
*
* @param Controller $controller
* @return string
* @access public
*/
function startup(&$controller) {
$controller->bar = 'fail';
}
@ -216,6 +228,12 @@ class BananaComponent extends Object {
* @subpackage cake.tests.cases.libs.controller
*/
class MutuallyReferencingOneComponent extends Object {
/**
* components property
*
* @var array
* @access public
*/
var $components = array('MutuallyReferencingTwo');
}
/**
@ -225,9 +243,14 @@ class MutuallyReferencingOneComponent extends Object {
* @subpackage cake.tests.cases.libs.controller
*/
class MutuallyReferencingTwoComponent extends Object {
/**
* components property
*
* @var array
* @access public
*/
var $components = array('MutuallyReferencingOne');
}
/**
* SomethingWithEmailComponent class
*
@ -235,6 +258,12 @@ class MutuallyReferencingTwoComponent extends Object {
* @subpackage cake.tests.cases.libs.controller
*/
class SomethingWithEmailComponent extends Object {
/**
* components property
*
* @var array
* @access public
*/
var $components = array('Email');
}
/**
@ -251,10 +280,21 @@ class ComponentTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->_pluginPaths = Configure::read('pluginPaths');
Configure::write('pluginPaths', array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
));
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('pluginPaths', $this->_pluginPaths);
ClassRegistry::flush();
}
/**
* testLoadComponents method
*
@ -321,7 +361,7 @@ class ComponentTest extends CakeTestCase {
$this->assertTrue(is_a($Controller->Apple->Orange->Banana, 'BananaComponent'));
$this->assertTrue(is_a($Controller->Apple->Orange->Controller, 'ComponentTestController'));
$this->assertTrue(empty($Controller->Apple->Session));
$this->assertTrue(empty($Controller->Apple->Orange->Session));
$this->assertTrue(empty($Controller->Apple->Orange->Session));
}
/**
* Tests Component::startup() and only running callbacks for components directly attached to
@ -365,7 +405,9 @@ class ComponentTest extends CakeTestCase {
* @return void
*/
function testComponentsWithParams() {
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), 'Components with Params test will be skipped as it needs a non-existent AppController. As the an AppController class exists, this cannot be run.');
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
return;
}
$Controller =& new ComponentTestController();
$Controller->components = array('ParamTest' => array('test' => 'value', 'flag'), 'Apple');
@ -430,7 +472,7 @@ class ComponentTest extends CakeTestCase {
$Controller->Component->initialize($Controller);
$Controller->beforeFilter();
$Controller->Component->startup($Controller);
$this->assertTrue(is_a(
$Controller->SomethingWithEmail,
'SomethingWithEmailComponent'
@ -445,11 +487,14 @@ class ComponentTest extends CakeTestCase {
));
}
/**
* test that SessionComponent doesn't get added if its already in the components array.
* Test that SessionComponent doesn't get added if its already in the components array.
*
* @return void
**/
* @access public
*/
function testDoubleLoadingOfSessionComponent() {
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController');
$Controller =& new ComponentTestController();
$Controller->uses = array();
$Controller->components = array('Session');
@ -458,5 +503,4 @@ class ComponentTest extends CakeTestCase {
$this->assertEqual($Controller->components, array('Session' => '', 'Orange' => array('colour' => 'blood orange')));
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* AclComponentTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5435
* @version $Revision$
@ -27,8 +27,7 @@
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'));
App::import(array('controller' .DS . 'components' . DS . 'acl', 'model' . DS . 'db_acl'));
/**
* AclNodeTwoTestBase class
*
@ -179,13 +178,11 @@ class DbAclTwoTest extends DbAcl {
* @subpackage cake.tests.cases.libs.controller.components
*/
class IniAclTest extends IniAcl {
}
/**
* Short description for class.
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class AclComponentTest extends CakeTestCase {
@ -217,6 +214,15 @@ class AclComponentTest extends CakeTestCase {
Configure::write('Acl.database', 'test_suite');
parent::before($method);
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Acl);
}
/**
* testAclCreate method
*
@ -543,15 +549,6 @@ class AclComponentTest extends CakeTestCase {
$this->assertFalse($this->Acl->check('nobody', 'comments'));
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Acl);
}
/**
* debug function - to help editing/creating test cases for the ACL component
*

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* AutComponentTest file
*
* Long description for file
*
@ -25,14 +25,12 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import(array('controller' . DS . 'components' . DS .'auth', 'controller' . DS . 'components' . DS .'acl'));
App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'));
App::import(array('controller' . DS . 'components' . DS . 'acl', 'model' . DS . 'db_acl'));
App::import('Core', 'Xml');
Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
/**
* Short description for class.
* TestAuthComponent class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class TestAuthComponent extends AuthComponent {
@ -61,9 +59,9 @@ class TestAuthComponent extends AuthComponent {
}
}
/**
* Short description for class.
* AuthUser class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class AuthUser extends CakeTestModel {
@ -117,12 +115,12 @@ class AuthUser extends CakeTestModel {
}
}
/**
* Short description for class.
*
* @package cake.tests
* @subpackage cake.tests.cases.libs.controller.components
*/
class AuthUserCustomField extends AuthUser{
* AuthUserCustomField class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class AuthUserCustomField extends AuthUser {
/**
* name property
*
@ -132,9 +130,9 @@ class AuthUserCustomField extends AuthUser{
var $name = 'AuthUserCustomField';
}
/**
* Short description for class.
* UuidUser class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class UuidUser extends CakeTestModel {
@ -195,9 +193,9 @@ class UuidUser extends CakeTestModel {
}
}
/**
* Short description for class.
* AuthTestController class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class AuthTestController extends Controller {
@ -271,7 +269,7 @@ class AuthTestController extends Controller {
* @return void
*/
function logout() {
//$this->redirect($this->Auth->logout());
// $this->redirect($this->Auth->logout());
}
/**
* add method
@ -403,9 +401,9 @@ class AjaxAuthController extends Controller {
}
}
/**
* Short description for class.
* AuthTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class AuthTest extends CakeTestCase {
@ -437,6 +435,13 @@ class AuthTest extends CakeTestCase {
* @return void
*/
function startTest() {
$this->_server = $_SERVER;
$this->_env = $_ENV;
$this->_securitySalt = Configure::read('Security.salt');
Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
$this->_acl = Configure::read('Acl');
Configure::write('Acl.database', 'test_suite');
Configure::write('Acl.classname', 'DbAcl');
@ -444,10 +449,30 @@ class AuthTest extends CakeTestCase {
$this->Controller->Component->init($this->Controller);
ClassRegistry::addObject('view', new View($this->Controller));
$this->Controller->Session->del('Auth');
$this->Controller->Session->del('Message.auth');
Router::reload();
$this->initialized = true;
}
/**
* endTest method
*
* @access public
* @return void
*/
function endTest() {
$_SERVER = $this->_server;
$_ENV = $this->_env;
Configure::write('Acl', $this->_acl);
Configure::write('Security.salt', $this->_securitySalt);
$this->Controller->Session->del('Auth');
$this->Controller->Session->del('Message.auth');
ClassRegistry::flush();
unset($this->Controller, $this->AuthUser);
}
/**
* testNoAuth method
*
@ -569,7 +594,6 @@ class AuthTest extends CakeTestCase {
$this->assertFalse($result);
$this->assertTrue($this->Controller->Session->check('Message.auth'));
$this->Controller->params = Router::parse('auth_test/camelCase');
$result = $this->Controller->Auth->startup($this->Controller);
$this->assertFalse($result);
@ -622,7 +646,6 @@ class AuthTest extends CakeTestCase {
$result = $this->Controller->Auth->isAuthorized();
$this->assertFalse($result);
}
/**
* testAuthorizeCrud method
*
@ -815,6 +838,24 @@ class AuthTest extends CakeTestCase {
$expected = Router::normalize('posts/view/1');
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
// QueryString parameters
$_back = $_GET;
$_GET = array(
'url' => '/posts/index/29',
'print' => 'true',
'refer' => 'menu'
);
$this->Controller->Session->del('Auth');
$url = '/posts/index/29?print=true&refer=menu';
$this->Controller->params = Dispatcher::parseParams($url);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->startup($this->Controller);
$expected = Router::normalize('posts/index/29?print=true&refer=menu');
$this->assertEqual($expected, $this->Controller->Session->read('Auth.redirect'));
$_GET = $_back;
//external authed action
$_SERVER['HTTP_REFERER'] = 'http://webmail.example.com/view/message';
$this->Controller->Session->del('Auth');
@ -1035,7 +1076,6 @@ class AuthTest extends CakeTestCase {
$user = $this->Controller->Auth->user();
$this->assertTrue(!!$user);
}
/**
* testCustomField method
*
@ -1070,7 +1110,6 @@ class AuthTest extends CakeTestCase {
$user = $this->Controller->Auth->user();
$this->assertTrue(!!$user);
}
/**
* testAdminRoute method
*
@ -1177,14 +1216,5 @@ class AuthTest extends CakeTestCase {
$this->Controller->Auth->shutdown($this->Controller);
$this->assertFalse($this->Controller->Session->read('Auth.redirect'));
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Controller, $this->AuthUser);
}
}
?>
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* CookieComponentTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5435
* @version $Revision$
@ -25,9 +25,26 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Core', array('Component', 'Controller', 'Cookie'));
/**
* CookieComponentTestController class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class CookieComponentTestController extends Controller {
/**
* components property
*
* @var array
* @access public
*/
var $components = array('Cookie');
/**
* beforeFilter method
*
* @access public
* @return void
*/
function beforeFilter() {
$this->Cookie->name = 'CakeTestCookie';
$this->Cookie->time = 10;
@ -38,29 +55,19 @@ class CookieComponentTestController extends Controller {
}
}
/**
* Short description for class.
* CookieComponentTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class CookieComponentTest extends CakeTestCase {
/**
* Controller property
*
* @var CookieComponentTestController
* @access public
*/
var $Controller;
function __encrypt($value) {
if (is_array($value)) {
$value = $this->__implode($value);
}
return "Q2FrZQ==." .base64_encode(Security::cipher($value, $this->Controller->Cookie->key));
}
function __implode($array) {
$string = '';
foreach ($array as $key => $value) {
$string .= ',' . $key . '|' . $value;
}
return substr($string, 1);
}
/**
* start
*
@ -75,6 +82,15 @@ class CookieComponentTest extends CakeTestCase {
$this->Controller->Component->startup($this->Controller);
$this->Controller->Cookie->destroy();
}
/**
* end
*
* @access public
* @return void
*/
function end() {
$this->Controller->Cookie->destroy();
}
/**
* testCookieName
*
@ -393,13 +409,31 @@ class CookieComponentTest extends CakeTestCase {
unset($_COOKIE['CakeTestCookie']);
}
/**
* end
* encrypt method
*
* @access public
* @return void
* @param mixed $value
* @return string
* @access private
*/
function end() {
$this->Controller->Cookie->destroy();
function __encrypt($value) {
if (is_array($value)) {
$value = $this->__implode($value);
}
return "Q2FrZQ==." . base64_encode(Security::cipher($value, $this->Controller->Cookie->key));
}
/**
* implode method
*
* @param array $value
* @return string
* @access private
*/
function __implode($array) {
$string = '';
foreach ($array as $key => $value) {
$string .= ',' . $key . '|' . $value;
}
return substr($string, 1);
}
}
?>

View file

@ -1,9 +1,9 @@
<?php
/* SVN FILE: $Id$ */
/**
* Series of tests for email component.
* EmailComponentTest file
*
* Long description for file
* Series of tests for email component.
*
* PHP versions 4 and 5
*
@ -24,8 +24,87 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
Configure::write('App.encoding', 'UTF-8');
App::import('Component', 'Email');
/**
* EmailTestComponent class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class EmailTestComponent extends EmailComponent {
/**
* smtpSend method override for testing
*
* @access public
* @return mixed
*/
function smtpSend($data, $code = '250') {
return parent::__smtpSend($data, $code);
}
/**
* Convenience setter method for testing.
*
* @access public
* @return void
*/
function setConnectionSocket(&$socket) {
$this->__smtpConnection = $socket;
}
/**
* Convenience getter method for testing.
*
* @access public
* @return mixed
*/
function getConnectionSocket() {
return $this->__smtpConnection;
}
/**
* Convenience setter for testing.
*
* @access public
* @return void
*/
function setHeaders($headers) {
$this->__header += $headers;
}
/**
* Convenience getter for testing.
*
* @access public
* @return array
*/
function getHeaders() {
return $this->__header;
}
/**
* Convenience setter for testing.
*
* @access public
* @return void
*/
function setBoundary() {
$this->__createBoundary();
}
/**
* Convenience getter for testing.
*
* @access public
* @return string
*/
function getBoundary() {
return $this->__boundary;
}
/**
* Convenience getter for testing.
*
* @access public
* @return string
*/
function getMessage() {
return $this->__message;
}
}
/**
* EmailTestController class
*
@ -53,8 +132,13 @@ class EmailTestController extends Controller {
* @var array
* @access public
*/
var $components = array('Email');
var $components = array('EmailTest');
/**
* pageTitle property
*
* @var string
* @access public
*/
var $pageTitle = 'EmailTest';
}
/**
@ -63,7 +147,14 @@ class EmailTestController extends Controller {
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class EmailTest extends CakeTestCase {
class EmailComponentTest extends CakeTestCase {
/**
* Controller property
*
* @var EmailTestController
* @access public
*/
var $Controller;
/**
* name property
*
@ -78,17 +169,35 @@ class EmailTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->_appEncoding = Configure::read('App.encoding');
Configure::write('App.encoding', 'UTF-8');
$this->Controller =& new EmailTestController();
restore_error_handler();
@$this->Controller->Component->init($this->Controller);
set_error_handler('simpleTestErrorHandler');
$this->Controller->Email->initialize($this->Controller, array());
$this->Controller->EmailTest->initialize($this->Controller, array());
ClassRegistry::addObject('view', new View($this->Controller));
$this->_viewPaths = Configure::read('viewPaths');
Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('App.encoding', $this->_appEncoding);
Configure::write('viewPaths', $this->_viewPaths);
$this->Controller->Session->del('Message');
restore_error_handler();
ClassRegistry::flush();
}
/**
* testBadSmtpSend method
*
@ -96,9 +205,9 @@ class EmailTest extends CakeTestCase {
* @return void
*/
function testBadSmtpSend() {
$this->Controller->Email->smtpOptions['host'] = 'blah';
$this->Controller->Email->delivery = 'smtp';
$this->assertFalse($this->Controller->Email->send('Should not work'));
$this->Controller->EmailTest->smtpOptions['host'] = 'blah';
$this->Controller->EmailTest->delivery = 'smtp';
$this->assertFalse($this->Controller->EmailTest->send('Should not work'));
}
/**
* testSmtpSend method
@ -107,21 +216,21 @@ class EmailTest extends CakeTestCase {
* @return void
*/
function testSmtpSend() {
if (!$this->skipIf(!@fsockopen('localhost', 25), 'No SMTP server running on localhost')) {
if (!$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
return;
}
$this->Controller->Email->reset();
$this->Controller->Email->to = 'postmaster@localhost';
$this->Controller->Email->from = 'noreply@example.com';
$this->Controller->Email->subject = 'Cake SMTP test';
$this->Controller->Email->replyTo = 'noreply@example.com';
$this->Controller->Email->template = null;
$this->Controller->EmailTest->reset();
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'Cake SMTP test';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$this->Controller->EmailTest->template = null;
$this->Controller->Email->delivery = 'smtp';
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->Controller->EmailTest->delivery = 'smtp';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->Controller->Email->_debug = true;
$this->Controller->Email->sendAs = 'text';
$this->Controller->EmailTest->_debug = true;
$this->Controller->EmailTest->sendAs = 'text';
$expect = <<<TEMPDOC
<pre>Host: localhost
Port: 25
@ -145,7 +254,7 @@ This is the body of the message
</pre>
TEMPDOC;
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
}
/**
@ -155,22 +264,24 @@ TEMPDOC;
* @return void
*/
function testAuthenticatedSmtpSend() {
$this->skipIf(!@fsockopen('localhost', 25), 'No SMTP server running on localhost');
$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost');
$this->Controller->Email->reset();
$this->Controller->Email->to = 'postmaster@localhost';
$this->Controller->Email->from = 'noreply@example.com';
$this->Controller->Email->subject = 'Cake SMTP test';
$this->Controller->Email->replyTo = 'noreply@example.com';
$this->Controller->Email->template = null;
$this->Controller->Email->smtpOptions['username'] = 'test';
$this->Controller->Email->smtpOptions['password'] = 'testing';
$this->Controller->EmailTest->reset();
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'Cake SMTP test';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$this->Controller->EmailTest->template = null;
$this->Controller->EmailTest->smtpOptions['username'] = 'test';
$this->Controller->EmailTest->smtpOptions['password'] = 'testing';
$this->Controller->Email->delivery = 'smtp';
$result = $this->Controller->Email->send('This is the body of the message');
$code = substr($this->Controller->Email->smtpError, 0, 3);
$this->skipIf(!$code, 'Authentication not enabled on server');
$this->assertTrue(!$result && $code == '535');
$this->Controller->EmailTest->delivery = 'smtp';
$result = $this->Controller->EmailTest->send('This is the body of the message');
$code = substr($this->Controller->EmailTest->smtpError, 0, 3);
$this->skipIf(!$code, '%s Authentication not enabled on server');
$this->assertFalse($result);
$this->assertEqual($code, '535');
}
/**
* testSendFormats method
@ -179,13 +290,13 @@ TEMPDOC;
* @return void
*/
function testSendFormats() {
$this->Controller->Email->reset();
$this->Controller->Email->to = 'postmaster@localhost';
$this->Controller->Email->from = 'noreply@example.com';
$this->Controller->Email->subject = 'Cake SMTP test';
$this->Controller->Email->replyTo = 'noreply@example.com';
$this->Controller->Email->template = null;
$this->Controller->Email->delivery = 'debug';
$this->Controller->EmailTest->reset();
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'Cake SMTP test';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$this->Controller->EmailTest->template = null;
$this->Controller->EmailTest->delivery = 'debug';
$message = <<<MSGBLOC
<pre>To: postmaster@localhost
@ -205,20 +316,20 @@ This is the body of the message
</pre>
MSGBLOC;
$this->Controller->Email->sendAs = 'text';
$this->Controller->EmailTest->sendAs = 'text';
$expect = str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $message);
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
$this->Controller->Email->sendAs = 'html';
$this->Controller->EmailTest->sendAs = 'html';
$expect = str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $message);
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
// TODO: better test for format of message sent?
$this->Controller->Email->sendAs = 'both';
$this->Controller->EmailTest->sendAs = 'both';
$expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-"' . "\n", $message);
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
}
/**
@ -228,13 +339,13 @@ MSGBLOC;
* @return void
*/
function testTemplates() {
$this->Controller->Email->reset();
$this->Controller->Email->to = 'postmaster@localhost';
$this->Controller->Email->from = 'noreply@example.com';
$this->Controller->Email->subject = 'Cake SMTP test';
$this->Controller->Email->replyTo = 'noreply@example.com';
$this->Controller->EmailTest->reset();
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'Cake SMTP test';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$this->Controller->Email->delivery = 'debug';
$this->Controller->EmailTest->delivery = 'debug';
$header = <<<HEADBLOC
To: postmaster@localhost
@ -253,8 +364,8 @@ Message:
HEADBLOC;
$this->Controller->Email->layout = 'default';
$this->Controller->Email->template = 'default';
$this->Controller->EmailTest->layout = 'default';
$this->Controller->EmailTest->template = 'default';
$text = <<<TEXTBLOC
@ -281,22 +392,22 @@ TEXTBLOC;
HTMLBLOC;
$this->Controller->Email->sendAs = 'text';
$this->Controller->EmailTest->sendAs = 'text';
$expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $header) . $text . "\n" . '</pre>';
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
$this->Controller->Email->sendAs = 'html';
$this->Controller->EmailTest->sendAs = 'html';
$expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . "\n" . '</pre>';
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
$this->Controller->Email->sendAs = 'both';
$this->Controller->EmailTest->sendAs = 'both';
$expect = str_replace('{CONTENTTYPE}', 'multipart/alternative; boundary="alt-"' . "\n", $header);
$expect .= '--alt-' . "\n" . 'Content-Type: text/plain; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $text . "\n\n";
$expect .= '--alt-' . "\n" . 'Content-Type: text/html; charset=UTF-8' . "\n" . 'Content-Transfer-Encoding: 7bit' . "\n\n" . $html . "\n\n";
$expect = '<pre>' . $expect . '--alt---' . "\n\n" . '</pre>';
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
$html = <<<HTMLBLOC
@ -315,9 +426,9 @@ HTMLBLOC;
HTMLBLOC;
$this->Controller->Email->sendAs = 'html';
$this->Controller->EmailTest->sendAs = 'html';
$expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/html; charset=UTF-8', $header) . $html . "\n" . '</pre>';
$this->assertTrue($this->Controller->Email->send('This is the body of the message', 'default', 'thin'));
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'default', 'thin'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
return;
@ -333,11 +444,34 @@ This email was sent using the CakePHP Framework, http://cakephp.org.
TEXTBLOC;
$this->Controller->Email->sendAs = 'text';
$this->Controller->EmailTest->sendAs = 'text';
$expect = '<pre>' . str_replace('{CONTENTTYPE}', 'text/plain; charset=UTF-8', $header) . $text . "\n" . '</pre>';
$this->assertTrue($this->Controller->Email->send('This is the body of the message', 'wide', 'default'));
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message', 'wide', 'default'));
$this->assertEqual($this->Controller->Session->read('Message.email.message'), $this->__osFix($expect));
}
/**
* testSmtpSendSocket method
*
* @access public
* @return void
*/
function testSmtpSendSocket() {
$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost');
$this->Controller->EmailTest->reset();
$socket =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->Controller->EmailTest->smtpOptions));
$this->Controller->EmailTest->setConnectionSocket($socket);
$this->assertTrue($this->Controller->EmailTest->getConnectionSocket());
$response = $this->Controller->EmailTest->smtpSend('HELO', '250');
$this->assertPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError);
$this->Controller->EmailTest->smtpError = null;
$response = $this->Controller->EmailTest->smtpSend('HELO somehostname', '250');
$this->assertNoPattern('/501 Syntax: HELO hostname/', $this->Controller->EmailTest->smtpError);
}
/**
* testSendDebug method
*
@ -345,15 +479,15 @@ TEXTBLOC;
* @return void
*/
function testSendDebug() {
$this->Controller->Email->reset();
$this->Controller->Email->to = 'postmaster@localhost';
$this->Controller->Email->from = 'noreply@example.com';
$this->Controller->Email->subject = 'Cake SMTP test';
$this->Controller->Email->replyTo = 'noreply@example.com';
$this->Controller->Email->template = null;
$this->Controller->EmailTest->reset();
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'Cake SMTP test';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$this->Controller->EmailTest->template = null;
$this->Controller->Email->delivery = 'debug';
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->Controller->EmailTest->delivery = 'debug';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
}
/**
* testContentStripping method
@ -365,41 +499,88 @@ TEXTBLOC;
$content = "Previous content\n--alt-\nContent-TypeContent-Type:: text/html; charsetcharset==utf-8\nContent-Transfer-Encoding: 7bit";
$content .= "\n\n<p>My own html content</p>";
$result = $this->Controller->Email->__strip($content, true);
$result = $this->Controller->EmailTest->__strip($content, true);
$expected = "Previous content\n--alt-\n text/html; utf-8\n 7bit\n\n<p>My own html content</p>";
$this->assertEqual($result, $expected);
}
/**
* testMultibyte method
*
* @access public
* @return void
*/
function testMultibyte() {
$this->Controller->Email->reset();
$this->Controller->Email->to = 'postmaster@localhost';
$this->Controller->Email->from = 'noreply@example.com';
$this->Controller->Email->subject = 'هذه رسالة بعنوان طويل مرسل للمستلم';
$this->Controller->Email->replyTo = 'noreply@example.com';
$this->Controller->Email->template = null;
$this->Controller->Email->delivery = 'debug';
$this->Controller->EmailTest->reset();
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
$this->Controller->EmailTest->subject = 'هذه رسالة بعنوان طويل مرسل للمستلم';
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
$this->Controller->EmailTest->template = null;
$this->Controller->EmailTest->delivery = 'debug';
$subject = '=?UTF-8?B?2YfYsNmHINix2LPYp9mE2Kkg2KjYudmG2YjYp9mGINi32YjZitmEINmF2LE=?=' . "\r\n" . ' =?UTF-8?B?2LPZhCDZhNmE2YXYs9iq2YTZhQ==?=';
$this->Controller->Email->sendAs = 'text';
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->Controller->EmailTest->sendAs = 'text';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
preg_match('/Subject: (.*)Header:/s', $this->Controller->Session->read('Message.email.message'), $matches);
$this->assertEqual(trim($matches[1]), $subject);
$this->Controller->Email->sendAs = 'html';
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->Controller->EmailTest->sendAs = 'html';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
preg_match('/Subject: (.*)Header:/s', $this->Controller->Session->read('Message.email.message'), $matches);
$this->assertEqual(trim($matches[1]), $subject);
$this->Controller->Email->sendAs = 'both';
$this->assertTrue($this->Controller->Email->send('This is the body of the message'));
$this->Controller->EmailTest->sendAs = 'both';
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
preg_match('/Subject: (.*)Header:/s', $this->Controller->Session->read('Message.email.message'), $matches);
$this->assertEqual(trim($matches[1]), $subject);
}
/**
* testReset method
*
* @access public
* @return void
*/
function testReset() {
$this->Controller->EmailTest->template = 'test_template';
$this->Controller->EmailTest->to = 'test.recipient@example.com';
$this->Controller->EmailTest->from = 'test.sender@example.com';
$this->Controller->EmailTest->replyTo = 'test.replyto@example.com';
$this->Controller->EmailTest->return = 'test.return@example.com';
$this->Controller->EmailTest->cc = array('cc1@example.com', 'cc2@example.com');
$this->Controller->EmailTest->bcc = array('bcc1@example.com', 'bcc2@example.com');
$this->Controller->EmailTest->subject = 'Test subject';
$this->Controller->EmailTest->additionalParams = 'X-additional-header';
$this->Controller->EmailTest->delivery = 'smtp';
$this->Controller->EmailTest->smtpOptions['host'] = 'blah';
$this->assertFalse($this->Controller->EmailTest->send('Should not work'));
$this->Controller->EmailTest->reset();
$this->assertNull($this->Controller->EmailTest->template);
$this->assertNull($this->Controller->EmailTest->to);
$this->assertNull($this->Controller->EmailTest->from);
$this->assertNull($this->Controller->EmailTest->replyTo);
$this->assertNull($this->Controller->EmailTest->return);
$this->assertIdentical($this->Controller->EmailTest->cc, array());
$this->assertIdentical($this->Controller->EmailTest->bcc, array());
$this->assertNull($this->Controller->EmailTest->subject);
$this->assertNull($this->Controller->EmailTest->additionalParams);
$this->assertIdentical($this->Controller->EmailTest->getHeaders(), array());
$this->assertNull($this->Controller->EmailTest->getBoundary());
$this->assertIdentical($this->Controller->EmailTest->getMessage(), array());
$this->assertNull($this->Controller->EmailTest->smtpError);
}
/**
* osFix method
*
* @param string $string
* @access private
* @return string
*/
function __osFix($string) {
return str_replace(array("\r\n", "\r"), "\n", $string);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* RequestHandlerComponentTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5435
* @version $Revision$
@ -92,18 +92,37 @@ class RequestHandlerTestDisabledController extends Controller {
}
parent::__construct();
}
/**
* beforeFilter method
*
* @return void
* @access public
*/
function beforeFilter() {
$this->RequestHandler->enabled = false;
}
}
/**
* Short description for class.
* RequestHandlerComponentTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class RequestHandlerComponentTest extends CakeTestCase {
/**
* Controller property
*
* @var RequestHandlerTestController
* @access public
*/
var $Controller;
/**
* RequestHandler property
*
* @var RequestHandlerComponent
* @access public
*/
var $RequestHandler;
/**
* setUp method
*
@ -114,15 +133,17 @@ class RequestHandlerComponentTest extends CakeTestCase {
$this->_init();
}
/**
* init method
* tearDown method
*
* @access protected
* @access public
* @return void
*/
function _init() {
$this->Controller = new RequestHandlerTestController(array('components' => array('RequestHandler')));
$this->Controller->constructClasses();
$this->RequestHandler =& $this->Controller->RequestHandler;
function tearDown() {
unset($this->RequestHandler);
unset($this->Controller);
if (!headers_sent()) {
header('Content-type: text/html'); //reset content type.
}
}
/**
* testInitializeCallback method
@ -196,7 +217,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
$_SERVER['CONTENT_TYPE'] = 'application/xml; charset=UTF-8';
$this->RequestHandler->startup($this->Controller);
$this->assertTrue(is_object($this->Controller->data));
$this->assertEqual(strtolower(get_class($this->Controller->data)), 'xml');
$this->assertEqual(strtolower(get_class($this->Controller->data)), 'xml');
}
/**
* testNonAjaxRedirect method
@ -395,6 +416,7 @@ class RequestHandlerComponentTest extends CakeTestCase {
$this->RequestHandler->ext = 'rss';
$this->assertEqual($this->RequestHandler->prefers(), 'rss');
$this->assertFalse($this->RequestHandler->prefers('xml'));
$this->assertEqual($this->RequestHandler->prefers(array('js', 'xml', 'xhtml')), 'xml');
$this->assertTrue($this->RequestHandler->accepts('xml'));
$_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5';
@ -481,17 +503,15 @@ class RequestHandlerComponentTest extends CakeTestCase {
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
}
/**
* tearDown method
* init method
*
* @access public
* @access protected
* @return void
*/
function tearDown() {
unset($this->RequestHandler);
unset($this->Controller);
if (!headers_sent()) {
header('Content-type: text/html'); //reset content type.
}
function _init() {
$this->Controller = new RequestHandlerTestController(array('components' => array('RequestHandler')));
$this->Controller->constructClasses();
$this->RequestHandler =& $this->Controller->RequestHandler;
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* SecurityComponentTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5435
* @version $Revision$
@ -25,22 +25,27 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Component', 'Security');
/**
* Short description for class.
* TestSecurityComponent
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class TestSecurityComponent extends SecurityComponent {
/**
* validatePost method
*
* @param Controller $controller
* @return unknown
*/
function validatePost(&$controller) {
return $this->_validatePost($controller);
}
}
/**
* Short description for class.
* SecurityTestController
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class SecurityTestController extends Controller {
@ -104,14 +109,27 @@ class SecurityTestController extends Controller {
$this->testHeaders[] = $status;
}
}
/**
* Short description for class.
* SecurityComponentTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class SecurityComponentTest extends CakeTestCase {
/**
* Controller property
*
* @var SecurityTestController
* @access public
*/
var $Controller;
/**
* oldSalt property
*
* @var string
* @access public
*/
var $oldSalt;
/**
* setUp method
*
@ -123,23 +141,22 @@ class SecurityComponentTest extends CakeTestCase {
$this->Controller->Component->init($this->Controller);
$this->Controller->Security =& $this->Controller->TestSecurity;
$this->Controller->Security->blackHoleCallback = 'fail';
$this->oldSalt = Configure::read('Security.salt');
Configure::write('Security.salt', 'foo!');
}
/**
* Tear-down method. Resets environment state.
* Tear-down method. Resets environment state.
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('Security.salt', $this->oldSalt);
$this->Controller->Session->del('_Token');
unset($this->Controller->Security);
unset($this->Controller->Component);
unset($this->Controller);
Configure::write('Security.salt', $this->oldSalt);
}
/**
* testStartup method
*
@ -584,7 +601,6 @@ DIGEST;
$result = $this->Controller->Security->validatePost($this->Controller);
$this->assertTrue($result);
}
/**
* test ValidatePost with multiple select elements.
*
@ -776,7 +792,6 @@ DIGEST;
$result = $this->Controller->Security->validatePost($this->Controller);
$this->assertTrue($result);
}
/**
* testValidateHasManyRecordsPass method
*
@ -1079,5 +1094,4 @@ DIGEST;
$this->assertEqual(current($this->Controller->testHeaders), $expected);
}
}
?>
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* SessionComponentTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
* @since CakePHP(tm) v 1.2.0.5436
* @version $Revision$
@ -29,12 +29,23 @@ App::import('Component', 'Session');
/**
* SessionTestController class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class SessionTestController extends Controller {
/**
* uses property
*
* @var array
* @access public
*/
var $uses = array();
/**
* session_id method
*
* @return string
* @access public
*/
function session_id() {
return $this->Session->id();
}
@ -42,23 +53,52 @@ class SessionTestController extends Controller {
/**
* OrangeSessionTestController class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class OrangeSessionTestController extends Controller {
/**
* uses property
*
* @var array
* @access public
*/
var $uses = array();
/**
* session_id method
*
* @return string
* @access public
*/
function session_id() {
return $this->Session->id();
}
}
/**
* Short description for class.
* SessionComponentTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class SessionComponentTest extends CakeTestCase {
/**
* setUp method
*
* @access public
* @return void
*/
function setUp() {
$this->_session = Configure::read('Session');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('Session', $this->_session);
}
/**
* testSessionAutoStart method
*
@ -300,6 +340,8 @@ class SessionComponentTest extends CakeTestCase {
$Session->setFlash('This is a test message', 'non_existing_layout');
$this->assertEqual($Session->read('Message.myFlash'), array('message' => 'This is a test message', 'layout' => 'default', 'params' => array()));
$Session->del('Message');
}
/**
* testSessionId method

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ControllerTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
* @since CakePHP(tm) v 1.2.0.5436
* @version $Revision$
@ -63,13 +63,13 @@ if (!class_exists('AppController')) {
*/
var $components = array('Cookie');
}
} else if (!defined('APP_CONTROLLER_EXISTS')) {
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
define('APP_CONTROLLER_EXISTS', true);
}
/**
* ControllerPost class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class ControllerPost extends CakeTestModel {
@ -146,7 +146,7 @@ class ControllerCommentsController extends AppController {
/**
* ControllerComment class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class ControllerComment extends CakeTestModel {
@ -182,7 +182,7 @@ class ControllerComment extends CakeTestModel {
/**
* ControllerAlias class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class ControllerAlias extends CakeTestModel {
@ -211,7 +211,7 @@ class ControllerAlias extends CakeTestModel {
/**
* ControllerPaginateModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class ControllerPaginateModel extends CakeTestModel {
@ -336,7 +336,6 @@ class TestComponent extends Object {
* @return void
*/
function beforeRedirect() {
return true;
}
}
/**
@ -352,7 +351,6 @@ class AnotherTestController extends AppController {
* @access public
*/
var $name = 'AnotherTest';
/**
* uses property
*
@ -362,9 +360,9 @@ class AnotherTestController extends AppController {
var $uses = null;
}
/**
* Short description for class.
* ControllerTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class ControllerTest extends CakeTestCase {
@ -417,7 +415,12 @@ class ControllerTest extends CakeTestCase {
Configure::write('pluginPaths', $_back['pluginPaths']);
unset($Controller);
}
/**
* testAliasName method
*
* @access public
* @return void
*/
function testAliasName() {
$Controller =& new Controller();
$Controller->uses = array('NameTest');
@ -428,7 +431,6 @@ class ControllerTest extends CakeTestCase {
unset($Controller);
}
/**
* testPersistent method
*
@ -602,6 +604,26 @@ class ControllerTest extends CakeTestCase {
);
$this->assertEqual($Controller->params['paging']['ControllerPost']['options'],$expected);
}
/**
* Test that special paginate types are called and that the type param doesn't leak out into defaults or options.
*
* @return void
**/
function testPaginateSpecialType() {
$Controller =& new Controller();
$Controller->uses = array('ControllerPost', 'ControllerComment');
$Controller->passedArgs[] = '1';
$Controller->params['url'] = array();
$Controller->constructClasses();
$Controller->paginate = array('ControllerPost' => array('popular', 'fields' => array('id', 'title')));
$result = $Controller->paginate('ControllerPost');
$this->assertEqual(Set::extract($result, '{n}.ControllerPost.id'), array(2, 3));
$this->assertEqual($Controller->ControllerPost->lastQuery['conditions'], array('ControllerPost.id > ' => '1'));
$this->assertFalse(isset($Controller->params['paging']['ControllerPost']['defaults'][0]));
$this->assertFalse(isset($Controller->params['paging']['ControllerPost']['options'][0]));
}
/**
* testDefaultPaginateParams method
*
@ -735,7 +757,6 @@ class ControllerTest extends CakeTestCase {
* @return void
*/
function testRedirect() {
$url = 'cakephp.org';
$codes = array(
100 => "Continue",
101 => "Switching Protocols",
@ -779,26 +800,85 @@ class ControllerTest extends CakeTestCase {
);
Mock::generatePartial('Controller', 'MockController', array('header'));
Mock::generate('TestComponent', 'MockTestComponent');
Mock::generate('TestComponent', 'MockTestBComponent');
App::import('Helper', 'Cache');
// $codes = array_merge($codes, array_flip($codes));
foreach ($codes as $code => $msg) {
$MockController =& new MockController();
$MockController->components = array('Test');
$MockController->Component =& new Component();
$MockController->Component->init($MockController);
$MockController->expectAt(0, 'header', array("HTTP/1.1 {$code} {$msg}"));
$MockController->expectAt(1, 'header', array('Location: http://cakephp.org'));
$MockController->expectCallCount('header', 2);
$MockController->redirect($url, (int) $code, false);
$MockController->redirect('http://cakephp.org', (int)$code, false);
$this->assertFalse($MockController->autoRender);
}
$codes = array_flip($codes);
foreach ($codes as $code => $msg) {
$MockController =& new MockController();
$MockController->components = array('Test');
$MockController->Component =& new Component();
$MockController->Component->init($MockController);
$MockController->expectAt(0, 'header', array("HTTP/1.1 {$code} {$msg}"));
$MockController->expectAt(1, 'header', array('Location: http://cakephp.org'));
$MockController->expectCallCount('header', 2);
$MockController->redirect($url, $code, false);
$MockController->redirect('http://cakephp.org', $msg, false);
$this->assertFalse($MockController->autoRender);
}
$MockController =& new MockController();
$MockController->Component =& new Component();
$MockController->Component->init($MockController);
$MockController->expectAt(0, 'header', array('Location: http://www.example.org/users/login'));
$MockController->expectCallCount('header', 1);
$MockController->redirect('http://www.example.org/users/login', null, false);
$MockController =& new MockController();
$MockController->Component =& new Component();
$MockController->Component->init($MockController);
$MockController->expectAt(0, 'header', array('HTTP/1.1 301 Moved Permanently'));
$MockController->expectAt(1, 'header', array('Location: http://www.example.org/users/login'));
$MockController->expectCallCount('header', 2);
$MockController->redirect('http://www.example.org/users/login', 301, false);
$MockController =& new MockController();
$MockController->components = array('MockTest');
$MockController->Component =& new Component();
$MockController->Component->init($MockController);
$MockController->MockTest->setReturnValue('beforeRedirect', null);
$MockController->expectAt(0, 'header', array('HTTP/1.1 301 Moved Permanently'));
$MockController->expectAt(1, 'header', array('Location: http://cakephp.org'));
$MockController->expectCallCount('header', 2);
$MockController->redirect('http://cakephp.org', 301, false);
$MockController =& new MockController();
$MockController->components = array('MockTest');
$MockController->Component =& new Component();
$MockController->Component->init($MockController);
$MockController->MockTest->setReturnValue('beforeRedirect', 'http://book.cakephp.org');
$MockController->expectAt(0, 'header', array('HTTP/1.1 301 Moved Permanently'));
$MockController->expectAt(1, 'header', array('Location: http://book.cakephp.org'));
$MockController->expectCallCount('header', 2);
$MockController->redirect('http://cakephp.org', 301, false);
$MockController =& new MockController();
$MockController->components = array('MockTest');
$MockController->Component =& new Component();
$MockController->Component->init($MockController);
$MockController->MockTest->setReturnValue('beforeRedirect', false);
$MockController->expectNever('header');
$MockController->redirect('http://cakephp.org', 301, false);
$MockController =& new MockController();
$MockController->components = array('MockTest', 'MockTestB');
$MockController->Component =& new Component();
$MockController->Component->init($MockController);
$MockController->MockTest->setReturnValue('beforeRedirect', 'http://book.cakephp.org');
$MockController->MockTestB->setReturnValue('beforeRedirect', 'http://bakery.cakephp.org');
$MockController->expectAt(0, 'header', array('HTTP/1.1 301 Moved Permanently'));
$MockController->expectAt(1, 'header', array('Location: http://bakery.cakephp.org'));
$MockController->expectCallCount('header', 2);
$MockController->redirect('http://cakephp.org', 301, false);
}
/**
* testMergeVars method
@ -807,7 +887,9 @@ class ControllerTest extends CakeTestCase {
* @return void
*/
function testMergeVars() {
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), 'MergeVars will be skipped as it needs a non-existent AppController. As the an AppController class exists, this cannot be run.');
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
return;
}
$TestController =& new TestController();
$TestController->constructClasses();
@ -859,7 +941,23 @@ class ControllerTest extends CakeTestCase {
$this->assertTrue(isset($TestController->ControllerComment));
}
/**
* Ensure that __mergeVars is not being greedy and merging with
* test that options from child classes replace those in the parent classes.
*
* @access public
* @return void
**/
function testChildComponentOptionsSupercedeParents() {
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
return;
}
$TestController =& new TestController();
$expected = array('foo');
$TestController->components = array('Cookie' => $expected);
$TestController->constructClasses();
$this->assertEqual($TestController->components['Cookie'], $expected);
}
/**
* Ensure that __mergeVars is not being greedy and merging with
* AppController when you make an instance of Controller
*
* @return void

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* PagesControllerTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
* @since CakePHP(tm) v 1.2.0.5436
* @version $Revision$
@ -24,14 +24,37 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Core', array('Controller', 'AppController', 'PagesController'));
if (!class_exists('AppController')) {
require_once LIBS . 'controller' . DS . 'app_controller.php';
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
define('APP_CONTROLLER_EXISTS', true);
}
App::import('Core', array('Controller', 'PagesController'));
/**
* Short description for class.
* PagesControllerTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class PagesControllerTest extends CakeTestCase {
/**
* setUp method
*
* @access public
* @return void
*/
function setUp() {
$this->_viewPaths = Configure::read('viewPaths');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('viewPaths', $this->_viewPaths);
}
/**
* testDisplay method
*
@ -39,6 +62,10 @@ class PagesControllerTest extends CakeTestCase {
* @return void
*/
function testDisplay() {
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
return;
}
Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS));
$Pages =& new PagesController();

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ScaffoldTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
* @since CakePHP(tm) v 1.2.0.5436
* @version $Revision$
@ -47,9 +47,8 @@ class ScaffoldMockController extends Controller {
*/
var $scaffold;
}
/**
* TestScaffoldMock
* TestScaffoldMock class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller
@ -72,7 +71,6 @@ class TestScaffoldMock extends Scaffold {
return $this->_params;
}
}
/**
* ScaffoldMock class
*
@ -112,9 +110,8 @@ class ScaffoldMock extends CakeTestModel {
)
);
}
/**
* ScaffoldAuthor class
* ScaffoldUser class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller
@ -140,7 +137,6 @@ class ScaffoldUser extends CakeTestModel {
)
);
}
/**
* ScaffoldComment class
*
@ -168,7 +164,6 @@ class ScaffoldComment extends CakeTestModel {
)
);
}
/**
* TestScaffoldView class
*
@ -188,9 +183,9 @@ class TestScaffoldView extends ScaffoldView {
}
}
/**
* ScaffoldViewTest Case.
* ScaffoldViewTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class ScaffoldViewTest extends CakeTestCase {
@ -210,6 +205,15 @@ class ScaffoldViewTest extends CakeTestCase {
function setUp() {
$this->Controller =& new ScaffoldMockController();
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Controller);
}
/**
* testGetViewFilename method
*
@ -298,7 +302,6 @@ class ScaffoldViewTest extends CakeTestCase {
Configure::write('pluginPaths', $_back['pluginPaths']);
Configure::write('Routing.admin', $_admin);
}
/**
* test default index scaffold generation
*
@ -505,26 +508,21 @@ class ScaffoldViewTest extends CakeTestCase {
Configure::write('Routing.admin', $_backAdmin);
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Controller);
}
}
/**
* Scaffold Test Case
* Scaffold Test class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class ScaffoldTestCase extends CakeTestCase {
class ScaffoldTest extends CakeTestCase {
/**
* Controller property
*
* @var SecurityTestController
* @access public
*/
var $Controller;
/**
* fixtures property
*
@ -541,6 +539,15 @@ class ScaffoldTestCase extends CakeTestCase {
function setUp() {
$this->Controller =& new ScaffoldMockController();
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Controller);
}
/**
* Test the correct Generation of Scaffold Params.
* This ensures that the correct action and view will be generated
@ -573,15 +580,5 @@ class ScaffoldTestCase extends CakeTestCase {
$result = $Scaffold->getParams();
$this->assertEqual($result['action'], 'admin_edit');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Controller);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* DebuggerTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -26,23 +26,24 @@
*/
App::import('Core', 'Debugger');
/**
* DebugggerTestCaseDebuggger
* DebugggerTestCaseDebuggger class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class DebuggerTestCaseDebugger extends Debugger {
class DebuggerTestCaseDebugger extends Debugger {
}
/**
* Debugger Test Case.
* DebuggerTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class DebuggerTest extends CakeTestCase {
//do not move code below or it change line numbers which are used in the tests
// !!!
// !!! Be careful with changing code below as it may
// !!! change line numbers which are used in the tests
// !!!
/**
* setUp method
*
@ -59,6 +60,15 @@ class DebuggerTest extends CakeTestCase {
}
}
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('log', true);
}
/**
* testDocRef method
*
@ -71,18 +81,18 @@ class DebuggerTest extends CakeTestCase {
$debugger = new Debugger();
$this->assertEqual(ini_get('docref_root'), 'http://php.net/');
}
/**
* test Excerpt writing
*
* @access public
* @return void
**/
*/
function testExcerpt() {
$return = Debugger::excerpt(__FILE__, 2, 2);
$this->assertTrue(is_array($return));
$this->assertEqual(count($return), 4);
$this->assertPattern('#/*&nbsp;SVN&nbsp;FILE:&nbsp;\$Id:&nbsp;debugger.test.php#', $return[1]);
$return = Debugger::excerpt('[internal]', 2, 2);
$this->assertTrue(empty($return));
}
@ -208,15 +218,14 @@ class DebuggerTest extends CakeTestCase {
Debugger::log('cool');
$result = file_get_contents(LOGS . 'debug.log');
$this->assertPattern('/DebuggerTest::testLog/', $result);
$this->assertPattern('/DebuggerTest\:\:testLog/', $result);
$this->assertPattern('/"cool"/', $result);
unlink(TMP . 'logs' . DS . 'debug.log');
Debugger::log(array('whatever', 'here'));
$result = file_get_contents(TMP . 'logs' . DS . 'debug.log');
$this->assertPattern('/DebuggerTest::testLog/', $result);
$this->assertPattern('/DebuggerTest\:\:testLog/', $result);
$this->assertPattern('/array/', $result);
$this->assertPattern('/"whatever",/', $result);
$this->assertPattern('/"here"/', $result);
@ -247,34 +256,24 @@ class DebuggerTest extends CakeTestCase {
$expected = "<pre>array(\n\t\"People\" => array()\n)</pre>";
$this->assertEqual($expected, $result);
}
/**
* test getInstance.
*
* @return void
**/
function testGetInstance() {
$result = Debugger::getInstance();
$this->assertIsA($result, 'Debugger');
$result = Debugger::getInstance('DebuggerTestCaseDebugger');
$this->assertIsA($result, 'DebuggerTestCaseDebugger');
$result = Debugger::getInstance();
$this->assertIsA($result, 'DebuggerTestCaseDebugger');
$result = Debugger::getInstance('Debugger');
$this->assertIsA($result, 'Debugger');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('log', true);
}
function testGetInstance() {
$result = Debugger::getInstance();
$this->assertIsA($result, 'Debugger');
$result = Debugger::getInstance('DebuggerTestCaseDebugger');
$this->assertIsA($result, 'DebuggerTestCaseDebugger');
$result = Debugger::getInstance();
$this->assertIsA($result, 'DebuggerTestCaseDebugger');
$result = Debugger::getInstance('Debugger');
$this->assertIsA($result, 'Debugger');
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ErrorHandlerTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -27,15 +27,13 @@
if (class_exists('TestErrorHandler')) {
return;
}
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
/**
* BlueberryComponent class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class BlueberryComponent extends Object {
@ -59,7 +57,7 @@ class BlueberryComponent extends Object {
/**
* BlueberryDispatcher class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class BlueberryDispatcher extends Dispatcher {
@ -77,7 +75,7 @@ class BlueberryDispatcher extends Dispatcher {
/**
* Short description for class.
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class AuthBlueberryUser extends CakeTestModel {
@ -97,54 +95,56 @@ class AuthBlueberryUser extends CakeTestModel {
var $useTable = false;
}
if (!class_exists('AppController')) {
/**
* AppController class
*
* @package cake.tests
* @subpackage cake.tests.cases.libs
*/
class AppController extends Controller {
/**
* components property
*
* @access public
* @return void
*/
var $components = array('Blueberry');
/**
* beforeRender method
*
* @access public
* @return void
*/
function beforeRender() {
echo $this->Blueberry->testName;
/**
* AppController class
*
* @package cake
* @subpackage cake.tests.cases.libs
*/
class AppController extends Controller {
/**
* components property
*
* @access public
* @return void
*/
var $components = array('Blueberry');
/**
* beforeRender method
*
* @access public
* @return void
*/
function beforeRender() {
echo $this->Blueberry->testName;
}
/**
* header method
*
* @access public
* @return void
*/
function header($header) {
echo $header;
}
/**
* _stop method
*
* @access public
* @return void
*/
function _stop($status = 0) {
echo 'Stopped with status: ' . $status;
}
}
/**
* header method
*
* @access public
* @return void
*/
function header($header) {
echo $header;
}
/**
* _stop method
*
* @access public
* @return void
*/
function _stop($status = 0) {
echo 'Stopped with status: ' . $status;
}
}
} elseif (!defined('APP_CONTROLLER_EXISTS')){
define('APP_CONTROLLER_EXISTS', true);
}
App::import('Core', array('Error', 'Controller'));
/**
* TestErrorController class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class TestErrorController extends AppController {
@ -169,7 +169,7 @@ class TestErrorController extends AppController {
/**
* BlueberryController class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class BlueberryController extends AppController {
@ -198,7 +198,7 @@ class BlueberryController extends AppController {
/**
* TestErrorHandler class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class TestErrorHandler extends ErrorHandler {
@ -213,12 +213,12 @@ class TestErrorHandler extends ErrorHandler {
}
}
/**
* Short description for class.
* ErrorHandlerTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class TestErrorHandlerTest extends CakeTestCase {
class ErrorHandlerTest extends CakeTestCase {
/**
* skip method
*
@ -226,7 +226,7 @@ class TestErrorHandlerTest extends CakeTestCase {
* @return void
*/
function skip() {
$this->skipif ((PHP_SAPI == 'cli'), 'TestErrorHandlerTest cannot be run from console');
$this->skipIf(PHP_SAPI === 'cli', '%s Cannot be run from console');
}
/**
* testError method
@ -259,7 +259,7 @@ class TestErrorHandlerTest extends CakeTestCase {
$result = ob_get_clean();
$this->assertPattern('/<h2>Not Found<\/h2>/', $result);
$this->assertPattern("/<strong>'\/test_error'<\/strong>/", $result);
ob_start();
$TestErrorHandler =& new TestErrorHandler('error404', array('message' => 'Page not found'));
ob_get_clean();
@ -279,6 +279,8 @@ class TestErrorHandlerTest extends CakeTestCase {
* @return void
*/
function testMissingController() {
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController');
ob_start();
$TestErrorHandler = new TestErrorHandler('missingController', array('className' => 'PostsController'));
$result = ob_get_clean();

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* FileTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -25,11 +25,10 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Core', 'File');
/**
* Short description for class.
* FileTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class FileTest extends CakeTestCase {
@ -96,7 +95,7 @@ class FileTest extends CakeTestCase {
$result = $this->File->Folder();
$this->assertIsA($result, 'Folder');
$this->skipIf(DIRECTORY_SEPARATOR === '\\', 'File permissions tests not supported on Windows');
$this->skipIf(DIRECTORY_SEPARATOR === '\\', '%s File permissions tests not supported on Windows');
$result = $this->File->perms();
$expecting = '0644';
$this->assertEqual($result, $expecting);

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* FolderTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -26,9 +26,9 @@
*/
App::import('Core', 'File');
/**
* Short description for class.
* FolderTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class FolderTest extends CakeTestCase {
@ -161,7 +161,7 @@ class FolderTest extends CakeTestCase {
* @access public
*/
function testChmod() {
$this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Folder permissions tests not supported on Windows');
$this->skipIf(DIRECTORY_SEPARATOR === '\\', '%s Folder permissions tests not supported on Windows');
$path = TEST_CAKE_CORE_INCLUDE_PATH . 'console' . DS . 'libs' . DS . 'templates' . DS . 'skel';
$Folder =& new Folder($path);
@ -271,13 +271,16 @@ class FolderTest extends CakeTestCase {
);
$result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false);
$this->assertEqual($result, $expected);
$this->assertIdentical(array_diff($expected[0], $result[0]), array());
$this->assertIdentical(array_diff($result[0], $expected[0]), array());
$result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false, 'dir');
$this->assertEqual($result, $expected[0]);
$this->assertIdentical(array_diff($expected[0], $result), array());
$this->assertIdentical(array_diff($result, $expected[0]), array());
$result = $Folder->tree(TEST_CAKE_CORE_INCLUDE_PATH . 'config', false, 'files');
$this->assertEqual($result, $expected[1]);
$this->assertIdentical(array_diff($expected[1], $result), array());
$this->assertIdentical(array_diff($result, $expected[1]), array());
}
/**
* testWindowsPath method
@ -405,10 +408,20 @@ class FolderTest extends CakeTestCase {
$Folder->cd(TEST_CAKE_CORE_INCLUDE_PATH . 'config');
$result = $Folder->find();
$expected = array('config.php', 'paths.php');
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->find('.*', true);
$expected = array('config.php', 'paths.php');
$this->assertIdentical($result, $expected);
$result = $Folder->find('.*\.php');
$expected = array('config.php', 'paths.php');
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->find('.*\.php', true);
$expected = array('config.php', 'paths.php');
$this->assertIdentical($result, $expected);
$result = $Folder->find('.*ig\.php');
@ -450,6 +463,14 @@ class FolderTest extends CakeTestCase {
TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php',
TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'paths.php'
);
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->findRecursive('(config|paths)\.php', true);
$expected = array(
TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'config.php',
TEST_CAKE_CORE_INCLUDE_PATH . 'config' . DS . 'paths.php'
);
$this->assertIdentical($result, $expected);
$Folder->cd(TMP);
@ -472,6 +493,14 @@ class FolderTest extends CakeTestCase {
TMP . 'testme' . DS . 'my.php',
TMP . 'testme' . DS . 'paths.php'
);
$this->assertIdentical(array_diff($expected, $result), array());
$this->assertIdentical(array_diff($result, $expected), array());
$result = $Folder->findRecursive('(paths|my)\.php', true);
$expected = array(
TMP . 'testme' . DS . 'my.php',
TMP . 'testme' . DS . 'paths.php'
);
$this->assertIdentical($result, $expected);
$Folder->cd(TEST_CAKE_CORE_INCLUDE_PATH . 'config');
@ -537,5 +566,141 @@ class FolderTest extends CakeTestCase {
);
$this->assertEqual($expected, $messages);
}
/**
* testCopy method
*
* Verify that directories and files are copied recursively
* even if the destination directory already exists.
* Subdirectories existing in both destination and source directory
* are skipped and not merged or overwritten.
*
* @return void
* @access public
* @link https://trac.cakephp.org/ticket/6259
*/
function testCopy() {
$path = TMP . 'folder_test';
$folder1 = $path . DS . 'folder1';
$folder2 = $folder1 . DS . 'folder2';
$folder3 = $path . DS . 'folder3';
$file1 = $folder1 . DS . 'file1.php';
$file2 = $folder2 . DS . 'file2.php';
new Folder($path, true);
new Folder($folder1, true);
new Folder($folder2, true);
new Folder($folder3, true);
touch($file1);
touch($file2);
$Folder =& new Folder($folder1);
$result = $Folder->copy($folder3);
$this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
$this->assertTrue(file_exists($folder3 . DS . 'folder2' . DS . 'file2.php'));
$Folder =& new Folder($folder3);
$Folder->delete();
$Folder =& new Folder($folder1);
$result = $Folder->copy($folder3);
$this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
$this->assertTrue(file_exists($folder3 . DS . 'folder2' . DS . 'file2.php'));
$Folder =& new Folder($folder3);
$Folder->delete();
new Folder($folder3, true);
new Folder($folder3 . DS . 'folder2', true);
file_put_contents($folder3 . DS . 'folder2' . DS . 'file2.php', 'untouched');
$Folder =& new Folder($folder1);
$result = $Folder->copy($folder3);
$this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
$this->assertEqual(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched');
$Folder =& new Folder($path);
$Folder->delete();
}
/**
* testMove method
*
* Verify that directories and files are moved recursively
* even if the destination directory already exists.
* Subdirectories existing in both destination and source directory
* are skipped and not merged or overwritten.
*
* @return void
* @access public
* @link https://trac.cakephp.org/ticket/6259
*/
function testMove() {
$path = TMP . 'folder_test';
$folder1 = $path . DS . 'folder1';
$folder2 = $folder1 . DS . 'folder2';
$folder3 = $path . DS . 'folder3';
$file1 = $folder1 . DS . 'file1.php';
$file2 = $folder2 . DS . 'file2.php';
new Folder($path, true);
new Folder($folder1, true);
new Folder($folder2, true);
new Folder($folder3, true);
touch($file1);
touch($file2);
$Folder =& new Folder($folder1);
$result = $Folder->move($folder3);
$this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
$this->assertTrue(is_dir($folder3 . DS . 'folder2'));
$this->assertTrue(file_exists($folder3 . DS . 'folder2' . DS . 'file2.php'));
$this->assertFalse(file_exists($file1));
$this->assertFalse(file_exists($folder2));
$this->assertFalse(file_exists($file2));
$Folder =& new Folder($folder3);
$Folder->delete();
new Folder($folder1, true);
new Folder($folder2, true);
touch($file1);
touch($file2);
$Folder =& new Folder($folder1);
$result = $Folder->move($folder3);
$this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
$this->assertTrue(is_dir($folder3 . DS . 'folder2'));
$this->assertTrue(file_exists($folder3 . DS . 'folder2' . DS . 'file2.php'));
$this->assertFalse(file_exists($file1));
$this->assertFalse(file_exists($folder2));
$this->assertFalse(file_exists($file2));
$Folder =& new Folder($folder3);
$Folder->delete();
new Folder($folder1, true);
new Folder($folder2, true);
new Folder($folder3, true);
new Folder($folder3 . DS . 'folder2', true);
touch($file1);
touch($file2);
file_put_contents($folder3 . DS . 'folder2' . DS . 'file2.php', 'untouched');
$Folder =& new Folder($folder1);
$result = $Folder->move($folder3);
$this->assertTrue($result);
$this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
$this->assertEqual(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched');
$this->assertFalse(file_exists($file1));
$this->assertFalse(file_exists($folder2));
$this->assertFalse(file_exists($file2));
$Folder =& new Folder($path);
$Folder->delete();
}
}
?>
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* HttpSocketTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -26,9 +26,9 @@
*/
App::import('Core', 'HttpSocket');
/**
* Short description for class.
* HttpSocketTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class HttpSocketTest extends CakeTestCase {
@ -49,6 +49,8 @@ class HttpSocketTest extends CakeTestCase {
/**
* This function sets up a TestHttpSocket instance we are going to use for testing
*
* @access public
* @return void
*/
function setUp() {
if (!class_exists('TestHttpSocket')) {
@ -62,6 +64,8 @@ class HttpSocketTest extends CakeTestCase {
/**
* We use this function to clean up after the test case was executed
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Socket, $this->RequestSocket);
@ -69,6 +73,8 @@ class HttpSocketTest extends CakeTestCase {
/**
* Test that HttpSocket::__construct does what one would expect it to do
*
* @access public
* @return void
*/
function testConstruct() {
$this->Socket->reset();
@ -92,10 +98,11 @@ class HttpSocketTest extends CakeTestCase {
$this->Socket->__construct(array('request' => array('uri' => 'http://www.cakephp.org:23/')));
$this->assertIdentical($this->Socket->config, $baseConfig);
}
/**
* Test that HttpSocket::configUri works properly with different types of arguments
*
* @access public
* @return void
*/
function testConfigUri() {
$this->Socket->reset();
@ -158,10 +165,11 @@ class HttpSocketTest extends CakeTestCase {
$this->assertIdentical($this->Socket->config, $expected);
$this->assertIdentical($r, false);
}
/**
* Tests that HttpSocket::request (the heart of the HttpSocket) is working properly.
*
* @access public
* @return void
*/
function testRequest() {
$this->Socket->reset();
@ -515,10 +523,11 @@ class HttpSocketTest extends CakeTestCase {
$this->RequestSocket->{low($method)}('http://www.google.com/', null, array('line' => 'Hey Server'));
}
}
/**
* Enter description here...
* testParseResponse method
*
* @access public
* @return void
*/
function testParseResponse() {
$this->Socket->reset();
@ -605,10 +614,11 @@ class HttpSocketTest extends CakeTestCase {
}
}
}
/**
* Enter description here...
* testDecodeBody method
*
* @access public
* @return void
*/
function testDecodeBody() {
$this->Socket->reset();
@ -647,10 +657,11 @@ class HttpSocketTest extends CakeTestCase {
}
}
}
/**
* Enter description here...
* testDecodeChunkedBody method
*
* @access public
* @return void
*/
function testDecodeChunkedBody() {
$this->Socket->reset();
@ -763,10 +774,11 @@ class HttpSocketTest extends CakeTestCase {
$r = $this->Socket->buildRequestLine("GET * HTTP/1.1\r\n");
$this->assertIdentical($r, "GET * HTTP/1.1\r\n");
}
/**
* Asserts that HttpSocket::parseUri is working properly
*
* @access public
* @return void
*/
function testParseUri() {
$this->Socket->reset();
@ -867,10 +879,11 @@ class HttpSocketTest extends CakeTestCase {
'port' => 8080,
));
}
/**
* Tests that HttpSocket::buildUri can turn all kinds of uri arrays (and strings) into fully or partially qualified URI's
*
* @access public
* @return void
*/
function testBuildUri() {
$this->Socket->reset();
@ -929,10 +942,11 @@ class HttpSocketTest extends CakeTestCase {
$r = $this->Socket->buildUri(array('scheme' => 'foo', 'host' => 'www.cakephp.org'));
$this->assertIdentical($r, 'foo://www.cakephp.org:80/');
}
/**
* Asserts that HttpSocket::parseQuery is working properly
*
* @access public
* @return void
*/
function testParseQuery() {
$this->Socket->reset();
@ -1033,11 +1047,12 @@ class HttpSocketTest extends CakeTestCase {
);
$this->assertIdentical($query, $expectedQuery);
}
/**
* Tests that HttpSocket::buildHeader can turn a given $header array into a proper header string according to
* HTTP 1.1 specs.
*
* @access public
* @return void
*/
function testBuildHeader() {
$this->Socket->reset();
@ -1070,10 +1085,11 @@ class HttpSocketTest extends CakeTestCase {
$this->assertIdentical($r, "Test\"@\"Field: My value\r\n");
}
/**
* Test that HttpSocket::parseHeader can take apart a given (and valid) $header string and turn it into an array.
*
* @access public
* @return void
*/
function testParseHeader() {
$this->Socket->reset();
@ -1131,10 +1147,10 @@ class HttpSocketTest extends CakeTestCase {
$this->assertIdentical($r, $expected);
}
/**
* undocumented function
* testParseCookies method
*
* @return void
* @access public
* @return void
*/
function testParseCookies() {
$header = array(
@ -1168,7 +1184,7 @@ class HttpSocketTest extends CakeTestCase {
$this->assertEqual($cookies, $expected);
}
/**
* undocumented function
* testBuildCookies method
*
* @return void
* @access public
@ -1191,6 +1207,8 @@ class HttpSocketTest extends CakeTestCase {
/**
* Tests that HttpSocket::__tokenEscapeChars() returns the right characters.
*
* @access public
* @return void
*/
function testTokenEscapeChars() {
$this->Socket->reset();
@ -1211,10 +1229,11 @@ class HttpSocketTest extends CakeTestCase {
$r = $this->Socket->__tokenEscapeChars(false);
$this->assertEqual($r, $expected);
}
/**
* Test that HttpSocket::escapeToken is escaping all characters as descriped in RFC 2616 (HTTP 1.1 specs)
*
* @access public
* @return void
*/
function testEscapeToken() {
$this->Socket->reset();
@ -1235,10 +1254,11 @@ class HttpSocketTest extends CakeTestCase {
$expectedToken = 'Extreme-":"Token-" "-""""@"-test';
$this->assertIdentical($expectedToken, $escapedToken);
}
/**
* Test that escaped token strings are properly unescaped by HttpSocket::unescapeToken
*
* @access public
* @return void
*/
function testUnescapeToken() {
$this->Socket->reset();
@ -1259,11 +1279,12 @@ class HttpSocketTest extends CakeTestCase {
$expectedToken = 'Extreme-:Token- -"@-test';
$this->assertIdentical($expectedToken, $escapedToken);
}
/**
* This tests asserts HttpSocket::reset() resets a HttpSocket instance to it's initial state (before Object::__construct
* got executed)
*
* @access public
* @return void
*/
function testReset() {
$this->Socket->reset();
@ -1281,11 +1302,12 @@ class HttpSocketTest extends CakeTestCase {
$this->assertIdentical($return, true);
}
/**
* This tests asserts HttpSocket::reset(false) resets certain HttpSocket properties to their initial state (before
* Object::__construct got executed).
*
* @access public
* @return void
*/
function testPartialReset() {
$this->Socket->reset();
@ -1308,6 +1330,5 @@ class HttpSocketTest extends CakeTestCase {
}
$this->assertIdentical($return, true);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* I18nTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -26,9 +26,9 @@
*/
App::import('Core', 'i18n');
/**
* Short description for class.
* I18nTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class I18nTest extends CakeTestCase {
@ -39,8 +39,18 @@ class I18nTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->_localePaths = Configure::read('localePaths');
Configure::write('localePaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale'));
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
Configure::write('localePaths', $this->_localePaths);
}
/**
* testDefaultStrings method
*
@ -2336,7 +2346,12 @@ class I18nTest extends CakeTestCase {
$this->assertFalse(in_array('24 everything else (from core translated)', $corePlurals));
$this->assertFalse(in_array('25 everything else (from core translated)', $corePlurals));
}
/**
* testPluginTranslation method
*
* @access public
* @return void
*/
function testPluginTranslation() {
$pluginPaths = Configure::read('pluginPaths');
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins'));

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* L10nTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -28,7 +28,7 @@ App::import('Core', 'l10n');
/**
* L10nTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class L10nTest extends CakeTestCase {

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for behavior.test.php
* BehaviorTest file
*
* Long description for behavior.test.php
*
@ -24,12 +24,11 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
App::import('Model', 'AppModel');
require_once dirname(__FILE__) . DS . 'models.php';
/**
* Short description for class.
* TestBehavior class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TestBehavior extends ModelBehavior {
@ -329,7 +328,6 @@ class TestBehavior extends ModelBehavior {
* @subpackage cake.tests.cases.libs.model
*/
class Test2Behavior extends TestBehavior{
}
/**
* Test3Behavior class
@ -338,7 +336,6 @@ class Test2Behavior extends TestBehavior{
* @subpackage cake.tests.cases.libs.model
*/
class Test3Behavior extends TestBehavior{
}
/**
* BehaviorTest class
@ -354,6 +351,15 @@ class BehaviorTest extends CakeTestCase {
* @access public
*/
var $fixtures = array('core.apple', 'core.sample');
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
ClassRegistry::flush();
}
/**
* testBehaviorBinding method
*
@ -942,10 +948,10 @@ class BehaviorTest extends CakeTestCase {
$expected = array('TestBehavior', 'Test2Behavior');
$this->assertIdentical($Apple->beforeTestResult, $expected);
}
/**
* Test attach and detaching
*
* @access public
* @return void
**/
function testBehaviorAttachAndDetach() {
@ -954,19 +960,8 @@ class BehaviorTest extends CakeTestCase {
$Sample->Behaviors->init($Sample->alias, $Sample->actsAs);
$Sample->Behaviors->attach('Test2');
$Sample->Behaviors->detach('Test3');
$Sample->Behaviors->trigger($Sample, 'beforeTest');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
ClassRegistry::flush();
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Acl behavior test
* AclBehaviorTest file
*
* Test the Acl Behavior
*
@ -26,11 +26,10 @@
*/
App::import('Behavior', 'Acl');
App::import('Core', 'db_acl');
/**
* Test Person Class - self joined model
* Test Person class - self joined model
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
*/
class AclPerson extends CakeTestModel {
@ -79,12 +78,12 @@ class AclPerson extends CakeTestModel {
'foreignKey' => 'mother_id'
)
);
/**
* ParentNode
* parentNode method
*
* @return void
**/
* @access public
*/
function parentNode() {
if (!$this->id && empty($this->data)) {
return null;
@ -99,13 +98,11 @@ class AclPerson extends CakeTestModel {
return array('AclPerson' => array('id' => $data['AclPerson']['mother_id']));
}
}
}
/**
* Acl Test User
* AclUser class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
*/
class AclUser extends CakeTestModel {
@ -139,11 +136,10 @@ class AclUser extends CakeTestModel {
return null;
}
}
/**
* Acl Test User
* AclPost class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
*/
class AclPost extends CakeTestModel {
@ -177,33 +173,62 @@ class AclPost extends CakeTestModel {
return null;
}
}
/**
* ACL behavior test class
* AclBehaviorTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class AclBehaviorTestCase extends CakeTestCase {
/**
* Aco property
*
* @var Aco
* @access public
*/
var $Aco;
/**
* Aro property
*
* @var Aro
* @access public
*/
var $Aro;
/**
* fixtures property
*
* @var array
* @access public
*/
var $fixtures = array('core.person', 'core.user', 'core.post', 'core.aco', 'core.aro', 'core.aros_aco');
/**
* Set up the test
*
* @return void
**/
* @access public
*/
function startTest() {
Configure::write('Acl.database', 'test_suite');
$this->Aco =& new Aco();
$this->Aro =& new Aro();
}
/**
* tearDown method
*
* @return void
* @access public
*/
function tearDown() {
ClassRegistry::flush();
unset($this->Aro, $this->Aco);
}
/**
* Test Setup of AclBehavior
*
* @return void
**/
* @access public
*/
function testSetup() {
$User =& new AclUser();
$this->assertTrue(isset($User->Behaviors->Acl->settings['User']));
@ -215,12 +240,12 @@ class AclBehaviorTestCase extends CakeTestCase {
$this->assertEqual($Post->Behaviors->Acl->settings['Post']['type'], 'controlled');
$this->assertTrue(is_object($Post->Aco));
}
/**
* test After Save
*
* @return void
**/
* @access public
*/
function testAfterSave() {
$Post =& new AclPost();
$data = array(
@ -264,12 +289,12 @@ class AclBehaviorTestCase extends CakeTestCase {
$this->assertEqual($node[0]['Aro']['parent_id'], 5);
$this->assertEqual($node[1]['Aro']['parent_id'], null);
}
/**
* Test After Delete
*
* @return void
**/
* @access public
*/
function testAfterDelete() {
$aroData = array(
'Aro' => array(
@ -317,12 +342,12 @@ class AclBehaviorTestCase extends CakeTestCase {
$this->assertTrue(empty($result));
}
/**
* Test Node()
*
* @return void
**/
* @access public
*/
function testNode() {
$Person =& new AclPerson();
$aroData = array(
@ -339,16 +364,5 @@ class AclBehaviorTestCase extends CakeTestCase {
$this->assertTrue(is_array($result));
$this->assertEqual(sizeof($result), 1);
}
/**
* tear down test
*
* @return void
**/
function tearDown() {
ClassRegistry::flush();
unset($this->Aro, $this->Aco);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ContainableBehaviorTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
* @since CakePHP(tm) v 1.2.0.5669
* @version $Revision$
@ -24,7 +24,6 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Core', array('AppModel', 'Model'));
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
/**
@ -33,7 +32,7 @@ require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
*/
class ContainableTest extends CakeTestCase {
class ContainableBehaviorTest extends CakeTestCase {
/**
* Fixtures associated with this test case
*
@ -52,6 +51,7 @@ class ContainableTest extends CakeTestCase {
function startTest() {
$this->User =& ClassRegistry::init('User');
$this->Article =& ClassRegistry::init('Article');
$this->Tag =& ClassRegistry::init('Tag');
$this->User->bind(array(
'Article' => array('type' => 'hasMany'),
@ -61,8 +61,13 @@ class ContainableTest extends CakeTestCase {
$this->User->ArticleFeatured->unbindModel(array('belongsTo' => array('Category')), false);
$this->User->ArticleFeatured->hasMany['Comment']['foreignKey'] = 'article_id';
$this->Tag->bind(array(
'Article' => array('type' => 'hasAndBelongsToMany')
));
$this->User->Behaviors->attach('Containable');
$this->Article->Behaviors->attach('Containable');
$this->Tag->Behaviors->attach('Containable');
}
/**
* Method executed after each test
@ -72,6 +77,7 @@ class ContainableTest extends CakeTestCase {
function endTest() {
unset($this->Article);
unset($this->User);
unset($this->Tag);
ClassRegistry::flush();
}
@ -125,6 +131,16 @@ class ContainableTest extends CakeTestCase {
$this->assertEqual(array_shift(Set::extract('/User/keep', $r)), array('keep' => array()));
$this->assertEqual(array_shift(Set::extract('/Comment/keep', $r)), array('keep' => array('User' => array())));
$this->assertEqual(array_shift(Set::extract('/Article/keep', $r)), array('keep' => array('Comment' => array())));
$r = $this->__containments($this->Tag, array('Article' => array('User' => array('Comment' => array(
'Attachment' => array('conditions' => array('Attachment.id >' => 1))
)))));
$this->assertTrue(Set::matches('/Attachment', $r));
$this->assertTrue(Set::matches('/Comment/keep/Attachment/conditions', $r));
$this->assertEqual($r['Comment']['keep']['Attachment']['conditions'], array('Attachment.id >' => 1));
$this->assertTrue(Set::matches('/User/keep/Comment', $r));
$this->assertTrue(Set::matches('/Article/keep/User', $r));
$this->assertTrue(Set::matches('/Tag/keep/Article', $r));
}
/**
* testInvalidContainments method
@ -2868,25 +2884,32 @@ class ContainableTest extends CakeTestCase {
$this->assertEqual($result, $expected);
$result = $this->Article->find('all', array('contain' => array('Comment(comment, published)' => 'Attachment(attachment)', 'User(user)'), 'fields' => array('title')));
if (!empty($result)) {
foreach($result as $i=>$article) {
foreach($article['Comment'] as $j=>$comment) {
$result[$i]['Comment'][$j] = array_diff_key($comment, array('id'=>true));
}
}
}
$expected = array(
array(
'Article' => array('title' => 'First Article', 'id' => 1),
'User' => array('user' => 'mariano', 'id' => 1),
'Comment' => array(
array('comment' => 'First Comment for First Article', 'published' => 'Y', 'id' => 1, 'article_id' => 1, 'Attachment' => array()),
array('comment' => 'Second Comment for First Article', 'published' => 'Y', 'id' => 2, 'article_id' => 1, 'Attachment' => array()),
array('comment' => 'Third Comment for First Article', 'published' => 'Y', 'id' => 3, 'article_id' => 1, 'Attachment' => array()),
array('comment' => 'Fourth Comment for First Article', 'published' => 'N', 'id' => 4, 'article_id' => 1, 'Attachment' => array()),
array('comment' => 'First Comment for First Article', 'published' => 'Y', 'article_id' => 1, 'Attachment' => array()),
array('comment' => 'Second Comment for First Article', 'published' => 'Y', 'article_id' => 1, 'Attachment' => array()),
array('comment' => 'Third Comment for First Article', 'published' => 'Y', 'article_id' => 1, 'Attachment' => array()),
array('comment' => 'Fourth Comment for First Article', 'published' => 'N', 'article_id' => 1, 'Attachment' => array()),
)
),
array(
'Article' => array('title' => 'Second Article', 'id' => 2),
'User' => array('user' => 'larry', 'id' => 3),
'Comment' => array(
array('comment' => 'First Comment for Second Article', 'published' => 'Y', 'id' => 5, 'article_id' => 2, 'Attachment' => array(
array('comment' => 'First Comment for Second Article', 'published' => 'Y', 'article_id' => 2, 'Attachment' => array(
'attachment' => 'attachment.zip', 'id' => 1
)),
array('comment' => 'Second Comment for Second Article', 'published' => 'Y', 'id' => 6, 'article_id' => 2, 'Attachment' => array())
array('comment' => 'Second Comment for Second Article', 'published' => 'Y', 'article_id' => 2, 'Attachment' => array())
)
),
array(
@ -3534,5 +3557,4 @@ class ContainableTest extends CakeTestCase {
return $debug;
}
}
?>
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* TranslateBehaviorTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
* @since CakePHP(tm) v 1.2.0.5669
* @version $Revision$
@ -30,14 +30,13 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
App::import('Core', array('AppModel', 'Model'));
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
/**
* TranslateTest class.
* TranslateBehaviorTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
*/
class TranslateTest extends CakeTestCase {
class TranslateBehaviorTest extends CakeTestCase {
/**
* autoFixtures property
*

View file

@ -1,9 +1,9 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* TreeBehaviorTest file
*
* Long description for file
* Holds several Test Cases
*
* PHP versions 4 and 5
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
* @since CakePHP(tm) v 1.2.0.5330
* @version $Revision$
@ -27,12 +27,12 @@
App::import('Core', array('AppModel', 'Model'));
require_once(dirname(dirname(__FILE__)) . DS . 'models.php');
/**
* NumberTreeCase class
* NumberTreeTest class
*
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
*/
class NumberTreeCase extends CakeTestCase {
class NumberTreeTest extends CakeTestCase {
/**
* settings property
*
@ -1205,12 +1205,12 @@ class NumberTreeCase extends CakeTestCase {
}
}
/**
* ScopedTreeCase class
* ScopedTreeTest class
*
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
*/
class ScopedTreeCase extends NumberTreeCase {
class ScopedTreeTest extends NumberTreeTest {
/**
* settings property
*
@ -1435,12 +1435,12 @@ class ScopedTreeCase extends NumberTreeCase {
}
}
/**
* AfterTreeCase class
* AfterTreeTest class
*
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
*/
class AfterTreeCase extends NumberTreeCase {
class AfterTreeTest extends NumberTreeTest {
/**
* settings property
*
@ -1479,12 +1479,12 @@ class AfterTreeCase extends NumberTreeCase {
}
}
/**
* UnconventionalTreeCase class
* UnconventionalTreeTest class
*
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
*/
class UnconventionalTreeCase extends NumberTreeCase {
class UnconventionalTreeTest extends NumberTreeTest {
/**
* settings property
*
@ -1506,12 +1506,12 @@ class UnconventionalTreeCase extends NumberTreeCase {
var $fixtures = array('core.unconventional_tree');
}
/**
* UuidTreeCase class
* UuidTreeTest class
*
* @package cake
* @subpackage cake.tests.cases.libs.model.behaviors
*/
class UuidTreeCase extends NumberTreeCase {
class UuidTreeTest extends NumberTreeTest {
/**
* settings property
*

View file

@ -1,9 +1,9 @@
<?php
/* SVN FILE: $Id$ */
/**
* AdoDB layer for DBO.
* DboAdodbTest file
*
* Long description for file
* AdoDB layer for DBO
*
* PHP versions 4 and 5
*
@ -24,16 +24,14 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
require_once LIBS.'model'.DS.'model.php';
require_once LIBS.'model'.DS.'datasources'.DS.'datasource.php';
require_once LIBS.'model'.DS.'datasources'.DS.'dbo_source.php';
require_once LIBS.'model'.DS.'datasources'.DS.'dbo'.DS.'dbo_adodb.php';
/**
* Short description for class.
* DboAdoTestDb
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class DboAdoTestDb extends DboAdodb {
@ -75,11 +73,10 @@ class DboAdoTestDb extends DboAdodb {
return $this->simulated[count($this->simulated) - 1];
}
}
/**
* Short description for class.
* AdodbTestModel
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class AdodbTestModel extends CakeTestModel {
@ -152,7 +149,6 @@ class AdodbTestModel extends CakeTestModel {
);
}
}
if (!class_exists('Article')) {
/**
* Article class
@ -168,32 +164,29 @@ if (!class_exists('Article')) {
* @access public
*/
var $name = 'Article';
}
}
/**
* The test class for the DboAdobd
* DboAdodbTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources.dbo
*/
class DboAdodbTest extends CakeTestCase {
/**
* The Dbo instance to be tested
*
* @var object
* @var DboSource
* @access public
*/
var $db = null;
/**
* undocumented class variable
* fixtures property
*
* @var string
* @access public
**/
var $fixtures = array('core.article');
/**
* Skip if cannot connect to AdoDb
*
@ -202,7 +195,7 @@ class DboAdodbTest extends CakeTestCase {
function skip() {
$this->_initDb();
$db =& ConnectionManager::getDataSource('test_suite');
$this->skipif($db->config['driver'] != 'adodb', 'Adodb connection not available');
$this->skipIf($db->config['driver'] != 'adodb', '%s Adodb connection not available');
}
/**
* Sets up a Dbo class instance for testing
@ -280,6 +273,5 @@ class DboAdodbTest extends CakeTestCase {
function testColumns() {
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* DboMssql test
* DboMssqlTest file
*
* PHP versions 4 and 5
*
@ -29,7 +29,6 @@ require_once LIBS.'model'.DS.'model.php';
require_once LIBS.'model'.DS.'datasources'.DS.'datasource.php';
require_once LIBS.'model'.DS.'datasources'.DS.'dbo_source.php';
require_once LIBS.'model'.DS.'datasources'.DS.'dbo'.DS.'dbo_mssql.php';
/**
* DboMssqlTestDb class
*
@ -37,14 +36,6 @@ require_once LIBS.'model'.DS.'datasources'.DS.'dbo'.DS.'dbo_mssql.php';
* @subpackage cake.tests.cases.libs.model.datasources.dbo
*/
class DboMssqlTestDb extends DboMssql {
function __construct() {}
function connect() {
$this->connected = true;
return true;
}
function lastError() {}
/**
* simulated property
*
@ -54,7 +45,7 @@ class DboMssqlTestDb extends DboMssql {
var $simulated = array();
/**
* fetchAllResultsStack
*
*
* @var array
* @access public
*/
@ -72,8 +63,8 @@ class DboMssqlTestDb extends DboMssql {
}
/**
* fetchAll method
*
* @param mixed $sql
*
* @param mixed $sql
* @access protected
* @return void
*/
@ -82,8 +73,8 @@ class DboMssqlTestDb extends DboMssql {
}
/**
* fetchAll method
*
* @param mixed $sql
*
* @param mixed $sql
* @access protected
* @return void
*/
@ -103,12 +94,21 @@ class DboMssqlTestDb extends DboMssql {
function getLastQuery() {
return $this->simulated[count($this->simulated) - 1];
}
}
/**
* Short description for class.
* getPrimaryKey method
*
* @package cake.tests
* @param mixed $model
* @access public
* @return void
*/
function getPrimaryKey($model) {
return parent::_getPrimaryKey($model);
}
}
/**
* MssqlTestModel class
*
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class MssqlTestModel extends Model {
@ -126,6 +126,32 @@ class MssqlTestModel extends Model {
* @access public
*/
var $useTable = false;
/**
* _schema property
*
* @var array
* @access protected
*/
var $_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
/**
* find method
*
@ -153,46 +179,27 @@ class MssqlTestModel extends Model {
return $conditions;
}
/**
* schema method
* setSchema method
*
* @param array $schema
* @access public
* @return void
*/
function schema() {
$this->_schema = array(
'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
'last_login'=> array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
);
return $this->_schema;
function setSchema($schema) {
$this->_schema = $schema;
}
}
/**
* The test class for the DboMssql
* DboMssqlTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources.dbo
*/
class DboMssqlTest extends CakeTestCase {
/**
* The Dbo instance to be tested
*
* @var object
* @var DboSource
* @access public
*/
var $db = null;
@ -203,7 +210,7 @@ class DboMssqlTest extends CakeTestCase {
*/
function skip() {
$this->_initDb();
$this->skipif ($this->db->config['driver'] != 'mssql', 'SQL Server connection not available');
$this->skipUnless($this->db->config['driver'] == 'mssql', '%s SQL Server connection not available');
}
/**
* Sets up a Dbo class instance for testing
@ -215,6 +222,15 @@ class DboMssqlTest extends CakeTestCase {
$this->db = new DboMssqlTestDb($db->config);
$this->model = new MssqlTestModel();
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->model);
}
/**
* testQuoting method
*
@ -284,7 +300,7 @@ class DboMssqlTest extends CakeTestCase {
}
/**
* testDescribe method
*
*
* @access public
* @return void
*/
@ -314,27 +330,68 @@ class DboMssqlTest extends CakeTestCase {
);
$this->assertEqual($result, $expected);
}
/**
* testUpdateAllSyntax method
*
* @return void
* @access public
*/
function testUpdateAllSyntax() {
$model = ClassRegistry::init('MssqlTestModel');
$fields = array('MssqlTestModel.client_id' => '[MssqlTestModel].[client_id] + 1');
$conditions = array('MssqlTestModel.updated <' => date('2009-01-01 00:00:00'));
$this->db->update($model, $fields, null, $conditions);
$this->db->update($this->model, $fields, null, $conditions);
$result = $this->db->getLastQuery();
$this->assertNoPattern('/MssqlTestModel/', $result);
$this->assertPattern('/^UPDATE \[mssql_test_models\]/', $result);
$this->assertPattern('/SET \[client_id\] = \[client_id\] \+ 1/', $result);
}
/**
* tearDown method
* testGetPrimaryKey method
*
* @access public
* @return void
* @access public
*/
function tearDown() {
unset($this->model);
function testGetPrimaryKey() {
$result = $this->db->getPrimaryKey($this->model);
$this->assertEqual($result, 'id');
$schema = $this->model->schema();
unset($schema['id']['key']);
$this->model->setSchema($schema);
$result = $this->db->getPrimaryKey($this->model);
$this->assertNull($result);
}
/**
* testInsertMulti
*
* @return void
* @access public
*/
function testInsertMulti() {
$fields = array('id', 'name', 'login');
$values = array('(1, \'Larry\', \'PhpNut\')', '(2, \'Renan\', \'renan.saddam\')');
$this->db->simulated = array();
$this->db->insertMulti($this->model, $fields, $values);
$result = $this->db->simulated;
$expected = array(
'SET IDENTITY_INSERT [mssql_test_models] ON',
'INSERT INTO [mssql_test_models] ([id], [name], [login]) VALUES (1, \'Larry\', \'PhpNut\')',
'INSERT INTO [mssql_test_models] ([id], [name], [login]) VALUES (2, \'Renan\', \'renan.saddam\')',
'SET IDENTITY_INSERT [mssql_test_models] OFF'
);
$this->assertEqual($result, $expected);
$fields = array('name', 'login');
$values = array('(\'Larry\', \'PhpNut\')', '(\'Renan\', \'renan.saddam\')');
$this->db->simulated = array();
$this->db->insertMulti($this->model, $fields, $values);
$result = $this->db->simulated;
$expected = array(
'INSERT INTO [mssql_test_models] ([name], [login]) VALUES (\'Larry\', \'PhpNut\')',
'INSERT INTO [mssql_test_models] ([name], [login]) VALUES (\'Renan\', \'renan.saddam\')'
);
$this->assertEqual($result, $expected);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* DboMysql test
* DboMysqlTest file
*
* PHP versions 4 and 5
*
@ -26,9 +26,9 @@ App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboMysql'));
Mock::generatePartial('DboMysql', 'QueryMockDboMysql', array('query'));
/**
* Short description for class.
* DboMysqlTestDb class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class DboMysqlTestDb extends DboMysql {
@ -71,9 +71,9 @@ class DboMysqlTestDb extends DboMysql {
}
}
/**
* Short description for class.
* MysqlTestModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class MysqlTestModel extends Model {
@ -147,16 +147,16 @@ class MysqlTestModel extends Model {
}
}
/**
* The test class for the DboMysql
* DboMysqlTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources.dbo
*/
class DboMysqlTest extends CakeTestCase {
/**
* The Dbo instance to be tested
*
* @var object
* @var DboSource
* @access public
*/
var $Db = null;
@ -167,7 +167,7 @@ class DboMysqlTest extends CakeTestCase {
*/
function skip() {
$this->_initDb();
$this->skipif($this->db->config['driver'] != 'mysql', 'MySQL connection not available');
$this->skipUnless($this->db->config['driver'] == 'mysql', '%s MySQL connection not available');
}
/**
* Sets up a Dbo class instance for testing
@ -372,76 +372,76 @@ class DboMysqlTest extends CakeTestCase {
$name = $this->db->fullTableName('simple');
$mockDbo =& new QueryMockDboMysql($this);
$columnData = array(
$columnData = array(
array('0' => array(
'Table' => 'with_compound_keys',
'Non_unique' => '0',
'Key_name' => 'PRIMARY',
'Seq_in_index' => '1',
'Column_name' => 'id',
'Collation' => 'A',
'Cardinality' => '0',
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => '',
'Index_type' => 'BTREE',
'Comment' => ''
)),
array('0' => array(
'Table' => 'with_compound_keys',
'Non_unique' => '1',
'Key_name' => 'pointless_bool',
'Seq_in_index' => '1',
'Column_name' => 'bool',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Table' => 'with_compound_keys',
'Non_unique' => '0',
'Key_name' => 'PRIMARY',
'Seq_in_index' => '1',
'Column_name' => 'id',
'Collation' => 'A',
'Cardinality' => '0',
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => '',
'Index_type' => 'BTREE',
'Comment' => ''
)),
array('0' => array(
'Table' => 'with_compound_keys',
'Non_unique' => '1',
'Key_name' => 'pointless_small_int',
'Seq_in_index' => '1',
'Column_name' => 'small_int',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Table' => 'with_compound_keys',
'Non_unique' => '1',
'Key_name' => 'pointless_bool',
'Seq_in_index' => '1',
'Column_name' => 'bool',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Comment' => ''
)),
)),
array('0' => array(
'Table' => 'with_compound_keys',
'Non_unique' => '1',
'Key_name' => 'one_way',
'Seq_in_index' => '1',
'Column_name' => 'bool',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Table' => 'with_compound_keys',
'Non_unique' => '1',
'Key_name' => 'pointless_small_int',
'Seq_in_index' => '1',
'Column_name' => 'small_int',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Comment' => ''
)),
)),
array('0' => array(
'Table' => 'with_compound_keys',
'Non_unique' => '1',
'Key_name' => 'one_way',
'Seq_in_index' => '2',
'Column_name' => 'small_int',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Comment' => ''
'Table' => 'with_compound_keys',
'Non_unique' => '1',
'Key_name' => 'one_way',
'Seq_in_index' => '1',
'Column_name' => 'bool',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Comment' => ''
)),
array('0' => array(
'Table' => 'with_compound_keys',
'Non_unique' => '1',
'Key_name' => 'one_way',
'Seq_in_index' => '2',
'Column_name' => 'small_int',
'Collation' => 'A',
'Cardinality' => NULL,
'Sub_part' => NULL,
'Packed' => NULL,
'Null' => 'YES',
'Index_type' => 'BTREE',
'Comment' => ''
))
);
$mockDbo->setReturnValue('query', $columnData, array('SHOW INDEX FROM ' . $name));
@ -504,7 +504,7 @@ class DboMysqlTest extends CakeTestCase {
}
/**
* testAlterSchemaIndexes method
*
*
* @access public
* @return void
*/
@ -538,10 +538,10 @@ class DboMysqlTest extends CakeTestCase {
'PRIMARY' => array('column' => 'id', 'unique' => 1))
)));
$this->db->query($this->db->alterSchema($schema2->compare($schema1)));
$indexes = $this->db->index('altertest');
$this->assertEqual($schema2->tables['altertest']['indexes'], $indexes);
// Change three indexes, delete one and add another one
$schema3 =& new CakeSchema(array(
'name' => 'AlterTest3',
@ -552,7 +552,7 @@ class DboMysqlTest extends CakeTestCase {
'group1' => array('type' => 'integer', 'null' => true),
'group2' => array('type' => 'integer', 'null' => true),
'indexes' => array(
'name_idx' => array('column' => 'name', 'unique' => 1),
'name_idx' => array('column' => 'name', 'unique' => 1),
'group_idx' => array('column' => 'group2', 'unique' => 0),
'compound_idx' => array('column' => array('group2', 'group1'), 'unique' => 0),
'id_name_idx' => array('column' => array('id', 'name'), 'unique' => 0))
@ -575,5 +575,4 @@ class DboMysqlTest extends CakeTestCase {
$this->db->query($this->db->dropSchema($schema1));
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* DboMysqli test
* DboMysqliTest file
*
* PHP versions 4 and 5
*
@ -22,16 +22,14 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboMysqli'));
/**
* Short description for class.
* DboMysqliTestDb class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class DboMysqliTestDb extends DboMysqli {
@ -74,9 +72,9 @@ class DboMysqliTestDb extends DboMysqli {
}
}
/**
* Short description for class.
* MysqliTestModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class MysqliTestModel extends Model {
@ -150,16 +148,16 @@ class MysqliTestModel extends Model {
}
}
/**
* The test class for the DboMysqli
* DboMysqliTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources.dbo
*/
class DboMysqliTest extends CakeTestCase {
/**
* The Dbo instance to be tested
*
* @var object
* @var DboSource
* @access public
*/
var $Db = null;
@ -170,7 +168,7 @@ class DboMysqliTest extends CakeTestCase {
*/
function skip() {
$this->_initDb();
$this->skipif($this->db->config['driver'] != 'mysqli', 'MySQLi connection not available');
$this->skipUnless($this->db->config['driver'] == 'mysqli', '%s MySQLi connection not available');
}
/**
* Sets up a Dbo class instance for testing
@ -300,5 +298,4 @@ class DboMysqliTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* DboOracle test
* DboOracleTest file
*
* PHP versions 4 and 5
*
@ -22,13 +22,11 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo_source.php';
require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS . 'dbo_oracle.php';
/**
* DboOracleTest class
*
@ -39,7 +37,7 @@ class DboOracleTest extends CakeTestCase {
/**
* fixtures property
*/
var $fixtures = array('core.oracle_user');
var $fixtures = array('core.oracle_user');
/**
* setup method
*
@ -57,9 +55,7 @@ class DboOracleTest extends CakeTestCase {
*/
function skip() {
$this->_initDb();
$this->skipif(
$this->db->config['driver'] != 'oracle', 'Oracle connection not available'
);
$this->skipUnless($this->db->config['driver'] == 'oracle', '%s Oracle connection not available');
}
/**
* testLastErrorStatement method
@ -99,7 +95,6 @@ class DboOracleTest extends CakeTestCase {
$this->db->config['password'] = $old_pw;
$this->db->connect();
}
/**
* testName method
*
@ -131,10 +126,5 @@ class DboOracleTest extends CakeTestCase {
$this->assertEqual($e, $r);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* DboPostgres test
* DboPostgresTest file
*
* PHP versions 4 and 5
*
@ -24,13 +24,11 @@
*/
App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboPostgres'));
App::import('Model', 'App');
require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php';
/**
* Short description for class.
* DboPostgresTestDb class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class DboPostgresTestDb extends DboPostgres {
@ -63,9 +61,9 @@ class DboPostgresTestDb extends DboPostgres {
}
}
/**
* Short description for class.
* PostgresTestModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class PostgresTestModel extends Model {
@ -139,9 +137,9 @@ class PostgresTestModel extends Model {
}
}
/**
* The test class for the DboPostgres
* DboPostgresTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources.dbo
*/
class DboPostgresTest extends CakeTestCase {
@ -159,19 +157,19 @@ class DboPostgresTest extends CakeTestCase {
* @var object
* @access public
*/
var $fixtures = array('core.user', 'core.binary_test', 'core.comment', 'core.article',
var $fixtures = array('core.user', 'core.binary_test', 'core.comment', 'core.article',
'core.tag', 'core.articles_tag', 'core.attachment', 'core.person', 'core.post', 'core.author');
/**
* Actual DB connection used in testing
*
* @var object
* @var DboSource
* @access public
*/
var $db = null;
/**
* Simulated DB connection used in testing
*
* @var object
* @var DboSource
* @access public
*/
var $db2 = null;
@ -182,7 +180,7 @@ class DboPostgresTest extends CakeTestCase {
*/
function skip() {
$this->_initDb();
$this->skipif($this->db->config['driver'] != 'postgres', 'PostgreSQL connection not available');
$this->skipUnless($this->db->config['driver'] == 'postgres', '%s PostgreSQL connection not available');
}
/**
* Set up test suite database connection
@ -376,7 +374,6 @@ class DboPostgresTest extends CakeTestCase {
$expected = '"foo" text DEFAULT \'FOO\'';
$this->assertEqual($this->db->buildColumn($result), $expected);
}
/**
* Tests that binary data is escaped/unescaped properly on reads and writes
*
@ -409,7 +406,6 @@ class DboPostgresTest extends CakeTestCase {
$result = $model->find('first');
$this->assertEqual($result['BinaryTest']['data'], $data);
}
/**
* Tests the syntax of generated schema indexes
*
@ -479,7 +475,6 @@ class DboPostgresTest extends CakeTestCase {
$db1->query('DROP TABLE ' . $db1->fullTableName('datatypes'));
}
/**
* Test index generation from table info.
*
@ -498,7 +493,7 @@ class DboPostgresTest extends CakeTestCase {
);
$result = $this->db->index($name);
$this->assertEqual($expected, $result);
$this->db->query('DROP TABLE ' . $name);
$name = $this->db->fullTableName('index_test_2', false);
$this->db->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )');
@ -532,7 +527,7 @@ class DboPostgresTest extends CakeTestCase {
)
));
$this->db->query($this->db->createSchema($Old));
$New =& new CakeSchema(array(
'connection' => 'test_suite',
'name' => 'AlterPosts',
@ -547,13 +542,13 @@ class DboPostgresTest extends CakeTestCase {
)
));
$this->db->query($this->db->alterSchema($New->compare($Old), 'alter_posts'));
$model = new CakeTestModel(array('table' => 'alter_posts', 'ds' => 'test_suite'));
$result = $model->schema();
$this->assertTrue(isset($result['status']));
$this->assertFalse(isset($result['published']));
$this->assertEqual($result['body']['type'], 'string');
$this->db->query($this->db->dropSchema($New));
}
/**
@ -561,7 +556,7 @@ class DboPostgresTest extends CakeTestCase {
*
* @access public
* @return void
*/
*/
function testAlterIndexes() {
$this->db->cacheSources = false;
@ -594,10 +589,10 @@ class DboPostgresTest extends CakeTestCase {
)
));
$this->db->query($this->db->alterSchema($schema2->compare($schema1)));
$indexes = $this->db->index('altertest');
$this->assertEqual($schema2->tables['altertest']['indexes'], $indexes);
// Change three indexes, delete one and add another one
$schema3 =& new CakeSchema(array(
'name' => 'AlterTest3',
@ -608,7 +603,7 @@ class DboPostgresTest extends CakeTestCase {
'group1' => array('type' => 'integer', 'null' => true),
'group2' => array('type' => 'integer', 'null' => true),
'indexes' => array(
'name_idx' => array('column' => 'name', 'unique' => 1),
'name_idx' => array('column' => 'name', 'unique' => 1),
'group_idx' => array('column' => 'group2', 'unique' => 0),
'compound_idx' => array('column' => array('group2', 'group1'), 'unique' => 0),
'another_idx' => array('column' => array('group1', 'name'), 'unique' => 0))

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* DboSqlite test
* DboSqliteTest file
*
* PHP versions 4 and 5
*
@ -23,11 +23,10 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboSqlite'));
/**
* Short description for class.
* DboSqliteTestDb class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class DboSqliteTestDb extends DboSqlite {
@ -60,9 +59,9 @@ class DboSqliteTestDb extends DboSqlite {
}
}
/**
* The test class for the DboPostgres
* DboSqliteTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources.dbo
*/
class DboSqliteTest extends CakeTestCase {
@ -83,14 +82,14 @@ class DboSqliteTest extends CakeTestCase {
/**
* Actual DB connection used in testing
*
* @var object
* @var DboSource
* @access public
*/
var $db = null;
/**
* Simulated DB connection used in testing
*
* @var object
* @var DboSource
* @access public
*/
var $db2 = null;
@ -101,7 +100,7 @@ class DboSqliteTest extends CakeTestCase {
*/
function skip() {
$this->_initDb();
$this->skipif($this->db->config['driver'] != 'sqlite', 'SQLite connection not available');
$this->skipUnless($this->db->config['driver'] == 'sqlite', '%s SQLite connection not available');
}
/**
* Set up test suite database connection
@ -150,7 +149,7 @@ class DboSqliteTest extends CakeTestCase {
*
* @access public
* @return void
*/
*/
function testIndex() {
$name = $this->db->fullTableName('with_a_key');
$this->db->query('CREATE TABLE ' . $name . ' ("id" int(11) PRIMARY KEY, "bool" int(1), "small_char" varchar(50), "description" varchar(40) );');
@ -160,12 +159,12 @@ class DboSqliteTest extends CakeTestCase {
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'pointless_bool' => array('column' => 'bool', 'unique' => 0),
'char_index' => array('column' => 'small_char', 'unique' => 1),
);
$result = $this->db->index($name);
$this->assertEqual($expected, $result);
$this->db->query('DROP TABLE ' . $name);
$this->db->query('CREATE TABLE ' . $name . ' ("id" int(11) PRIMARY KEY, "bool" int(1), "small_char" varchar(50), "description" varchar(40) );');
$this->db->query('CREATE UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")');
$expected = array(
@ -176,7 +175,6 @@ class DboSqliteTest extends CakeTestCase {
$this->assertEqual($expected, $result);
$this->db->query('DROP TABLE ' . $name);
}
/**
* Tests that cached table descriptions are saved under the sanitized key name
*
@ -199,7 +197,7 @@ class DboSqliteTest extends CakeTestCase {
$db->cacheSources = false;
$fileName = '_' . preg_replace('/[^A-Za-z0-9_\-+]/', '_', TMP . $dbName) . '_list';
$result = Cache::read($fileName, '_cake_model_');
$this->assertEqual($result, array('test_list'));
@ -207,5 +205,4 @@ class DboSqliteTest extends CakeTestCase {
Configure::write('Cache.disable', true);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* DboSourceTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -30,11 +30,10 @@ if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
App::import('Core', array('Model', 'DataSource', 'DboSource', 'DboMysql'));
App::import('Model', 'App');
require_once dirname(dirname(__FILE__)) . DS . 'models.php';
/**
* Short description for class.
* TestModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class TestModel extends CakeTestModel {
@ -106,9 +105,9 @@ class TestModel extends CakeTestModel {
}
}
/**
* Short description for class.
* TestModel2 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class TestModel2 extends CakeTestModel {
@ -128,9 +127,9 @@ class TestModel2 extends CakeTestModel {
var $useTable = false;
}
/**
* Short description for class.
* TestModel4 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class TestModel3 extends CakeTestModel {
@ -150,9 +149,9 @@ class TestModel3 extends CakeTestModel {
var $useTable = false;
}
/**
* Short description for class.
* TestModel4 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class TestModel4 extends CakeTestModel {
@ -232,6 +231,12 @@ class TestModel4 extends CakeTestModel {
return $this->_schema;
}
}
/**
* TestModel4TestModel7 class
*
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class TestModel4TestModel7 extends CakeTestModel {
/**
* name property
@ -271,9 +276,9 @@ class TestModel4TestModel7 extends CakeTestModel {
}
}
/**
* Short description for class.
* TestModel5 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class TestModel5 extends CakeTestModel {
@ -338,9 +343,9 @@ class TestModel5 extends CakeTestModel {
}
}
/**
* Short description for class.
* TestModel6 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class TestModel6 extends CakeTestModel {
@ -395,9 +400,9 @@ class TestModel6 extends CakeTestModel {
}
}
/**
* Short description for class.
* TestModel7 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class TestModel7 extends CakeTestModel {
@ -441,9 +446,9 @@ class TestModel7 extends CakeTestModel {
}
}
/**
* Short description for class.
* TestModel8 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class TestModel8 extends CakeTestModel {
@ -501,9 +506,9 @@ class TestModel8 extends CakeTestModel {
}
}
/**
* Short description for class.
* TestModel9 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class TestModel9 extends CakeTestModel {
@ -1136,11 +1141,10 @@ class ArticleFeatured2 extends CakeTestModel {
return $this->_schema;
}
}
/**
* Short description for class.
* DboSourceTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model.datasources
*/
class DboSourceTest extends CakeTestCase {
@ -3135,7 +3139,7 @@ class DboSourceTest extends CakeTestCase {
'fields' => null, 'order' => null, 'recursive' => null
));
$this->assertEqual($result, $expected);
$result = $this->testDb->query('findByFindBy', array('value'), $this->Model);
$expected = array('first', array(
'conditions' => array('TestModel.find_by' => 'value'),
@ -3806,5 +3810,4 @@ class DboSourceTest extends CakeTestCase {
$this->assertNoPattern('/Took:/s', $contents);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* DbAclTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components.dbacl.models
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -27,16 +27,14 @@
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
App::import('Component', 'Acl');
App::import('Core', 'db_acl');
/**
* DB ACL wrapper test class
*
* @package cake.tests
* @subpackage cake.tests.cases.libs.controller.components
*/
* DB ACL wrapper test class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class DbAclNodeTestBase extends AclNode {
/**
* useDbConfig property
@ -53,13 +51,12 @@ class DbAclNodeTestBase extends AclNode {
*/
var $cacheSources = false;
}
/**
* Aro Test Wrapper
*
* @package cake.tests
* @subpackage cake.tests.cases.libs.controller.components
*/
* Aro Test Wrapper
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class DbAroTest extends DbAclNodeTestBase {
/**
* name property
@ -83,13 +80,12 @@ class DbAroTest extends DbAclNodeTestBase {
*/
var $hasAndBelongsToMany = array('DbAcoTest' => array('with' => 'DbPermissionTest'));
}
/**
* Aco Test Wrapper
*
* @package cake.tests
* @subpackage cake.tests.cases.libs.controller.components
*/
* Aco Test Wrapper
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class DbAcoTest extends DbAclNodeTestBase {
/**
* name property
@ -113,13 +109,12 @@ class DbAcoTest extends DbAclNodeTestBase {
*/
var $hasAndBelongsToMany = array('DbAroTest' => array('with' => 'DbPermissionTest'));
}
/**
* Permission Test Wrapper
*
* @package cake.tests
* @subpackage cake.tests.cases.libs.controller.components
*/
* Permission Test Wrapper
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class DbPermissionTest extends CakeTestModel {
/**
* name property
@ -151,11 +146,11 @@ class DbPermissionTest extends CakeTestModel {
var $belongsTo = array('DbAroTest' => array('foreignKey' => 'aro_id'), 'DbAcoTest' => array('foreignKey' => 'aco_id'));
}
/**
* Short description for class.
*
* @package cake.tests
* @subpackage cake.tests.cases.libs.controller.components
*/
* DboActionTest class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class DbAcoActionTest extends CakeTestModel {
/**
* name property
@ -180,11 +175,11 @@ class DbAcoActionTest extends CakeTestModel {
var $belongsTo = array('DbAcoTest' => array('foreignKey' => 'aco_id'));
}
/**
* Short description for class.
*
* @package cake.tests
* @subpackage cake.tests.cases.libs.controller.components
*/
* DbAroUserTest class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class DbAroUserTest extends CakeTestModel {
/**
* name property
@ -215,13 +210,12 @@ class DbAroUserTest extends CakeTestModel {
}
}
}
/**
* Short description for class.
*
* @package cake.tests
* @subpackage cake.tests.cases.libs.controller.components
*/
* DbAclTest class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller.components
*/
class DbAclTest extends DbAcl {
/**
* construct method
@ -237,9 +231,9 @@ class DbAclTest extends DbAcl {
}
}
/**
* Short description for class.
* AclNodeTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.controller.components.dbacl.models
*/
class AclNodeTest extends CakeTestCase {

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ModelTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -24,14 +24,12 @@
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Core', array('AppModel', 'Model'));
require_once dirname(__FILE__) . DS . 'models.php';
/**
* Short description for class.
* ModelTest
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ModelTest extends CakeTestCase {
@ -65,9 +63,11 @@ class ModelTest extends CakeTestCase {
'core.dependency', 'core.story', 'core.stories_tag', 'core.cd', 'core.book', 'core.basket',
'core.overall_favorite', 'core.account', 'core.content', 'core.content_account',
'core.film_file', 'core.test_plugin_article', 'core.test_plugin_comment', 'core.uuiditem',
'core.counter_cache_user', 'core.counter_cache_post', 'core.uuidportfolio',
'core.uuiditems_uuidportfolio', 'core.uuiditems_uuidportfolio_numericid',
'core.fruit', 'core.fruits_uuid_tag', 'core.uuid_tag'
'core.counter_cache_user', 'core.counter_cache_post',
'core.counter_cache_user_nonstandard_primary_key',
'core.counter_cache_post_nonstandard_primary_key', 'core.uuidportfolio',
'core.uuiditems_uuidportfolio', 'core.uuiditems_uuidportfolio_numericid', 'core.fruit',
'core.fruits_uuid_tag', 'core.uuid_tag'
);
/**
* start method
@ -90,6 +90,15 @@ class ModelTest extends CakeTestCase {
parent::end();
Configure::write('debug', $this->debug);
}
/**
* endTest method
*
* @access public
* @return void
*/
function endTest() {
ClassRegistry::flush();
}
/**
* testAutoConstructAssociations method
*
@ -956,7 +965,6 @@ class ModelTest extends CakeTestCase {
$result = $Article->read(null, 2);
$this->assertEqual($result['Article']['title'], 'Staying alive');
}
/**
* testCreationOfEmptyRecord method
*
@ -1809,10 +1817,11 @@ class ModelTest extends CakeTestCase {
/**
* Test find(count) with Db::expression
*
* @access public
* @return void
**/
*/
function testFindCountWithDbExpressions() {
if ($this->skipif($this->db->config['driver'] == 'postgres', 'testFindCountWithExpressions is not compatible with Postgres')) {
if ($this->skipIf($this->db->config['driver'] == 'postgres', '%s testFindCountWithExpressions is not compatible with Postgres')) {
return;
}
$this->loadFixtures('Project');
@ -2999,16 +3008,16 @@ class ModelTest extends CakeTestCase {
)
);
$this->assertEqual($result, $expected);
$this->loadFixtures('JoinA', 'JoinC', 'JoinAC', 'JoinB', 'JoinAB');
$TestModel = new JoinA();
$TestModel->hasBelongsToMany['JoinC']['unique'] = true;
$data = array(
'JoinA' => array(
'id' => 1,
'name' => 'Join A 1',
'body' => 'Join A 1 Body',
'name' => 'Join A 1',
'body' => 'Join A 1 Body',
),
'JoinC' => array(
'JoinC' => array(
@ -3182,7 +3191,6 @@ class ModelTest extends CakeTestCase {
Configure::write('Cache.check', $_back['check']);
Configure::write('Cache.disable', $_back['disable']);
}
/**
* testSaveAll method
*
@ -3248,12 +3256,12 @@ class ModelTest extends CakeTestCase {
$expected = array('id' => '2', 'comment_id' => '7', 'attachment' => 'some_file.tgz', 'created' => $ts, 'updated' => $ts);
$this->assertEqual($result[6]['Attachment'], $expected);
}
/**
* Test SaveAll with Habtm relations
*
* @access public
* @return void
**/
*/
function testSaveAllHabtm() {
$this->loadFixtures('Article', 'Tag', 'Comment', 'User');
$data = array(
@ -3279,10 +3287,15 @@ class ModelTest extends CakeTestCase {
$this->assertEqual(count($result['Comment']), 1);
$this->assertEqual(count($result['Comment'][0]['comment']['Article comment']), 1);
}
/**
* Test SaveAll with Habtm relations and extra join table fields
*
* @access public
* @return void
*/
function testSaveAllHabtmWithExtraJoinTableFields() {
$this->loadFixtures('Something', 'SomethingElse', 'JoinThing');
$data = array(
'Something' => array(
'id' => 4,
@ -3301,18 +3314,18 @@ class ModelTest extends CakeTestCase {
$result = $Something->saveAll($data);
$this->assertTrue($result);
$result = $Something->read();
$this->assertEqual(count($result['SomethingElse']), 3);
$this->assertTrue(Set::matches('/Something[id=4]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=1]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=1]/JoinThing[something_else_id=1]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=1]/JoinThing[doomed=1]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=2]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=2]/JoinThing[something_else_id=2]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=2]/JoinThing[doomed=0]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=3]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[something_else_id=3]', $result));
$this->assertTrue(Set::matches('/SomethingElse[id=3]/JoinThing[doomed=1]', $result));
@ -3753,7 +3766,6 @@ class ModelTest extends CakeTestCase {
);
$this->assertEqual($TestModel->validationErrors, $expected);
}
/**
* testSaveAllValidateFirst method
*
@ -3800,8 +3812,8 @@ class ModelTest extends CakeTestCase {
$model->deleteAll(true);
$data = array(
'Article' => array(
'title' => 'Post with Author saveAlled from comment',
'body' => 'This post will be saved with an author',
'title' => 'Post with Author saveAlled from comment',
'body' => 'This post will be saved with an author',
'user_id' => 2
),
'Comment' => array(
@ -3810,7 +3822,7 @@ class ModelTest extends CakeTestCase {
);
$result = $model->Comment->saveAll($data, array('validate' => 'first'));
$this->assertTrue($result);
$result = $model->find('all');
$this->assertEqual($result[0]['Article']['title'], 'Post with Author saveAlled from comment');
$this->assertEqual($result[0]['Comment'][0]['comment'], 'Only new comment');
@ -3866,7 +3878,6 @@ class ModelTest extends CakeTestCase {
$result = $user[$User->alias]['post_count'];
$expected = 3;
$this->assertEqual($result, $expected);
}
/**
* Tests that counter caches are updated when records are deleted
@ -3909,6 +3920,32 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($users[0]['User']['post_count'], 1);
$this->assertEqual($users[1]['User']['post_count'], 2);
}
/**
* Test counter cache with models that use a non-standard (i.e. not using 'id')
* as their primary key.
*
* @access public
* @return void
*/
function testCounterCacheWithNonstandardPrimaryKey() {
$this->loadFixtures(
'CounterCacheUserNonstandardPrimaryKey',
'CounterCachePostNonstandardPrimaryKey'
);
$User = new CounterCacheUserNonstandardPrimaryKey();
$Post = new CounterCachePostNonstandardPrimaryKey();
$data = $Post->find('first', array(
'conditions' => array('pid' => 1),'recursive' => -1
));
$data[$Post->alias]['uid'] = 301;
$Post->save($data);
$users = $User->find('all',array('order' => 'User.uid'));
$this->assertEqual($users[0]['User']['post_count'], 1);
$this->assertEqual($users[1]['User']['post_count'], 2);
}
/**
* test Counter Cache With Self Joining table
*
@ -3929,7 +3966,6 @@ class ModelTest extends CakeTestCase {
$expected = array_fill(0, 1, 1);
$this->assertEqual($result, $expected);
}
/**
* testSaveWithCounterCacheScope method
*
@ -3954,6 +3990,10 @@ class ModelTest extends CakeTestCase {
$TestModel2->saveField('published', true);
$result = $TestModel->findById(1);
$this->assertIdentical($result['Syfile']['item_count'], '2');
$TestModel2->save(array('id' => 1, 'syfile_id' => 1, 'published'=> false));
$result = $TestModel->findById(1);
$this->assertIdentical($result['Syfile']['item_count'], '1');
}
/**
* testDel method
@ -3991,6 +4031,36 @@ class ModelTest extends CakeTestCase {
array('Article' => array('id' => 1, 'title' => 'First Article' ))
);
$this->assertEqual($result, $expected);
// make sure deleting a non-existent record doesn't break save()
// ticket #6293
$this->loadFixtures('Uuid');
$Uuid =& new Uuid();
$data = array(
'B607DAB9-88A2-46CF-B57C-842CA9E3B3B3',
'52C8865C-10EE-4302-AE6C-6E7D8E12E2C8',
'8208C7FE-E89C-47C5-B378-DED6C271F9B8');
foreach ($data as $id) {
$Uuid->save(array('id' => $id));
}
$Uuid->del('52C8865C-10EE-4302-AE6C-6E7D8E12E2C8');
$Uuid->del('52C8865C-10EE-4302-AE6C-6E7D8E12E2C8');
foreach ($data as $id) {
$Uuid->save(array('id' => $id));
}
$result = $Uuid->find('all', array(
'conditions' => array('id' => $data),
'fields' => array('id'),
'order' => 'id'));
$expected = array(
array('Uuid' => array(
'id' => '52C8865C-10EE-4302-AE6C-6E7D8E12E2C8')),
array('Uuid' => array(
'id' => '8208C7FE-E89C-47C5-B378-DED6C271F9B8')),
array('Uuid' => array(
'id' => 'B607DAB9-88A2-46CF-B57C-842CA9E3B3B3')));
$this->assertEqual($result, $expected);
}
/**
* testDeleteAll method
@ -4786,9 +4856,8 @@ class ModelTest extends CakeTestCase {
$expected = $TestModel->save($data);
$this->assertFalse($expected);
}
// function testBasicValidation() {
// $TestModel =& new ValidationTest();
// $TestModel =& new ValidationTest1();
// $TestModel->testing = true;
// $TestModel->set(array('title' => '', 'published' => 1));
// $this->assertEqual($TestModel->invalidFields(), array('title' => 'This field cannot be left blank'));
@ -4929,7 +4998,7 @@ class ModelTest extends CakeTestCase {
* @return void
*/
function testMultipleValidation() {
$TestModel =& new ValidationTest();
$TestModel =& new ValidationTest1();
}
/**
* Tests validation parameter order in custom validation methods
@ -4938,7 +5007,7 @@ class ModelTest extends CakeTestCase {
* @return void
*/
function testValidationParams() {
$TestModel =& new ValidationTest();
$TestModel =& new ValidationTest1();
$TestModel->validate['title'] = array('rule' => 'customValidatorWithParams', 'required' => true);
$TestModel->create(array('title' => 'foo'));
$TestModel->invalidFields();
@ -4965,7 +5034,7 @@ class ModelTest extends CakeTestCase {
* @return void
*/
function testInvalidFieldsWithFieldListParams() {
$TestModel =& new ValidationTest();
$TestModel =& new ValidationTest1();
$TestModel->validate = $validate = array(
'title' => array('rule' => 'customValidator', 'required' => true),
'name' => array('rule' => 'allowEmpty', 'required' => true),
@ -4983,6 +5052,13 @@ class ModelTest extends CakeTestCase {
$TestModel->invalidFields(array('fieldList' => array('name', 'title')));
$expected = array('name' => 'This field cannot be left blank', 'title' => 'This field cannot be left blank');
$this->assertEqual($TestModel->validationErrors, $expected);
$TestModel->validationErrors = array();
$TestModel->whitelist = array('name');
$TestModel->invalidFields();
$expected = array('name' => 'This field cannot be left blank');
$this->assertEqual($TestModel->validationErrors, $expected);
$TestModel->validationErrors = array();
$this->assertEqual($TestModel->validate, $validate);
}
@ -4993,10 +5069,10 @@ class ModelTest extends CakeTestCase {
* @return void
*/
function testAllowSimulatedFields() {
$TestModel =& new ValidationTest();
$TestModel =& new ValidationTest1();
$TestModel->create(array('title' => 'foo', 'bar' => 'baz'));
$expected = array('ValidationTest' => array('title' => 'foo', 'bar' => 'baz'));
$expected = array('ValidationTest1' => array('title' => 'foo', 'bar' => 'baz'));
$this->assertEqual($TestModel->data, $expected);
}
/**
@ -5006,7 +5082,7 @@ class ModelTest extends CakeTestCase {
* @return void
*/
function testInvalidAssociation() {
$TestModel =& new ValidationTest();
$TestModel =& new ValidationTest1();
$this->assertNull($TestModel->getAssociated('Foo'));
}
/**
@ -5519,7 +5595,7 @@ class ModelTest extends CakeTestCase {
function testZeroDefaultFieldValue() {
$this->skipIf(
$this->db->config['driver'] == 'sqlite',
'SQLite uses loose typing, this operation is unsupported'
'%s SQLite uses loose typing, this operation is unsupported'
);
$this->loadFixtures('DataTest');
$TestModel =& new DataTest();
@ -5530,7 +5606,6 @@ class ModelTest extends CakeTestCase {
$this->assertIdentical($result['DataTest']['count'], '0');
$this->assertIdentical($result['DataTest']['float'], '0');
}
/**
* testNonNumericHabtmJoinKey method
*
@ -5820,7 +5895,6 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($db2->fullTableName($TestModel, false), 'apples');
$this->assertEqual($db1->fullTableName($TestModel, false), 'apples');
}
/**
* testDynamicBehaviorAttachment method
*
@ -5851,7 +5925,6 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($TestModel->Behaviors->attached(), array());
$this->assertFalse(isset($TestModel->Behaviors->Tree));
}
/**
* Tests cross database joins. Requires $test and $test2 to both be set in DATABASE_CONFIG
* NOTE: When testing on MySQL, you must set 'persistent' => false on *both* database connections,
@ -6151,7 +6224,7 @@ class ModelTest extends CakeTestCase {
function testGroupBy() {
$db = ConnectionManager::getDataSource('test_suite');
$isStrictGroupBy = in_array($db->config['driver'], array('postgres', 'oracle'));
if ($this->skipif($isStrictGroupBy, 'Postgresql and Oracle have strict GROUP BY and are incompatible with this test.')) {
if ($this->skipIf($isStrictGroupBy, '%s Postgresql and Oracle have strict GROUP BY and are incompatible with this test.')) {
return;
}
@ -6470,7 +6543,12 @@ class ModelTest extends CakeTestCase {
$result = $Portfolio->ItemsPortfolio->find('all', array('conditions' => array('ItemsPortfolio.portfolio_id' => 1)));
$this->assertFalse($result);
}
/**
* testDeleteArticleBLinks method
*
* @access public
* @return void
*/
function testDeleteArticleBLinks() {
$this->loadFixtures('Article', 'ArticlesTag', 'Tag');
$TestModel =& new ArticleB();
@ -6493,21 +6571,16 @@ class ModelTest extends CakeTestCase {
);
$this->assertEqual($result, $expected);
}
/**
* testPkInHAbtmLinkModelArticleB
*
* @access public
* @return void
*/
function testPkInHabtmLinkModelArticleB() {
$this->loadFixtures('Article', 'Tag');
$TestModel2 =& new ArticleB();
$this->assertEqual($TestModel2->ArticlesTag->primaryKey, 'article_id');
}
/**
* endTest method
*
* @access public
* @return void
*/
function endTest() {
ClassRegistry::flush();
}
}
?>
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Mock models
* Mock models file
*
* Mock classes for use in Model and related test cases
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
* @since CakePHP(tm) v 1.2.0.6464
* @version $Revision$
@ -27,11 +27,10 @@
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
}
/**
* Test class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Test extends CakeTestModel {
@ -67,7 +66,7 @@ class Test extends CakeTestModel {
/**
* TestAlias class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TestAlias extends CakeTestModel {
@ -110,7 +109,7 @@ class TestAlias extends CakeTestModel {
/**
* TestValidate class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TestValidate extends CakeTestModel {
@ -169,7 +168,7 @@ class TestValidate extends CakeTestModel {
/**
* User class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class User extends CakeTestModel {
@ -191,7 +190,7 @@ class User extends CakeTestModel {
/**
* Article class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Article extends CakeTestModel {
@ -263,7 +262,7 @@ class Article extends CakeTestModel {
/**
* NumericArticle class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class NumericArticle extends CakeTestModel {
@ -285,7 +284,7 @@ class NumericArticle extends CakeTestModel {
/**
* Article10 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Article10 extends CakeTestModel {
@ -314,7 +313,7 @@ class Article10 extends CakeTestModel {
/**
* ArticleFeatured class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ArticleFeatured extends CakeTestModel {
@ -364,7 +363,7 @@ class ArticleFeatured extends CakeTestModel {
/**
* Featured class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Featured extends CakeTestModel {
@ -386,7 +385,7 @@ class Featured extends CakeTestModel {
/**
* Tag class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Tag extends CakeTestModel {
@ -401,7 +400,7 @@ class Tag extends CakeTestModel {
/**
* ArticlesTag class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ArticlesTag extends CakeTestModel {
@ -416,7 +415,7 @@ class ArticlesTag extends CakeTestModel {
/**
* ArticleFeaturedsTag class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ArticleFeaturedsTag extends CakeTestModel {
@ -431,7 +430,7 @@ class ArticleFeaturedsTag extends CakeTestModel {
/**
* Comment class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Comment extends CakeTestModel {
@ -460,7 +459,7 @@ class Comment extends CakeTestModel {
/**
* Modified Comment Class has afterFind Callback
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ModifiedComment extends CakeTestModel {
@ -501,7 +500,7 @@ class ModifiedComment extends CakeTestModel {
/**
* MergeVarPluginAppModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class MergeVarPluginAppModel extends AppModel {
@ -517,7 +516,7 @@ class MergeVarPluginAppModel extends AppModel {
/**
* MergeVarPluginPost class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class MergeVarPluginPost extends MergeVarPluginAppModel {
@ -539,7 +538,7 @@ class MergeVarPluginPost extends MergeVarPluginAppModel {
/**
* MergeVarPluginComment class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class MergeVarPluginComment extends MergeVarPluginAppModel {
@ -563,7 +562,7 @@ class MergeVarPluginComment extends MergeVarPluginAppModel {
/**
* Attachment class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Attachment extends CakeTestModel {
@ -578,7 +577,7 @@ class Attachment extends CakeTestModel {
/**
* Category class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Category extends CakeTestModel {
@ -593,7 +592,7 @@ class Category extends CakeTestModel {
/**
* CategoryThread class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class CategoryThread extends CakeTestModel {
@ -615,7 +614,7 @@ class CategoryThread extends CakeTestModel {
/**
* Apple class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Apple extends CakeTestModel {
@ -658,7 +657,7 @@ class Apple extends CakeTestModel {
/**
* Sample class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Sample extends CakeTestModel {
@ -680,7 +679,7 @@ class Sample extends CakeTestModel {
/**
* AnotherArticle class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class AnotherArticle extends CakeTestModel {
@ -702,7 +701,7 @@ class AnotherArticle extends CakeTestModel {
/**
* Advertisement class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Advertisement extends CakeTestModel {
@ -724,7 +723,7 @@ class Advertisement extends CakeTestModel {
/**
* Home class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Home extends CakeTestModel {
@ -746,7 +745,7 @@ class Home extends CakeTestModel {
/**
* Post class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Post extends CakeTestModel {
@ -768,7 +767,7 @@ class Post extends CakeTestModel {
/**
* Author class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Author extends CakeTestModel {
@ -801,7 +800,7 @@ class Author extends CakeTestModel {
/**
* ModifiedAuthor class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ModifiedAuthor extends Author {
@ -829,7 +828,7 @@ class ModifiedAuthor extends Author {
/**
* Project class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Project extends CakeTestModel {
@ -851,7 +850,7 @@ class Project extends CakeTestModel {
/**
* Thread class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Thread extends CakeTestModel {
@ -880,7 +879,7 @@ class Thread extends CakeTestModel {
/**
* Message class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Message extends CakeTestModel {
@ -902,7 +901,7 @@ class Message extends CakeTestModel {
/**
* Bid class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Bid extends CakeTestModel {
@ -924,7 +923,7 @@ class Bid extends CakeTestModel {
/**
* NodeAfterFind class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class NodeAfterFind extends CakeTestModel {
@ -984,7 +983,7 @@ class NodeAfterFind extends CakeTestModel {
/**
* NodeAfterFindSample class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class NodeAfterFindSample extends CakeTestModel {
@ -1013,7 +1012,7 @@ class NodeAfterFindSample extends CakeTestModel {
/**
* NodeNoAfterFind class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class NodeNoAfterFind extends CakeTestModel {
@ -1063,7 +1062,7 @@ class NodeNoAfterFind extends CakeTestModel {
/**
* Node class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Node extends CakeTestModel{
@ -1093,7 +1092,7 @@ class Node extends CakeTestModel{
/**
* Dependency class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Dependency extends CakeTestModel {
@ -1108,7 +1107,7 @@ class Dependency extends CakeTestModel {
/**
* ModelA class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ModelA extends CakeTestModel {
@ -1137,7 +1136,7 @@ class ModelA extends CakeTestModel {
/**
* ModelB class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ModelB extends CakeTestModel {
@ -1166,7 +1165,7 @@ class ModelB extends CakeTestModel {
/**
* ModelC class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ModelC extends CakeTestModel {
@ -1195,7 +1194,7 @@ class ModelC extends CakeTestModel {
/**
* ModelD class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ModelD extends CakeTestModel {
@ -1217,7 +1216,7 @@ class ModelD extends CakeTestModel {
/**
* Something class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Something extends CakeTestModel {
@ -1239,7 +1238,7 @@ class Something extends CakeTestModel {
/**
* SomethingElse class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class SomethingElse extends CakeTestModel {
@ -1261,7 +1260,7 @@ class SomethingElse extends CakeTestModel {
/**
* JoinThing class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class JoinThing extends CakeTestModel {
@ -1283,7 +1282,7 @@ class JoinThing extends CakeTestModel {
/**
* Portfolio class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Portfolio extends CakeTestModel {
@ -1305,7 +1304,7 @@ class Portfolio extends CakeTestModel {
/**
* Item class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Item extends CakeTestModel {
@ -1334,7 +1333,7 @@ class Item extends CakeTestModel {
/**
* ItemsPortfolio class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ItemsPortfolio extends CakeTestModel {
@ -1349,7 +1348,7 @@ class ItemsPortfolio extends CakeTestModel {
/**
* Syfile class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Syfile extends CakeTestModel {
@ -1371,7 +1370,7 @@ class Syfile extends CakeTestModel {
/**
* Image class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Image extends CakeTestModel {
@ -1386,7 +1385,7 @@ class Image extends CakeTestModel {
/**
* DeviceType class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class DeviceType extends CakeTestModel {
@ -1426,7 +1425,7 @@ class DeviceType extends CakeTestModel {
/**
* DeviceTypeCategory class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class DeviceTypeCategory extends CakeTestModel {
@ -1441,7 +1440,7 @@ class DeviceTypeCategory extends CakeTestModel {
/**
* FeatureSet class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class FeatureSet extends CakeTestModel {
@ -1456,7 +1455,7 @@ class FeatureSet extends CakeTestModel {
/**
* ExteriorTypeCategory class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ExteriorTypeCategory extends CakeTestModel {
@ -1478,7 +1477,7 @@ class ExteriorTypeCategory extends CakeTestModel {
/**
* Document class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Document extends CakeTestModel {
@ -1500,7 +1499,7 @@ class Document extends CakeTestModel {
/**
* Device class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Device extends CakeTestModel {
@ -1515,7 +1514,7 @@ class Device extends CakeTestModel {
/**
* DocumentDirectory class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class DocumentDirectory extends CakeTestModel {
@ -1530,7 +1529,7 @@ class DocumentDirectory extends CakeTestModel {
/**
* PrimaryModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class PrimaryModel extends CakeTestModel {
@ -1545,7 +1544,7 @@ class PrimaryModel extends CakeTestModel {
/**
* SecondaryModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class SecondaryModel extends CakeTestModel {
@ -1560,7 +1559,7 @@ class SecondaryModel extends CakeTestModel {
/**
* JoinA class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class JoinA extends CakeTestModel {
@ -1582,7 +1581,7 @@ class JoinA extends CakeTestModel {
/**
* JoinB class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class JoinB extends CakeTestModel {
@ -1604,7 +1603,7 @@ class JoinB extends CakeTestModel {
/**
* JoinC class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class JoinC extends CakeTestModel {
@ -1626,7 +1625,7 @@ class JoinC extends CakeTestModel {
/**
* ThePaper class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ThePaper extends CakeTestModel {
@ -1662,7 +1661,7 @@ class ThePaper extends CakeTestModel {
/**
* Monkey class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Monkey extends CakeTestModel {
@ -1684,7 +1683,7 @@ class Monkey extends CakeTestModel {
/**
* AssociationTest1 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class AssociationTest1 extends CakeTestModel {
@ -1715,7 +1714,7 @@ class AssociationTest1 extends CakeTestModel {
/**
* AssociationTest2 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class AssociationTest2 extends CakeTestModel {
@ -1746,7 +1745,7 @@ class AssociationTest2 extends CakeTestModel {
/**
* Callback class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Callback extends CakeTestModel {
@ -1755,7 +1754,7 @@ class Callback extends CakeTestModel {
/**
* Uuid class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Uuid extends CakeTestModel {
@ -1770,7 +1769,7 @@ class Uuid extends CakeTestModel {
/**
* DataTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class DataTest extends CakeTestModel {
@ -1785,7 +1784,7 @@ class DataTest extends CakeTestModel {
/**
* TheVoid class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TheVoid extends CakeTestModel {
@ -1805,19 +1804,19 @@ class TheVoid extends CakeTestModel {
var $useTable = false;
}
/**
* ValidationTest class
* ValidationTest1 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ValidationTest extends CakeTestModel {
class ValidationTest1 extends CakeTestModel {
/**
* name property
*
* @var string 'ValidationTest'
* @access public
*/
var $name = 'ValidationTest';
var $name = 'ValidationTest1';
/**
* useTable property
*
@ -1880,7 +1879,7 @@ class ValidationTest extends CakeTestModel {
/**
* ValidationTest2 class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ValidationTest2 extends CakeTestModel {
@ -1936,7 +1935,7 @@ class ValidationTest2 extends CakeTestModel {
/**
* Person class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Person extends CakeTestModel {
@ -1964,7 +1963,7 @@ class Person extends CakeTestModel {
/**
* UnderscoreField class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class UnderscoreField extends CakeTestModel {
@ -1979,7 +1978,7 @@ class UnderscoreField extends CakeTestModel {
/**
* Product class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Product extends CakeTestModel {
@ -1994,7 +1993,7 @@ class Product extends CakeTestModel {
/**
* Story class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Story extends CakeTestModel {
@ -2030,7 +2029,7 @@ class Story extends CakeTestModel {
/**
* Cd class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Cd extends CakeTestModel {
@ -2052,7 +2051,7 @@ class Cd extends CakeTestModel {
/**
* Book class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Book extends CakeTestModel {
@ -2074,7 +2073,7 @@ class Book extends CakeTestModel {
/**
* OverallFavorite class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class OverallFavorite extends CakeTestModel {
@ -2089,7 +2088,7 @@ class OverallFavorite extends CakeTestModel {
/**
* MyUser class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class MyUser extends CakeTestModel {
@ -2111,7 +2110,7 @@ class MyUser extends CakeTestModel {
/**
* MyCategory class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class MyCategory extends CakeTestModel {
@ -2133,7 +2132,7 @@ class MyCategory extends CakeTestModel {
/**
* MyProduct class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class MyProduct extends CakeTestModel {
@ -2155,7 +2154,7 @@ class MyProduct extends CakeTestModel {
/**
* MyCategoriesMyUser class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class MyCategoriesMyUser extends CakeTestModel {
@ -2170,7 +2169,7 @@ class MyCategoriesMyUser extends CakeTestModel {
/**
* MyCategoriesMyProduct class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class MyCategoriesMyProduct extends CakeTestModel {
@ -2185,7 +2184,7 @@ class MyCategoriesMyProduct extends CakeTestModel {
/**
* I18nModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class I18nModel extends CakeTestModel {
@ -2214,7 +2213,7 @@ class I18nModel extends CakeTestModel {
/**
* NumberTree class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class NumberTree extends CakeTestModel {
@ -2277,7 +2276,7 @@ class NumberTree extends CakeTestModel {
/**
* FlagTree class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class FlagTree extends NumberTree {
@ -2292,7 +2291,7 @@ class FlagTree extends NumberTree {
/**
* UnconventionalTree class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class UnconventionalTree extends NumberTree {
@ -2314,7 +2313,7 @@ class UnconventionalTree extends NumberTree {
/**
* UuidTree class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class UuidTree extends NumberTree {
@ -2330,7 +2329,7 @@ class UuidTree extends NumberTree {
/**
* Campaign class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Campaign extends CakeTestModel {
@ -2352,7 +2351,7 @@ class Campaign extends CakeTestModel {
/**
* Ad class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Ad extends CakeTestModel {
@ -2381,7 +2380,7 @@ class Ad extends CakeTestModel {
/**
* AfterTree class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class AfterTree extends NumberTree {
@ -2409,7 +2408,7 @@ class AfterTree extends NumberTree {
/**
* Nonconformant Content class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Content extends CakeTestModel {
@ -2445,7 +2444,7 @@ class Content extends CakeTestModel {
/**
* Nonconformant Account class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Account extends CakeTestModel {
@ -2474,7 +2473,7 @@ class Account extends CakeTestModel {
/**
* Nonconformant ContentAccount class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class ContentAccount extends CakeTestModel {
@ -2503,7 +2502,7 @@ class ContentAccount extends CakeTestModel {
/**
* FilmFile class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class FilmFile extends CakeTestModel {
@ -2512,7 +2511,7 @@ class FilmFile extends CakeTestModel {
/**
* Basket test model
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Basket extends CakeTestModel {
@ -2531,7 +2530,7 @@ class Basket extends CakeTestModel {
/**
* TestPluginArticle class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TestPluginArticle extends CakeTestModel {
@ -2566,7 +2565,7 @@ class TestPluginArticle extends CakeTestModel {
/**
* TestPluginComment class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TestPluginComment extends CakeTestModel {
@ -2594,7 +2593,7 @@ class TestPluginComment extends CakeTestModel {
/**
* Uuidportfolio class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Uuidportfolio extends CakeTestModel {
@ -2616,7 +2615,7 @@ class Uuidportfolio extends CakeTestModel {
/**
* Uuiditem class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class Uuiditem extends CakeTestModel {
@ -2641,7 +2640,7 @@ class Uuiditem extends CakeTestModel {
/**
* UuiditemsPortfolio class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class UuiditemsUuidportfolio extends CakeTestModel {
@ -2656,7 +2655,7 @@ class UuiditemsUuidportfolio extends CakeTestModel {
/**
* UuiditemsPortfolioNumericid class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class UuiditemsUuidportfolioNumericid extends CakeTestModel {
@ -2671,7 +2670,7 @@ class UuiditemsUuidportfolioNumericid extends CakeTestModel {
/**
* TranslateTestModel class.
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TranslateTestModel extends CakeTestModel {
@ -2700,7 +2699,7 @@ class TranslateTestModel extends CakeTestModel {
/**
* TranslatedItem class.
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TranslatedItem extends CakeTestModel {
@ -2736,7 +2735,7 @@ class TranslatedItem extends CakeTestModel {
/**
* TranslatedItemWithTable class.
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TranslatedItemWithTable extends CakeTestModel {
@ -2786,7 +2785,7 @@ class TranslatedItemWithTable extends CakeTestModel {
/**
* TranslateArticleModel class.
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TranslateArticleModel extends CakeTestModel {
@ -2815,7 +2814,7 @@ class TranslateArticleModel extends CakeTestModel {
/**
* TranslatedArticle class.
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TranslatedArticle extends CakeTestModel {
@ -2859,7 +2858,6 @@ class TranslatedArticle extends CakeTestModel {
class CounterCacheUser extends CakeTestModel {
var $name = 'CounterCacheUser';
var $alias = 'User';
var $fixture = 'counter_cache_user';
var $hasMany = array('Post' => array(
'className' => 'CounterCachePost',
@ -2870,7 +2868,6 @@ class CounterCacheUser extends CakeTestModel {
class CounterCachePost extends CakeTestModel {
var $name = 'CounterCachePost';
var $alias = 'Post';
var $fixture = 'counter_cache_user';
var $belongsTo = array('User' => array(
'className' => 'CounterCacheUser',
@ -2879,6 +2876,29 @@ class CounterCachePost extends CakeTestModel {
));
}
class CounterCacheUserNonstandardPrimaryKey extends CakeTestModel {
var $name = 'CounterCacheUserNonstandardPrimaryKey';
var $alias = 'User';
var $primaryKey = 'uid';
var $hasMany = array('Post' => array(
'className' => 'CounterCachePostNonstandardPrimaryKey',
'foreignKey' => 'uid'
));
}
class CounterCachePostNonstandardPrimaryKey extends CakeTestModel {
var $name = 'CounterCachePostNonstandardPrimaryKey';
var $alias = 'Post';
var $primaryKey = 'pid';
var $belongsTo = array('User' => array(
'className' => 'CounterCacheUserNonstandardPrimaryKey',
'foreignKey' => 'uid',
'counterCache' => true
));
}
class ArticleB extends CakeTestModel {
var $name = 'ArticleB';
var $useTable = 'articles';

View file

@ -15,7 +15,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5550
* @version $Revision$
@ -24,11 +24,10 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Core', 'Schema');
/**
* Test for Schema database management
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class MyAppSchema extends CakeSchema {
@ -102,7 +101,7 @@ class MyAppSchema extends CakeSchema {
/**
* TestAppSchema class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class TestAppSchema extends CakeSchema {
@ -200,9 +199,9 @@ class TestAppSchema extends CakeSchema {
}
}
/**
* Short description for class.
* SchmeaPost class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class SchemaPost extends CakeTestModel {
@ -234,12 +233,11 @@ class SchemaPost extends CakeTestModel {
* @access public
*/
var $hasAndBelongsToMany = array('SchemaTag');
}
/**
* Short description for class.
* SchemaComment class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class SchemaComment extends CakeTestModel {
@ -266,9 +264,9 @@ class SchemaComment extends CakeTestModel {
var $belongsTo = array('SchemaPost');
}
/**
* Short description for class.
* SchemaTag class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class SchemaTag extends CakeTestModel {
@ -295,9 +293,9 @@ class SchemaTag extends CakeTestModel {
var $hasAndBelongsToMany = array('SchemaPost');
}
/**
* Short description for class.
* SchemaDatatype class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs.model
*/
class SchemaDatatype extends CakeTestModel {
@ -319,8 +317,9 @@ class SchemaDatatype extends CakeTestModel {
/**
* Testdescribe class
*
* This class is defined purely to inherit the cacheSources variable otherwise testSchemaCreatTable will fail if
* listSources has already been called and its source cache populated - I.e. if the test is run within a group
* This class is defined purely to inherit the cacheSources variable otherwise
* testSchemaCreatTable will fail if listSources has already been called and
* its source cache populated - I.e. if the test is run within a group
*
* @uses CakeTestModel
* @package
@ -336,9 +335,9 @@ class Testdescribe extends CakeTestModel {
var $name = 'Testdescribe';
}
/**
* Short description for class.
* CakeSchemaTest
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class CakeSchemaTest extends CakeTestCase {
@ -358,6 +357,15 @@ class CakeSchemaTest extends CakeTestCase {
function startTest() {
$this->Schema = new TestAppSchema();
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Schema);
}
/**
* testSchemaName method
*
@ -471,7 +479,7 @@ class CakeSchemaTest extends CakeTestCase {
function testSchemaCreateTable() {
$db =& ConnectionManager::getDataSource('test_suite');
$db->cacheSources = false;
$Schema =& new CakeSchema(array(
'connection' => 'test_suite',
'testdescribes' => array(
@ -481,25 +489,16 @@ class CakeSchemaTest extends CakeTestCase {
),
));
$sql = $db->createSchema($Schema);
$col = $Schema->tables['testdescribes']['int_null'];
$col['name'] = 'int_null';
$column = $this->db->buildColumn($col);
$this->assertPattern('/' . preg_quote($column, '/') . '/', $sql);
$col = $Schema->tables['testdescribes']['int_not_null'];
$col['name'] = 'int_not_null';
$column = $this->db->buildColumn($col);
$this->assertPattern('/' . preg_quote($column, '/') . '/', $sql);
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Schema);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* MultibyteTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.6833
* @version $Revision$
@ -26,9 +26,9 @@
*/
App::import('Core', 'Multibyte');
/**
* Short description for class.
* MultibyteTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class MultibyteTest extends CakeTestCase {

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* ObjectTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -117,6 +117,37 @@ class RequestActionController extends Controller {
return $this->params;
}
}
/**
* RequestActionPersistentController class
*
* @package cake
* @subpackage cake.tests.cases.libs
*/
class RequestActionPersistentController extends Controller {
/**
* uses property
*
* @var array
* @access public
*/
var $uses = array('PersisterOne');
/**
* persistModel property
*
* @var array
* @access public
*/
var $persistModel = true;
/**
* post pass, testing post passing
*
* @return array
**/
function index() {
return 'This is a test';
}
}
/**
* TestObject class
*
@ -240,7 +271,6 @@ class TestObject extends Object {
function methodWithOptionalParam($param = null) {
$this->methodCalls[] = array('methodWithOptionalParam' => array($param));
}
/**
* testPersist
*
@ -250,24 +280,20 @@ class TestObject extends Object {
return $this->_persist($name, $return, $object, $type);
}
}
/**
* ObjectTestModel
* ObjectTestModel class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class ObjectTestModel extends CakeTestModel {
var $useTable = false;
var $name = 'ObjectTestModel';
}
/**
* Object Test Class
* Object Test class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class ObjectTest extends CakeTestCase {
@ -276,7 +302,7 @@ class ObjectTest extends CakeTestCase {
*
* @var string
**/
var $fixtures = array('core.post');
var $fixtures = array('core.post', 'core.comment');
/**
* setUp method
*
@ -286,6 +312,15 @@ class ObjectTest extends CakeTestCase {
function setUp() {
$this->object = new TestObject();
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->object);
}
/**
* testLog method
*
@ -378,6 +413,104 @@ class ObjectTest extends CakeTestCase {
Configure::write('Cache.disable', $cacheDisable);
}
/**
* testPersistWithRequestAction method
*
* @access public
* @return void
*/
function testPersistWithBehavior() {
ClassRegistry::flush();
$cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
Configure::write('modelPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS));
Configure::write('behaviorPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS));
$this->assertFalse(class_exists('PersisterOneBehaviorBehavior'));
$this->assertFalse(class_exists('PersisterTwoBehaviorBehavior'));
$Controller = new RequestActionPersistentController();
$Controller->persistModel = true;
$Controller->constructClasses();
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisterone.php'));
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisteroneregistry.php'));
$contents = str_replace('"PersisterOne"', '"PersisterTwo"', file_get_contents(CACHE . 'persistent' . DS . 'persisteroneregistry.php'));
$contents = str_replace('persister_one_', 'persister_two_', file_get_contents(CACHE . 'persistent' . DS . 'persisteroneregistry.php'));
$result = file_put_contents(CACHE . 'persistent' . DS . 'persisteroneregistry.php', $contents);
$this->assertTrue(class_exists('PersisterOneBehaviorBehavior'));
$this->assertFalse(class_exists('PersisterTwoBehaviorBehavior'));
$Controller = new RequestActionPersistentController();
$Controller->persistModel = true;
$Controller->constructClasses();
$this->assertTrue(class_exists('PersisterOneBehaviorBehavior'));
$this->assertTrue(class_exists('PersisterTwoBehaviorBehavior'));
@unlink(CACHE . 'persistent' . DS . 'persisterone.php');
@unlink(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
}
/**
* testPersistWithBehaviorAndRequestAction method
*
* @see testPersistWithBehavior
* @access public
* @return void
*/
function testPersistWithBehaviorAndRequestAction() {
ClassRegistry::flush();
$cacheDisable = Configure::read('Cache.disable');
Configure::write('Cache.disable', false);
$this->assertFalse(class_exists('ContainableBehavior'));
Configure::write('modelPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS));
Configure::write('behaviorPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models'. DS . 'behaviors' . DS));
$this->assertFalse(class_exists('PersistOneBehaviorBehavior'));
$this->assertFalse(class_exists('PersistTwoBehaviorBehavior'));
$Controller = new RequestActionPersistentController();
$Controller->persistModel = true;
$Controller->constructClasses();
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisterone.php'));
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisteroneregistry.php'));
$keys = ClassRegistry::keys();
$this->assertEqual($keys, array('persister_one', 'comment', 'persister_one_behavior_behavior'));
ob_start();
$Controller->set('content_for_layout', 'cool');
$Controller->render('index', 'ajax', '/layouts/ajax');
$result = ob_get_clean();
$keys = ClassRegistry::keys();
$this->assertEqual($keys, array('persister_one', 'comment', 'persister_one_behavior_behavior', 'view'));
$result = $this->object->requestAction('/request_action_persistent/index');
$expected = 'This is a test';
$this->assertEqual($result, $expected);
@unlink(CACHE . 'persistent' . DS . 'persisterone.php');
@unlink(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
$Controller = new RequestActionPersistentController();
$Controller->persistModel = true;
$Controller->constructClasses();
@unlink(CACHE . 'persistent' . DS . 'persisterone.php');
@unlink(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
Configure::write('Cache.disable', $cacheDisable);
}
/**
* testToString method
*
* @access public
@ -593,7 +726,6 @@ class ObjectTest extends CakeTestCase {
$_POST = $_tmp;
}
/**
* testCakeError
*
@ -602,14 +734,5 @@ class ObjectTest extends CakeTestCase {
function testCakeError() {
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->object);
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* OverloadableTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -26,9 +26,9 @@
*/
App::import('Core', 'Overloadable');
/**
* Short description for class.
* OverloadableTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class OverloadableTest extends CakeTestCase {
@ -39,7 +39,7 @@ class OverloadableTest extends CakeTestCase {
* @return void
*/
function skip() {
$this->skipif (true, 'OverloadableTest not implemented');
$this->skipIf(true, ' %s OverloadableTest not implemented');
}
}
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* RouterTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -29,11 +29,10 @@ App::import('Core', array('Router', 'Debugger'));
if (!defined('FULL_BASE_URL')) {
define('FULL_BASE_URL', 'http://cakephp.org');
}
/**
* Short description for class.
* RouterTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class RouterTest extends CakeTestCase {
@ -1317,9 +1316,18 @@ class RouterTest extends CakeTestCase {
$expected = '/others/edit/1';
$this->assertEqual($result, $expected);
$result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true));;
$result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true));
$expected = '/protected/others/edit/1';
$this->assertEqual($result, $expected);
$result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1));
$expected = '/protected/others/edit/1/page:1';
$this->assertEqual($result, $expected);
Router::connectNamed(array('random'));
$result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value'));
$expected = '/protected/others/edit/1/random:my-value';
$this->assertEqual($result, $expected);
}
/**
* testRemoveBase method
@ -1494,7 +1502,6 @@ class RouterTest extends CakeTestCase {
$expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'index');
$this->assertEqual($result, $expected);
}
/**
* Tests URL generation with flags and prefixes in and out of context
*

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* SanitizeTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5428
* @version $Revision$
@ -70,9 +70,9 @@ class SanitizeArticle extends CakeTestModel {
var $useTable = 'articles';
}
/**
* Short description for class.
* SanitizeTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class SanitizeTest extends CakeTestCase {
@ -445,5 +445,4 @@ class SanitizeTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
}
?>
?>

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* SecurityTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.5432
* @version $Revision$
@ -26,9 +26,9 @@
*/
App::import('Core', 'Security');
/**
* Short description for class.
* SecurityTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class SecurityTest extends CakeTestCase {
@ -90,6 +90,9 @@ class SecurityTest extends CakeTestCase {
* @return void
*/
function testHash() {
$Security = Security::getInstance();
$_hashType = $Security->hashType;
$key = 'someKey';
$hash = 'someHash';
@ -126,6 +129,8 @@ class SecurityTest extends CakeTestCase {
$this->assertIdentical(strlen(Security::hash($key, 'sha256', false)), 64);
$this->assertIdentical(strlen(Security::hash($key, 'sha256', true)), 64);
}
Security::setHash($_hashType);
}
/**
* testCipher method

View file

@ -1,7 +1,7 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
* SessionTest file
*
* Long description for file
*
@ -16,7 +16,7 @@
* @filesource
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
@ -28,13 +28,34 @@ if (!class_exists('CakeSession')) {
App::import('Core', 'Session');
}
/**
* Short description for class.
* SessionTest class
*
* @package cake.tests
* @package cake
* @subpackage cake.tests.cases.libs
*/
class SessionTest extends CakeTestCase {
var $fixtures = array('core.session');
/**
* startCase method
*
* @access public
* @return void
*/
function startCase() {
// Make sure garbage colector will be called
$this->__gc_divisor = ini_get('session.gc_divisor');
ini_set('session.gc_divisor', '1');
}
/**
* endCase method
*
* @access public
* @return void
*/
function endCase() {
// Revert to the default setting
ini_set('session.gc_divisor', $this->__gc_divisor);
}
/**
* setUp method
*
@ -369,6 +390,11 @@ class SessionTest extends CakeTestCase {
$this->Session->destroy();
$this->assertFalse($this->Session->read('SessionTestCase'));
session_write_close();
unset($_SESSION);
ini_set('session.save_handler', 'files');
Configure::write('Session.save', 'php');
$this->setUp();
}
}
?>

Some files were not shown because too many files have changed in this diff Show more