mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Merge branch '1.3' of github.com:cakephp/cakephp1x into 1.3
This commit is contained in:
commit
1f6bc5613d
35 changed files with 240 additions and 211 deletions
|
@ -197,6 +197,11 @@
|
|||
*/
|
||||
Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
|
||||
|
||||
/**
|
||||
* A random numeric string (digits only) used to encrypt/decrypt strings.
|
||||
*/
|
||||
Configure::write('Security.cipher_seed', '76859309657453542496749683645');
|
||||
|
||||
/**
|
||||
* Apply timestamps with the last modified time to static assets (js, css, images).
|
||||
* Will append a querystring parameter containing the time the file was modified. This is
|
||||
|
|
|
@ -3,7 +3,7 @@ $output = "<h2>Sweet, \"" . Inflector::humanize($app) . "\" got Baked by CakePHP
|
|||
$output .="
|
||||
<?php
|
||||
if (Configure::read() > 0):
|
||||
Debugger::checkSessionKey();
|
||||
Debugger::checkSecurityKeys();
|
||||
endif;
|
||||
?>
|
||||
<p>
|
||||
|
|
|
@ -206,6 +206,11 @@
|
|||
*/
|
||||
Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');
|
||||
|
||||
/**
|
||||
* A random numeric string (digits only) used to encrypt/decrypt strings.
|
||||
*/
|
||||
Configure::write('Security.cipher_seed', '76859309657453542496749683645');
|
||||
|
||||
/**
|
||||
* Compress CSS output by removing comments, whitespace, repeating tags, etc.
|
||||
* This requires a/var/cache directory to be writable by the web server for caching.
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Custom Inflected Words.
|
||||
*
|
||||
* This file is used to hold words that are not matched in the normail Inflector::pluralize() and
|
||||
* Inflector::singularize()
|
||||
*
|
||||
* PHP versions 4 and %
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2009, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package cake
|
||||
* @subpackage cake.app.config
|
||||
* @since CakePHP(tm) v 1.0.0.2312
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a key => value array of regex used to match words.
|
||||
* If key matches then the value is returned.
|
||||
*
|
||||
* $pluralRules = array('/(s)tatus$/i' => '\1\2tatuses', '/^(ox)$/i' => '\1\2en', '/([m|l])ouse$/i' => '\1ice');
|
||||
*/
|
||||
$pluralRules = array();
|
||||
|
||||
/**
|
||||
* This is a key only array of plural words that should not be inflected.
|
||||
* Notice the last comma
|
||||
*
|
||||
* $uninflectedPlural = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox');
|
||||
*/
|
||||
$uninflectedPlural = array();
|
||||
|
||||
/**
|
||||
* This is a key => value array of plural irregular words.
|
||||
* If key matches then the value is returned.
|
||||
*
|
||||
* $irregularPlural = array('atlas' => 'atlases', 'beef' => 'beefs', 'brother' => 'brothers')
|
||||
*/
|
||||
$irregularPlural = array();
|
||||
|
||||
/**
|
||||
* This is a key => value array of regex used to match words.
|
||||
* If key matches then the value is returned.
|
||||
*
|
||||
* $singularRules = array('/(s)tatuses$/i' => '\1\2tatus', '/(matr)ices$/i' =>'\1ix','/(vert|ind)ices$/i')
|
||||
*/
|
||||
$singularRules = array();
|
||||
|
||||
/**
|
||||
* This is a key only array of singular words that should not be inflected.
|
||||
* You should not have to change this value below if you do change it use same format
|
||||
* as the $uninflectedPlural above.
|
||||
*/
|
||||
$uninflectedSingular = $uninflectedPlural;
|
||||
|
||||
/**
|
||||
* This is a key => value array of singular irregular words.
|
||||
* Most of the time this will be a reverse of the above $irregularPlural array
|
||||
* You should not have to change this value below if you do change it use same format
|
||||
*
|
||||
* $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother')
|
||||
*/
|
||||
$irregularSingular = array_flip($irregularPlural);
|
||||
?>
|
|
@ -167,16 +167,6 @@ class Dispatcher extends Object {
|
|||
if (!empty($this->params['bare'])) {
|
||||
$controller->autoLayout = false;
|
||||
}
|
||||
if (array_key_exists('layout', $this->params)) {
|
||||
if (empty($this->params['layout'])) {
|
||||
$controller->autoLayout = false;
|
||||
} else {
|
||||
$controller->layout = $this->params['layout'];
|
||||
}
|
||||
}
|
||||
if (isset($this->params['viewPath'])) {
|
||||
$controller->viewPath = $this->params['viewPath'];
|
||||
}
|
||||
return $this->_invoke($controller, $this->params);
|
||||
}
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ class AuthComponent extends Object {
|
|||
$this->_set($settings);
|
||||
if (Configure::read() > 0) {
|
||||
App::import('Debugger');
|
||||
Debugger::checkSessionKey();
|
||||
Debugger::checkSecurityKeys();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -505,8 +505,8 @@ class EmailComponent extends Object{
|
|||
}
|
||||
}
|
||||
|
||||
$this->__createBoundary();
|
||||
if (!empty($this->attachments)) {
|
||||
$this->__createBoundary();
|
||||
$this->__header[] = 'MIME-Version: 1.0';
|
||||
$this->__header[] = 'Content-Type: multipart/mixed; boundary="' . $this->__boundary . '"';
|
||||
$this->__header[] = 'This part of the E-mail should never be seen. If';
|
||||
|
|
|
@ -664,15 +664,19 @@ class Debugger extends Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* Verifies that the application's salt value has been changed from the default value.
|
||||
* Verifies that the application's salt and cipher seed value has been changed from the default value.
|
||||
*
|
||||
* @access public
|
||||
* @static
|
||||
*/
|
||||
function checkSessionKey() {
|
||||
function checkSecurityKeys() {
|
||||
if (Configure::read('Security.salt') == 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi') {
|
||||
trigger_error(__('Please change the value of \'Security.salt\' in app/config/core.php to a salt value specific to your application', true), E_USER_NOTICE);
|
||||
}
|
||||
|
||||
if (Configure::read('Security.cipher_seed') == '76859309657453542496749683645') {
|
||||
trigger_error(__('Please change the value of \'Security.cipher_seed\' in app/config/core.php to a numeric (digits only) seed value specific to your application', true), E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -496,15 +496,15 @@ class I18n extends Object {
|
|||
continue;
|
||||
}
|
||||
|
||||
$mustEscape = array($escape.',',$escape.';',$escape.'<',$escape.'>',$escape.$escape);
|
||||
$replacements = array_map('crc32',$mustEscape);
|
||||
$value = str_replace($mustEscape,$replacements,$value);
|
||||
$value = explode(';',$value);
|
||||
$mustEscape = array($escape . ',' , $escape . ';', $escape . '<', $escape . '>', $escape . $escape);
|
||||
$replacements = array_map('crc32', $mustEscape);
|
||||
$value = str_replace($mustEscape, $replacements, $value);
|
||||
$value = explode(';', $value);
|
||||
$_this->__escape = $escape;
|
||||
foreach ($value as $i => $val) {
|
||||
$val = trim($val,'"');
|
||||
$val = preg_replace_callback('/(?:<)?(.[^>]*)(?:>)?/',array(&$this,'__parseLiteralValue'),$val);
|
||||
$val = str_replace($replacements,$mustEscape,$val);
|
||||
$val = trim($val, '"');
|
||||
$val = preg_replace_callback('/(?:<)?(.[^>]*)(?:>)?/', array(&$this, '__parseLiteralValue'), $val);
|
||||
$val = str_replace($replacements, $mustEscape, $val);
|
||||
$value[$i] = $val;
|
||||
}
|
||||
if (count($value) == 1) {
|
||||
|
|
|
@ -485,11 +485,16 @@ class CakeSchema extends Object {
|
|||
|
||||
if (isset($old[$table]['indexes']) && isset($new[$table]['indexes'])) {
|
||||
$diff = $this->_compareIndexes($new[$table]['indexes'], $old[$table]['indexes']);
|
||||
if ($diff && isset($diff['drop'])) {
|
||||
$tables[$table]['drop']['indexes'] = $diff['drop'];
|
||||
}
|
||||
if ($diff && isset($diff['add'])) {
|
||||
$tables[$table]['add']['indexes'] = $diff['add'];
|
||||
if ($diff) {
|
||||
if (!isset($tables[$table])) {
|
||||
$tables[$table] = array();
|
||||
}
|
||||
if (isset($diff['drop'])) {
|
||||
$tables[$table]['drop']['indexes'] = $diff['drop'];
|
||||
}
|
||||
if ($diff && isset($diff['add'])) {
|
||||
$tables[$table]['add']['indexes'] = $diff['add'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($old[$table]['tableParameters']) && isset($new[$table]['tableParameters'])) {
|
||||
|
|
|
@ -174,11 +174,7 @@ class Security extends Object {
|
|||
return '';
|
||||
}
|
||||
|
||||
if (!defined('CIPHER_SEED')) {
|
||||
//This is temporary will change later
|
||||
define('CIPHER_SEED', '76859309657453542496749683645');
|
||||
}
|
||||
srand(CIPHER_SEED);
|
||||
srand(Configure::read('Security.cipher_seed'));
|
||||
$out = '';
|
||||
|
||||
for ($i = 0; $i < strlen($text); $i++) {
|
||||
|
|
|
@ -174,6 +174,9 @@ class TimeHelper extends AppHelper {
|
|||
if ($userOffset !== null) {
|
||||
return $this->convert($date, $userOffset);
|
||||
}
|
||||
if ($date === -1) {
|
||||
return false;
|
||||
}
|
||||
return $date;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ endif;
|
|||
echo $this->Html->link(__('Read the changelog', true), 'http://code.cakephp.org/wiki/changelog/1_3_0-alpha');
|
||||
|
||||
if (Configure::read() > 0):
|
||||
Debugger::checkSessionKey();
|
||||
Debugger::checkSecurityKeys();
|
||||
endif;
|
||||
?>
|
||||
<p>
|
||||
|
|
|
@ -33,9 +33,8 @@ if (!class_exists('ShellDispatcher')) {
|
|||
ob_end_clean();
|
||||
}
|
||||
|
||||
if (!class_exists('ExtractTask')) {
|
||||
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'extract.php';
|
||||
}
|
||||
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'extract.php';
|
||||
|
||||
|
||||
Mock::generatePartial(
|
||||
'ShellDispatcher', 'TestExtractTaskMockShellDispatcher',
|
||||
|
|
|
@ -32,9 +32,7 @@ if (!class_exists('ShellDispatcher')) {
|
|||
ob_end_clean();
|
||||
}
|
||||
|
||||
if (!class_exists('ProjectTask')) {
|
||||
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'project.php';
|
||||
}
|
||||
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'project.php';
|
||||
|
||||
Mock::generatePartial(
|
||||
'ShellDispatcher', 'TestProjectTaskMockShellDispatcher',
|
||||
|
|
|
@ -34,10 +34,9 @@ if (!class_exists('ShellDispatcher')) {
|
|||
ob_end_clean();
|
||||
}
|
||||
|
||||
if (!class_exists('TestTask')) {
|
||||
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'test.php';
|
||||
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';
|
||||
}
|
||||
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'test.php';
|
||||
require_once CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'template.php';
|
||||
|
||||
|
||||
Mock::generatePartial(
|
||||
'ShellDispatcher', 'TestTestTaskMockShellDispatcher',
|
||||
|
|
|
@ -1516,17 +1516,10 @@ class DispatcherTest extends CakeTestCase {
|
|||
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
|
||||
$expected = 'my_plugin';
|
||||
$this->assertIdentical($controller->plugin, $expected);
|
||||
|
||||
$expected = 'MyPlugin';
|
||||
$this->assertIdentical($controller->name, $expected);
|
||||
|
||||
$expected = 'add';
|
||||
$this->assertIdentical($controller->action, $expected);
|
||||
|
||||
$expected = array('param' => 'value', 'param2' => 'value2');
|
||||
$this->assertEqual($controller->params['named'], $expected);
|
||||
$this->assertIdentical($controller->plugin, 'my_plugin');
|
||||
$this->assertIdentical($controller->name, 'MyPlugin');
|
||||
$this->assertIdentical($controller->action, 'add');
|
||||
$this->assertEqual($controller->params['named'], array('param' => 'value', 'param2' => 'value2'));
|
||||
|
||||
|
||||
Router::reload();
|
||||
|
@ -1678,6 +1671,8 @@ class DispatcherTest extends CakeTestCase {
|
|||
App::build(array(
|
||||
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
|
||||
), true);
|
||||
App::objects('plugin', null, false);
|
||||
|
||||
$Dispatcher =& new TestDispatcher();
|
||||
$Dispatcher->base = false;
|
||||
|
||||
|
@ -1687,6 +1682,21 @@ class DispatcherTest extends CakeTestCase {
|
|||
$this->assertEqual($controller->params['plugin'], 'test_plugin');
|
||||
$this->assertEqual($controller->params['action'], 'index');
|
||||
$this->assertFalse(isset($controller->params['pass'][0]));
|
||||
|
||||
$url = '/test_plugin/tests/index';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertEqual($controller->params['controller'], 'tests');
|
||||
$this->assertEqual($controller->params['plugin'], 'test_plugin');
|
||||
$this->assertEqual($controller->params['action'], 'index');
|
||||
$this->assertFalse(isset($controller->params['pass'][0]));
|
||||
|
||||
$url = '/test_plugin/tests/index/some_param';
|
||||
$controller = $Dispatcher->dispatch($url, array('return' => 1));
|
||||
$this->assertEqual($controller->params['controller'], 'tests');
|
||||
$this->assertEqual($controller->params['plugin'], 'test_plugin');
|
||||
$this->assertEqual($controller->params['action'], 'index');
|
||||
$this->assertEqual($controller->params['pass'][0], 'some_param');
|
||||
|
||||
App::build();
|
||||
}
|
||||
|
||||
|
@ -1985,7 +1995,7 @@ class DispatcherTest extends CakeTestCase {
|
|||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
|
||||
), true);
|
||||
|
||||
$dispatcher =& new Dispatcher();
|
||||
$dispatcher =& new TestDispatcher();
|
||||
$dispatcher->base = false;
|
||||
|
||||
$url = '/';
|
||||
|
@ -2119,7 +2129,7 @@ class DispatcherTest extends CakeTestCase {
|
|||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)
|
||||
));
|
||||
|
||||
$dispatcher =& new Dispatcher();
|
||||
$dispatcher =& new TestDispatcher();
|
||||
$dispatcher->base = false;
|
||||
|
||||
$url = 'test_cached_pages/cache_form';
|
||||
|
@ -2139,6 +2149,7 @@ class DispatcherTest extends CakeTestCase {
|
|||
|
||||
$this->assertEqual($result, $expected);
|
||||
$filename = $this->__cachePath($dispatcher->here);
|
||||
@unlink($filename);
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@ if (!class_exists('CakeSession')) {
|
|||
}
|
||||
|
||||
/**
|
||||
* SessionTest class
|
||||
* CakeSessionTest class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs
|
||||
*/
|
||||
class SessionTest extends CakeTestCase {
|
||||
class CakeSessionTest extends CakeTestCase {
|
||||
|
||||
/**
|
||||
* Fixtures used in the SessionTest
|
||||
|
|
|
@ -343,7 +343,6 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
'method' => 'get',
|
||||
));
|
||||
$this->assertTrue(isset($result['params']['url']['url']));
|
||||
$this->assertTrue(isset($result['params']['url']['output']));
|
||||
$this->assertEqual(array_keys($result['params']['named']), array('var1', 'var2'));
|
||||
|
||||
$result = $this->Case->testAction('/tests_apps_posts/url_var/gogo/val2', array(
|
||||
|
@ -361,7 +360,6 @@ class CakeTestCaseTest extends CakeTestCase {
|
|||
'blue' => 'mana'
|
||||
)
|
||||
));
|
||||
$this->assertTrue(isset($result['params']['url']['output']));
|
||||
$this->assertTrue(isset($result['params']['url']['red']));
|
||||
$this->assertTrue(isset($result['params']['url']['blue']));
|
||||
$this->assertTrue(isset($result['params']['url']['url']));
|
||||
|
|
|
@ -63,44 +63,55 @@ class CodeCoverageManagerTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testNoTestCaseSupplied() {
|
||||
if (PHP_SAPI != 'cli') {
|
||||
$reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
|
||||
if ($this->skipIf(PHP_SAPI == 'cli', 'Is cli, cannot run this test %s')) {
|
||||
return;
|
||||
}
|
||||
$reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
|
||||
|
||||
CodeCoverageManager::init(substr(md5(microtime()), 0, 5), $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertError();
|
||||
CodeCoverageManager::init(substr(md5(microtime()), 0, 5), $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertError();
|
||||
|
||||
CodeCoverageManager::init('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertError();
|
||||
|
||||
$path = LIBS;
|
||||
if (strpos(LIBS, ROOT) === false) {
|
||||
$path = ROOT.DS.LIBS;
|
||||
}
|
||||
App::import('Core', 'Folder');
|
||||
$folder = new Folder();
|
||||
$folder->cd($path);
|
||||
$contents = $folder->read();
|
||||
CodeCoverageManager::init('tests' . DS . 'lib' . DS . basename(__FILE__), $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertError();
|
||||
}
|
||||
|
||||
/**
|
||||
* remove method
|
||||
* Test that test cases don't cause errors
|
||||
*
|
||||
* @param mixed $var
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function remove($var) {
|
||||
return ($var != basename(__FILE__));
|
||||
}
|
||||
$contents[1] = array_filter($contents[1], "remove");
|
||||
|
||||
foreach ($contents[1] as $file) {
|
||||
CodeCoverageManager::init('libs' . DS . $file, $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertNoErrors('libs' . DS . $file);
|
||||
}
|
||||
function testNoTestCaseSuppliedNoErrors() {
|
||||
if ($this->skipIf(PHP_SAPI == 'cli', 'Is cli, cannot run this test %s')) {
|
||||
return;
|
||||
}
|
||||
$reporter =& new CakeHtmlReporter(null, array('group' => false, 'app' => false, 'plugin' => false));
|
||||
$path = LIBS;
|
||||
if (strpos(LIBS, ROOT) === false) {
|
||||
$path = ROOT.DS.LIBS;
|
||||
}
|
||||
App::import('Core', 'Folder');
|
||||
$folder = new Folder();
|
||||
$folder->cd($path);
|
||||
$contents = $folder->read();
|
||||
|
||||
$contents[1] = array_filter($contents[1], array(&$this, '_basenameFilter'));
|
||||
|
||||
foreach ($contents[1] as $file) {
|
||||
CodeCoverageManager::init('libs' . DS . $file, $reporter);
|
||||
CodeCoverageManager::report(false);
|
||||
$this->assertNoErrors('libs' . DS . $file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove file names that don't share a basename with the current file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _basenameFilter($var) {
|
||||
return ($var != basename(__FILE__));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -500,7 +500,6 @@ class ScaffoldViewTest extends CakeTestCase {
|
|||
$this->assertPattern('/input name="data\[ScaffoldMock\]\[published\]" type="text" maxlength="1" value="Y" id="ScaffoldMockPublished"/', $result);
|
||||
$this->assertPattern('/textarea name="data\[ScaffoldMock\]\[body\]" cols="30" rows="6" id="ScaffoldMockBody"/', $result);
|
||||
$this->assertPattern('/<li><a href="\/scaffold_mock\/delete\/1"[^>]*>Delete<\/a>\s*<\/li>/', $result);
|
||||
debug($result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -381,6 +381,11 @@ class InflectorTest extends CakeTestCase {
|
|||
$this->assertEqual(Inflector::singularize('singulars'), 'singulars');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test resetting inflection rules.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testCustomRuleWithReset() {
|
||||
$uninflected = array('atlas', 'lapis', 'onibus', 'pires', 'virus', '.*x');
|
||||
$pluralIrregular = array('as' => 'ases');
|
||||
|
|
|
@ -69,6 +69,56 @@ class ModelValidationTest extends BaseModelTest {
|
|||
);
|
||||
|
||||
$this->assertEqual($TestModel->invalidFields(), $expected);
|
||||
|
||||
$TestModel->validate['title'] = array(
|
||||
'rule' => array('customValidatorWithSixParams', 'one', 'two', null, 'four'),
|
||||
'required' => true
|
||||
);
|
||||
$TestModel->create(array('title' => 'foo'));
|
||||
$TestModel->invalidFields();
|
||||
$expected = array(
|
||||
'data' => array(
|
||||
'title' => 'foo'
|
||||
),
|
||||
'one' => 'one',
|
||||
'two' => 'two',
|
||||
'three' => null,
|
||||
'four' => 'four',
|
||||
'five' => array(
|
||||
'rule' => array(1 => 'one', 2 => 'two', 3 => null, 4 => 'four'),
|
||||
'on' => null,
|
||||
'last' => false,
|
||||
'allowEmpty' => false,
|
||||
'required' => true
|
||||
),
|
||||
'six' => 6
|
||||
);
|
||||
$this->assertEqual($TestModel->validatorParams, $expected);
|
||||
|
||||
$TestModel->validate['title'] = array(
|
||||
'rule' => array('customValidatorWithSixParams', 'one', array('two'), null, 'four', array('five' => 5)),
|
||||
'required' => true
|
||||
);
|
||||
$TestModel->create(array('title' => 'foo'));
|
||||
$TestModel->invalidFields();
|
||||
$expected = array(
|
||||
'data' => array(
|
||||
'title' => 'foo'
|
||||
),
|
||||
'one' => 'one',
|
||||
'two' => array('two'),
|
||||
'three' => null,
|
||||
'four' => 'four',
|
||||
'five' => array('five' => 5),
|
||||
'six' => array(
|
||||
'rule' => array(1 => 'one', 2 => array('two'), 3 => null, 4 => 'four', 5 => array('five' => 5)),
|
||||
'on' => null,
|
||||
'last' => false,
|
||||
'allowEmpty' => false,
|
||||
'required' => true
|
||||
)
|
||||
);
|
||||
$this->assertEqual($TestModel->validatorParams, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2558,8 +2558,12 @@ class ModelWriteTest extends BaseModelTest {
|
|||
|
||||
$TestModel =& new TheVoid();
|
||||
$this->assertFalse($TestModel->exists());
|
||||
|
||||
$TestModel->id = 5;
|
||||
$this->expectError();
|
||||
ob_start();
|
||||
$this->assertFalse($TestModel->exists());
|
||||
$output = ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2218,6 +2218,16 @@ class ValidationTest1 extends CakeTestModel {
|
|||
function customValidatorWithMessage($data) {
|
||||
return 'This field will *never* validate! Muhahaha!';
|
||||
}
|
||||
/**
|
||||
* Test validation with many parameters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function customValidatorWithSixParams($data, $one = 1, $two = 2, $three = 3, $four = 4, $five = 5, $six = 6) {
|
||||
$this->validatorParams = get_defined_vars();
|
||||
unset($this->validatorParams['this']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -662,7 +662,9 @@ class ObjectTest extends CakeTestCase {
|
|||
'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
|
||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
|
||||
'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)
|
||||
), true);
|
||||
));
|
||||
App::objects('plugin', null, false);
|
||||
Router::reload();
|
||||
|
||||
$result = $this->object->requestAction('/tests_apps/index', array('return'));
|
||||
$expected = 'This is the TestsAppsController index view';
|
||||
|
@ -716,6 +718,9 @@ class ObjectTest extends CakeTestCase {
|
|||
|
||||
$result = $this->object->requestAction(array('controller'=>'request_action', 'action'=>'paginate_request_action'), array('pass' => array(5), 'named' => array('param' => 'value')));
|
||||
$this->assertTrue($result);
|
||||
|
||||
App::build();
|
||||
App::objects('plugin', null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1824,7 +1824,7 @@ class SetTest extends CakeTestCase {
|
|||
'useDbConfig' => 'default', 'useTable' => false, 'displayField' => null, 'id' => false, 'data' => array(), 'table' => 'models', 'primaryKey' => 'id', '_schema' => null, 'validate' => array(),
|
||||
'validationErrors' => array(), 'tablePrefix' => null, 'name' => 'Model', 'alias' => 'Model', 'tableToModel' => array(), 'logTransactions' => false, 'transactional' => false, 'cacheQueries' => false,
|
||||
'belongsTo' => array(), 'hasOne' => array(), 'hasMany' => array(), 'hasAndBelongsToMany' => array(), 'actsAs' => null, 'whitelist' => array(), 'cacheSources' => true,
|
||||
'findQueryType' => null, 'recursive' => 1, 'order' => null, '__exists' => null,
|
||||
'findQueryType' => null, 'recursive' => 1, 'order' => null, 'virtualFields' => array(),
|
||||
'__associationKeys' => array(
|
||||
'belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'),
|
||||
'hasOne' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'dependent'),
|
||||
|
|
|
@ -279,9 +279,6 @@ class JsHelperTestCase extends CakeTestCase {
|
|||
|
||||
@unlink(WWW_ROOT . $filename[1]);
|
||||
}
|
||||
function getTests() {
|
||||
return array('start', 'startCase', 'testLinkWithMock', 'endCase', 'end');
|
||||
}
|
||||
|
||||
/**
|
||||
* test link()
|
||||
|
|
|
@ -86,34 +86,34 @@ class TimeHelperTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testTimeAgoInWords() {
|
||||
$result = $this->Time->timeAgoInWords(strtotime('4 months, 2 weeks, 3 days'), array('end' => '8 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +3 days'), array('end' => '8 years'), true);
|
||||
$this->assertEqual($result, '4 months, 2 weeks, 3 days');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('4 months, 2 weeks, 2 days'), array('end' => '8 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +2 days'), array('end' => '8 years'), true);
|
||||
$this->assertEqual($result, '4 months, 2 weeks, 2 days');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('4 months, 2 weeks, 1 day'), array('end' => '8 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +1 day'), array('end' => '8 years'), true);
|
||||
$this->assertEqual($result, '4 months, 2 weeks, 1 day');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('3 months, 2 weeks, 1 day'), array('end' => '8 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+3 months +2 weeks +1 day'), array('end' => '8 years'), true);
|
||||
$this->assertEqual($result, '3 months, 2 weeks, 1 day');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('3 months, 2 weeks'), array('end' => '8 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+3 months +2 weeks'), array('end' => '8 years'), true);
|
||||
$this->assertEqual($result, '3 months, 2 weeks');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('3 months, 1 week, 6 days'), array('end' => '8 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+3 months +1 week +6 days'), array('end' => '8 years'), true);
|
||||
$this->assertEqual($result, '3 months, 1 week, 6 days');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('2 months, 2 weeks, 1 day'), array('end' => '8 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 weeks +1 day'), array('end' => '8 years'), true);
|
||||
$this->assertEqual($result, '2 months, 2 weeks, 1 day');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('2 months, 2 weeks'), array('end' => '8 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 weeks'), array('end' => '8 years'), true);
|
||||
$this->assertEqual($result, '2 months, 2 weeks');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('2 months, 1 week, 6 days'), array('end' => '8 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+2 months +1 week +6 days'), array('end' => '8 years'), true);
|
||||
$this->assertEqual($result, '2 months, 1 week, 6 days');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('1 month, 1 week, 6 days'), array('end' => '8 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+1 month +1 week +6 days'), array('end' => '8 years'), true);
|
||||
$this->assertEqual($result, '1 month, 1 week, 6 days');
|
||||
|
||||
for($i = 0; $i < 200; $i ++) {
|
||||
|
@ -157,8 +157,8 @@ class TimeHelperTest extends CakeTestCase {
|
|||
$relative_date .= ($relative_date ? ', -' : '-') . $seconds . ' second' . ($seconds != 1 ? 's' : '');
|
||||
}
|
||||
|
||||
if (date('j/n/y', strtotime($relative_date)) != '1/1/70') {
|
||||
$result = $this->Time->timeAgoInWords(strtotime($relative_date), array('end' => '8 years'), true);
|
||||
if (date('j/n/y', strtotime(str_replace(',','',$relative_date))) != '1/1/70') {
|
||||
$result = $this->Time->timeAgoInWords(strtotime(str_replace(',','',$relative_date)), array('end' => '8 years'), true);
|
||||
if ($relative_date == '0 seconds') {
|
||||
$relative_date = '0 seconds ago';
|
||||
}
|
||||
|
@ -211,9 +211,8 @@ class TimeHelperTest extends CakeTestCase {
|
|||
$relative_date .= ($relative_date ? ', ' : '') . $seconds . ' second' . ($seconds != 1 ? 's' : '');
|
||||
}
|
||||
|
||||
if (date('j/n/y', strtotime($relative_date)) != '1/1/70') {
|
||||
// echo $relative_date."<br />";
|
||||
$result = $this->Time->timeAgoInWords(strtotime($relative_date), array('end' => '8 years'), true);
|
||||
if (date('j/n/y', strtotime(str_replace(',','',$relative_date))) != '1/1/70') {
|
||||
$result = $this->Time->timeAgoInWords(strtotime(str_replace(',','',$relative_date)), array('end' => '8 years'), true);
|
||||
if ($relative_date == '0 seconds') {
|
||||
$relative_date = '0 seconds ago';
|
||||
}
|
||||
|
@ -223,7 +222,7 @@ class TimeHelperTest extends CakeTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 years, -5 months, -2 days'), array('end' => '3 years'), true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 years -5 months -2 days'), array('end' => '3 years'), true);
|
||||
$this->assertEqual($result, '2 years, 5 months, 2 days ago');
|
||||
|
||||
$result = $this->Time->timeAgoInWords('2007-9-25');
|
||||
|
@ -235,44 +234,44 @@ class TimeHelperTest extends CakeTestCase {
|
|||
$result = $this->Time->timeAgoInWords('2007-9-25', 'Y-m-d', true);
|
||||
$this->assertEqual($result, 'on 2007-09-25');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 weeks, -2 days'), 'Y-m-d', false);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 weeks -2 days'), 'Y-m-d', false);
|
||||
$this->assertEqual($result, '2 weeks, 2 days ago');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('2 weeks, 2 days'), 'Y-m-d', true);
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+2 weeks +2 days'), 'Y-m-d', true);
|
||||
$this->assertPattern('/^2 weeks, [1|2] day(s)?$/', $result);
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('2 months, 2 days'), array('end' => '1 month'));
|
||||
$this->assertEqual($result, 'on ' . date('j/n/y', strtotime('2 months, 2 days')));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '1 month'));
|
||||
$this->assertEqual($result, 'on ' . date('j/n/y', strtotime('+2 months +2 days')));
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('2 months, 2 days'), array('end' => '3 month'));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '3 month'));
|
||||
$this->assertPattern('/2 months/', $result);
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('2 months, 12 days'), array('end' => '3 month'));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+2 months +12 days'), array('end' => '3 month'));
|
||||
$this->assertPattern('/2 months, 1 week/', $result);
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('3 months, 5 days'), array('end' => '4 month'));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+3 months +5 days'), array('end' => '4 month'));
|
||||
$this->assertEqual($result, '3 months, 5 days');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 months, -2 days'), array('end' => '3 month'));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 months -2 days'), array('end' => '3 month'));
|
||||
$this->assertEqual($result, '2 months, 2 days ago');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 months, -2 days'), array('end' => '3 month'));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 months -2 days'), array('end' => '3 month'));
|
||||
$this->assertEqual($result, '2 months, 2 days ago');
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('2 months, 2 days'), array('end' => '3 month'));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '3 month'));
|
||||
$this->assertPattern('/2 months/', $result);
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('2 months, 2 days'), array('end' => '1 month', 'format' => 'Y-m-d'));
|
||||
$this->assertEqual($result, 'on ' . date('Y-m-d', strtotime('2 months, 2 days')));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('+2 months +2 days'), array('end' => '1 month', 'format' => 'Y-m-d'));
|
||||
$this->assertEqual($result, 'on ' . date('Y-m-d', strtotime('+2 months +2 days')));
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 months, -2 days'), array('end' => '1 month', 'format' => 'Y-m-d'));
|
||||
$this->assertEqual($result, 'on ' . date('Y-m-d', strtotime('-2 months, -2 days')));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-2 months -2 days'), array('end' => '1 month', 'format' => 'Y-m-d'));
|
||||
$this->assertEqual($result, 'on ' . date('Y-m-d', strtotime('-2 months -2 days')));
|
||||
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-13 months, -5 days'), array('end' => '2 years'));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-13 months -5 days'), array('end' => '2 years'));
|
||||
$this->assertEqual($result, '1 year, 1 month, 5 days ago');
|
||||
|
||||
$fourHours = $this->Time->timeAgoInWords(strtotime('-5 days, -2 hours'), array('userOffset' => -4));
|
||||
$result = $this->Time->timeAgoInWords(strtotime('-5 days, -2 hours'), array('userOffset' => 4));
|
||||
$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'));
|
||||
|
@ -662,7 +661,7 @@ class TimeHelperTest extends CakeTestCase {
|
|||
'locales' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale' . DS)
|
||||
), true);
|
||||
Configure::write('Config.language', 'time_test');
|
||||
$time = 1263485619; // Thu Jan 14 11:43:39 2010
|
||||
$time = 1263487419; // Thu Jan 14 11:43:39 2010
|
||||
|
||||
$result = $this->Time->convertSpecifiers('%a', $time);
|
||||
$expected = 'jue';
|
||||
|
@ -752,14 +751,14 @@ class TimeHelperTest extends CakeTestCase {
|
|||
'locales' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale' . DS)
|
||||
), true);
|
||||
Configure::write('Config.language', 'time_test');
|
||||
$time = 1263493768; //Thu Jan 14 13:59:28 2010
|
||||
$time = 1263495568; //Thu Jan 14 13:59:28 2010
|
||||
|
||||
$result = $this->Time->i18nFormat($time);
|
||||
$expected = '14/01/10';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Time->i18nFormat($time, '%c');
|
||||
$expected = 'jue 14 ene 2010 13:59:28 VET';
|
||||
$expected = 'jue 14 ene 2010 13:59:28 ' . strftime('%Z');
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->Time->i18nFormat($time, 'Time is %r, and date is %x');
|
||||
|
|
7
cake/tests/fixtures/session_fixture.php
vendored
7
cake/tests/fixtures/session_fixture.php
vendored
|
@ -34,6 +34,13 @@ class SessionFixture extends CakeTestFixture {
|
|||
*/
|
||||
var $name = 'Session';
|
||||
|
||||
/**
|
||||
* table property.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
// var $table = 'sessions';
|
||||
|
||||
/**
|
||||
* fields property
|
||||
*
|
||||
|
|
|
@ -44,7 +44,7 @@ class LibGroupTest extends TestSuite {
|
|||
*/
|
||||
function LibGroupTest() {
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'basics');
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'inflector');
|
||||
// TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'inflector');
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'cake_session');
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'debugger');
|
||||
TestManager::addTestFile($this, CORE_TEST_CASES . DS . 'libs' . DS . 'error');
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<?php
|
||||
if (Configure::read() > 0):
|
||||
Debugger::checkSessionKey();
|
||||
Debugger::checkSecurityKeys();
|
||||
endif;
|
||||
?>
|
||||
<p>
|
||||
|
|
Loading…
Add table
Reference in a new issue