function entity_translation_test_check_save in Entity Translation 7
Test implementation for save hooks.
2 calls to entity_translation_test_check_save()
File
- tests/
entity_translation_test.module, line 37 - Testing functionality for Entity Translation module.
Code
function entity_translation_test_check_save($entity_type, $entity, $translation, $hook) {
list($id, , ) = entity_extract_ids($entity_type, $entity);
$match = FALSE;
$row = db_select('entity_translation', 'et')
->fields('et')
->condition('entity_type', $entity_type)
->condition('entity_id', $id)
->condition('language', $translation['language'])
->orderBy('created')
->execute()
->fetch(PDO::FETCH_ASSOC);
if ($row) {
$match = TRUE;
foreach ($translation as $key => $value) {
if ($row[$key] != $value) {
$match = FALSE;
break;
}
}
}
variable_set('entity_translation_test_save', array(
$hook => $match,
));
}