Deleting a vocabulary.
function testTaxonomyAdminDeletingVocabulary() {
// Create a vocabulary.
$vid = drupal_strtolower($this
->randomName());
$edit = array(
'name' => $this
->randomName(),
'vid' => $vid,
);
$this
->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
$this
->assertText(t('Created new vocabulary'), 'New vocabulary was created.');
// Check the created vocabulary.
$this->container
->get('plugin.manager.entity')
->getStorageController('taxonomy_vocabulary')
->resetCache();
$vocabulary = taxonomy_vocabulary_load($vid);
$this
->assertTrue($vocabulary, 'Vocabulary found.');
// Delete the vocabulary.
$edit = array();
$this
->drupalPost('admin/structure/taxonomy/manage/' . $vocabulary
->id() . '/edit', $edit, t('Delete'));
$this
->assertRaw(t('Are you sure you want to delete the vocabulary %name?', array(
'%name' => $vocabulary->name,
)), '[confirm deletion] Asks for confirmation.');
$this
->assertText(t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), '[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,
)), 'Vocabulary deleted.');
$this->container
->get('plugin.manager.entity')
->getStorageController('taxonomy_vocabulary')
->resetCache();
$this
->assertFalse(taxonomy_vocabulary_load($vid), t('Vocabulary not found.'));
}