diff --git a/modules/simpletest/tests/taxonomy_test.test b/modules/simpletest/tests/taxonomy_test.test deleted file mode 100644 index 9d51e328f5de1a8c66d89bcee5dc794f5a47f988..0000000000000000000000000000000000000000 --- a/modules/simpletest/tests/taxonomy_test.test +++ /dev/null @@ -1,53 +0,0 @@ -<?php -// $Id$ - -class TaxonomyHooksTestCase extends DrupalWebTestCase { - function getInfo() { - return array( - 'name' => t('Taxonomy term hooks'), - 'description' => t('Hooks for taxonomy term load/save/delete.'), - 'group' => t('Taxonomy') - ); - } - - function setUp() { - parent::setUp('taxonomy', 'taxonomy_test'); - $taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy')); - $this->drupalLogin($taxonomy_admin); - } - - /** - * Test that hooks are run correctly on creating, editing and deleting a term. - */ - function testTaxonomyTermHooks() { - // Create a taxonomy vocabulary. - $edit = array( - 'name' => $this->randomName(), - ); - $this->drupalPost('admin/content/taxonomy/add', $edit, t('Save')); - - // Create a term with one antonym. - $edit = array( - 'name' => $this->randomName(), - 'antonyms' => 'Long', - ); - $this->drupalPost('admin/content/taxonomy/1/add', $edit, t('Save')); - $terms = taxonomy_get_term_by_name($edit['name']); - $term = taxonomy_term_load($terms[0]->tid); - $this->assertEqual($term->antonyms[0], $edit['antonyms'], t('Antonyms were loaded into the term object')); - - // Update the term with a different antonym. - $edit = array( - 'name' => $this->randomName(), - 'antonyms' => 'Short', - ); - $this->drupalPost('taxonomy/term/' . $term->tid . '/edit', $edit, t('Save')); - $term = taxonomy_term_load($term->tid, TRUE); - $this->assertTrue(in_array($edit['antonyms'], $term->antonyms), t('Antonym was successfully edited')); - - // Delete the term. - taxonomy_term_delete($term->tid); - $antonyms = db_query('SELECT taid FROM {term_antonym} WHERE tid = :tid', array(':tid' => $term->tid))->fetchField(); - $this->assertFalse($antonyms, t('The antonyms were deleted from the database.')); - } -} diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 8d6a2c1ba8c70f16cd308a77b98d263bdd530a1c..0047e36ab608e608ac72faa3f935a1c3df25cc3b 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -500,3 +500,57 @@ class TaxonomyLoadMultipleUnitTest extends TaxonomyWebTestCase { $this->assertEqual($term->tid, $loaded_term->tid, t('Term loaded by name successfully.')); } } + +/** + * Tests for taxonomy hook invocation. + */ +class TaxonomyHooksTestCase extends DrupalWebTestCase { + function getInfo() { + return array( + 'name' => t('Taxonomy term hooks'), + 'description' => t('Hooks for taxonomy term load/save/delete.'), + 'group' => t('Taxonomy') + ); + } + + function setUp() { + parent::setUp('taxonomy', 'taxonomy_test'); + $taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy')); + $this->drupalLogin($taxonomy_admin); + } + + /** + * Test that hooks are run correctly on creating, editing and deleting a term. + */ + function testTaxonomyTermHooks() { + // Create a taxonomy vocabulary. + $edit = array( + 'name' => $this->randomName(), + ); + $this->drupalPost('admin/content/taxonomy/add', $edit, t('Save')); + + // Create a term with one antonym. + $edit = array( + 'name' => $this->randomName(), + 'antonyms' => 'Long', + ); + $this->drupalPost('admin/content/taxonomy/1/add', $edit, t('Save')); + $terms = taxonomy_get_term_by_name($edit['name']); + $term = taxonomy_term_load($terms[0]->tid); + $this->assertEqual($term->antonyms[0], $edit['antonyms'], t('Antonyms were loaded into the term object')); + + // Update the term with a different antonym. + $edit = array( + 'name' => $this->randomName(), + 'antonyms' => 'Short', + ); + $this->drupalPost('taxonomy/term/' . $term->tid . '/edit', $edit, t('Save')); + $term = taxonomy_term_load($term->tid, TRUE); + $this->assertTrue(in_array($edit['antonyms'], $term->antonyms), t('Antonym was successfully edited')); + + // Delete the term. + taxonomy_term_delete($term->tid); + $antonyms = db_query('SELECT taid FROM {term_antonym} WHERE tid = :tid', array(':tid' => $term->tid))->fetchField(); + $this->assertFalse($antonyms, t('The antonyms were deleted from the database.')); + } +}