function TMGMTEntitySourceTestCase::checkTranslatedData in Translation Management Tool 7
Compares the data from an entity with the translated data.
Parameters
$tentity: The translated entity object.
$data: An array with the translated data.
$langcode: The code of the target language.
2 calls to TMGMTEntitySourceTestCase::checkTranslatedData()
- TMGMTEntitySourceTestCase::testEntitySourceNode in sources/
entity/ tmgmt_entity.source.test - Tests nodes field translation.
- TMGMTEntitySourceTestCase::testEntitySourceTerm in sources/
entity/ tmgmt_entity.source.test - Tests taxonomy terms field translation.
File
- sources/
entity/ tmgmt_entity.source.test, line 170
Class
- TMGMTEntitySourceTestCase
- Basic Entity Source tests.
Code
function checkTranslatedData($tentity, $data, $langcode) {
foreach (element_children($data) as $field_name) {
foreach (element_children($data[$field_name]) as $delta) {
foreach (element_children($data[$field_name][$delta]) as $column) {
$column_value = $data[$field_name][$delta][$column];
if (!empty($column_value['#translate'])) {
$this
->assertEqual($tentity->{$field_name}[$langcode][$delta][$column], $column_value['#translation']['#text'], format_string('The field %field:%delta has been populated with the proper translated data.', array(
'%field' => $field_name,
'delta' => $delta,
)));
}
else {
$this
->assertEqual($tentity->{$field_name}[$langcode][$delta][$column], $column_value['#text'], format_string('The field %field:%delta has been populated with the proper untranslated data.', array(
'%field' => $field_name,
'delta' => $delta,
)));
}
}
}
}
}