summaryrefslogtreecommitdiff
path: root/modules/taxonomy/taxonomy.test
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2008-09-24 02:59:42 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2008-09-24 02:59:42 +0000
commit9bc36524f2782336e75e45b928db5d23da747c26 (patch)
tree02342bba09a01eee025b4bbafbe71fc3a233d14c /modules/taxonomy/taxonomy.test
parent06d0d8c2a45da477480f667975fc0dcd48231df2 (diff)
downloadbrdo-9bc36524f2782336e75e45b928db5d23da747c26.tar.gz
brdo-9bc36524f2782336e75e45b928db5d23da747c26.tar.bz2
#244662 by solotandem and catch: Fix taxonomy_vocabulary_load() when called multiple times.
Diffstat (limited to 'modules/taxonomy/taxonomy.test')
-rw-r--r--modules/taxonomy/taxonomy.test60
1 files changed, 58 insertions, 2 deletions
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 4bb132f73..1f96bdaaf 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -1,6 +1,56 @@
<?php
// $Id$
+class TaxonomyVocabularyLoadTestCase extends DrupalWebTestCase {
+ /**
+ * Implementation of getInfo().
+ */
+ function getInfo() {
+ return array(
+ 'name' => t('Loading taxonomy vocabularies'),
+ 'description' => t('Test loading vocabularies under various conditions.'),
+ 'group' => t('Taxonomy'),
+ );
+ }
+
+ /**
+ * Implementation of setUp() {
+ */
+ function setUp() {
+ parent::setUp('taxonomy');
+ $admin_user = $this->drupalCreateUser(array('administer taxonomy'));
+ $this->drupalLogin($admin_user);
+ }
+
+ /**
+ * Ensure that when an invalid vocabulary vid is loaded, it is possible
+ * to load the same vid successfully if it subsequently becomes valid.
+ */
+ function testTaxonomyVocabularyLoadReturnFalse() {
+ // Load a vocabulary that doesn't exist.
+ $vocabularies = taxonomy_get_vocabularies();
+ $vid = count($vocabularies) + 1;
+ $vocabulary = taxonomy_vocabulary_load($vid);
+ // This should not return an object because no such vocabulary exists.
+ $this->assertTrue(!is_object($vocabulary), t('No object loaded.'));
+
+ // Create a new vocabulary.
+ $edit = array(
+ 'name' => $this->randomName(),
+ 'description' => $this->randomName(),
+ 'help' => '',
+ 'weight' => 0,
+ );
+ $this->drupalPost('admin/content/taxonomy/add/vocabulary', $edit, t('Save'));
+
+ // Load the vocabulary with the same $vid from earlier.
+ // This should return a vocabulary object since it now matches a real vid.
+ $vocabulary = taxonomy_vocabulary_load($vid);
+ $this->assertTrue(is_object($vocabulary), t('Vocabulary is an object'));
+ $this->assertTrue($vocabulary->vid == $vid, t('Valid vocabulary vid is the same as our previously invalid one.'));
+ }
+}
+
class TaxonomyVocabularyFunctionsTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo().
@@ -8,12 +58,19 @@ class TaxonomyVocabularyFunctionsTestCase extends DrupalWebTestCase {
function getInfo() {
return array(
'name' => t('Vocabulary functions'),
- 'description' => t('Create/Edit/Delete vocabulary and assert that all fields were properly saved.'),
+ 'description' => t('Test loading, saving, and deleting vocabularies.'),
'group' => t('Taxonomy')
);
}
/**
+ * Implementation of setUp().
+ */
+ function setUp() {
+ parent::setUp('taxonomy');
+ }
+
+ /**
* Create/Edit/Delete vocabulary and assert that all fields were properly saved.
*/
function testVocabularyFunctions() {
@@ -81,7 +138,6 @@ class TaxonomyVocabularyFunctionsTestCase extends DrupalWebTestCase {
}
}
-
class TaxonomyTermFunctionsTestCase extends DrupalWebTestCase {
/**
* Implementation of getInfo().