summaryrefslogtreecommitdiff
path: root/modules/taxonomy/taxonomy.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/taxonomy/taxonomy.test')
-rw-r--r--modules/taxonomy/taxonomy.test54
1 files changed, 54 insertions, 0 deletions
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 42b4d4767..a84962d0f 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -1879,3 +1879,57 @@ class TaxonomyThemeTestCase extends TaxonomyWebTestCase {
$this->assertRaw('seven/style.css', t("The administrative theme's CSS appears on the page for editing a taxonomy term."));
}
}
+
+/**
+ * Tests the functionality of EntityFieldQuery for taxonomy entities.
+ */
+class TaxonomyEFQTestCase extends TaxonomyWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Taxonomy EntityFieldQuery',
+ 'description' => 'Verifies operation of a taxonomy-based EntityFieldQuery.',
+ 'group' => 'Taxonomy',
+ );
+ }
+
+ function setUp() {
+ parent::setUp();
+ $this->admin_user = $this->drupalCreateUser(array('administer taxonomy'));
+ $this->drupalLogin($this->admin_user);
+ $this->vocabulary = $this->createVocabulary();
+ }
+
+ /**
+ * Tests that a basic taxonomy EntityFieldQuery works.
+ */
+ function testTaxonomyEFQ() {
+ $terms = array();
+ for ($i = 0; $i < 5; $i++) {
+ $term = $this->createTerm($this->vocabulary);
+ $terms[$term->tid] = $term;
+ }
+ $query = new EntityFieldQuery();
+ $query->entityCondition('entity_type', 'taxonomy_term');
+ $result = $query->execute();
+ $result = $result['taxonomy_term'];
+ asort($result);
+ $this->assertEqual(array_keys($terms), array_keys($result), 'Taxonomy terms were retrieved by EntityFieldQuery.');
+
+ // Create a second vocabulary and five more terms.
+ $vocabulary2 = $this->createVocabulary();
+ $terms2 = array();
+ for ($i = 0; $i < 5; $i++) {
+ $term = $this->createTerm($vocabulary2);
+ $terms2[$term->tid] = $term;
+ }
+
+ $query = new EntityFieldQuery();
+ $query->entityCondition('entity_type', 'taxonomy_term');
+ $query->entityCondition('bundle', $vocabulary2->machine_name);
+ $result = $query->execute();
+ $result = $result['taxonomy_term'];
+ asort($result);
+ $this->assertEqual(array_keys($terms2), array_keys($result), format_string('Taxonomy terms from the %name vocabulary were retrieved by EntityFieldQuery.', array('%name' => $vocabulary2->name)));
+ }
+
+}