mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge branch '1.3' of git@github.com:cakephp/cakephp1x into 1.3
This commit is contained in:
commit
5ceb19304e
14 changed files with 157 additions and 17 deletions
|
@ -44,8 +44,8 @@
|
|||
/**
|
||||
* As of 1.3, additional rules for the inflector are added below
|
||||
*
|
||||
* Inflector::rule('singular', array('rules' => array(), irregular' => array(), 'uninflected' => array()));
|
||||
* Inflector::rule('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
|
||||
* Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
|
||||
* Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
|
||||
*
|
||||
*/
|
||||
?>
|
|
@ -79,7 +79,7 @@ ul, li {
|
|||
}
|
||||
#header h1 {
|
||||
line-height:20px;
|
||||
background: #003d4c url('../img/cake.icon.png') no-repeat left;
|
||||
background: #003d4c url('../img/cake.icon.gif') no-repeat left;
|
||||
color: #fff;
|
||||
padding: 0px 30px;
|
||||
}
|
||||
|
@ -532,4 +532,4 @@ div.code-coverage-results span.result-ok {
|
|||
}
|
||||
div.code-coverage-results span.result-good {
|
||||
color: #0a0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -920,8 +920,11 @@ class EmailComponent extends Object{
|
|||
$fm .= sprintf('%s%3$s%3$s%s', 'Message:', $message, $nl);
|
||||
$fm .= '</pre>';
|
||||
|
||||
$this->Controller->Session->setFlash($fm, 'default', null, 'email');
|
||||
return true;
|
||||
if (isset($this->Controller->Session)) {
|
||||
$this->Controller->Session->setFlash($fm, 'default', null, 'email');
|
||||
return true;
|
||||
}
|
||||
return $fm;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ class Inflector {
|
|||
'/Ð|Ď|Đ/' => 'D',
|
||||
'/ð|ď|đ/' => 'd',
|
||||
'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě/' => 'E',
|
||||
'/è|é|ê|ë|ē|ĕ|ė|ę|ě|&/' => 'e',
|
||||
'/è|é|ê|ë|ē|ĕ|ė|ę|ě/' => 'e',
|
||||
'/Ĝ|Ğ|Ġ|Ģ/' => 'G',
|
||||
'/ĝ|ğ|ġ|ģ/' => 'g',
|
||||
'/Ĥ|Ħ/' => 'H',
|
||||
|
|
|
@ -187,7 +187,7 @@ class ContainableBehavior extends ModelBehavior {
|
|||
foreach (array('hasOne', 'belongsTo') as $type) {
|
||||
if (!empty($Model->{$type})) {
|
||||
foreach ($Model->{$type} as $assoc => $data) {
|
||||
if (!empty($data['fields'])) {
|
||||
if ($Model->useDbConfig == $Model->{$assoc}->useDbConfig && !empty($data['fields'])) {
|
||||
foreach ((array) $data['fields'] as $field) {
|
||||
$query['fields'][] = (strpos($field, '.') === false ? $assoc . '.' : '') . $field;
|
||||
}
|
||||
|
@ -195,15 +195,24 @@ class ContainableBehavior extends ModelBehavior {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($mandatory[$Model->alias])) {
|
||||
foreach ($mandatory[$Model->alias] as $field) {
|
||||
if ($field == '--primaryKey--') {
|
||||
$field = $Model->primaryKey;
|
||||
} else if (preg_match('/^.+\.\-\-[^-]+\-\-$/', $field)) {
|
||||
list($modelName, $field) = explode('.', $field);
|
||||
$field = $modelName . '.' . (($field === '--primaryKey--') ? $Model->$modelName->primaryKey : $field);
|
||||
if ($Model->useDbConfig == $Model->{$modelName}->useDbConfig) {
|
||||
$field = $modelName . '.' . (
|
||||
($field === '--primaryKey--') ? $Model->$modelName->primaryKey : $field
|
||||
);
|
||||
} else {
|
||||
$field = null;
|
||||
}
|
||||
}
|
||||
if ($field !== null) {
|
||||
$query['fields'][] = $field;
|
||||
}
|
||||
$query['fields'][] = $field;
|
||||
}
|
||||
}
|
||||
$query['fields'] = array_unique($query['fields']);
|
||||
|
|
|
@ -1893,7 +1893,7 @@ class Model extends Overloadable {
|
|||
*
|
||||
* @param mixed $conditions Conditions to match
|
||||
* @param boolean $cascade Set to true to delete records that depend on this record
|
||||
* @param boolean $callbacks Run callbacks (not being used)
|
||||
* @param boolean $callbacks Run callbacks
|
||||
* @return boolean True on success, false on failure
|
||||
* @access public
|
||||
* @link http://book.cakephp.org/view/1038/deleteAll
|
||||
|
|
|
@ -216,8 +216,9 @@ class FormHelper extends AppHelper {
|
|||
$object =& $this->_introspectModel($model);
|
||||
$this->setEntity($model . '.', true);
|
||||
|
||||
if (isset($this->fieldset[$this->model()]['key'])) {
|
||||
$data = $this->fieldset[$this->model()];
|
||||
$modelEntity = $this->model();
|
||||
if (isset($this->fieldset[$modelEntity]['key'])) {
|
||||
$data = $this->fieldset[$modelEntity];
|
||||
$recordExists = (
|
||||
isset($this->data[$model]) &&
|
||||
!empty($this->data[$model][$data['key']])
|
||||
|
|
|
@ -283,4 +283,4 @@ class MediaView extends View {
|
|||
@ob_flush();
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
42
cake/tests/cases/libs/cache/memcache.test.php
vendored
42
cake/tests/cases/libs/cache/memcache.test.php
vendored
|
@ -52,7 +52,11 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
function setUp() {
|
||||
$this->_cacheDisable = Configure::read('Cache.disable');
|
||||
Configure::write('Cache.disable', false);
|
||||
Cache::config('memcache', array('engine' => 'Memcache', 'prefix' => 'cake_'));
|
||||
Cache::config('memcache', array(
|
||||
'engine' => 'Memcache',
|
||||
'prefix' => 'cake_',
|
||||
'duration' => 3600
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,5 +270,41 @@ class MemcacheEngineTest extends CakeTestCase {
|
|||
$result = Cache::read('test_increment');
|
||||
$this->assertEqual(8, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that configurations don't conflict, when a file engine is declared after a memcache one.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testConfigurationConflict() {
|
||||
Cache::config('long_memcache', array(
|
||||
'engine' => 'Memcache',
|
||||
'duration'=> '+2 seconds',
|
||||
'servers' => array('127.0.0.1:11211'),
|
||||
));
|
||||
Cache::config('short_memcache', array(
|
||||
'engine' => 'Memcache',
|
||||
'duration'=> '+1 seconds',
|
||||
'servers' => array('127.0.0.1:11211'),
|
||||
));
|
||||
Cache::config('some_file', array('engine' => 'File'));
|
||||
|
||||
$this->assertTrue(Cache::write('duration_test', 'yay', 'long_memcache'));
|
||||
$this->assertTrue(Cache::write('short_duration_test', 'boo', 'short_memcache'));
|
||||
|
||||
$this->assertEqual(Cache::read('duration_test', 'long_memcache'), 'yay', 'Value was not read %s');
|
||||
$this->assertEqual(Cache::read('short_duration_test', 'short_memcache'), 'boo', 'Value was not read %s');
|
||||
|
||||
sleep(1);
|
||||
$this->assertEqual(Cache::read('duration_test', 'long_memcache'), 'yay', 'Value was not read %s');
|
||||
|
||||
sleep(2);
|
||||
$this->assertFalse(Cache::read('short_duration_test', 'short_memcache'), 'Cache was not invalidated %s');
|
||||
$this->assertFalse(Cache::read('duration_test', 'long_memcache'), 'Value did not expire %s');
|
||||
|
||||
Cache::delete('duration_test', 'long_memcache');
|
||||
Cache::delete('short_duration_test', 'short_memcache');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -583,7 +583,34 @@ TEXTBLOC;
|
|||
$this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
|
||||
$this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result);
|
||||
$this->assertPattern('/This is the body of the message/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test send with delivery = debug and not using sessions.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testSendDebugWithNoSessions() {
|
||||
$session =& $this->Controller->Session;
|
||||
unset($this->Controller->Session);
|
||||
$this->Controller->EmailTest->to = 'postmaster@localhost';
|
||||
$this->Controller->EmailTest->from = 'noreply@example.com';
|
||||
$this->Controller->EmailTest->subject = 'Cake Debug Test';
|
||||
$this->Controller->EmailTest->replyTo = 'noreply@example.com';
|
||||
$this->Controller->EmailTest->template = null;
|
||||
|
||||
$this->Controller->EmailTest->delivery = 'debug';
|
||||
$result = $this->Controller->EmailTest->send('This is the body of the message');
|
||||
|
||||
$this->assertPattern('/To: postmaster@localhost\n/', $result);
|
||||
$this->assertPattern('/Subject: Cake Debug Test\n/', $result);
|
||||
$this->assertPattern('/Reply-To: noreply@example.com\n/', $result);
|
||||
$this->assertPattern('/From: noreply@example.com\n/', $result);
|
||||
$this->assertPattern('/X-Mailer: CakePHP Email Component\n/', $result);
|
||||
$this->assertPattern('/Content-Type: text\/plain; charset=UTF-8\n/', $result);
|
||||
$this->assertPattern('/Content-Transfer-Encoding: 7bitParameters:\n/', $result);
|
||||
$this->assertPattern('/This is the body of the message/', $result);
|
||||
$this->Controller->Session = $session;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3593,6 +3593,50 @@ class ContainableBehaviorTest extends CakeTestCase {
|
|||
$this->assertEqual($expected, $this->Article->hasAndBelongsToMany);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that autoFields doesn't splice in fields from other databases.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testAutoFieldsWithMultipleDatabases() {
|
||||
$config = new DATABASE_CONFIG();
|
||||
|
||||
$skip = $this->skipIf(
|
||||
!isset($config->test) || !isset($config->test2),
|
||||
'%s Primary and secondary test databases not configured, skipping cross-database '
|
||||
.'join tests.'
|
||||
.' To run these tests, you must define $test and $test2 in your database configuration.'
|
||||
);
|
||||
if ($skip) {
|
||||
return;
|
||||
}
|
||||
|
||||
$db =& ConnectionManager::getDataSource('test2');
|
||||
$this->_fixtures[$this->_fixtureClassMap['User']]->create($db);
|
||||
$this->_fixtures[$this->_fixtureClassMap['User']]->insert($db);
|
||||
|
||||
$this->Article->User->setDataSource('test2');
|
||||
|
||||
$result = $this->Article->find('all', array(
|
||||
'fields' => array('Article.title'),
|
||||
'contain' => array('User')
|
||||
));
|
||||
$this->assertTrue(isset($result[0]['Article']));
|
||||
$this->assertTrue(isset($result[0]['User']));
|
||||
|
||||
$this->_fixtures[$this->_fixtureClassMap['User']]->drop($db);
|
||||
}
|
||||
/**
|
||||
* test that autoFields doesn't splice in columns that aren't part of the join.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testAutoFieldsWithRecursiveNegativeOne() {
|
||||
$this->Article->recursive = -1;
|
||||
$result = $this->Article->field('title', array('Article.title' => 'First Article'));
|
||||
$this->assertNoErrors();
|
||||
$this->assertEqual($result, 'First Article', 'Field is wrong');
|
||||
}
|
||||
/**
|
||||
* containments method
|
||||
*
|
||||
|
|
|
@ -441,6 +441,22 @@ class JavascriptTest extends CakeTestCase {
|
|||
$result = $this->Javascript->object($object, array('quoteKeys' => false, 'stringKeys' => array('key1', 'key3')));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$expected = '{?Object?:{?key1?:"val1",?key2?:"val2",?key3?:"val3"}}';
|
||||
$result = $this->Javascript->object($object, array('q' => '?'));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$expected = '{?Object?:{?key1?:"val1",?key2?:val2,?key3?:"val3"}}';
|
||||
$result = $this->Javascript->object($object, array(
|
||||
'q' => '?', 'stringKeys' => array('key3', 'key1')
|
||||
));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$expected = '{?Object?:{?key1?:val1,?key2?:"val2",?key3?:val3}}';
|
||||
$result = $this->Javascript->object($object, array(
|
||||
'q' => '?', 'stringKeys' => array('key3', 'key1'), 'quoteKeys' => false
|
||||
));
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Javascript->useNative = $oldNative;
|
||||
}
|
||||
|
||||
|
|
|
@ -782,4 +782,4 @@ class TimeHelperTest extends CakeTestCase {
|
|||
$this->assertEqual($this->Time->format($time, '%c'), $this->Time->i18nFormat($time, '%c'));
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
|
@ -178,4 +178,4 @@ class MediaViewTest extends CakeTestCase {
|
|||
$this->assertFalse($result);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
Loading…
Reference in a new issue