mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Add test for issue #2595
Fold conditions that did the same thing and add a test case. Closes #2595
This commit is contained in:
parent
a4f138813b
commit
3763350667
2 changed files with 26 additions and 3 deletions
|
@ -305,9 +305,7 @@ class TranslateBehavior extends ModelBehavior {
|
|||
}
|
||||
} else {
|
||||
$value = '';
|
||||
if (is_numeric($row[$Model->alias][$aliasVirtual])) {
|
||||
$value = $row[$Model->alias][$aliasVirtual];
|
||||
} elseif (!empty($row[$Model->alias][$aliasVirtual])) {
|
||||
if (is_numeric($row[$Model->alias][$aliasVirtual]) || !empty($row[$Model->alias][$aliasVirtual])) {
|
||||
$value = $row[$Model->alias][$aliasVirtual];
|
||||
}
|
||||
$row[$Model->alias][$aliasField] = $value;
|
||||
|
|
|
@ -354,6 +354,31 @@ class TranslateBehaviorTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test loading fields with 0 as the translated value.
|
||||
*/
|
||||
public function testFetchTranslationsWithZero() {
|
||||
$this->loadFixtures('Translate', 'TranslatedItem');
|
||||
|
||||
$model = new TranslatedItem();
|
||||
$translateModel = $model->translateModel();
|
||||
$translateModel->updateAll(array('content' => '"0"'));
|
||||
$model->locale = 'eng';
|
||||
|
||||
$result = $model->read(null, 1);
|
||||
$expected = array(
|
||||
'TranslatedItem' => array(
|
||||
'id' => 1,
|
||||
'slug' => 'first_translated',
|
||||
'locale' => 'eng',
|
||||
'title' => '0',
|
||||
'content' => '0',
|
||||
'translated_article_id' => 1,
|
||||
)
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testLocaleMultiple method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue