TaxonomyVocabularyFunctionalTest::testTaxonomyAdminDeletingVocabulary

7 taxonomy.test TaxonomyVocabularyFunctionalTest::testTaxonomyAdminDeletingVocabulary()
8 taxonomy.test TaxonomyVocabularyFunctionalTest::testTaxonomyAdminDeletingVocabulary()

Deleting a vocabulary.

File

modules/taxonomy/taxonomy.test, line 149
Tests for taxonomy.module.

Code

function testTaxonomyAdminDeletingVocabulary() {
  // Create a vocabulary.
  $edit = array(
    'name' => $this->randomName(), 
    'machine_name' => drupal_strtolower($this->randomName()),
  );
  $this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
  $this->assertText(t('Created new vocabulary'), t('New vocabulary was created.'));

  // Check the created vocabulary.
  $vocabularies = taxonomy_get_vocabularies();
  $vid = $vocabularies[count($vocabularies) -1]->vid;
  entity_get_controller('taxonomy_vocabulary')->resetCache();
  $vocabulary = taxonomy_vocabulary_load($vid);
  $this->assertTrue($vocabulary, t('Vocabulary found in database'));

  // Delete the vocabulary.
  $edit = array();
  $this->drupalPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/edit', $edit, t('Delete'));
  $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', array('%name' => $vocabulary->name)), t('[confirm deletion] Asks for confirmation.'));
  $this->assertText(t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), t('[confirm deletion] Inform that all terms will be deleted.'));

  // Confirm deletion.
  $this->drupalPost(NULL, NULL, t('Delete'));
  $this->assertRaw(t('Deleted vocabulary %name.', array('%name' => $vocabulary->name)), t('Vocabulary deleted'));
  entity_get_controller('taxonomy_vocabulary')->resetCache();
  $this->assertFalse(taxonomy_vocabulary_load($vid), t('Vocabulary is not found in the database'));
}
Login or register to post comments