summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-10-05 17:55:07 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-10-05 17:55:07 -0700
commit1961c111758267667fca2731e1953d3cb4ec52bf (patch)
treeeb4735cc2d4390d47c4e094a0be504fbe3e2eaff /modules/simpletest
parent18fb44809f2d98af2921db0b275b32626aa19ed1 (diff)
downloadbrdo-1961c111758267667fca2731e1953d3cb4ec52bf.tar.gz
brdo-1961c111758267667fca2731e1953d3cb4ec52bf.tar.bz2
Issue #1292922 by loganfsmyth, plach: Fixed EntityFieldQuery count query broken for translatable fields.
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/entity_query.test39
1 files changed, 39 insertions, 0 deletions
diff --git a/modules/simpletest/tests/entity_query.test b/modules/simpletest/tests/entity_query.test
index 3c53eae47..ec951f8e2 100644
--- a/modules/simpletest/tests/entity_query.test
+++ b/modules/simpletest/tests/entity_query.test
@@ -1075,6 +1075,45 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
}
/**
+ * Tests querying translatable fields.
+ */
+ function testEntityFieldQueryTranslatable() {
+
+ // Make a test field translatable AND cardinality one.
+ $this->fields[0]['translatable'] = TRUE;
+ $this->fields[0]['cardinality'] = 1;
+ field_update_field($this->fields[0]);
+ field_test_entity_info_translatable('test_entity', TRUE);
+ drupal_static_reset('field_available_languages');
+
+ // Create more items with different languages.
+ $entity = new stdClass();
+ $entity->ftid = 1;
+ $entity->ftvid = 1;
+ $entity->fttype = 'test_bundle';
+
+ // Set fields in two languages with one field value.
+ foreach (array(LANGUAGE_NONE, 'en') as $langcode) {
+ $entity->{$this->field_names[0]}[$langcode][0]['value'] = 1234;
+ }
+
+ field_attach_update('test_entity', $entity);
+
+ // Look up number of results when querying a single entity with multilingual
+ // field values.
+ $query = new EntityFieldQuery();
+ $query_count = $query
+ ->entityCondition('entity_type', 'test_entity')
+ ->entityCondition('bundle', 'test_bundle')
+ ->entityCondition('entity_id', '1')
+ ->fieldCondition($this->fields[0])
+ ->count()
+ ->execute();
+
+ $this->assertEqual($query_count, 1, t("Count on translatable cardinality one field is correct."));
+ }
+
+ /**
* Tests field meta conditions.
*/
function testEntityFieldQueryMetaConditions() {