Skip to content
Permalink
Browse files

not overwritting fields with a null translation

  • Loading branch information...
lorenzo committed Jan 27, 2014
1 parent 8db0595 commit 6fe3d92de8794541b67ec3370559e7d37209e3b9
@@ -219,7 +219,11 @@ protected function _rowMapper($results, $locale) {
continue;
}
$row->set($field, $translation->get('content'), $options);
$content = $translation->get('content');
if ($content !== null) {
$row->set($field, $content, $options);
}
unset($row[$name]);
}
@@ -78,6 +78,23 @@ public function testFindSingleLocale() {
$this->assertSame($expected, $results);
}
/**
* Tests that fields from a translated model are not overriden if translation
* is null
*
* @return void
*/
public function testFindSingleLocaleWithNullTranslation() {
$table = TableRegistry::get('Comments');
$table->addBehavior('Translate', ['fields' => ['comment']]);
$table->locale('spa');
$results = $table->find()
->where(['Comments.id' => 6])
->combine('id', 'comment')->toArray();
$expected = [6 => 'Second Comment for Second Article'];
$this->assertSame($expected, $results);
}
/**
* Tests that overriding fields with the translate behavior works when
* using conditions and that all other columns are preserved

0 comments on commit 6fe3d92

Please sign in to comment.
You can’t perform that action at this time.