| 7 taxonomy.test | TaxonomyHooksTestCase::testTaxonomyTermHooks() |
| 8 taxonomy.test | TaxonomyHooksTestCase::testTaxonomyTermHooks() |
Test that hooks are run correctly on creating, editing and deleting a term.
File
- modules/
taxonomy/ taxonomy.test, line 1382 - Tests for taxonomy.module.
Code
function testTaxonomyTermHooks() {
$vocabulary = $this->createVocabulary();
// Create a term with one antonym.
$edit = array(
'name' => $this->randomName(),
'antonym' => 'Long',
);
$this->drupalPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add', $edit, t('Save'));
$terms = taxonomy_get_term_by_name($edit['name']);
$term = reset($terms);
$this->assertEqual($term->antonym, $edit['antonym'], t('Antonym was loaded into the term object'));
// Update the term with a different antonym.
$edit = array(
'name' => $this->randomName(),
'antonym' => 'Short',
);
$this->drupalPost('taxonomy/term/' . $term->tid . '/edit', $edit, t('Save'));
taxonomy_terms_static_reset();
$term = taxonomy_term_load($term->tid);
$this->assertEqual($edit['antonym'], $term->antonym, t('Antonym was successfully edited'));
// Delete the term.
taxonomy_term_delete($term->tid);
$antonym = db_query('SELECT tid FROM {taxonomy_term_antonym} WHERE tid = :tid', array(':tid' => $term->tid))->fetchField();
$this->assertFalse($antonym, t('The antonym were deleted from the database.'));
}
Login or register to post comments