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.test28
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 372982c9b..39164190b 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -895,6 +895,34 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
// Try to load the term using a substring of the name.
$terms = taxonomy_get_term_by_name(drupal_substr($term->name, 2));
$this->assertFalse($terms);
+
+ // Create a new term in a different vocabulary with the same name.
+ $new_vocabulary = $this->createVocabulary();
+ $new_term = new stdClass();
+ $new_term->name = $term->name;
+ $new_term->vid = $new_vocabulary->vid;
+ taxonomy_term_save($new_term);
+
+ // Load multiple terms with the same name.
+ $terms = taxonomy_get_term_by_name($term->name);
+ $this->assertEqual(count($terms), 2, t('Two terms loaded with the same name.'));
+
+ // Load single term when restricted to one vocabulary.
+ $terms = taxonomy_get_term_by_name($term->name, $this->vocabulary->machine_name);
+ $this->assertEqual(count($terms), 1, t('One term loaded when restricted by vocabulary.'));
+ $this->assertTrue(isset($terms[$term->tid]), t('Term loaded using exact name and vocabulary machine name.'));
+
+ // Create a new term with another name.
+ $term2 = $this->createTerm($this->vocabulary);
+
+ // Try to load a term by name that doesn't exist in this vocabulary but
+ // exists in another vocabulary.
+ $terms = taxonomy_get_term_by_name($term2->name, $new_vocabulary->machine_name);
+ $this->assertFalse($terms, t('Invalid term name restricted by vocabulary machine name not loaded.'));
+
+ // Try to load terms filtering by a non-existing vocabulary.
+ $terms = taxonomy_get_term_by_name($term2->name, 'non_existing_vocabulary');
+ $this->assertEqual(count($terms), 0, t('No terms loaded when restricted by a non-existing vocabulary.'));
}
}