mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch 'local/svn/1.2.x.x' into 1.2
This commit is contained in:
commit
a2b22ce80e
29 changed files with 10471 additions and 9496 deletions
|
@ -624,9 +624,9 @@ if (!function_exists('file_put_contents')) {
|
|||
}
|
||||
|
||||
if ($return === false) {
|
||||
echo I18n::translate($singular, $plural, null, 5, $count);
|
||||
echo I18n::translate($singular, $plural, null, 6, $count);
|
||||
} else {
|
||||
return I18n::translate($singular, $plural, null, 5, $count);
|
||||
return I18n::translate($singular, $plural, null, 6, $count);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -672,9 +672,9 @@ if (!function_exists('file_put_contents')) {
|
|||
}
|
||||
|
||||
if ($return === false) {
|
||||
echo I18n::translate($singular, $plural, $domain, 5, $count);
|
||||
echo I18n::translate($singular, $plural, $domain, 6, $count);
|
||||
} else {
|
||||
return I18n::translate($singular, $plural, $domain, 5, $count);
|
||||
return I18n::translate($singular, $plural, $domain, 6, $count);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -723,13 +723,13 @@ if (!function_exists('file_put_contents')) {
|
|||
* Valid categories are: LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES and LC_ALL.
|
||||
*
|
||||
* Note that the category must be specified with a numeric value, instead of the constant name. The values are:
|
||||
* LC_CTYPE 0
|
||||
* LC_NUMERIC 1
|
||||
* LC_TIME 2
|
||||
* LC_COLLATE 3
|
||||
* LC_MONETARY 4
|
||||
* LC_MESSAGES 5
|
||||
* LC_ALL 6
|
||||
* LC_ALL 0
|
||||
* LC_COLLATE 1
|
||||
* LC_CTYPE 2
|
||||
* LC_MONETARY 3
|
||||
* LC_NUMERIC 4
|
||||
* LC_TIME 5
|
||||
* LC_MESSAGES 6
|
||||
*
|
||||
* @param string $domain Domain
|
||||
* @param string $singular Singular string to translate
|
||||
|
|
|
@ -252,8 +252,7 @@ class ConsoleShell extends Shell {
|
|||
if ($this->__isValidModel($modelToSave)) {
|
||||
// Extract the array of data we are trying to build
|
||||
list($foo, $data) = explode("->save", $command);
|
||||
$badChars = array("(", ")");
|
||||
$data = str_replace($badChars, "", $data);
|
||||
$data = preg_replace('/^\(*(array)?\(*(.+?)\)*$/i', '\\2', $data);
|
||||
$saveCommand = "\$this->{$modelToSave}->save(array('{$modelToSave}' => array({$data})));";
|
||||
@eval($saveCommand);
|
||||
$this->out('Saved record for ' . $modelToSave);
|
||||
|
@ -336,4 +335,4 @@ class ConsoleShell extends Shell {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -199,7 +199,7 @@ class SchemaShell extends Shell {
|
|||
}
|
||||
}
|
||||
$db =& ConnectionManager::getDataSource($this->Schema->connection);
|
||||
$contents = "#". $Schema->name ." sql generated on: " . date('Y-m-d H:m:s') . " : ". time()."\n\n";
|
||||
$contents = "#". $Schema->name ." sql generated on: " . date('Y-m-d H:i:s') . " : ". time()."\n\n";
|
||||
$contents .= $db->dropSchema($Schema) . "\n\n". $db->createSchema($Schema);
|
||||
if ($write) {
|
||||
if (strpos($write, '.sql') === false) {
|
||||
|
|
|
@ -484,7 +484,7 @@ class ControllerTask extends Shell {
|
|||
$this->out("\nBaking unit test for $className...");
|
||||
|
||||
$header = '$Id';
|
||||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $className ."Controller Test cases generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
|
||||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $className ."Controller Test cases generated on: " . date('Y-m-d H:i:s') . " : ". time() . "*/\n{$out}?>";
|
||||
return $this->createFile($path . $filename, $content);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -733,7 +733,7 @@ class ModelTask extends Shell {
|
|||
$this->out("\nBaking unit test for $className...");
|
||||
|
||||
$header = '$Id';
|
||||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $className ." Test cases generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
|
||||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $className ." Test cases generated on: " . date('Y-m-d H:i:s') . " : ". time() . "*/\n{$out}?>";
|
||||
return $this->createFile($path . $filename, $content);
|
||||
}
|
||||
return false;
|
||||
|
@ -927,7 +927,7 @@ class ModelTask extends Shell {
|
|||
}
|
||||
$filename = Inflector::underscore($model).'_fixture.php';
|
||||
$header = '$Id';
|
||||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $model ." Fixture generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
|
||||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $model ." Fixture generated on: " . date('Y-m-d H:i:s') . " : ". time() . "*/\n{$out}?>";
|
||||
$this->out("\nBaking test fixture for $model...");
|
||||
if ($this->createFile($path . $filename, $content)) {
|
||||
return str_replace("\t\t", "\t\t\t", $records);
|
||||
|
|
|
@ -181,7 +181,7 @@ class TestTask extends Shell {
|
|||
}
|
||||
|
||||
$header = '$Id';
|
||||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $name ." Test cases generated on: " . date('Y-m-d H:m:s') . " : ". time() . "*/\n{$out}?>";
|
||||
$content = "<?php \n/* SVN FILE: $header$ */\n/* ". $name ." Test cases generated on: " . date('Y-m-d H:i:s') . " : ". time() . "*/\n{$out}?>";
|
||||
return $this->createFile($this->filePath . Inflector::underscore($name) . '.test.php', $content);
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -346,6 +346,7 @@ class EmailComponent extends Object{
|
|||
$this->subject = null;
|
||||
$this->additionalParams = null;
|
||||
$this->smtpError = null;
|
||||
$this->attachments = array();
|
||||
$this->__header = array();
|
||||
$this->__boundary = null;
|
||||
$this->__message = array();
|
||||
|
|
|
@ -585,7 +585,7 @@ class RequestHandlerComponent extends Object {
|
|||
if (empty($this->__renderType)) {
|
||||
$controller->viewPath .= '/' . $type;
|
||||
} else {
|
||||
$remove = preg_replace("/(?:\/{$type})$/", '/' . $type, $controller->viewPath);
|
||||
$remove = preg_replace("/(?:\/{$this->__renderType})$/", '/' . $type, $controller->viewPath);
|
||||
$controller->viewPath = $remove;
|
||||
}
|
||||
$this->__renderType = $type;
|
||||
|
|
|
@ -220,7 +220,10 @@ class HttpSocket extends CakeSocket {
|
|||
$this->request['header']['Content-Length'] = strlen($this->request['body']);
|
||||
}
|
||||
|
||||
$connectionType = @$this->request['header']['Connection'];
|
||||
$connectionType = null;
|
||||
if (isset($this->request['header']['Connection'])) {
|
||||
$connectionType = $this->request['header']['Connection'];
|
||||
}
|
||||
$this->request['header'] = $this->buildHeader($this->request['header']).$cookies;
|
||||
|
||||
if (empty($this->request['line'])) {
|
||||
|
@ -395,7 +398,11 @@ class HttpSocket extends CakeSocket {
|
|||
}
|
||||
|
||||
$response['header'] = $this->parseHeader($response['raw']['header']);
|
||||
$decoded = $this->decodeBody($response['raw']['body'], @$response['header']['Transfer-Encoding']);
|
||||
$transferEncoding = null;
|
||||
if (isset($response['header']['Transfer-Encoding'])) {
|
||||
$transferEncoding = $response['header']['Transfer-Encoding'];
|
||||
}
|
||||
$decoded = $this->decodeBody($response['raw']['body'], $transferEncoding);
|
||||
$response['body'] = $decoded['body'];
|
||||
|
||||
if (!empty($decoded['header'])) {
|
||||
|
|
|
@ -62,7 +62,7 @@ class I18n extends Object {
|
|||
* Current language used for translations
|
||||
*
|
||||
* @var string
|
||||
* @access private;
|
||||
* @access private
|
||||
*/
|
||||
var $__lang = null;
|
||||
/**
|
||||
|
@ -94,7 +94,9 @@ class I18n extends Object {
|
|||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $__categories = array('LC_CTYPE', 'LC_NUMERIC', 'LC_TIME', 'LC_COLLATE', 'LC_MONETARY', 'LC_MESSAGES', 'LC_ALL');
|
||||
var $__categories = array(
|
||||
'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'
|
||||
);
|
||||
/**
|
||||
* Return a static instance of the I18n class
|
||||
*
|
||||
|
@ -111,7 +113,7 @@ class I18n extends Object {
|
|||
}
|
||||
/**
|
||||
* Used by the translation functions in basics.php
|
||||
* Can also be used like I18n::translate(); but only if the uses('i18n'); has been used to load the class.
|
||||
* Can also be used like I18n::translate(); but only if the App::import('I18n'); has been used to load the class.
|
||||
*
|
||||
* @param string $singular String to translate
|
||||
* @param string $plural Plural string (if any)
|
||||
|
@ -121,7 +123,7 @@ class I18n extends Object {
|
|||
* @return string translated strings.
|
||||
* @access public
|
||||
*/
|
||||
function translate($singular, $plural = null, $domain = null, $category = null, $count = null) {
|
||||
function translate($singular, $plural = null, $domain = null, $category = 6, $count = null) {
|
||||
$_this =& I18n::getInstance();
|
||||
|
||||
if (strpos($singular, "\r\n") !== false) {
|
||||
|
|
|
@ -827,8 +827,11 @@ class Model extends Overloadable {
|
|||
$type = $this->getColumnType($field);
|
||||
|
||||
if (in_array($type, array('datetime', 'timestamp', 'date', 'time'))) {
|
||||
$useNewDate = (isset($data['year']) || isset($data['month']) || isset($data['day']) || isset($data['hour']) || isset($data['minute']));
|
||||
$useNewDate = (isset($data['year']) || isset($data['month']) ||
|
||||
isset($data['day']) || isset($data['hour']) || isset($data['minute']));
|
||||
|
||||
$dateFields = array('Y' => 'year', 'm' => 'month', 'd' => 'day', 'H' => 'hour', 'i' => 'min', 's' => 'sec');
|
||||
$timeFields = array('H' => 'hour', 'i' => 'min', 's' => 'sec');
|
||||
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
$format = $db->columns[$type]['format'];
|
||||
|
@ -840,27 +843,42 @@ class Model extends Overloadable {
|
|||
if (isset($data['hour']) && isset($data['meridian']) && $data['hour'] == 12 && 'am' == $data['meridian']) {
|
||||
$data['hour'] = '00';
|
||||
}
|
||||
|
||||
foreach ($dateFields as $key => $val) {
|
||||
if (in_array($val, array('hour', 'min', 'sec'))) {
|
||||
if (!isset($data[$val]) || $data[$val] === '0' || empty($data[$val])) {
|
||||
if ($type == 'time') {
|
||||
foreach ($timeFields as $key => $val) {
|
||||
if (!isset($data[$val]) || $data[$val] === '0' || $data[$val] === '00') {
|
||||
$data[$val] = '00';
|
||||
} elseif ($data[$val] === '') {
|
||||
$data[$val] = '';
|
||||
} else {
|
||||
$data[$val] = sprintf('%02d', $data[$val]);
|
||||
}
|
||||
if (!empty($data[$val])) {
|
||||
$date[$key] = $data[$val];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (in_array($type, array('datetime', 'timestamp', 'date')) && !isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) || $data[$val][0] === '-')) {
|
||||
return null;
|
||||
} elseif (isset($data[$val]) && !empty($data[$val])) {
|
||||
$date[$key] = $data[$val];
|
||||
}
|
||||
|
||||
if ($type == 'datetime' || $type == 'timestamp' || $type == 'date') {
|
||||
foreach ($dateFields as $key => $val) {
|
||||
if ($val == 'hour' || $val == 'min' || $val == 'sec') {
|
||||
if (!isset($data[$val]) || $data[$val] === '0' || $data[$val] === '00') {
|
||||
$data[$val] = '00';
|
||||
} else {
|
||||
$data[$val] = sprintf('%02d', $data[$val]);
|
||||
}
|
||||
}
|
||||
if (!isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) || $data[$val][0] === '-')) {
|
||||
return null;
|
||||
}
|
||||
if (isset($data[$val]) && !empty($data[$val])) {
|
||||
$date[$key] = $data[$val];
|
||||
}
|
||||
}
|
||||
}
|
||||
$date = str_replace(array_keys($date), array_values($date), $format);
|
||||
if ($type == 'time' && $date == '00:00:00') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($useNewDate && (!empty($date))) {
|
||||
if ($useNewDate && !empty($date)) {
|
||||
return $date;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,7 +120,11 @@ class CakeSocket extends Object {
|
|||
$this->setLastError($errStr, $errNum);
|
||||
}
|
||||
|
||||
return $this->connected = is_resource($this->connection);
|
||||
$this->connected = is_resource($this->connection);
|
||||
if ($this->connected) {
|
||||
stream_set_timeout($this->connection, $this->config['timeout']);
|
||||
}
|
||||
return $this->connected;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -218,7 +222,13 @@ class CakeSocket extends Object {
|
|||
}
|
||||
|
||||
if (!feof($this->connection)) {
|
||||
return fread($this->connection, $length);
|
||||
$buffer = fread($this->connection, $length);
|
||||
$info = stream_get_meta_data($this->connection);
|
||||
if ($info['timed_out']) {
|
||||
$this->setLastError(E_WARNING, __('Connection timed out', true));
|
||||
return false;
|
||||
}
|
||||
return $buffer;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -316,7 +316,7 @@ class HtmlHelper extends AppHelper {
|
|||
/**
|
||||
* Creates a link element for CSS stylesheets.
|
||||
*
|
||||
* @param mixed $path The name of a CSS style sheet or an array containing names of
|
||||
* @param mixed $path The name of a CSS style sheet or an array containing names of
|
||||
* CSS stylesheets. If `$path` is prefixed with '/', the path will be relative to the webroot
|
||||
* of your application. Otherwise, the path will be relative to your CSS path, usually webroot/css.
|
||||
* @param string $rel Rel attribute. Defaults to "stylesheet". If equal to 'import' the stylesheet will be imported.
|
||||
|
@ -437,10 +437,11 @@ class HtmlHelper extends AppHelper {
|
|||
} elseif ($path[0] === '/') {
|
||||
$path = $this->webroot($path);
|
||||
} elseif (strpos($path, '://') === false) {
|
||||
if ((Configure::read('Asset.timestamp') == true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') {
|
||||
$path .= '?' . @filemtime(str_replace('/', DS, WWW_ROOT . IMAGES_URL . $path));
|
||||
}
|
||||
$path = $this->webroot(IMAGES_URL . $path);
|
||||
|
||||
if ((Configure::read('Asset.timestamp') == true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') {
|
||||
$path .= '?' . @filemtime(str_replace('/', DS, WWW_ROOT . $path));
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($options['alt'])) {
|
||||
|
@ -639,4 +640,4 @@ class HtmlHelper extends AppHelper {
|
|||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
|
@ -60,10 +60,10 @@ class JavascriptHelper extends AppHelper {
|
|||
* @access public
|
||||
*/
|
||||
var $tags = array(
|
||||
'javascriptblock' => '<script type="text/javascript">%s</script>',
|
||||
'javascriptstart' => '<script type="text/javascript">',
|
||||
'javascriptlink' => '<script type="text/javascript" src="%s"></script>',
|
||||
'javascriptend' => '</script>'
|
||||
'javascriptend' => '</script>',
|
||||
'javascriptblock' => '<script type="text/javascript">%s</script>',
|
||||
'javascriptlink' => '<script type="text/javascript" src="%s"></script>'
|
||||
);
|
||||
/**
|
||||
* Holds options passed to codeBlock(), saved for when block is dumped to output
|
||||
|
@ -173,42 +173,28 @@ class JavascriptHelper extends AppHelper {
|
|||
$options = array();
|
||||
}
|
||||
$defaultOptions = array('allowCache' => true, 'safe' => true, 'inline' => true);
|
||||
$options = array_merge($defaultOptions, compact('safe'), $options);
|
||||
$options = array_merge($defaultOptions, $options);
|
||||
|
||||
if ($this->_cacheEvents && $this->_cacheAll && $options['allowCache'] && $script !== null) {
|
||||
if (empty($script)) {
|
||||
$this->__scriptBuffer = @ob_get_contents();
|
||||
$this->_blockOptions = $options;
|
||||
$this->inBlock = true;
|
||||
@ob_end_clean();
|
||||
ob_start();
|
||||
return null;
|
||||
}
|
||||
if ($this->_cacheEvents && $this->_cacheAll && $options['allowCache']) {
|
||||
$this->_cachedEvents[] = $script;
|
||||
return null;
|
||||
}
|
||||
if ($options['safe'] || $this->safe) {
|
||||
$script = "\n" . '//<![CDATA[' . "\n" . $script . "\n" . '//]]>' . "\n";
|
||||
}
|
||||
if ($options['inline']) {
|
||||
return sprintf($this->tags['javascriptblock'], $script);
|
||||
} else {
|
||||
$block = ($script !== null);
|
||||
$safe = ($options['safe'] || $this->safe);
|
||||
if ($safe && !($this->_cacheAll && $options['allowCache'])) {
|
||||
$script = "\n" . '//<![CDATA[' . "\n" . $script;
|
||||
if ($block) {
|
||||
$script .= "\n" . '//]]>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($script === null) {
|
||||
$this->__scriptBuffer = @ob_get_contents();
|
||||
$this->_blockOptions = $options;
|
||||
$this->inBlock = true;
|
||||
@ob_end_clean();
|
||||
ob_start();
|
||||
return null;
|
||||
} else if (!$block) {
|
||||
$this->_blockOptions = $options;
|
||||
}
|
||||
|
||||
if ($options['inline']) {
|
||||
if ($block) {
|
||||
return sprintf($this->tags['javascriptblock'], $script);
|
||||
} else {
|
||||
$safe = ($safe ? "\n" . '//<![CDATA[' . "\n" : '');
|
||||
return $this->tags['javascriptstart'] . $safe;
|
||||
}
|
||||
} elseif ($block) {
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
$view->addScript(sprintf($this->tags['javascriptblock'], $script));
|
||||
}
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
$view->addScript(sprintf($this->tags['javascriptblock'], $script));
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -217,26 +203,23 @@ class JavascriptHelper extends AppHelper {
|
|||
* @return mixed
|
||||
*/
|
||||
function blockEnd() {
|
||||
if (!isset($this->inBlock) || !$this->inBlock) {
|
||||
return;
|
||||
}
|
||||
$script = @ob_get_contents();
|
||||
@ob_end_clean();
|
||||
ob_start();
|
||||
echo $this->__scriptBuffer;
|
||||
$this->__scriptBuffer = null;
|
||||
$options = $this->_blockOptions;
|
||||
$safe = ((isset($options['safe']) && $options['safe']) || $this->safe);
|
||||
$this->_blockOptions = array();
|
||||
$this->inBlock = false;
|
||||
|
||||
if (isset($options['inline']) && !$options['inline']) {
|
||||
$view =& ClassRegistry::getObject('view');
|
||||
$view->addScript(sprintf($this->tags['javascriptblock'], $script));
|
||||
}
|
||||
|
||||
if (!empty($script) && $this->_cacheAll && $options['allowCache']) {
|
||||
$this->_cachedEvents[] = $script;
|
||||
|
||||
if (empty($script)) {
|
||||
return null;
|
||||
}
|
||||
return ife($safe, "\n" . '//]]>' . "\n", '').$this->tags['javascriptend'];
|
||||
|
||||
return $this->codeBlock($script, $options);
|
||||
}
|
||||
/**
|
||||
* Returns a JavaScript include tag (SCRIPT element). If the filename is prefixed with "/",
|
||||
|
|
|
@ -388,16 +388,16 @@ class BasicsTest extends CakeTestCase {
|
|||
function test__c() {
|
||||
Configure::write('Config.language', 'rule_1_po');
|
||||
|
||||
$result = __c('Plural Rule 1', 5, true);
|
||||
$result = __c('Plural Rule 1', 6, true);
|
||||
$expected = 'Plural Rule 1 (translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = __c('Plural Rule 1 (from core)', 5, true);
|
||||
$result = __c('Plural Rule 1 (from core)', 6, true);
|
||||
$expected = 'Plural Rule 1 (from core translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
ob_start();
|
||||
__c('Plural Rule 1 (from core)', 5);
|
||||
__c('Plural Rule 1 (from core)', 6);
|
||||
$result = ob_get_clean();
|
||||
$expected = 'Plural Rule 1 (from core translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
@ -411,24 +411,24 @@ class BasicsTest extends CakeTestCase {
|
|||
function test__dc() {
|
||||
Configure::write('Config.language', 'rule_1_po');
|
||||
|
||||
$result = __dc('default', 'Plural Rule 1', 5, true);
|
||||
$result = __dc('default', 'Plural Rule 1', 6, true);
|
||||
$expected = 'Plural Rule 1 (translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = __dc('default', 'Plural Rule 1 (from core)', 5, true);
|
||||
$result = __dc('default', 'Plural Rule 1 (from core)', 6, true);
|
||||
$expected = 'Plural Rule 1 (from core translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = __dc('core', 'Plural Rule 1', 5, true);
|
||||
$result = __dc('core', 'Plural Rule 1', 6, true);
|
||||
$expected = 'Plural Rule 1';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = __dc('core', 'Plural Rule 1 (from core)', 5, true);
|
||||
$result = __dc('core', 'Plural Rule 1 (from core)', 6, true);
|
||||
$expected = 'Plural Rule 1 (from core translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
ob_start();
|
||||
__dc('default', 'Plural Rule 1 (from core)', 5);
|
||||
__dc('default', 'Plural Rule 1 (from core)', 6);
|
||||
$result = ob_get_clean();
|
||||
$expected = 'Plural Rule 1 (from core translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
@ -442,20 +442,20 @@ class BasicsTest extends CakeTestCase {
|
|||
function test__dcn() {
|
||||
Configure::write('Config.language', 'rule_1_po');
|
||||
|
||||
$result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, 5, true);
|
||||
$result = __dcn('default', '%d = 1', '%d = 0 or > 1', 0, 6, true);
|
||||
$expected = '%d = 0 or > 1 (translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 5, true);
|
||||
$result = __dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 6, true);
|
||||
$expected = '%d = 1 (from core translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 5, true);
|
||||
$result = __dcn('core', '%d = 1', '%d = 0 or > 1', 0, 6, true);
|
||||
$expected = '%d = 0 or > 1';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
ob_start();
|
||||
__dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 5);
|
||||
__dcn('default', '%d = 1 (from core)', '%d = 0 or > 1 (from core)', 1, 6);
|
||||
$result = ob_get_clean();
|
||||
$expected = '%d = 1 (from core translated)';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
|
|
@ -574,6 +574,7 @@ TEXTBLOC;
|
|||
$this->Controller->EmailTest->additionalParams = 'X-additional-header';
|
||||
$this->Controller->EmailTest->delivery = 'smtp';
|
||||
$this->Controller->EmailTest->smtpOptions['host'] = 'blah';
|
||||
$this->Controller->EmailTest->attachments = array('attachment1', 'attachment2');
|
||||
|
||||
$this->assertFalse($this->Controller->EmailTest->send('Should not work'));
|
||||
|
||||
|
@ -592,6 +593,7 @@ TEXTBLOC;
|
|||
$this->assertNull($this->Controller->EmailTest->getBoundary());
|
||||
$this->assertIdentical($this->Controller->EmailTest->getMessage(), array());
|
||||
$this->assertNull($this->Controller->EmailTest->smtpError);
|
||||
$this->assertIdentical($this->Controller->EmailTest->attachments, array());
|
||||
}
|
||||
/**
|
||||
* osFix method
|
||||
|
|
|
@ -35,6 +35,13 @@ Mock::generatePartial('RequestHandlerComponent', 'NoStopRequestHandler', array('
|
|||
* @subpackage cake.tests.cases.libs.controller.components
|
||||
*/
|
||||
class RequestHandlerTestController extends Controller {
|
||||
/**
|
||||
* name property
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
**/
|
||||
var $name = 'RequestHandlerTest';
|
||||
/**
|
||||
* uses property
|
||||
*
|
||||
|
@ -124,21 +131,32 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
*/
|
||||
var $RequestHandler;
|
||||
/**
|
||||
* setUp method
|
||||
* startTest method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
function startTest() {
|
||||
$this->_init();
|
||||
}
|
||||
/**
|
||||
* tearDown method
|
||||
* init method
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
function _init() {
|
||||
$this->Controller = new RequestHandlerTestController(array('components' => array('RequestHandler')));
|
||||
$this->Controller->constructClasses();
|
||||
$this->RequestHandler =& $this->Controller->RequestHandler;
|
||||
}
|
||||
/**
|
||||
* endTest method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
function endTest() {
|
||||
unset($this->RequestHandler);
|
||||
unset($this->Controller);
|
||||
if (!headers_sent()) {
|
||||
|
@ -241,6 +259,24 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$this->RequestHandler->renderAs($this->Controller, 'xml');
|
||||
$this->assertTrue(in_array('Xml', $this->Controller->helpers));
|
||||
}
|
||||
/**
|
||||
* test that calling renderAs() more than once continues to work.
|
||||
*
|
||||
* @link #6466
|
||||
* @return void
|
||||
**/
|
||||
function testRenderAsCalledTwice() {
|
||||
$this->RequestHandler->renderAs($this->Controller, 'xml');
|
||||
$this->assertEqual($this->Controller->viewPath, 'request_handler_test/xml');
|
||||
$this->assertEqual($this->Controller->layoutPath, 'xml');
|
||||
|
||||
$this->assertTrue(in_array('Xml', $this->Controller->helpers));
|
||||
|
||||
$this->RequestHandler->renderAs($this->Controller, 'js');
|
||||
$this->assertEqual($this->Controller->viewPath, 'request_handler_test/js');
|
||||
$this->assertEqual($this->Controller->layoutPath, 'js');
|
||||
$this->assertTrue(in_array('Js', $this->Controller->helpers));
|
||||
}
|
||||
/**
|
||||
* testRequestClientTypes method
|
||||
*
|
||||
|
@ -502,16 +538,5 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
Configure::write('viewPaths', $_paths);
|
||||
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||
}
|
||||
/**
|
||||
* init method
|
||||
*
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
function _init() {
|
||||
$this->Controller = new RequestHandlerTestController(array('components' => array('RequestHandler')));
|
||||
$this->Controller->constructClasses();
|
||||
$this->RequestHandler =& $this->Controller->RequestHandler;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -39,8 +39,15 @@ class I18nTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
$this->_objects = Configure::read('__objects');
|
||||
Configure::write('__objects', array());
|
||||
|
||||
$this->_localePaths = Configure::read('localePaths');
|
||||
Configure::write('localePaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale'));
|
||||
|
||||
$this->_pluginPaths = Configure::read('pluginPaths');
|
||||
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins'));
|
||||
|
||||
}
|
||||
/**
|
||||
* tearDown method
|
||||
|
@ -50,6 +57,9 @@ class I18nTest extends CakeTestCase {
|
|||
*/
|
||||
function tearDown() {
|
||||
Configure::write('localePaths', $this->_localePaths);
|
||||
Configure::write('pluginPaths', $this->_pluginPaths);
|
||||
Configure::write('__objects', $this->_objects);
|
||||
|
||||
}
|
||||
/**
|
||||
* testDefaultStrings method
|
||||
|
@ -2353,9 +2363,6 @@ class I18nTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testPluginTranslation() {
|
||||
$pluginPaths = Configure::read('pluginPaths');
|
||||
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins'));
|
||||
|
||||
Configure::write('Config.language', 'po');
|
||||
$singular = $this->__domainSingular();
|
||||
$this->assertEqual('Plural Rule 1 (from plugin)', $singular);
|
||||
|
@ -2387,8 +2394,6 @@ class I18nTest extends CakeTestCase {
|
|||
$this->assertTrue(in_array('23 = 0 or > 1 (from plugin)', $plurals));
|
||||
$this->assertTrue(in_array('24 = 0 or > 1 (from plugin)', $plurals));
|
||||
$this->assertTrue(in_array('25 = 0 or > 1 (from plugin)', $plurals));
|
||||
|
||||
Configure::write('pluginPaths', $pluginPaths);
|
||||
}
|
||||
/**
|
||||
* testPoMultipleLineTranslation method
|
||||
|
@ -2484,6 +2489,12 @@ class I18nTest extends CakeTestCase {
|
|||
$expected = 'this is a "quoted string" (translated)';
|
||||
$this->assertEqual(__('this is a "quoted string"', true), $expected);
|
||||
}
|
||||
/**
|
||||
* testFloatValue method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testFloatValue() {
|
||||
Configure::write('Config.language', 'rule_9_po');
|
||||
|
||||
|
@ -2499,6 +2510,70 @@ class I18nTest extends CakeTestCase {
|
|||
$expected = "%d everything else (translated)";
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
/**
|
||||
* testCategory method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testCategory() {
|
||||
Configure::write('Config.language', 'po');
|
||||
$category = $this->__category();
|
||||
$this->assertEqual('Monetary Po (translated)', $category);
|
||||
}
|
||||
/**
|
||||
* testPluginCategory method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testPluginCategory() {
|
||||
Configure::write('Config.language', 'po');
|
||||
|
||||
$singular = $this->__domainCategorySingular();
|
||||
$this->assertEqual('Monetary Plural Rule 1 (from plugin)', $singular);
|
||||
|
||||
$plurals = $this->__domainCategoryPlural();
|
||||
$this->assertTrue(in_array('Monetary 0 = 0 or > 1 (from plugin)', $plurals));
|
||||
$this->assertTrue(in_array('Monetary 1 = 1 (from plugin)', $plurals));
|
||||
}
|
||||
/**
|
||||
* testCategoryThenSingular method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function testCategoryThenSingular() {
|
||||
Configure::write('Config.language', 'po');
|
||||
$category = $this->__category();
|
||||
$this->assertEqual('Monetary Po (translated)', $category);
|
||||
|
||||
$singular = $this->__singular();
|
||||
$this->assertEqual('Po (translated)', $singular);
|
||||
}
|
||||
/**
|
||||
* Singular method
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __domainCategorySingular($domain = 'test_plugin', $category = LC_MONETARY) {
|
||||
$singular = __dc($domain, 'Plural Rule 1', $category, true);
|
||||
return $singular;
|
||||
}
|
||||
/**
|
||||
* Plural method
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __domainCategoryPlural($domain = 'test_plugin', $category = LC_MONETARY) {
|
||||
$plurals = array();
|
||||
for ($number = 0; $number <= 25; $number++) {
|
||||
$plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category, true), (float)$number);
|
||||
}
|
||||
return $plurals;
|
||||
}
|
||||
/**
|
||||
* Singular method
|
||||
*
|
||||
|
@ -2522,6 +2597,16 @@ class I18nTest extends CakeTestCase {
|
|||
}
|
||||
return $plurals;
|
||||
}
|
||||
/**
|
||||
* category method
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
function __category($category = LC_MONETARY) {
|
||||
$singular = __c('Plural Rule 1', $category, true);
|
||||
return $singular;
|
||||
}
|
||||
/**
|
||||
* Singular method
|
||||
*
|
||||
|
|
|
@ -337,6 +337,58 @@ class Test2Behavior extends TestBehavior{
|
|||
*/
|
||||
class Test3Behavior extends TestBehavior{
|
||||
}
|
||||
/**
|
||||
* Test4Behavior class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class Test4Behavior extends ModelBehavior{
|
||||
function setup(&$model, $config = null) {
|
||||
$model->bindModel(
|
||||
array('hasMany' => array('Comment'))
|
||||
);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Test5Behavior class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class Test5Behavior extends ModelBehavior{
|
||||
function setup(&$model, $config = null) {
|
||||
$model->bindModel(
|
||||
array('belongsTo' => array('User'))
|
||||
);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Test6Behavior class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class Test6Behavior extends ModelBehavior{
|
||||
function setup(&$model, $config = null) {
|
||||
$model->bindModel(
|
||||
array('hasAndBelongsToMany' => array('Tag'))
|
||||
);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Test7Behavior class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.model
|
||||
*/
|
||||
class Test7Behavior extends ModelBehavior{
|
||||
function setup(&$model, $config = null) {
|
||||
$model->bindModel(
|
||||
array('hasOne' => array('Attachment'))
|
||||
);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* BehaviorTest class
|
||||
*
|
||||
|
@ -350,7 +402,10 @@ class BehaviorTest extends CakeTestCase {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $fixtures = array('core.apple', 'core.sample');
|
||||
var $fixtures = array(
|
||||
'core.apple', 'core.sample', 'core.article', 'core.user', 'core.comment',
|
||||
'core.attachment', 'core.tag', 'core.articles_tag'
|
||||
);
|
||||
/**
|
||||
* tearDown method
|
||||
*
|
||||
|
@ -948,6 +1003,53 @@ class BehaviorTest extends CakeTestCase {
|
|||
$expected = array('TestBehavior', 'Test2Behavior');
|
||||
$this->assertIdentical($Apple->beforeTestResult, $expected);
|
||||
}
|
||||
/**
|
||||
* undocumented function
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function testBindModelCallsInBehaviors() {
|
||||
$this->loadFixtures('Article', 'Comment');
|
||||
|
||||
// hasMany
|
||||
$Article = new Article();
|
||||
$Article->unbindModel(array('hasMany' => array('Comment')));
|
||||
$result = $Article->find('first');
|
||||
$this->assertFalse(array_key_exists('Comment', $result));
|
||||
|
||||
$Article->Behaviors->attach('Test4');
|
||||
$result = $Article->find('first');
|
||||
$this->assertTrue(array_key_exists('Comment', $result));
|
||||
|
||||
// belongsTo
|
||||
$Article->unbindModel(array('belongsTo' => array('User')));
|
||||
$result = $Article->find('first');
|
||||
$this->assertFalse(array_key_exists('User', $result));
|
||||
|
||||
$Article->Behaviors->attach('Test5');
|
||||
$result = $Article->find('first');
|
||||
$this->assertTrue(array_key_exists('User', $result));
|
||||
|
||||
// hasAndBelongsToMany
|
||||
$Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')));
|
||||
$result = $Article->find('first');
|
||||
$this->assertFalse(array_key_exists('Tag', $result));
|
||||
|
||||
$Article->Behaviors->attach('Test6');
|
||||
$result = $Article->find('first');
|
||||
$this->assertTrue(array_key_exists('Comment', $result));
|
||||
|
||||
// hasOne
|
||||
$Comment = new Comment();
|
||||
$Comment->unbindModel(array('hasOne' => array('Attachment')));
|
||||
$result = $Comment->find('first');
|
||||
$this->assertFalse(array_key_exists('Attachment', $result));
|
||||
|
||||
$Comment->Behaviors->attach('Test7');
|
||||
$result = $Comment->find('first');
|
||||
$this->assertTrue(array_key_exists('Attachment', $result));
|
||||
}
|
||||
/**
|
||||
* Test attach and detaching
|
||||
*
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -144,6 +144,18 @@ class SocketTest extends CakeTestCase {
|
|||
$this->Socket = new CakeSocket(array('timeout' => 5));
|
||||
$this->Socket->connect();
|
||||
$this->assertEqual($this->Socket->read(26), null);
|
||||
|
||||
$config = array('host' => 'www.cakephp.org', 'timeout' => 1);
|
||||
$this->Socket = new CakeSocket($config);
|
||||
$this->assertTrue($this->Socket->connect());
|
||||
$this->assertFalse($this->Socket->read(1024 * 1024));
|
||||
$this->assertEqual($this->Socket->lastError(), '2: ' . __('Connection timed out', true));
|
||||
|
||||
$config = array('host' => 'www.cakephp.org', 'timeout' => 30);
|
||||
$this->Socket = new CakeSocket($config);
|
||||
$this->assertTrue($this->Socket->connect());
|
||||
$this->assertEqual($this->Socket->read(26), null);
|
||||
$this->assertEqual($this->Socket->lastError(), null);
|
||||
}
|
||||
/**
|
||||
* testLastError method
|
||||
|
|
|
@ -56,12 +56,33 @@ class TheHtmlTestController extends Controller {
|
|||
*/
|
||||
class HtmlHelperTest extends CakeTestCase {
|
||||
/**
|
||||
* html property
|
||||
* Html property
|
||||
*
|
||||
* @var mixed null
|
||||
* @var object
|
||||
* @access public
|
||||
*/
|
||||
var $html = null;
|
||||
var $Html = null;
|
||||
/**
|
||||
* Backup of app encoding configuration setting
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
var $_appEncoding;
|
||||
/**
|
||||
* Backup of asset configuration settings
|
||||
*
|
||||
* @var string
|
||||
* @access protected
|
||||
*/
|
||||
var $_asset;
|
||||
/**
|
||||
* Backup of debug configuration setting
|
||||
*
|
||||
* @var integer
|
||||
* @access protected
|
||||
*/
|
||||
var $_debug;
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
|
@ -73,6 +94,8 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$view =& new View(new TheHtmlTestController());
|
||||
ClassRegistry::addObject('view', $view);
|
||||
$this->_appEncoding = Configure::read('App.encoding');
|
||||
$this->_asset = Configure::read('Asset');
|
||||
$this->_debug = Configure::read('debug');
|
||||
}
|
||||
/**
|
||||
* tearDown method
|
||||
|
@ -82,6 +105,8 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
*/
|
||||
function tearDown() {
|
||||
Configure::write('App.encoding', $this->_appEncoding);
|
||||
Configure::write('Asset', $this->_asset);
|
||||
Configure::write('debug', $this->_debug);
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
/**
|
||||
|
@ -254,14 +279,34 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$result = $this->Html->image('cake.icon.gif');
|
||||
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));
|
||||
|
||||
$back = Configure::read('debug');
|
||||
Configure::write('debug', 0);
|
||||
Configure::write('Asset.timestamp', 'force');
|
||||
|
||||
$result = $this->Html->image('cake.icon.gif');
|
||||
$this->assertTags($result, array('img' => array('src' => 'preg:/img\/cake\.icon\.gif\?\d+/', 'alt' => '')));
|
||||
}
|
||||
/**
|
||||
* Tests creation of an image tag using a theme and asset timestamping
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @link https://trac.cakephp.org/ticket/6490
|
||||
*/
|
||||
function testImageTagWithTheme() {
|
||||
$file = WWW_ROOT . 'themed' . DS . 'default' . DS . 'img' . DS . 'cake.power.gif';
|
||||
$message = "File '{$file}' not present. %s";
|
||||
$this->skipUnless(file_exists($file), $message);
|
||||
|
||||
Configure::write('debug', $back);
|
||||
Configure::write('Asset.timestamp', true);
|
||||
Configure::write('debug', 1);
|
||||
$this->Html->themeWeb = 'themed/default/';
|
||||
|
||||
$result = $this->Html->image('cake.power.gif');
|
||||
$this->assertTags($result, array(
|
||||
'img' => array(
|
||||
'src' => 'preg:/themed\/default\/img\/cake\.power\.gif\?\d+/',
|
||||
'alt' => ''
|
||||
)));
|
||||
}
|
||||
/**
|
||||
* testStyle method
|
||||
|
@ -331,7 +376,6 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$expected['link']['href'] = 'preg:/.*css\/cake\.generic\.css\?[0-9]+/';
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$debug = Configure::read('debug');
|
||||
Configure::write('debug', 0);
|
||||
|
||||
$result = $this->Html->css('cake.generic');
|
||||
|
@ -357,8 +401,6 @@ class HtmlHelperTest extends CakeTestCase {
|
|||
$expected['link']['href'] = 'preg:/\/testing\/longer\/css\/cake\.generic\.css\?/';
|
||||
$this->assertTags($result, $expected);
|
||||
$this->Html->webroot = $webroot;
|
||||
|
||||
Configure::write('debug', $debug);
|
||||
}
|
||||
/**
|
||||
* testCharsetTag method
|
||||
|
|
|
@ -95,13 +95,25 @@ class TestJavascriptObject {
|
|||
* @since CakePHP Test Suite v 1.0.0.0
|
||||
*/
|
||||
class JavascriptTest extends CakeTestCase {
|
||||
/**
|
||||
* Regexp for CDATA start block
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $cDataStart = 'preg:/^\/\/<!\[CDATA\[[\n\r]*/';
|
||||
/**
|
||||
* Regexp for CDATA end block
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $cDataEnd = 'preg:/[^\]]*\]\]\>[\s\r\n]*/';
|
||||
/**
|
||||
* setUp method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
function startTest() {
|
||||
$this->Javascript =& new JavascriptHelper();
|
||||
$this->Javascript->Html =& new HtmlHelper();
|
||||
$this->Javascript->Form =& new FormHelper();
|
||||
|
@ -114,7 +126,7 @@ class JavascriptTest extends CakeTestCase {
|
|||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
function endTest() {
|
||||
unset($this->Javascript->Html);
|
||||
unset($this->Javascript->Form);
|
||||
unset($this->Javascript);
|
||||
|
@ -356,11 +368,14 @@ class JavascriptTest extends CakeTestCase {
|
|||
|
||||
$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8));
|
||||
$result = $this->Javascript->object($object, array('block' => true));
|
||||
$expected = '{"title":"New thing","indexes":[5,6,7,8]}';
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*' . str_replace('/', '\\/', preg_quote($expected)) . '\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">.+<\/script>$/s', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
'{"title":"New thing","indexes":[5,6,7,8]}',
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8), 'object' => array('inner' => array('value' => 1)));
|
||||
$result = $this->Javascript->object($object);
|
||||
|
@ -402,7 +417,6 @@ class JavascriptTest extends CakeTestCase {
|
|||
|
||||
$this->Javascript->useNative = $oldNative;
|
||||
}
|
||||
|
||||
/**
|
||||
* testScriptBlock method
|
||||
*
|
||||
|
@ -410,68 +424,101 @@ class JavascriptTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testScriptBlock() {
|
||||
ob_flush();
|
||||
$result = $this->Javascript->codeBlock('something');
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
'something',
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->codeBlock('something', array('allowCache' => true, 'safe' => false));
|
||||
$this->assertPattern('/^<script[^<>]+>something<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">something<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
'something',
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->codeBlock('something', array('allowCache' => false, 'safe' => false));
|
||||
$this->assertPattern('/^<script[^<>]+>something<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">something<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
'something',
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->codeBlock('something', true);
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*something\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*something\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
'something',
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->codeBlock('something', false);
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*something\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*something\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
'something',
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->codeBlock('something', array('safe' => false));
|
||||
$this->assertPattern('/^<script[^<>]+>something<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">something<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
|
||||
$result = $this->Javascript->blockEnd();
|
||||
$this->assertPattern('/^<\/script>$/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
'something',
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->codeBlock('something', array('safe' => true));
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*something\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*something\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
'something',
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->codeBlock(null, array('safe' => true, 'allowCache' => false));
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*$/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$this->assertNull($result);
|
||||
echo 'this is some javascript';
|
||||
|
||||
$result = $this->Javascript->blockEnd();
|
||||
$this->assertPattern('/^\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
|
||||
$result = $this->Javascript->codeBlock('something');
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*something\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">.+<\/script>$/s', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
'this is some javascript',
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->codeBlock();
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*$/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
|
||||
$this->assertNull($result);
|
||||
echo "alert('hey');";
|
||||
$result = $this->Javascript->blockEnd();
|
||||
$this->assertPattern('/^\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
"alert('hey');",
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Javascript->cacheEvents(false, true);
|
||||
$this->assertFalse($this->Javascript->inBlock);
|
||||
|
||||
$result = $this->Javascript->codeBlock();
|
||||
$this->assertIdentical($result, null);
|
||||
$this->assertTrue($this->Javascript->inBlock);
|
||||
|
@ -491,11 +538,16 @@ class JavascriptTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testOutOfLineScriptWriting() {
|
||||
echo $this->Javascript->codeBlock('$(document).ready(function() { /* ... */ });', array('inline' => false));
|
||||
echo $this->Javascript->codeBlock('$(document).ready(function() { });', array('inline' => false));
|
||||
|
||||
$this->Javascript->codeBlock(null, array('inline' => false));
|
||||
echo '$(function(){ /* ... */ });';
|
||||
echo '$(function(){ });';
|
||||
$this->Javascript->blockEnd();
|
||||
$script = $this->View->scripts();
|
||||
|
||||
$this->assertEqual(count($script), 2);
|
||||
$this->assertPattern('/' . preg_quote('$(document).ready(function() { });', '/') . '/', $script[0]);
|
||||
$this->assertPattern('/' . preg_quote('$(function(){ });', '/') . '/', $script[1]);
|
||||
}
|
||||
/**
|
||||
* testEvent method
|
||||
|
@ -505,52 +557,78 @@ class JavascriptTest extends CakeTestCase {
|
|||
*/
|
||||
function testEvent() {
|
||||
$result = $this->Javascript->event('myId', 'click', 'something();');
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*.+\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">.+' . str_replace('/', '\\/', preg_quote('Event.observe($(\'myId\'), \'click\', function(event) { something(); }, false);')) . '.+<\/script>$/s', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
"Event.observe($('myId'), 'click', function(event) { something(); }, false);",
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->event('myId', 'click', 'something();', array('safe' => false));
|
||||
$this->assertPattern('/^<script[^<>]+>[^<>]+<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">' . str_replace('/', '\\/', preg_quote('Event.observe($(\'myId\'), \'click\', function(event) { something(); }, false);')) . '<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
"Event.observe($('myId'), 'click', function(event) { something(); }, false);",
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->event('myId', 'click');
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*.+\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">.+' . str_replace('/', '\\/', preg_quote('Event.observe($(\'myId\'), \'click\', function(event) { }, false);')) . '.+<\/script>$/s', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
"Event.observe($('myId'), 'click', function(event) { }, false);",
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->event('myId', 'click', 'something();', false);
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*.+\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">.+' . str_replace('/', '\\/', preg_quote('Event.observe($(\'myId\'), \'click\', function(event) { something(); }, false);')) . '.+<\/script>$/s', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
"Event.observe($('myId'), 'click', function(event) { something(); }, false);",
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->event('myId', 'click', 'something();', array('useCapture' => true));
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*.+\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">.+' . str_replace('/', '\\/', preg_quote('Event.observe($(\'myId\'), \'click\', function(event) { something(); }, true);')) . '.+<\/script>$/s', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
"Event.observe($('myId'), 'click', function(event) { something(); }, true);",
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->event('document', 'load');
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*.+\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">.+' . str_replace('/', '\\/', preg_quote('Event.observe(document, \'load\', function(event) { }, false);')) . '.+<\/script>$/s', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
"Event.observe(document, 'load', function(event) { }, false);",
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->event('$(\'myId\')', 'click', 'something();', array('safe' => false));
|
||||
$this->assertPattern('/^<script[^<>]+>[^<>]+<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">' . str_replace('/', '\\/', preg_quote('Event.observe($(\'myId\'), \'click\', function(event) { something(); }, false);')) . '<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
"Event.observe($('myId'), 'click', function(event) { something(); }, false);",
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->event('\'document\'', 'load', 'something();', array('safe' => false));
|
||||
$this->assertPattern('/^<script[^<>]+>[^<>]+<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">' . str_replace('/', '\\/', preg_quote('Event.observe(\'document\', \'load\', function(event) { something(); }, false);')) . '<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
"Event.observe('document', 'load', function(event) { something(); }, false);",
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$this->Javascript->cacheEvents();
|
||||
$result = $this->Javascript->event('myId', 'click', 'something();');
|
||||
|
@ -577,10 +655,14 @@ class JavascriptTest extends CakeTestCase {
|
|||
$this->assertNull($result);
|
||||
|
||||
$result = $this->Javascript->writeEvents();
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*.+\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">.+' . str_replace('/', '\\/', preg_quote('Event.observe($(\'myId\'), \'click\', function(event) { something(); }, false);')) . '.+<\/script>$/s', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
"Event.observe($('myId'), 'click', function(event) { something(); }, false);",
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->getCache();
|
||||
$this->assertTrue(empty($result));
|
||||
|
@ -595,10 +677,15 @@ class JavascriptTest extends CakeTestCase {
|
|||
$this->assertNull($result);
|
||||
$this->assertEqual(count($resultScripts), 1);
|
||||
$result = current($resultScripts);
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*.+\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">.+' . str_replace('/', '\\/', preg_quote('Event.observe($(\'myId\'), \'click\', function(event) { something(); }, false);')) . '.+<\/script>$/s', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
"Event.observe($('myId'), 'click', function(event) { something(); }, false);",
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->getCache();
|
||||
$this->assertTrue(empty($result));
|
||||
|
@ -698,7 +785,7 @@ class JavascriptTest extends CakeTestCase {
|
|||
|
||||
$data['mystring'] = "a \"double-quoted\" string";
|
||||
$this->assertEqual(json_encode($data), $this->Javascript->object($data));
|
||||
|
||||
|
||||
$data['mystring'] = 'a \\"double-quoted\\" string';
|
||||
$this->assertEqual(json_encode($data), $this->Javascript->object($data));
|
||||
}
|
||||
|
@ -739,11 +826,15 @@ class JavascriptTest extends CakeTestCase {
|
|||
ob_start();
|
||||
$this->Javascript->afterRender();
|
||||
$result = ob_get_clean();
|
||||
|
||||
$this->assertPattern('/^<script[^<>]+>\s*' . str_replace('/', '\\/', preg_quote('//<![CDATA[')) . '\s*.+\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript">.+' . str_replace('/', '\\/', preg_quote('Event.observe($(\'myId\'), \'click\', function(event) { something(); }, false);')) . '.+<\/script>$/s', $result);
|
||||
$this->assertPattern('/^<script[^<>]+type="text\/javascript"[^<>]*>/', $result);
|
||||
$this->assertNoPattern('/^<script[^type]=[^<>]*>/', $result);
|
||||
|
||||
$expected = array(
|
||||
'script' => array('type' => 'text/javascript'),
|
||||
$this->cDataStart,
|
||||
"Event.observe($('myId'), 'click', function(event) { something(); }, false);",
|
||||
$this->cDataEnd,
|
||||
'/script'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Javascript->getCache();
|
||||
$this->assertTrue(empty($result));
|
||||
|
|
|
@ -140,10 +140,20 @@ class TextHelperTest extends CakeTestCase {
|
|||
$text1 = '<p>strongbow isn’t real cider</p>';
|
||||
$text2 = '<p>strongbow <strong>isn’t</strong> real cider</p>';
|
||||
$text3 = '<img src="what-a-strong-mouse.png" alt="What a strong mouse!" />';
|
||||
$text4 = 'What a strong mouse: <img src="what-a-strong-mouse.png" alt="What a strong mouse!" />';
|
||||
|
||||
$expected = '<p><b>strong</b>bow isn’t real cider</p>';
|
||||
$this->assertEqual($this->Text->highlight($text1, 'strong', '<b>\1</b>', true), $expected);
|
||||
|
||||
$expected = '<p><b>strong</b>bow <strong>isn’t</strong> real cider</p>';
|
||||
$this->assertEqual($this->Text->highlight($text2, 'strong', '<b>\1</b>', true), $expected);
|
||||
|
||||
$this->assertEqual($this->Text->highlight($text1, 'strong', '<b>\1</b>', true), '<p><b>strong</b>bow isn’t real cider</p>');
|
||||
$this->assertEqual($this->Text->highlight($text2, 'strong', '<b>\1</b>', true), '<p><b>strong</b>bow <strong>isn’t</strong> real cider</p>');
|
||||
$this->assertEqual($this->Text->highlight($text3, 'strong', '<b>\1</b>', true), $text3);
|
||||
|
||||
$this->assertEqual($this->Text->highlight($text3, array('strong', 'what'), '<b>\1</b>', true), $text3);
|
||||
|
||||
$expected = '<b>What</b> a <b>strong</b> mouse: <img src="what-a-strong-mouse.png" alt="What a strong mouse!" />';
|
||||
$this->assertEqual($this->Text->highlight($text4, array('strong', 'what'), '<b>\1</b>', true), $expected);
|
||||
}
|
||||
/**
|
||||
* testStripLinks method
|
||||
|
@ -277,22 +287,32 @@ class TextHelperTest extends CakeTestCase {
|
|||
$expected = '...with test text...';
|
||||
$result = $this->Text->excerpt($text, 'test', 9, '...');
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
|
||||
$expected = 'This is a...';
|
||||
$result = $this->Text->excerpt($text, 'not_found', 9, '...');
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
|
||||
$expected = 'This is a phras...';
|
||||
$result = $this->Text->excerpt($text, null, 9, '...');
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
|
||||
$expected = $text;
|
||||
$result = $this->Text->excerpt($text, null, 200, '...');
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
|
||||
$expected = '...phrase...';
|
||||
$result = $this->Text->excerpt($text, 'phrase', 2, '...');
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$phrase = 'This is a phrase with test';
|
||||
$expected = $text;
|
||||
$result = $this->Text->excerpt($text, $phrase, strlen($phrase) + 3, '...');
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$phrase = 'This is a phrase with text';
|
||||
$expected = $text;
|
||||
$result = $this->Text->excerpt($text, $phrase, 10, '...');
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
/**
|
||||
* testExcerptCaseInsensitivity method
|
||||
|
|
|
@ -276,6 +276,23 @@ class TimeHelperTest extends CakeTestCase {
|
|||
$fourHours = $this->Time->timeAgoInWords(strtotime('-5 days, -2 hours'), array('userOffset' => -4));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-5 days, -2 hours'), array('userOffset' => 4));
|
||||
$this->assertEqual($fourHours, $result);
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 hours'));
|
||||
$expected = '2 hours ago';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-12 minutes'));
|
||||
$expected = '12 minutes ago';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-12 seconds'));
|
||||
$expected = '12 seconds ago';
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$time = strtotime('-3 years -12 months');
|
||||
$result = $this->Time->timeAgoInWords($time);
|
||||
$expected = 'on ' . date('j/n/y', $time);
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
/**
|
||||
* testRelative method
|
||||
|
|
56
cake/tests/groups/database.group.php
Normal file
56
cake/tests/groups/database.group.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* DatabaseGroupTest file
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
|
||||
*
|
||||
* Licensed under The Open Group Test Suite License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @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
|
||||
* @subpackage cake.tests.groups
|
||||
* @since CakePHP(tm) v 1.2.0.5517
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
/**
|
||||
* DatabaseGroupTest class
|
||||
*
|
||||
* This test group will run all behavior, schema and datasource tests excluding database
|
||||
* driver-specific tests
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.groups
|
||||
*/
|
||||
class DatabaseGroupTest extends GroupTest {
|
||||
/**
|
||||
* label property
|
||||
*
|
||||
* @var string 'All model tests'
|
||||
* @access public
|
||||
*/
|
||||
var $label = 'Datasources, Schema and DbAcl tests';
|
||||
/**
|
||||
* ModelGroupTest method
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function DatabaseGroupTest() {
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'db_acl');
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'schema');
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'datasources' . DS . 'dbo_source');
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -37,10 +37,10 @@ class ModelGroupTest extends GroupTest {
|
|||
/**
|
||||
* label property
|
||||
*
|
||||
* @var string 'All model tests'
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $label = 'Model, all Behaviors and Datasources';
|
||||
var $label = 'Model & Behavior tests';
|
||||
/**
|
||||
* ModelGroupTest method
|
||||
*
|
||||
|
@ -49,9 +49,6 @@ class ModelGroupTest extends GroupTest {
|
|||
*/
|
||||
function ModelGroupTest() {
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'model');
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'db_acl');
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'schema');
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'datasources' . DS . 'dbo_source');
|
||||
TestManager::addTestCasesFromDirectory($this, CORE_TEST_CASES . DS . 'libs' . DS . 'model' . DS . 'behaviors');
|
||||
}
|
||||
}
|
||||
|
|
18
cake/tests/test_app/locale/po/LC_MONETARY/default.po
Normal file
18
cake/tests/test_app/locale/po/LC_MONETARY/default.po
Normal file
|
@ -0,0 +1,18 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: CakePHP Testsuite\n"
|
||||
"POT-Creation-Date: 2008-05-15 02:51-0700\n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: CakePHP I18N & I10N Team <i10n.cakephp@gmail.com>\n"
|
||||
"Language-Team: CakePHP I18N & I10N Team <i10n.cakephp@gmail.com>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
|
||||
"X-Poedit-Language: Three Forms of Plurals\n"
|
||||
"X-Poedit-SourceCharset: utf-8\n"
|
||||
msgid ""
|
||||
msgstr "header"
|
||||
|
||||
msgid "Plural Rule 1"
|
||||
msgstr "Monetary Po (translated)"
|
|
@ -0,0 +1,22 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: CakePHP Testsuite\n"
|
||||
"POT-Creation-Date: 2008-05-15 02:51-0700\n"
|
||||
"PO-Revision-Date: \n"
|
||||
"Last-Translator: CakePHP I18N & I10N Team <i10n.cakephp@gmail.com>\n"
|
||||
"Language-Team: CakePHP I18N & I10N Team <i10n.cakephp@gmail.com>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Poedit-Language: Two Forms of Plurals\n"
|
||||
"X-Poedit-SourceCharset: utf-8\n"
|
||||
|
||||
msgid "Plural Rule 1"
|
||||
msgstr "Monetary Plural Rule 1 (from plugin)"
|
||||
|
||||
msgid "%d = 1"
|
||||
msgid_plural "%d = 0 or > 1"
|
||||
msgstr[0] "Monetary %d = 1 (from plugin)"
|
||||
msgstr[1] "Monetary %d = 0 or > 1 (from plugin)"
|
||||
|
Loading…
Reference in a new issue