summaryrefslogtreecommitdiff
path: root/modules/field/tests
diff options
context:
space:
mode:
Diffstat (limited to 'modules/field/tests')
-rw-r--r--modules/field/tests/field.test8
-rw-r--r--modules/field/tests/field_test.module9
2 files changed, 12 insertions, 5 deletions
diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test
index 9281273f6..ebb1c9f91 100644
--- a/modules/field/tests/field.test
+++ b/modules/field/tests/field.test
@@ -2681,6 +2681,9 @@ class FieldTranslationsTestCase extends FieldTestCase {
* Test the multilanguage logic of _field_invoke().
*/
function testFieldInvoke() {
+ // Enable field translations for the entity.
+ field_test_entity_info_translatable('test_entity', TRUE);
+
$entity_type = 'test_entity';
$entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);
@@ -2708,6 +2711,7 @@ class FieldTranslationsTestCase extends FieldTestCase {
// forwarded to the callback function.
$this->assertEqual($hash, $result, t('The result for %language is correctly stored.', array('%language' => $langcode)));
}
+
$this->assertEqual(count($results), count($available_languages), t('No unavailable language has been processed.'));
}
@@ -2767,8 +2771,8 @@ class FieldTranslationsTestCase extends FieldTestCase {
foreach ($results as $langcode => $result) {
if (isset($values[$id][$langcode])) {
$hash = hash('sha256', serialize(array($entity_type, $entities[$id], $this->field_name, $langcode, $values[$id][$langcode])));
- // Check whether the parameters passed to _field_invoke() were correctly
- // forwarded to the callback function.
+ // Check whether the parameters passed to _field_invoke_multiple()
+ // were correctly forwarded to the callback function.
$this->assertEqual($hash, $result, t('The result for entity %id/%language is correctly stored.', array('%id' => $id, '%language' => $langcode)));
}
}
diff --git a/modules/field/tests/field_test.module b/modules/field/tests/field_test.module
index 9e2fef62c..7f43fbf09 100644
--- a/modules/field/tests/field_test.module
+++ b/modules/field/tests/field_test.module
@@ -88,9 +88,12 @@ function field_test_field_test_op($entity_type, $entity, $field, $instance, $lan
function field_test_field_test_op_multiple($entity_type, $entities, $field, $instances, $langcode, &$items) {
$result = array();
foreach ($entities as $id => $entity) {
- if (isset($items[$id])) {
- $result[$id] = array($langcode => hash('sha256', serialize(array($entity_type, $entity, $field['field_name'], $langcode, $items[$id]))));
- }
+ // Entities, instances and items are assumed to be consistently grouped by
+ // language. To verify this we try to access all the passed data structures
+ // by entity id. If they are grouped correctly, one entity, one instance and
+ // one array of items should be available for each entity id.
+ $field_name = $instances[$id]['field_name'];
+ $result[$id] = array($langcode => hash('sha256', serialize(array($entity_type, $entity, $field_name, $langcode, $items[$id]))));
}
return $result;
}