1 taxonomy.test TaxonomyVocabularyFunctionalTest::testTaxonomyAdminDeletingVocabulary()

Deleting a vocabulary.

File

core/modules/taxonomy/tests/taxonomy.test, line 224
Tests for taxonomy.module.

Class

TaxonomyVocabularyFunctionalTest
Tests the taxonomy vocabulary interface.

Code

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

  // Check the created vocabulary.
  backdrop_static_reset('taxonomy_vocabulary_load_multiple');
  $vocabulary = taxonomy_vocabulary_load($vocabulary_name);
  $this->assertTrue($vocabulary, 'Vocabulary found in database.');

  // Delete the vocabulary.
  $this->backdropPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/delete', NULL, t('Delete'));
  $this->assertRaw(t('Deleted vocabulary %name.', array('%name' => $vocabulary->name)), 'Vocabulary deleted.');
  backdrop_static_reset('taxonomy_vocabulary_load_multiple');
  $this->assertFalse(taxonomy_vocabulary_load($vocabulary_name), 'Vocabulary is not found in config.');
}