mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge remote-tracking branch 'origin/2.2' into 2.2
This commit is contained in:
commit
e7a7a177cc
50 changed files with 720 additions and 578 deletions
|
@ -89,17 +89,24 @@ Cache::config('default', array('engine' => 'File'));
|
|||
* The settings below can be used to set additional paths to models, views and controllers.
|
||||
*
|
||||
* App::build(array(
|
||||
* 'Plugin' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),
|
||||
* 'Model' => array('/full/path/to/models/', '/next/full/path/to/models/'),
|
||||
* 'View' => array('/full/path/to/views/', '/next/full/path/to/views/'),
|
||||
* 'Controller' => array('/full/path/to/controllers/', '/next/full/path/to/controllers/'),
|
||||
* 'Model/Datasource' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'),
|
||||
* 'Model/Behavior' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'),
|
||||
* 'Controller/Component' => array('/full/path/to/components/', '/next/full/path/to/components/'),
|
||||
* 'View/Helper' => array('/full/path/to/helpers/', '/next/full/path/to/helpers/'),
|
||||
* 'Vendor' => array('/full/path/to/vendors/', '/next/full/path/to/vendors/'),
|
||||
* 'Console/Command' => array('/full/path/to/shells/', '/next/full/path/to/shells/'),
|
||||
* 'Locale' => array('/full/path/to/locale/', '/next/full/path/to/locale/')
|
||||
* 'Model' => array('/path/to/models', '/next/path/to/models'),
|
||||
* 'Model/Behavior' => array('/path/to/behaviors', '/next/path/to/behaviors'),
|
||||
* 'Model/Datasource' => array('/path/to/datasources', '/next/path/to/datasources'),
|
||||
* 'Model/Datasource/Database' => array('/path/to/databases', '/next/path/to/database'),
|
||||
* 'Model/Datasource/Session' => array('/path/to/sessions', '/next/path/to/sessions'),
|
||||
* 'Controller' => array('/path/to/controllers', '/next/path/to/controllers'),
|
||||
* 'Controller/Component' => array('/path/to/components', '/next/path/to/components'),
|
||||
* 'Controller/Component/Auth' => array('/path/to/auths', '/next/path/to/auths'),
|
||||
* 'Controller/Component/Acl' => array('/path/to/acls', '/next/path/to/acls'),
|
||||
* 'View' => array('/path/to/views', '/next/path/to/views'),
|
||||
* 'View/Helper' => array('/path/to/helpers', '/next/path/to/helpers'),
|
||||
* 'Console' => array('/path/to/consoles', '/next/path/to/consoles'),
|
||||
* 'Console/Command' => array('/path/to/commands', '/next/path/to/commands'),
|
||||
* 'Console/Command/Task' => array('/path/to/tasks', '/next/path/to/tasks'),
|
||||
* 'Lib' => array('/path/to/libs', '/next/path/to/libs'),
|
||||
* 'Locale' => array('/path/to/locales', '/next/path/to/locales'),
|
||||
* 'Vendor' => array('/path/to/vendors', '/next/path/to/vendors'),
|
||||
* 'Plugin' => array('/path/to/plugins', '/next/path/to/plugins'),
|
||||
* ));
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -16,4 +16,4 @@
|
|||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
?>
|
||||
<?php echo $content_for_layout; ?>
|
||||
<?php echo $this->fetch('content'); ?>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<?php echo $scripts_for_layout; ?>
|
||||
<script type="text/javascript"><?php echo $content_for_layout; ?></script>
|
||||
<script type="text/javascript"><?php echo $this->fetch('content'); ?></script>
|
||||
|
|
|
@ -8,7 +8,7 @@ if (!isset($channel['title'])) {
|
|||
|
||||
echo $this->Rss->document(
|
||||
$this->Rss->channel(
|
||||
array(), $channel, $content_for_layout
|
||||
array(), $channel, $this->fetch('content')
|
||||
)
|
||||
);
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $content_for_layout; ?>
|
||||
<?php echo $this->fetch('content'); ?>
|
||||
|
|
|
@ -129,7 +129,7 @@ abstract class CacheEngine {
|
|||
*
|
||||
* @param string $groups name of the group to be cleared
|
||||
* @return boolean
|
||||
**/
|
||||
*/
|
||||
public function clearGroup($group) {
|
||||
return false;
|
||||
}
|
||||
|
@ -140,10 +140,10 @@ abstract class CacheEngine {
|
|||
* the token representing each group in the cache key
|
||||
*
|
||||
* @return array
|
||||
**/
|
||||
public function groups() {
|
||||
return $this->settings['groups'];
|
||||
}
|
||||
*/
|
||||
public function groups() {
|
||||
return $this->settings['groups'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache Engine settings
|
||||
|
|
|
@ -115,7 +115,7 @@ class RedisEngine extends CacheEngine {
|
|||
public function read($key) {
|
||||
$value = $this->_Redis->get($key);
|
||||
if (ctype_digit($value)) {
|
||||
$value = (int) $value;
|
||||
$value = (int)$value;
|
||||
}
|
||||
if ($value !== false && is_string($value)) {
|
||||
$value = unserialize($value);
|
||||
|
@ -132,7 +132,7 @@ class RedisEngine extends CacheEngine {
|
|||
* @throws CacheException when you try to increment with compress = true
|
||||
*/
|
||||
public function increment($key, $offset = 1) {
|
||||
return (int) $this->_Redis->incrBy($key, $offset);
|
||||
return (int)$this->_Redis->incrBy($key, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,7 +144,7 @@ class RedisEngine extends CacheEngine {
|
|||
* @throws CacheException when you try to decrement with compress = true
|
||||
*/
|
||||
public function decrement($key, $offset = 1) {
|
||||
return (int) $this->_Redis->decrBy($key, $offset);
|
||||
return (int)$this->_Redis->decrBy($key, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -464,6 +464,8 @@ class ExtractTask extends AppShell {
|
|||
* @return void
|
||||
*/
|
||||
protected function _buildFiles() {
|
||||
$paths = $this->_paths;
|
||||
$paths[] = realpath(APP) . DS;
|
||||
foreach ($this->_translations as $domain => $translations) {
|
||||
foreach ($translations as $msgid => $details) {
|
||||
$plural = $details['msgid_plural'];
|
||||
|
@ -474,7 +476,7 @@ class ExtractTask extends AppShell {
|
|||
$occurrences[] = $file . ':' . implode(';', $lines);
|
||||
}
|
||||
$occurrences = implode("\n#: ", $occurrences);
|
||||
$header = '#: ' . str_replace($this->_paths, '', $occurrences) . "\n";
|
||||
$header = '#: ' . str_replace($paths, '', $occurrences) . "\n";
|
||||
|
||||
if ($plural === false) {
|
||||
$sentence = "msgid \"{$msgid}\"\n";
|
||||
|
|
|
@ -30,17 +30,24 @@ Cache::config('default', array('engine' => 'File'));
|
|||
* The settings below can be used to set additional paths to models, views and controllers.
|
||||
*
|
||||
* App::build(array(
|
||||
* 'Plugin' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),
|
||||
* 'Model' => array('/full/path/to/models/', '/next/full/path/to/models/'),
|
||||
* 'View' => array('/full/path/to/views/', '/next/full/path/to/views/'),
|
||||
* 'Controller' => array('/full/path/to/controllers/', '/next/full/path/to/controllers/'),
|
||||
* 'Model/Datasource' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'),
|
||||
* 'Model/Behavior' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'),
|
||||
* 'Controller/Component' => array('/full/path/to/components/', '/next/full/path/to/components/'),
|
||||
* 'View/Helper' => array('/full/path/to/helpers/', '/next/full/path/to/helpers/'),
|
||||
* 'Vendor' => array('/full/path/to/vendors/', '/next/full/path/to/vendors/'),
|
||||
* 'Console/Command' => array('/full/path/to/shells/', '/next/full/path/to/shells/'),
|
||||
* 'Locale' => array('/full/path/to/locale/', '/next/full/path/to/locale/')
|
||||
* 'Model' => array('/path/to/models', '/next/path/to/models'),
|
||||
* 'Model/Behavior' => array('/path/to/behaviors', '/next/path/to/behaviors'),
|
||||
* 'Model/Datasource' => array('/path/to/datasources', '/next/path/to/datasources'),
|
||||
* 'Model/Datasource/Database' => array('/path/to/databases', '/next/path/to/database'),
|
||||
* 'Model/Datasource/Session' => array('/path/to/sessions', '/next/path/to/sessions'),
|
||||
* 'Controller' => array('/path/to/controllers', '/next/path/to/controllers'),
|
||||
* 'Controller/Component' => array('/path/to/components', '/next/path/to/components'),
|
||||
* 'Controller/Component/Auth' => array('/path/to/auths', '/next/path/to/auths'),
|
||||
* 'Controller/Component/Acl' => array('/path/to/acls', '/next/path/to/acls'),
|
||||
* 'View' => array('/path/to/views', '/next/path/to/views'),
|
||||
* 'View/Helper' => array('/path/to/helpers', '/next/path/to/helpers'),
|
||||
* 'Console' => array('/path/to/consoles', '/next/path/to/consoles'),
|
||||
* 'Console/Command' => array('/path/to/commands', '/next/path/to/commands'),
|
||||
* 'Console/Command/Task' => array('/path/to/tasks', '/next/path/to/tasks'),
|
||||
* 'Lib' => array('/path/to/libs', '/next/path/to/libs'),
|
||||
* 'Locale' => array('/path/to/locales', '/next/path/to/locales'),
|
||||
* 'Vendor' => array('/path/to/vendors', '/next/path/to/vendors'),
|
||||
* 'Plugin' => array('/path/to/plugins', '/next/path/to/plugins'),
|
||||
* ));
|
||||
*
|
||||
*/
|
||||
|
@ -83,4 +90,4 @@ Cache::config('default', array('engine' => 'File'));
|
|||
Configure::write('Dispatcher.filters', array(
|
||||
'AssetDispatcher',
|
||||
'CacheDispatcher'
|
||||
));
|
||||
));
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo $content_for_layout;?>
|
||||
<?php echo $this->fetch('content');?>
|
||||
|
||||
<p>This email was sent using the <a href="http://cakephp.org">CakePHP Framework</a></p>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
*/
|
||||
?>
|
||||
|
||||
<?php echo $content_for_layout;?>
|
||||
<?php echo $this->fetch('content');?>
|
||||
|
||||
This email was sent using the CakePHP Framework, http://cakephp.org.
|
||||
|
|
|
@ -16,4 +16,4 @@
|
|||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
?>
|
||||
<?php echo $content_for_layout; ?>
|
||||
<?php echo $this->fetch('content'); ?>
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<?php echo $scripts_for_layout; ?>
|
||||
<script type="text/javascript"><?php echo $content_for_layout; ?></script>
|
||||
<script type="text/javascript"><?php echo $this->fetch('content'); ?></script>
|
||||
|
|
|
@ -8,7 +8,7 @@ if (!isset($channel['title'])) {
|
|||
|
||||
echo $this->Rss->document(
|
||||
$this->Rss->channel(
|
||||
array(), $channel, $content_for_layout
|
||||
array(), $channel, $this->fetch('content')
|
||||
)
|
||||
);
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<?php echo $content_for_layout; ?>
|
||||
<?php echo $this->fetch('content'); ?>
|
||||
|
|
|
@ -420,31 +420,6 @@ class EmailComponent extends Component {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the specified string using the current charset
|
||||
*
|
||||
* @param string $subject String to encode
|
||||
* @return string Encoded string
|
||||
*/
|
||||
protected function _encode($subject) {
|
||||
$subject = $this->_strip($subject);
|
||||
|
||||
$nl = "\r\n";
|
||||
if ($this->delivery == 'mail') {
|
||||
$nl = '';
|
||||
}
|
||||
$internalEncoding = function_exists('mb_internal_encoding');
|
||||
if ($internalEncoding) {
|
||||
$restore = mb_internal_encoding();
|
||||
mb_internal_encoding($this->charset);
|
||||
}
|
||||
$return = mb_encode_mimeheader($subject, $this->charset, 'B', $nl);
|
||||
if ($internalEncoding) {
|
||||
mb_internal_encoding($restore);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format addresses to be an array with email as key and alias as value
|
||||
*
|
||||
|
@ -455,7 +430,7 @@ class EmailComponent extends Component {
|
|||
$formatted = array();
|
||||
foreach ($addresses as $address) {
|
||||
if (preg_match('/((.*))?\s?<(.+)>/', $address, $matches) && !empty($matches[2])) {
|
||||
$formatted[$this->_strip($matches[3])] = $this->_encode($matches[2]);
|
||||
$formatted[$this->_strip($matches[3])] = $matches[2];
|
||||
} else {
|
||||
$address = $this->_strip($address);
|
||||
$formatted[$address] = $address;
|
||||
|
|
|
@ -77,17 +77,6 @@ class Mysql extends DboSource {
|
|||
*/
|
||||
protected $_useAlias = true;
|
||||
|
||||
/**
|
||||
* Index of basic SQL commands
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_commands = array(
|
||||
'begin' => 'START TRANSACTION',
|
||||
'commit' => 'COMMIT',
|
||||
'rollback' => 'ROLLBACK'
|
||||
);
|
||||
|
||||
/**
|
||||
* List of engine specific additional field parameters used on table creating
|
||||
*
|
||||
|
@ -262,15 +251,6 @@ class Mysql extends DboSource {
|
|||
return $this->_execute('SHOW VARIABLES LIKE ?', array('character_set_client'))->fetchObject()->Value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version string of the database server
|
||||
*
|
||||
* @return string The database encoding
|
||||
*/
|
||||
public function getVersion() {
|
||||
return $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query charset by collation
|
||||
*
|
||||
|
@ -696,4 +676,13 @@ class Mysql extends DboSource {
|
|||
return $this->config['database'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the server support nested transactions
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function supportNestedTransaction() {
|
||||
return $this->nestedTransaction && version_compare($this->getVersion(), '4.1', '>=');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,17 +33,6 @@ class Postgres extends DboSource {
|
|||
*/
|
||||
public $description = "PostgreSQL DBO Driver";
|
||||
|
||||
/**
|
||||
* Index of basic SQL commands
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_commands = array(
|
||||
'begin' => 'BEGIN',
|
||||
'commit' => 'COMMIT',
|
||||
'rollback' => 'ROLLBACK'
|
||||
);
|
||||
|
||||
/**
|
||||
* Base driver configuration settings. Merged with user settings.
|
||||
*
|
||||
|
@ -906,4 +895,13 @@ class Postgres extends DboSource {
|
|||
return $this->config['schema'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the server support nested transactions
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function supportNestedTransaction() {
|
||||
return $this->nestedTransaction && version_compare($this->getVersion(), '8.0', '>=');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -559,4 +559,13 @@ class Sqlite extends DboSource {
|
|||
return "main"; // Sqlite Datasource does not support multidb
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the server support nested transactions
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function supportNestedTransaction() {
|
||||
return $this->nestedTransaction && version_compare($this->getVersion(), '3.6.8', '>=');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -98,31 +98,12 @@ class Sqlserver extends DboSource {
|
|||
'boolean' => array('name' => 'bit')
|
||||
);
|
||||
|
||||
/**
|
||||
* Index of basic SQL commands
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_commands = array(
|
||||
'begin' => 'BEGIN TRANSACTION',
|
||||
'commit' => 'COMMIT',
|
||||
'rollback' => 'ROLLBACK'
|
||||
);
|
||||
|
||||
/**
|
||||
* Magic column name used to provide pagination support for SQLServer 2008
|
||||
* which lacks proper limit/offset support.
|
||||
*/
|
||||
const ROW_COUNTER = '_cake_page_rownum_';
|
||||
|
||||
/**
|
||||
* The version of SQLServer being used. If greater than 11
|
||||
* Normal limit offset statements will be used
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_version;
|
||||
|
||||
/**
|
||||
* Connects to the database using options in the given configuration array.
|
||||
*
|
||||
|
@ -151,7 +132,6 @@ class Sqlserver extends DboSource {
|
|||
throw new MissingConnectionException(array('class' => $e->getMessage()));
|
||||
}
|
||||
|
||||
$this->_version = $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
return $this->connected;
|
||||
}
|
||||
|
||||
|
@ -515,7 +495,7 @@ class Sqlserver extends DboSource {
|
|||
}
|
||||
|
||||
// For older versions use the subquery version of pagination.
|
||||
if (version_compare($this->_version, '11', '<') && preg_match('/FETCH\sFIRST\s+([0-9]+)/i', $limit, $offset)) {
|
||||
if (version_compare($this->getVersion(), '11', '<') && preg_match('/FETCH\sFIRST\s+([0-9]+)/i', $limit, $offset)) {
|
||||
preg_match('/OFFSET\s*(\d+)\s*.*?(\d+)\s*ROWS/', $limit, $limitOffset);
|
||||
|
||||
$limit = 'TOP ' . intval($limitOffset[2]);
|
||||
|
|
|
@ -69,6 +69,15 @@ class DboSource extends DataSource {
|
|||
*/
|
||||
public $cacheMethods = true;
|
||||
|
||||
/**
|
||||
* Flag to support nested transactions. If it is set to false, you will be able to use
|
||||
* the transaction methods (begin/commit/rollback), but just the global transaction will
|
||||
* be executed.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $nestedTransaction = true;
|
||||
|
||||
/**
|
||||
* Print full query debug info?
|
||||
*
|
||||
|
@ -183,17 +192,6 @@ class DboSource extends DataSource {
|
|||
*/
|
||||
protected $_transactionNesting = 0;
|
||||
|
||||
/**
|
||||
* Index of basic SQL commands
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_commands = array(
|
||||
'begin' => 'BEGIN',
|
||||
'commit' => 'COMMIT',
|
||||
'rollback' => 'ROLLBACK'
|
||||
);
|
||||
|
||||
/**
|
||||
* Default fields that are used by the DBO
|
||||
*
|
||||
|
@ -294,12 +292,21 @@ class DboSource extends DataSource {
|
|||
/**
|
||||
* Get the underlying connection object.
|
||||
*
|
||||
* @return PDOConnection
|
||||
* @return PDO
|
||||
*/
|
||||
public function getConnection() {
|
||||
return $this->_connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version string of the database server
|
||||
*
|
||||
* @return string The database version
|
||||
*/
|
||||
public function getVersion() {
|
||||
return $this->_connection->getAttribute(PDO::ATTR_SERVER_VERSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a quoted and escaped string of $data for use in an SQL statement.
|
||||
*
|
||||
|
@ -2019,6 +2026,15 @@ class DboSource extends DataSource {
|
|||
return $this->execute('TRUNCATE TABLE ' . $this->fullTableName($table));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the server support nested transactions
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function supportNestedTransaction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin a transaction
|
||||
*
|
||||
|
@ -2027,15 +2043,33 @@ class DboSource extends DataSource {
|
|||
* or a transaction has not started).
|
||||
*/
|
||||
public function begin() {
|
||||
if ($this->_transactionStarted || $this->_connection->beginTransaction()) {
|
||||
if ($this->fullDebug && empty($this->_transactionNesting)) {
|
||||
$this->logQuery('BEGIN');
|
||||
if ($this->_transactionStarted) {
|
||||
if ($this->supportNestedTransaction()) {
|
||||
return $this->_beginNested();
|
||||
}
|
||||
$this->_transactionStarted = true;
|
||||
$this->_transactionNesting++;
|
||||
return true;
|
||||
return $this->_transactionStarted;
|
||||
}
|
||||
return false;
|
||||
|
||||
$this->_transactionNesting = 0;
|
||||
if ($this->fullDebug) {
|
||||
$this->logQuery('BEGIN');
|
||||
}
|
||||
return $this->_transactionStarted = $this->_connection->beginTransaction();
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin a nested transaction
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _beginNested() {
|
||||
$query = 'SAVEPOINT LEVEL' . ++$this->_transactionNesting;
|
||||
if ($this->fullDebug) {
|
||||
$this->logQuery($query);
|
||||
}
|
||||
$this->_connection->exec($query);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2046,19 +2080,38 @@ class DboSource extends DataSource {
|
|||
* or a transaction has not started).
|
||||
*/
|
||||
public function commit() {
|
||||
if ($this->_transactionStarted) {
|
||||
$this->_transactionNesting--;
|
||||
if ($this->_transactionNesting <= 0) {
|
||||
$this->_transactionStarted = false;
|
||||
$this->_transactionNesting = 0;
|
||||
if ($this->fullDebug) {
|
||||
$this->logQuery('COMMIT');
|
||||
}
|
||||
return $this->_connection->commit();
|
||||
}
|
||||
return true;
|
||||
if (!$this->_transactionStarted) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
if ($this->_transactionNesting === 0) {
|
||||
if ($this->fullDebug) {
|
||||
$this->logQuery('COMMIT');
|
||||
}
|
||||
$this->_transactionStarted = false;
|
||||
return $this->_connection->commit();
|
||||
}
|
||||
|
||||
if ($this->supportNestedTransaction()) {
|
||||
return $this->_commitNested();
|
||||
}
|
||||
|
||||
$this->_transactionNesting--;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit a nested transaction
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _commitNested() {
|
||||
$query = 'RELEASE SAVEPOINT LEVEL' . $this->_transactionNesting--;
|
||||
if ($this->fullDebug) {
|
||||
$this->logQuery($query);
|
||||
}
|
||||
$this->_connection->exec($query);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2069,15 +2122,38 @@ class DboSource extends DataSource {
|
|||
* or a transaction has not started).
|
||||
*/
|
||||
public function rollback() {
|
||||
if ($this->_transactionStarted && $this->_connection->rollBack()) {
|
||||
if (!$this->_transactionStarted) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->_transactionNesting === 0) {
|
||||
if ($this->fullDebug) {
|
||||
$this->logQuery('ROLLBACK');
|
||||
}
|
||||
$this->_transactionStarted = false;
|
||||
$this->_transactionNesting = 0;
|
||||
return true;
|
||||
return $this->_connection->rollBack();
|
||||
}
|
||||
return false;
|
||||
|
||||
if ($this->supportNestedTransaction()) {
|
||||
return $this->_rollbackNested();
|
||||
}
|
||||
|
||||
$this->_transactionNesting--;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rollback a nested transaction
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function _rollbackNested() {
|
||||
$query = 'ROLLBACK TO SAVEPOINT LEVEL' . $this->_transactionNesting--;
|
||||
if ($this->fullDebug) {
|
||||
$this->logQuery($query);
|
||||
}
|
||||
$this->_connection->exec($query);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1629,7 +1629,7 @@ class Model extends Object implements CakeEventListener {
|
|||
if (!array_key_exists('format', $colType)) {
|
||||
$time = strtotime('now');
|
||||
} else {
|
||||
$time = $colType['formatter']($colType['format']);
|
||||
$time = call_user_func($colType['formatter'], $colType['format']);
|
||||
}
|
||||
if (!empty($this->whitelist)) {
|
||||
$this->whitelist[] = $updateCol;
|
||||
|
|
|
@ -320,21 +320,31 @@ class CakeRequest implements ArrayAccess {
|
|||
|
||||
if (isset($_FILES['data'])) {
|
||||
foreach ($_FILES['data'] as $key => $data) {
|
||||
foreach ($data as $model => $fields) {
|
||||
if (is_array($fields)) {
|
||||
foreach ($fields as $field => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
$this->data[$model][$field][$k][$key] = $v;
|
||||
}
|
||||
} else {
|
||||
$this->data[$model][$field][$key] = $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->data[$model][$key] = $fields;
|
||||
}
|
||||
}
|
||||
$this->_processFileData('', $data, $key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively walks the FILES array restructuring the data
|
||||
* into something sane and useable.
|
||||
*
|
||||
* @param string $path The dot separated path to insert $data into.
|
||||
* @param array $data The data to traverse/insert.
|
||||
* @param string $field The terminal field name, which is the top level key in $_FILES.
|
||||
* @return void
|
||||
*/
|
||||
protected function _processFileData($path, $data, $field) {
|
||||
foreach ($data as $key => $fields) {
|
||||
$newPath = $key;
|
||||
if (!empty($path)) {
|
||||
$newPath = $path . '.' . $key;
|
||||
}
|
||||
if (is_array($fields)) {
|
||||
$this->_processFileData($newPath, $fields, $field);
|
||||
} else {
|
||||
$newPath .= '.' . $field;
|
||||
$this->data = Set::insert($this->data, $newPath, $fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class Dispatcher implements CakeEventListener {
|
|||
* Event manager, used to handle dispatcher filters
|
||||
*
|
||||
* @var CakeEventMaanger
|
||||
**/
|
||||
*/
|
||||
protected $_eventManager;
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ class Dispatcher implements CakeEventListener {
|
|||
* creted. Attaches the default listeners and filters
|
||||
*
|
||||
* @return CakeEventmanger
|
||||
**/
|
||||
*/
|
||||
public function getEventManager() {
|
||||
if (!$this->_eventManager) {
|
||||
$this->_eventManager = new CakeEventManager();
|
||||
|
@ -77,7 +77,7 @@ class Dispatcher implements CakeEventListener {
|
|||
* Returns the list of events this object listents to.
|
||||
*
|
||||
* @return array
|
||||
**/
|
||||
*/
|
||||
public function implementedEvents() {
|
||||
return array('Dispatcher.beforeDispatch' => 'parseParams');
|
||||
}
|
||||
|
@ -88,7 +88,8 @@ class Dispatcher implements CakeEventListener {
|
|||
*
|
||||
* @param CakeEventManager $manager
|
||||
* @return void
|
||||
**/
|
||||
* @throws MissingDispatcherFilterException
|
||||
*/
|
||||
protected function _attachFilters($manager) {
|
||||
$filters = Configure::read('Dispatcher.filters');
|
||||
if (empty($filters)) {
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Routing
|
||||
* @since CakePHP(tm) v 2.2
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @since CakePHP(tm) v 2.2
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
App::uses('DispatcherFilter', 'Routing');
|
||||
|
@ -31,7 +27,7 @@ class CacheDispatcher extends DispatcherFilter {
|
|||
* This filter should run before the request gets parsed by router
|
||||
*
|
||||
* @var int
|
||||
**/
|
||||
*/
|
||||
public $priority = 9;
|
||||
|
||||
/**
|
||||
|
@ -68,4 +64,4 @@ class CacheDispatcher extends DispatcherFilter {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1014,7 +1014,8 @@ class Router {
|
|||
public static function normalize($url = '/') {
|
||||
if (is_array($url)) {
|
||||
$url = Router::url($url);
|
||||
} elseif (preg_match('/^[a-z\-]+:\/\//', $url)) {
|
||||
}
|
||||
if (preg_match('/^[a-z\-]+:\/\//', $url)) {
|
||||
return $url;
|
||||
}
|
||||
$request = Router::getRequest();
|
||||
|
|
|
@ -410,7 +410,7 @@ class FileEngineTest extends CakeTestCase {
|
|||
$this->assertTrue(Cache::write('test_groups3', 'value3', 'file_groups'));
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Tests that deleteing from a groups-enabled config is possible
|
||||
*
|
||||
* @return void
|
||||
|
|
|
@ -220,7 +220,6 @@ class RegisEngineTest extends CakeTestCase {
|
|||
$this->assertEquals(3, $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test clearing redis.
|
||||
*
|
||||
|
@ -333,4 +332,4 @@ class RegisEngineTest extends CakeTestCase {
|
|||
$this->assertFalse(Cache::read('test_groups', 'redis_groups'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,7 +163,6 @@ class FormAuthenticateTest extends CakeTestCase {
|
|||
), App::RESET);
|
||||
CakePlugin::load('TestPlugin');
|
||||
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$PluginModel = ClassRegistry::init('TestPlugin.TestPluginAuthUser');
|
||||
$user['id'] = 1;
|
||||
$user['username'] = 'gwoo';
|
||||
|
@ -185,7 +184,7 @@ class FormAuthenticateTest extends CakeTestCase {
|
|||
'username' => 'gwoo',
|
||||
'created' => '2007-03-17 01:16:23'
|
||||
);
|
||||
$this->assertTrue($result['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result['updated']);
|
||||
unset($result['updated']);
|
||||
$this->assertEquals($expected, $result);
|
||||
CakePlugin::unload();
|
||||
|
|
|
@ -868,4 +868,22 @@ HTMLBLOC;
|
|||
$this->assertNotRegExp('/Message-ID:/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure from/to are not double encoded when UTF-8 is present
|
||||
*/
|
||||
public function testEncodingFrom() {
|
||||
$this->Controller->EmailTest->to = 'Teßt <test@example.com>';
|
||||
$this->Controller->EmailTest->from = 'Teßt <test@example.com>';
|
||||
$this->Controller->EmailTest->subject = 'Cake Debug Test';
|
||||
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
|
||||
$this->Controller->EmailTest->template = null;
|
||||
|
||||
$this->Controller->EmailTest->delivery = 'DebugComp';
|
||||
$this->assertTrue($this->Controller->EmailTest->send('This is the body of the message'));
|
||||
$result = DebugCompTransport::$lastEmail;
|
||||
|
||||
$this->assertContains('From: =?UTF-8?B?VGXDn3Qg?= <test@example.com>', $result);
|
||||
$this->assertContains('To: =?UTF-8?B?VGXDn3Qg?= <test@example.com>', $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class MysqlTest extends CakeTestCase {
|
|||
public $fixtures = array(
|
||||
'core.apple', 'core.article', 'core.articles_tag', 'core.attachment', 'core.comment',
|
||||
'core.sample', 'core.tag', 'core.user', 'core.post', 'core.author', 'core.data_test',
|
||||
'core.binary_test'
|
||||
'core.binary_test', 'app.address'
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -3579,4 +3579,38 @@ class MysqlTest extends CakeTestCase {
|
|||
->with("TRUNCATE TABLE `$schema`.`tbl_articles`");
|
||||
$this->Dbo->truncate('articles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test nested transaction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNestedTransaction() {
|
||||
$this->skipIf($this->Dbo->supportNestedTransaction() === false, 'The MySQL server do not support nested transaction');
|
||||
|
||||
$this->loadFixtures('Address');
|
||||
$model = ClassRegistry::init('Address');
|
||||
$model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
|
||||
$model->cacheQueries = false;
|
||||
$this->Dbo->cacheMethods = false;
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->commit());
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -909,4 +909,37 @@ class PostgresTest extends CakeTestCase {
|
|||
$this->Dbo->truncate('articles');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test nested transaction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNestedTransaction() {
|
||||
$this->skipIf($this->Dbo->supportNestedTransaction() === false, 'The Postgres server do not support nested transaction');
|
||||
|
||||
$this->loadFixtures('Article');
|
||||
$model = new Article();
|
||||
$model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
|
||||
$model->cacheQueries = false;
|
||||
$this->Dbo->cacheMethods = false;
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->commit());
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -383,4 +383,37 @@ class SqliteTest extends CakeTestCase {
|
|||
$this->assertTrue(Validation::uuid($result['Uuid']['id']), 'Not a uuid');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test nested transaction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testNestedTransaction() {
|
||||
$this->skipIf($this->Dbo->supportNestedTransaction() === false, 'The Sqlite version do not support nested transaction');
|
||||
|
||||
$this->loadFixtures('User');
|
||||
$model = new User();
|
||||
$model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
|
||||
$model->cacheQueries = false;
|
||||
$this->Dbo->cacheMethods = false;
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->begin());
|
||||
$this->assertTrue($model->delete(1));
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
$this->assertTrue($this->Dbo->commit());
|
||||
$this->assertEmpty($model->read(null, 1));
|
||||
|
||||
$this->assertTrue($this->Dbo->rollback());
|
||||
$this->assertNotEmpty($model->read(null, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ class MockDataSource extends DataSource {
|
|||
|
||||
class DboTestSource extends DboSource {
|
||||
|
||||
public static $nested = true;
|
||||
|
||||
public function connect($config = array()) {
|
||||
$this->connected = true;
|
||||
}
|
||||
|
@ -51,6 +53,10 @@ class DboTestSource extends DboSource {
|
|||
$this->_connection = $conn;
|
||||
}
|
||||
|
||||
public function supportNestedTransaction() {
|
||||
return $this->nestedTransaction && self::$nested;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -834,6 +840,79 @@ class DboSourceTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $log['log'][0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test nested transaction calls
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTransactionNested() {
|
||||
$conn = $this->getMock('MockPDO');
|
||||
$db = new DboTestSource();
|
||||
$db->setConnection($conn);
|
||||
DboTestSource::$nested = true;
|
||||
|
||||
$conn->expects($this->at(0))->method('beginTransaction')->will($this->returnValue(true));
|
||||
$conn->expects($this->at(1))->method('exec')->with($this->equalTo('SAVEPOINT LEVEL1'))->will($this->returnValue(true));
|
||||
$conn->expects($this->at(2))->method('exec')->with($this->equalTo('RELEASE SAVEPOINT LEVEL1'))->will($this->returnValue(true));
|
||||
$conn->expects($this->at(3))->method('exec')->with($this->equalTo('SAVEPOINT LEVEL1'))->will($this->returnValue(true));
|
||||
$conn->expects($this->at(4))->method('exec')->with($this->equalTo('ROLLBACK TO SAVEPOINT LEVEL1'))->will($this->returnValue(true));
|
||||
$conn->expects($this->at(5))->method('commit')->will($this->returnValue(true));
|
||||
|
||||
$this->_runTransactions($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test nested transaction calls without support
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTransactionNestedWithoutSupport() {
|
||||
$conn = $this->getMock('MockPDO');
|
||||
$db = new DboTestSource();
|
||||
$db->setConnection($conn);
|
||||
$db->nestedTransaction = false;
|
||||
DboTestSource::$nested = true;
|
||||
|
||||
$conn->expects($this->once())->method('beginTransaction')->will($this->returnValue(true));
|
||||
$conn->expects($this->never())->method('exec');
|
||||
$conn->expects($this->once())->method('commit')->will($this->returnValue(true));
|
||||
|
||||
$this->_runTransactions($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test nested transaction disabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testTransactionNestedDisabled() {
|
||||
$conn = $this->getMock('MockPDO');
|
||||
$db = new DboTestSource();
|
||||
$db->setConnection($conn);
|
||||
DboTestSource::$nested = false;
|
||||
|
||||
$conn->expects($this->once())->method('beginTransaction')->will($this->returnValue(true));
|
||||
$conn->expects($this->never())->method('exec');
|
||||
$conn->expects($this->once())->method('commit')->will($this->returnValue(true));
|
||||
|
||||
$this->_runTransactions($db);
|
||||
}
|
||||
|
||||
/**
|
||||
* Nested transaction calls
|
||||
*
|
||||
* @param DboTestSource $db
|
||||
* @return void
|
||||
*/
|
||||
protected function _runTransactions($db) {
|
||||
$db->begin();
|
||||
$db->begin();
|
||||
$db->commit();
|
||||
$db->begin();
|
||||
$db->rollback();
|
||||
$db->commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test build statement with some fields missing
|
||||
*
|
||||
|
|
|
@ -1866,7 +1866,6 @@ class ModelIntegrationTest extends BaseModelTest {
|
|||
'doomed' => true
|
||||
))));
|
||||
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$TestModel->save();
|
||||
|
||||
$TestModel->hasAndBelongsToMany['SomethingElse']['order'] = 'SomethingElse.id ASC';
|
||||
|
@ -1920,7 +1919,7 @@ class ModelIntegrationTest extends BaseModelTest {
|
|||
)
|
||||
)
|
||||
);
|
||||
$this->assertTrue($result['Something']['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result['Something']['updated']);
|
||||
unset($result['Something']['updated']);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
|
|
@ -1613,7 +1613,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$TestModel->id = 2;
|
||||
$data = array('Tag' => array('Tag' => array(2)));
|
||||
$TestModel->save($data);
|
||||
|
@ -1627,7 +1626,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'body' => 'Second Article Body',
|
||||
'published' => 'Y',
|
||||
'created' => '2007-03-18 10:41:23',
|
||||
'updated' => $ts
|
||||
'updated' => self::date()
|
||||
),
|
||||
'Tag' => array(
|
||||
array(
|
||||
|
@ -2561,29 +2560,28 @@ class ModelWriteTest extends BaseModelTest {
|
|||
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$TestModel->id = 1;
|
||||
$data = array(
|
||||
'JoinA' => array(
|
||||
'id' => '1',
|
||||
'name' => 'New name for Join A 1',
|
||||
'updated' => $ts
|
||||
'updated' => self::date()
|
||||
),
|
||||
'JoinB' => array(
|
||||
array(
|
||||
'id' => 1,
|
||||
'join_b_id' => 2,
|
||||
'other' => 'New data for Join A 1 Join B 2',
|
||||
'created' => $ts,
|
||||
'updated' => $ts
|
||||
'created' => self::date(),
|
||||
'updated' => self::date()
|
||||
)),
|
||||
'JoinC' => array(
|
||||
array(
|
||||
'id' => 1,
|
||||
'join_c_id' => 2,
|
||||
'other' => 'New data for Join A 1 Join C 2',
|
||||
'created' => $ts,
|
||||
'updated' => $ts
|
||||
'created' => self::date(),
|
||||
'updated' => self::date()
|
||||
)));
|
||||
|
||||
$TestModel->set($data);
|
||||
|
@ -2596,7 +2594,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'name' => 'New name for Join A 1',
|
||||
'body' => 'Join A 1 Body',
|
||||
'created' => '2008-01-03 10:54:23',
|
||||
'updated' => $ts
|
||||
'updated' => self::date()
|
||||
),
|
||||
'JoinB' => array(
|
||||
0 => array(
|
||||
|
@ -2609,8 +2607,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'join_a_id' => 1,
|
||||
'join_b_id' => 2,
|
||||
'other' => 'New data for Join A 1 Join B 2',
|
||||
'created' => $ts,
|
||||
'updated' => $ts
|
||||
'created' => self::date(),
|
||||
'updated' => self::date()
|
||||
))),
|
||||
'JoinC' => array(
|
||||
0 => array(
|
||||
|
@ -2623,8 +2621,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'join_a_id' => 1,
|
||||
'join_c_id' => 2,
|
||||
'other' => 'New data for Join A 1 Join C 2',
|
||||
'created' => $ts,
|
||||
'updated' => $ts
|
||||
'created' => self::date(),
|
||||
'updated' => self::date()
|
||||
))));
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -2642,7 +2640,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$result = $TestModel->find('all');
|
||||
$this->assertEquals(3, count($result));
|
||||
$this->assertFalse(isset($result[3]));
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
|
||||
$TestModel->saveAll(array(
|
||||
'Post' => array(
|
||||
|
@ -2669,10 +2666,10 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'password' => '5f4dcc3b5aa765d61d8327deb882cf90',
|
||||
'test' => 'working'
|
||||
));
|
||||
$this->assertTrue($result[3]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[3]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[3]['Author']['created'] >= $ts);
|
||||
$this->assertTrue($result[3]['Author']['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[3]['Author']['created']);
|
||||
$this->assertEquals(self::date(), $result[3]['Author']['updated']);
|
||||
unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
|
||||
unset($result[3]['Author']['created'], $result[3]['Author']['updated']);
|
||||
$this->assertEquals($expected, $result[3]);
|
||||
|
@ -2684,7 +2681,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
// SQLite seems to reset the PK counter when that happens, so we need this to make the tests pass
|
||||
$this->db->truncate($TestModel);
|
||||
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$TestModel->saveAll(array(
|
||||
array(
|
||||
'title' => 'Multi-record post 1',
|
||||
|
@ -2718,16 +2714,15 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'body' => 'Second multi-record post',
|
||||
'published' => 'N'
|
||||
)));
|
||||
$this->assertTrue($result[0]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[0]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[1]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[1]['Post']['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[0]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[0]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[1]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[1]['Post']['updated']);
|
||||
unset($result[0]['Post']['created'], $result[0]['Post']['updated']);
|
||||
unset($result[1]['Post']['created'], $result[1]['Post']['updated']);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$TestModel = new Comment();
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$result = $TestModel->saveAll(array(
|
||||
'Comment' => array(
|
||||
'article_id' => 2,
|
||||
|
@ -2748,8 +2743,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'comment' => 'New comment with attachment',
|
||||
'published' => 'Y'
|
||||
);
|
||||
$this->assertTrue($result[6]['Comment']['created'] >= $ts);
|
||||
$this->assertTrue($result[6]['Comment']['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[6]['Comment']['created']);
|
||||
$this->assertEquals(self::date(), $result[6]['Comment']['updated']);
|
||||
unset($result[6]['Comment']['created'], $result[6]['Comment']['updated']);
|
||||
$this->assertEquals($expected, $result[6]['Comment']);
|
||||
|
||||
|
@ -2758,8 +2753,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'comment_id' => '7',
|
||||
'attachment' => 'some_file.tgz'
|
||||
);
|
||||
$this->assertTrue($result[6]['Attachment']['created'] >= $ts);
|
||||
$this->assertTrue($result[6]['Attachment']['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[6]['Attachment']['created']);
|
||||
$this->assertEquals(self::date(), $result[6]['Attachment']['updated']);
|
||||
unset($result[6]['Attachment']['created'], $result[6]['Attachment']['updated']);
|
||||
$this->assertEquals($expected, $result[6]['Attachment']);
|
||||
}
|
||||
|
@ -4056,7 +4051,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
||||
array('author_id' => 1, 'title' => '')
|
||||
);
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$this->assertFalse($TestModel->saveAll($data));
|
||||
|
||||
$result = $TestModel->find('all', array('recursive' => -1));
|
||||
|
@ -4098,8 +4092,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'title' => 'New Fourth Post',
|
||||
'body' => null,
|
||||
'published' => 'N',
|
||||
'created' => $ts,
|
||||
'updated' => $ts
|
||||
'created' => self::date(),
|
||||
'updated' => self::date()
|
||||
));
|
||||
|
||||
$expected[] = array(
|
||||
|
@ -4109,8 +4103,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'title' => 'New Fifth Post',
|
||||
'body' => null,
|
||||
'published' => 'N',
|
||||
'created' => $ts,
|
||||
'updated' => $ts
|
||||
'created' => self::date(),
|
||||
'updated' => self::date()
|
||||
));
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -4125,7 +4119,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
array('author_id' => 1, 'title' => ''),
|
||||
array('author_id' => 1, 'title' => 'New Sixth Post')
|
||||
);
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$this->assertFalse($TestModel->saveAll($data));
|
||||
|
||||
$result = $TestModel->find('all', array('recursive' => -1));
|
||||
|
@ -4167,8 +4160,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'title' => 'New Fourth Post',
|
||||
'body' => 'Third Post Body',
|
||||
'published' => 'N',
|
||||
'created' => $ts,
|
||||
'updated' => $ts
|
||||
'created' => self::date(),
|
||||
'updated' => self::date()
|
||||
));
|
||||
|
||||
$expected[] = array(
|
||||
|
@ -4178,8 +4171,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'title' => 'Third Post',
|
||||
'body' => 'Third Post Body',
|
||||
'published' => 'N',
|
||||
'created' => $ts,
|
||||
'updated' => $ts
|
||||
'created' => self::date(),
|
||||
'updated' => self::date()
|
||||
));
|
||||
}
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -4264,7 +4257,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'author_id' => 2
|
||||
));
|
||||
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$this->assertTrue($TestModel->saveAll($data));
|
||||
|
||||
$result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC'));
|
||||
|
@ -4305,10 +4297,10 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'body' => 'Fourth post body',
|
||||
'published' => 'N'
|
||||
)));
|
||||
$this->assertTrue($result[0]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[1]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[3]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[3]['Post']['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[0]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[1]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['updated']);
|
||||
unset($result[0]['Post']['updated'], $result[1]['Post']['updated']);
|
||||
unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -4399,10 +4391,10 @@ class ModelWriteTest extends BaseModelTest {
|
|||
)
|
||||
);
|
||||
|
||||
$this->assertTrue($result[0]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[1]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[3]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[3]['Post']['created'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[0]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[1]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['created']);
|
||||
unset(
|
||||
$result[0]['Post']['updated'], $result[1]['Post']['updated'],
|
||||
$result[3]['Post']['updated'], $result[3]['Post']['created']
|
||||
|
@ -4731,7 +4723,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$result = $TestModel->find('all');
|
||||
$this->assertEquals(3, count($result));
|
||||
$this->assertFalse(isset($result[3]));
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
|
||||
$TestModel->saveAssociated(array(
|
||||
'Post' => array(
|
||||
|
@ -4758,10 +4749,10 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'password' => '5f4dcc3b5aa765d61d8327deb882cf90',
|
||||
'test' => 'working'
|
||||
));
|
||||
$this->assertTrue($result[3]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[3]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[3]['Author']['created'] >= $ts);
|
||||
$this->assertTrue($result[3]['Author']['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[3]['Author']['created']);
|
||||
$this->assertEquals(self::date(), $result[3]['Author']['updated']);
|
||||
unset(
|
||||
$result[3]['Post']['updated'], $result[3]['Post']['created'],
|
||||
$result[3]['Author']['updated'], $result[3]['Author']['created']
|
||||
|
@ -4769,10 +4760,7 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$this->assertEquals($expected, $result[3]);
|
||||
$this->assertEquals(4, count($result));
|
||||
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
|
||||
$TestModel = new Comment();
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$result = $TestModel->saveAssociated(array(
|
||||
'Comment' => array(
|
||||
'article_id' => 2,
|
||||
|
@ -4793,8 +4781,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'comment' => 'New comment with attachment',
|
||||
'published' => 'Y'
|
||||
);
|
||||
$this->assertTrue($result[6]['Comment']['updated'] >= $ts);
|
||||
$this->assertTrue($result[6]['Comment']['created'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[6]['Comment']['updated']);
|
||||
$this->assertEquals(self::date(), $result[6]['Comment']['created']);
|
||||
unset($result[6]['Comment']['updated'], $result[6]['Comment']['created']);
|
||||
$this->assertEquals($expected, $result[6]['Comment']);
|
||||
|
||||
|
@ -4803,8 +4791,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'comment_id' => '7',
|
||||
'attachment' => 'some_file.tgz'
|
||||
);
|
||||
$this->assertTrue($result[6]['Attachment']['updated'] >= $ts);
|
||||
$this->assertTrue($result[6]['Attachment']['created'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[6]['Attachment']['updated']);
|
||||
$this->assertEquals(self::date(), $result[6]['Attachment']['created']);
|
||||
unset($result[6]['Attachment']['updated'], $result[6]['Attachment']['created']);
|
||||
$this->assertEquals($expected, $result[6]['Attachment']);
|
||||
}
|
||||
|
@ -4823,7 +4811,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
// SQLite seems to reset the PK counter when that happens, so we need this to make the tests pass
|
||||
$this->db->truncate($TestModel);
|
||||
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$TestModel->saveMany(array(
|
||||
array(
|
||||
'title' => 'Multi-record post 1',
|
||||
|
@ -4860,10 +4847,10 @@ class ModelWriteTest extends BaseModelTest {
|
|||
)
|
||||
)
|
||||
);
|
||||
$this->assertTrue($result[0]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[0]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[1]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[1]['Post']['created'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[0]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[0]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[1]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[1]['Post']['created']);
|
||||
unset($result[0]['Post']['updated'], $result[0]['Post']['created']);
|
||||
unset($result[1]['Post']['updated'], $result[1]['Post']['created']);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -5414,7 +5401,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
||||
array('author_id' => 1, 'title' => '')
|
||||
);
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$this->assertFalse($TestModel->saveMany($data));
|
||||
|
||||
$result = $TestModel->find('all', array('recursive' => -1));
|
||||
|
@ -5467,10 +5453,10 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'published' => 'N',
|
||||
));
|
||||
|
||||
$this->assertTrue($result[3]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[3]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[4]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[4]['Post']['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[4]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[4]['Post']['updated']);
|
||||
unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
|
||||
unset($result[4]['Post']['created'], $result[4]['Post']['updated']);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -5485,7 +5471,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
array('author_id' => 1, 'title' => ''),
|
||||
array('author_id' => 1, 'title' => 'New Sixth Post')
|
||||
);
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$this->assertFalse($TestModel->saveMany($data));
|
||||
|
||||
$result = $TestModel->find('all', array('recursive' => -1));
|
||||
|
@ -5537,10 +5522,10 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'body' => 'Third Post Body',
|
||||
'published' => 'N'
|
||||
));
|
||||
$this->assertTrue($result[3]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[3]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[4]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[4]['Post']['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[4]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[4]['Post']['updated']);
|
||||
unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
|
||||
unset($result[4]['Post']['created'], $result[4]['Post']['updated']);
|
||||
}
|
||||
|
@ -5609,7 +5594,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$this->loadFixtures('Post', 'Author', 'Comment', 'Attachment');
|
||||
$TestModel = new Post();
|
||||
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$data = array(
|
||||
array(
|
||||
'id' => '1',
|
||||
|
@ -5672,10 +5656,10 @@ class ModelWriteTest extends BaseModelTest {
|
|||
)
|
||||
);
|
||||
|
||||
$this->assertTrue($result[0]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[1]['Post']['updated'] >= $ts);
|
||||
$this->assertTrue($result[3]['Post']['created'] >= $ts);
|
||||
$this->assertTrue($result[3]['Post']['updated'] >= $ts);
|
||||
$this->assertEquals(self::date(), $result[0]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[1]['Post']['updated']);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['created']);
|
||||
$this->assertEquals(self::date(), $result[3]['Post']['updated']);
|
||||
unset($result[0]['Post']['updated'], $result[1]['Post']['updated']);
|
||||
unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -6372,7 +6356,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$result = $TestModel->find('all');
|
||||
$this->assertEquals(3, count($result));
|
||||
$this->assertFalse(isset($result[3]));
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
|
||||
// test belongsTo
|
||||
$fieldList = array(
|
||||
|
@ -6398,15 +6381,15 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'title' => 'Post without body',
|
||||
'body' => null,
|
||||
'published' => 'N',
|
||||
'created' => $ts,
|
||||
'updated' => $ts,
|
||||
'created' => self::date(),
|
||||
'updated' => self::date(),
|
||||
),
|
||||
'Author' => array (
|
||||
'id' => '5',
|
||||
'user' => 'bob',
|
||||
'password' => null,
|
||||
'created' => $ts,
|
||||
'updated' => $ts,
|
||||
'created' => self::date(),
|
||||
'updated' => self::date(),
|
||||
'test' => 'working',
|
||||
),
|
||||
);
|
||||
|
@ -6418,7 +6401,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
// test multirecord
|
||||
$this->db->truncate($TestModel);
|
||||
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
$fieldList = array('title', 'author_id');
|
||||
$TestModel->saveAll(array(
|
||||
array(
|
||||
|
@ -6444,8 +6426,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'title' => 'Multi-record post 1',
|
||||
'body' => '',
|
||||
'published' => 'N',
|
||||
'created' => $ts,
|
||||
'updated' => $ts
|
||||
'created' => self::date(),
|
||||
'updated' => self::date()
|
||||
)
|
||||
),
|
||||
array(
|
||||
|
@ -6455,8 +6437,8 @@ class ModelWriteTest extends BaseModelTest {
|
|||
'title' => 'Multi-record post 2',
|
||||
'body' => '',
|
||||
'published' => 'N',
|
||||
'created' => $ts,
|
||||
'updated' => $ts
|
||||
'created' => self::date(),
|
||||
'updated' => self::date()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -6544,7 +6526,6 @@ class ModelWriteTest extends BaseModelTest {
|
|||
$result = $TestModel->find('all');
|
||||
$this->assertEquals(3, count($result));
|
||||
$this->assertFalse(isset($result[3]));
|
||||
$ts = date('Y-m-d H:i:s');
|
||||
|
||||
// test belongsTo
|
||||
$fieldList = array(
|
||||
|
|
|
@ -30,10 +30,6 @@ class CakeRequestTest extends CakeTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->_server = $_SERVER;
|
||||
$this->_get = $_GET;
|
||||
$this->_post = $_POST;
|
||||
$this->_files = $_FILES;
|
||||
$this->_app = Configure::read('App');
|
||||
$this->_case = null;
|
||||
if (isset($_GET['case'])) {
|
||||
|
@ -51,10 +47,6 @@ class CakeRequestTest extends CakeTestCase {
|
|||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
$_SERVER = $this->_server;
|
||||
$_GET = $this->_get;
|
||||
$_POST = $this->_post;
|
||||
$_FILES = $this->_files;
|
||||
if (!empty($this->_case)) {
|
||||
$_GET['case'] = $this->_case;
|
||||
}
|
||||
|
@ -217,94 +209,106 @@ class CakeRequestTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFILESParsing() {
|
||||
$_FILES = array('data' => array('name' => array(
|
||||
'File' => array(
|
||||
array('data' => 'cake_sqlserver_patch.patch'),
|
||||
array('data' => 'controller.diff'),
|
||||
array('data' => ''),
|
||||
array('data' => ''),
|
||||
public function testFilesParsing() {
|
||||
$_FILES = array(
|
||||
'data' => array(
|
||||
'name' => array(
|
||||
'File' => array(
|
||||
array('data' => 'cake_sqlserver_patch.patch'),
|
||||
array('data' => 'controller.diff'),
|
||||
array('data' => ''),
|
||||
array('data' => ''),
|
||||
),
|
||||
'Post' => array('attachment' => 'jquery-1.2.1.js'),
|
||||
),
|
||||
'type' => array(
|
||||
'File' => array(
|
||||
array('data' => ''),
|
||||
array('data' => ''),
|
||||
array('data' => ''),
|
||||
array('data' => ''),
|
||||
),
|
||||
'Post' => array('attachment' => 'application/x-javascript'),
|
||||
),
|
||||
'Post' => array('attachment' => 'jquery-1.2.1.js'),
|
||||
),
|
||||
'type' => array(
|
||||
'File' => array(
|
||||
array('data' => ''),
|
||||
array('data' => ''),
|
||||
array('data' => ''),
|
||||
array('data' => ''),
|
||||
'tmp_name' => array(
|
||||
'File' => array(
|
||||
array('data' => '/private/var/tmp/phpy05Ywj'),
|
||||
array('data' => '/private/var/tmp/php7MBztY'),
|
||||
array('data' => ''),
|
||||
array('data' => ''),
|
||||
),
|
||||
'Post' => array('attachment' => '/private/var/tmp/phpEwlrIo'),
|
||||
),
|
||||
'Post' => array('attachment' => 'application/x-javascript'),
|
||||
),
|
||||
'tmp_name' => array(
|
||||
'File' => array(
|
||||
array('data' => '/private/var/tmp/phpy05Ywj'),
|
||||
array('data' => '/private/var/tmp/php7MBztY'),
|
||||
array('data' => ''),
|
||||
array('data' => ''),
|
||||
'error' => array(
|
||||
'File' => array(
|
||||
array('data' => 0),
|
||||
array('data' => 0),
|
||||
array('data' => 4),
|
||||
array('data' => 4)
|
||||
),
|
||||
'Post' => array('attachment' => 0)
|
||||
),
|
||||
'Post' => array('attachment' => '/private/var/tmp/phpEwlrIo'),
|
||||
),
|
||||
'error' => array(
|
||||
'File' => array(
|
||||
array('data' => 0),
|
||||
array('data' => 0),
|
||||
array('data' => 4),
|
||||
array('data' => 4)
|
||||
'size' => array(
|
||||
'File' => array(
|
||||
array('data' => 6271),
|
||||
array('data' => 350),
|
||||
array('data' => 0),
|
||||
array('data' => 0),
|
||||
),
|
||||
'Post' => array('attachment' => 80469)
|
||||
),
|
||||
'Post' => array('attachment' => 0)
|
||||
),
|
||||
'size' => array(
|
||||
'File' => array(
|
||||
array('data' => 6271),
|
||||
array('data' => 350),
|
||||
array('data' => 0),
|
||||
array('data' => 0),
|
||||
),
|
||||
'Post' => array('attachment' => 80469)
|
||||
),
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
$request = new CakeRequest('some/path');
|
||||
$expected = array(
|
||||
'File' => array(
|
||||
array('data' => array(
|
||||
'name' => 'cake_sqlserver_patch.patch',
|
||||
'type' => '',
|
||||
'tmp_name' => '/private/var/tmp/phpy05Ywj',
|
||||
'error' => 0,
|
||||
'size' => 6271,
|
||||
)),
|
||||
array(
|
||||
'data' => array(
|
||||
'name' => 'controller.diff',
|
||||
'type' => '',
|
||||
'tmp_name' => '/private/var/tmp/php7MBztY',
|
||||
'error' => 0,
|
||||
'size' => 350,
|
||||
)),
|
||||
array('data' => array(
|
||||
'name' => '',
|
||||
'type' => '',
|
||||
'tmp_name' => '',
|
||||
'error' => 4,
|
||||
'size' => 0,
|
||||
)),
|
||||
array('data' => array(
|
||||
'name' => '',
|
||||
'type' => '',
|
||||
'tmp_name' => '',
|
||||
'error' => 4,
|
||||
'size' => 0,
|
||||
)),
|
||||
'name' => 'cake_sqlserver_patch.patch',
|
||||
'type' => '',
|
||||
'tmp_name' => '/private/var/tmp/phpy05Ywj',
|
||||
'error' => 0,
|
||||
'size' => 6271,
|
||||
)
|
||||
),
|
||||
array(
|
||||
'data' => array(
|
||||
'name' => 'controller.diff',
|
||||
'type' => '',
|
||||
'tmp_name' => '/private/var/tmp/php7MBztY',
|
||||
'error' => 0,
|
||||
'size' => 350,
|
||||
)
|
||||
),
|
||||
array(
|
||||
'data' => array(
|
||||
'name' => '',
|
||||
'type' => '',
|
||||
'tmp_name' => '',
|
||||
'error' => 4,
|
||||
'size' => 0,
|
||||
)
|
||||
),
|
||||
array(
|
||||
'data' => array(
|
||||
'name' => '',
|
||||
'type' => '',
|
||||
'tmp_name' => '',
|
||||
'error' => 4,
|
||||
'size' => 0,
|
||||
)
|
||||
),
|
||||
),
|
||||
'Post' => array('attachment' => array(
|
||||
'name' => 'jquery-1.2.1.js',
|
||||
'type' => 'application/x-javascript',
|
||||
'tmp_name' => '/private/var/tmp/phpEwlrIo',
|
||||
'error' => 0,
|
||||
'size' => 80469,
|
||||
))
|
||||
'Post' => array(
|
||||
'attachment' => array(
|
||||
'name' => 'jquery-1.2.1.js',
|
||||
'type' => 'application/x-javascript',
|
||||
'tmp_name' => '/private/var/tmp/phpEwlrIo',
|
||||
'error' => 0,
|
||||
'size' => 80469,
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->assertEquals($expected, $request->data);
|
||||
|
||||
|
@ -343,12 +347,12 @@ class CakeRequestTest extends CakeTestCase {
|
|||
1 => array(
|
||||
'birth_cert' => '/private/var/tmp/phpbsUWfH',
|
||||
'passport' => '/private/var/tmp/php7f5zLt',
|
||||
'drivers_license' => '/private/var/tmp/phpMXpZgT',
|
||||
'drivers_license' => '/private/var/tmp/phpMXpZgT',
|
||||
),
|
||||
2 => array(
|
||||
'birth_cert' => '/private/var/tmp/php5kHZt0',
|
||||
'passport' => '/private/var/tmp/phpnYkOuM',
|
||||
'drivers_license' => '/private/var/tmp/php9Rq0P3',
|
||||
'passport' => '/private/var/tmp/phpnYkOuM',
|
||||
'drivers_license' => '/private/var/tmp/php9Rq0P3',
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -357,12 +361,12 @@ class CakeRequestTest extends CakeTestCase {
|
|||
1 => array(
|
||||
'birth_cert' => 0,
|
||||
'passport' => 0,
|
||||
'drivers_license' => 0,
|
||||
'drivers_license' => 0,
|
||||
),
|
||||
2 => array(
|
||||
'birth_cert' => 0,
|
||||
'passport' => 0,
|
||||
'drivers_license' => 0,
|
||||
'passport' => 0,
|
||||
'drivers_license' => 0,
|
||||
)
|
||||
)
|
||||
),
|
||||
|
@ -371,12 +375,12 @@ class CakeRequestTest extends CakeTestCase {
|
|||
1 => array(
|
||||
'birth_cert' => 123,
|
||||
'passport' => 458,
|
||||
'drivers_license' => 875,
|
||||
'drivers_license' => 875,
|
||||
),
|
||||
2 => array(
|
||||
'birth_cert' => 876,
|
||||
'passport' => 976,
|
||||
'drivers_license' => 9783,
|
||||
'passport' => 976,
|
||||
'drivers_license' => 9783,
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -48,7 +48,7 @@ class TestDispatcher extends Dispatcher {
|
|||
* Controller instance, made publicly available for testing
|
||||
*
|
||||
* @var Controller
|
||||
**/
|
||||
*/
|
||||
public $controller;
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ class TestDispatcher extends Dispatcher {
|
|||
*
|
||||
* @param CakeEvent
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function filterTest($event) {
|
||||
$event->data['request']->params['eventName'] = $event->name();
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class TestDispatcher extends Dispatcher {
|
|||
*
|
||||
* @param CakeEvent
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function filterTest2($event) {
|
||||
$event->stopPropagation();
|
||||
return $event->data['response'];
|
||||
|
@ -783,7 +783,6 @@ class DispatcherTest extends CakeTestCase {
|
|||
$Dispatcher->dispatch($url, $response, array('return' => 1));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testDispatch method
|
||||
*
|
||||
|
@ -1194,7 +1193,7 @@ class DispatcherTest extends CakeTestCase {
|
|||
* Tests that it is possible to attach filter classes to the dispatch cycle
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function testDispatcherFilterSuscriber() {
|
||||
App::build(array(
|
||||
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS),
|
||||
|
@ -1234,7 +1233,7 @@ class DispatcherTest extends CakeTestCase {
|
|||
*
|
||||
* @expectedException MissingDispatcherFilterException
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function testDispatcherFilterSuscriberMissing() {
|
||||
App::build(array(
|
||||
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
|
||||
|
@ -1250,12 +1249,11 @@ class DispatcherTest extends CakeTestCase {
|
|||
$dispatcher->dispatch($request, $response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests it is possible to attach single callables as filters
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function testDispatcherFilterCallable() {
|
||||
App::build(array(
|
||||
'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS)
|
||||
|
@ -1513,7 +1511,6 @@ class DispatcherTest extends CakeTestCase {
|
|||
$this->assertEquals('404', $response->statusCode());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Data provider for cached actions.
|
||||
*
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* RouterTest file
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
|
||||
|
@ -41,7 +37,7 @@ class AssetDispatcherTest extends CakeTestCase {
|
|||
$filter = new AssetDispatcher();
|
||||
$response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
Configure::write('Asset.filter', array(
|
||||
'js' => '',
|
||||
'js' => '',
|
||||
'css' => ''
|
||||
));
|
||||
App::build(array(
|
||||
|
@ -85,11 +81,11 @@ class AssetDispatcherTest extends CakeTestCase {
|
|||
* file dispatching
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
*/
|
||||
public function testNotModified() {
|
||||
$filter = new AssetDispatcher();
|
||||
Configure::write('Asset.filter', array(
|
||||
'js' => '',
|
||||
'js' => '',
|
||||
'css' => ''
|
||||
));
|
||||
App::build(array(
|
||||
|
@ -125,4 +121,4 @@ class AssetDispatcherTest extends CakeTestCase {
|
|||
$this->assertSame($response, $filter->beforeDispatch($event));
|
||||
$this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,29 @@ class CakeTestSuiteTest extends CakeTestCase {
|
|||
|
||||
$suite->addTestDirectoryRecursive($Folder->pwd());
|
||||
|
||||
$Folder->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* testAddTestDirectoryRecursiveWithNonPhp
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddTestDirectoryRecursiveWithNonPhp() {
|
||||
$this->skipIf(!is_writeable(TMP), 'Cant addTestDirectoryRecursiveWithNonPhp unless the tmp folder is writable.');
|
||||
|
||||
$Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
|
||||
touch($Folder->path . DS . 'BackupTest.php~');
|
||||
touch($Folder->path . DS . 'SomeNotesTest.txt');
|
||||
touch($Folder->path . DS . 'NotHiddenTest.php');
|
||||
|
||||
$suite = $this->getMock('CakeTestSuite', array('addTestFile'));
|
||||
$suite
|
||||
->expects($this->exactly(1))
|
||||
->method('addTestFile');
|
||||
|
||||
$suite->addTestDirectoryRecursive($Folder->pwd());
|
||||
|
||||
$Folder->delete();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ class InflectorTest extends CakeTestCase {
|
|||
$this->assertEquals(Inflector::singularize('cafes'), 'cafe');
|
||||
$this->assertEquals(Inflector::singularize('roofs'), 'roof');
|
||||
$this->assertEquals(Inflector::singularize('foes'), 'foe');
|
||||
$this->assertEquals(Inflector::singularize('databases'), 'database');
|
||||
|
||||
$this->assertEquals(Inflector::singularize(''), '');
|
||||
}
|
||||
|
|
|
@ -4799,84 +4799,12 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$this->assertTags($result, $expected);
|
||||
$this->assertNotRegExp('/<option[^<>]+value=""[^<>]+selected="selected"[^>]*>/', $result);
|
||||
|
||||
|
||||
$result = $this->Form->dateTime('Contact.date', 'DMY', '12', array('value' => false));
|
||||
$expected = array(
|
||||
array('select' => array('name' => 'data[Contact][date][day]', 'id' => 'ContactDateDay')),
|
||||
$daysRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
'-',
|
||||
array('select' => array('name' => 'data[Contact][date][month]', 'id' => 'ContactDateMonth')),
|
||||
$monthsRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
'-',
|
||||
array('select' => array('name' => 'data[Contact][date][year]', 'id' => 'ContactDateYear')),
|
||||
$yearsRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
array('select' => array('name' => 'data[Contact][date][hour]', 'id' => 'ContactDateHour')),
|
||||
$hoursRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
':',
|
||||
array('select' => array('name' => 'data[Contact][date][min]', 'id' => 'ContactDateMin')),
|
||||
$minutesRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
' ',
|
||||
array('select' => array('name' => 'data[Contact][date][meridian]', 'id' => 'ContactDateMeridian')),
|
||||
$meridianRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
$this->assertNotRegExp('/<option[^<>]+value=""[^<>]+selected="selected"[^>]*>/', $result);
|
||||
|
||||
$result = $this->Form->dateTime('Contact.date', 'DMY', '12', array('value' => ''));
|
||||
$expected = array(
|
||||
array('select' => array('name' => 'data[Contact][date][day]', 'id' => 'ContactDateDay')),
|
||||
$daysRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
'-',
|
||||
array('select' => array('name' => 'data[Contact][date][month]', 'id' => 'ContactDateMonth')),
|
||||
$monthsRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
'-',
|
||||
array('select' => array('name' => 'data[Contact][date][year]', 'id' => 'ContactDateYear')),
|
||||
$yearsRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
array('select' => array('name' => 'data[Contact][date][hour]', 'id' => 'ContactDateHour')),
|
||||
$hoursRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
':',
|
||||
array('select' => array('name' => 'data[Contact][date][min]', 'id' => 'ContactDateMin')),
|
||||
$minutesRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
' ',
|
||||
array('select' => array('name' => 'data[Contact][date][meridian]', 'id' => 'ContactDateMeridian')),
|
||||
$meridianRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
$this->assertNotRegExp('/<option[^<>]+value=""[^<>]+selected="selected"[^>]*>/', $result);
|
||||
|
||||
|
@ -4930,53 +4858,7 @@ class FormHelperTest extends CakeTestCase {
|
|||
$this->assertNotRegExp('/<option[^<>]+value=""[^<>]+selected="selected"[^>]*>/', $result);
|
||||
|
||||
$result = $this->Form->dateTime('Contact.date', 'DMY', '12', array('minuteInterval' => 5, 'value' => ''));
|
||||
$expected = array(
|
||||
array('select' => array('name' => 'data[Contact][date][day]', 'id' => 'ContactDateDay')),
|
||||
$daysRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
'-',
|
||||
array('select' => array('name' => 'data[Contact][date][month]', 'id' => 'ContactDateMonth')),
|
||||
$monthsRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
'-',
|
||||
array('select' => array('name' => 'data[Contact][date][year]', 'id' => 'ContactDateYear')),
|
||||
$yearsRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
array('select' => array('name' => 'data[Contact][date][hour]', 'id' => 'ContactDateHour')),
|
||||
$hoursRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select',
|
||||
':',
|
||||
array('select' => array('name' => 'data[Contact][date][min]', 'id' => 'ContactDateMin')),
|
||||
$minutesRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
array('option' => array('value' => '00')),
|
||||
'00',
|
||||
'/option',
|
||||
array('option' => array('value' => '05')),
|
||||
'05',
|
||||
'/option',
|
||||
array('option' => array('value' => '10')),
|
||||
'10',
|
||||
'/option',
|
||||
'*/select',
|
||||
' ',
|
||||
array('select' => array('name' => 'data[Contact][date][meridian]', 'id' => 'ContactDateMeridian')),
|
||||
$meridianRegex,
|
||||
array('option' => array('value' => '')),
|
||||
'/option',
|
||||
'*/select'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
$this->assertNotRegExp('/<option[^<>]+value=""[^<>]+selected="selected"[^>]*>/', $result);
|
||||
$result = $this->Form->dateTime('Contact.date', 'DMY', '12', array('minuteInterval' => 5, 'value' => ''));
|
||||
|
||||
$this->Form->request->data['Contact']['data'] = null;
|
||||
$result = $this->Form->dateTime('Contact.date', 'DMY', '12');
|
||||
|
|
|
@ -1263,33 +1263,6 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->nestedList($list, null);
|
||||
$expected = array(
|
||||
'<ul',
|
||||
'<li', 'Item 1', '/li',
|
||||
'<li', 'Item 2',
|
||||
'<ul', '<li', 'Item 2.1', '/li', '/ul',
|
||||
'/li',
|
||||
'<li', 'Item 3', '/li',
|
||||
'<li', 'Item 4',
|
||||
'<ul',
|
||||
'<li', 'Item 4.1', '/li',
|
||||
'<li', 'Item 4.2', '/li',
|
||||
'<li', 'Item 4.3',
|
||||
'<ul',
|
||||
'<li', 'Item 4.3.1', '/li',
|
||||
'<li', 'Item 4.3.2', '/li',
|
||||
'/ul',
|
||||
'/li',
|
||||
'/ul',
|
||||
'/li',
|
||||
'<li', 'Item 5',
|
||||
'<ul',
|
||||
'<li', 'Item 5.1', '/li',
|
||||
'<li', 'Item 5.2', '/li',
|
||||
'/ul',
|
||||
'/li',
|
||||
'/ul'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->nestedList($list, array(), array(), 'ol');
|
||||
|
@ -1323,33 +1296,6 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->nestedList($list, 'ol');
|
||||
$expected = array(
|
||||
'<ol',
|
||||
'<li', 'Item 1', '/li',
|
||||
'<li', 'Item 2',
|
||||
'<ol', '<li', 'Item 2.1', '/li', '/ol',
|
||||
'/li',
|
||||
'<li', 'Item 3', '/li',
|
||||
'<li', 'Item 4',
|
||||
'<ol',
|
||||
'<li', 'Item 4.1', '/li',
|
||||
'<li', 'Item 4.2', '/li',
|
||||
'<li', 'Item 4.3',
|
||||
'<ol',
|
||||
'<li', 'Item 4.3.1', '/li',
|
||||
'<li', 'Item 4.3.2', '/li',
|
||||
'/ol',
|
||||
'/li',
|
||||
'/ol',
|
||||
'/li',
|
||||
'<li', 'Item 5',
|
||||
'<ol',
|
||||
'<li', 'Item 5.1', '/li',
|
||||
'<li', 'Item 5.2', '/li',
|
||||
'/ol',
|
||||
'/li',
|
||||
'/ol'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Html->nestedList($list, array('class' => 'list'));
|
||||
|
|
|
@ -155,6 +155,16 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See CakeTestSuiteDispatcher::date()
|
||||
*
|
||||
* @param string $format format to be used.
|
||||
* @return string
|
||||
*/
|
||||
public static function date($format = 'Y-m-d H:i:s') {
|
||||
return CakeTestSuiteDispatcher::date($format);
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart PHPUnit overrides don't match CakePHP
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,7 +37,9 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite {
|
|||
list($dirs, $files) = $Folder->read(true, true, true);
|
||||
|
||||
foreach ($files as $file) {
|
||||
$this->addTestFile($file);
|
||||
if (substr($file, -4) === '.php') {
|
||||
$this->addTestFile($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +54,9 @@ class CakeTestSuite extends PHPUnit_Framework_TestSuite {
|
|||
$files = $Folder->tree(null, true, 'files');
|
||||
|
||||
foreach ($files as $file) {
|
||||
$this->addTestFile($file);
|
||||
if (substr($file, -4) === '.php') {
|
||||
$this->addTestFile($file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -247,6 +247,7 @@ class CakeTestSuiteDispatcher {
|
|||
restore_error_handler();
|
||||
|
||||
try {
|
||||
self::time();
|
||||
$command = new CakeTestSuiteCommand('CakeTestLoader', $commandArgs);
|
||||
$result = $command->run($options);
|
||||
} catch (MissingConnectionException $exception) {
|
||||
|
@ -257,4 +258,29 @@ class CakeTestSuiteDispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a static timestamp
|
||||
*
|
||||
* @param boolean $reset to set new static timestamp.
|
||||
* @return integer timestamp
|
||||
*/
|
||||
public static function time($reset = false) {
|
||||
static $now;
|
||||
if ($reset || !$now) {
|
||||
$now = time();
|
||||
}
|
||||
return $now;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns formatted date string using static time
|
||||
* This method is being used as formatter for created, modified and updated fields in Model::save()
|
||||
*
|
||||
* @param string $format format to be used.
|
||||
* @return string formatted date
|
||||
*/
|
||||
public static function date($format) {
|
||||
return date($format, self::time());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,5 +53,18 @@ class CakeTestModel extends Model {
|
|||
}
|
||||
return $queryData;
|
||||
}
|
||||
/**
|
||||
* Overriding save() to set CakeTestSuiteDispatcher::date() as formatter for created, modified and updated fields
|
||||
*
|
||||
* @param array $data
|
||||
* @param mixed $validate
|
||||
* @param array $fieldList
|
||||
*/
|
||||
|
||||
}
|
||||
public function save($data = null, $validate = true, $fieldList = array()) {
|
||||
$db = $this->getDataSource();
|
||||
$db->columns['datetime']['formatter'] = 'CakeTestSuiteDispatcher::date';
|
||||
return parent::save($data, $validate, $fieldList);
|
||||
}
|
||||
|
||||
}
|
|
@ -33,12 +33,24 @@ class CakeHtmlReporter extends CakeBaseReporter {
|
|||
*/
|
||||
public function paintHeader() {
|
||||
$this->_headerSent = true;
|
||||
$this->sendContentType();
|
||||
$this->sendNoCacheHeaders();
|
||||
$this->paintDocumentStart();
|
||||
$this->paintTestMenu();
|
||||
echo "<ul class='tests'>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content-type header so it is in the correct encoding.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sendContentType() {
|
||||
if (!headers_sent()) {
|
||||
header('Content-Type: text/html; charset=' . Configure::read('App.encoding'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the document start content contained in header.php
|
||||
*
|
||||
|
|
|
@ -124,7 +124,7 @@ class Inflector {
|
|||
'/(drive)s$/i' => '\1',
|
||||
'/([^fo])ves$/i' => '\1fe',
|
||||
'/(^analy)ses$/i' => '\1sis',
|
||||
'/(analy|ba|diagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
|
||||
'/(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
|
||||
'/([ti])a$/i' => '\1um',
|
||||
'/(p)eople$/i' => '\1\2erson',
|
||||
'/(m)en$/i' => '\1an',
|
||||
|
|
|
@ -50,7 +50,9 @@ class HelperCollection extends ObjectCollection implements CakeEventListener {
|
|||
*
|
||||
* @param string $helper The helper name to be loaded
|
||||
* @return boolean wheter the helper could be loaded or not
|
||||
**/
|
||||
* @throws MissingHelperException When a helper could not be found.
|
||||
* App helpers are searched, and then plugin helpers.
|
||||
*/
|
||||
public function __isset($helper) {
|
||||
if (parent::__isset($helper)) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue