function VocabularyUiTest::testTaxonomyAdminDeletingVocabulary in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/taxonomy/src/Tests/VocabularyUiTest.php \Drupal\taxonomy\Tests\VocabularyUiTest::testTaxonomyAdminDeletingVocabulary()
Deleting a vocabulary.
File
- core/
modules/ taxonomy/ src/ Tests/ VocabularyUiTest.php, line 134 - Contains \Drupal\taxonomy\Tests\VocabularyUiTest.
Class
- VocabularyUiTest
- Tests the taxonomy vocabulary interface.
Namespace
Drupal\taxonomy\TestsCode
function testTaxonomyAdminDeletingVocabulary() {
// Create a vocabulary.
$vid = Unicode::strtolower($this
->randomMachineName());
$edit = array(
'name' => $this
->randomMachineName(),
'vid' => $vid,
);
$this
->drupalPostForm('admin/structure/taxonomy/add', $edit, t('Save'));
$this
->assertText(t('Created new vocabulary'), 'New vocabulary was created.');
// Check the created vocabulary.
$this->container
->get('entity.manager')
->getStorage('taxonomy_vocabulary')
->resetCache();
$vocabulary = Vocabulary::load($vid);
$this
->assertTrue($vocabulary, 'Vocabulary found.');
// Delete the vocabulary.
$this
->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary
->id());
$this
->clickLink(t('Delete'));
$this
->assertRaw(t('Are you sure you want to delete the vocabulary %name?', array(
'%name' => $vocabulary
->label(),
)), '[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
->drupalPostForm(NULL, NULL, t('Delete'));
$this
->assertRaw(t('Deleted vocabulary %name.', array(
'%name' => $vocabulary
->label(),
)), 'Vocabulary deleted.');
$this->container
->get('entity.manager')
->getStorage('taxonomy_vocabulary')
->resetCache();
$this
->assertFalse(Vocabulary::load($vid), 'Vocabulary not found.');
}