function VocabularyUiTest::testTaxonomyAdminDeletingVocabulary
Same name in other branches
- 9 core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php \Drupal\Tests\taxonomy\Functional\VocabularyUiTest::testTaxonomyAdminDeletingVocabulary()
- 8.9.x core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php \Drupal\Tests\taxonomy\Functional\VocabularyUiTest::testTaxonomyAdminDeletingVocabulary()
- 10 core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php \Drupal\Tests\taxonomy\Functional\VocabularyUiTest::testTaxonomyAdminDeletingVocabulary()
Deleting a vocabulary.
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ VocabularyUiTest.php, line 160
Class
- VocabularyUiTest
- Tests the taxonomy vocabulary interface.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testTaxonomyAdminDeletingVocabulary() : void {
// Create a vocabulary.
$vid = $this->randomMachineName();
$edit = [
'name' => $this->randomMachineName(),
'vid' => $vid,
];
$this->drupalGet('admin/structure/taxonomy/add');
$this->submitForm($edit, 'Save');
$this->assertSession()
->pageTextContains('Created new vocabulary');
// Check the created vocabulary.
$this->container
->get('entity_type.manager')
->getStorage('taxonomy_vocabulary')
->resetCache();
$vocabulary = Vocabulary::load($vid);
$this->assertNotEmpty($vocabulary, 'Vocabulary found.');
// Delete the vocabulary.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id());
$this->clickLink('Delete');
$this->assertSession()
->pageTextContains("Are you sure you want to delete the vocabulary {$vocabulary->label()}?");
$this->assertSession()
->pageTextContains('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.');
// Confirm deletion.
$this->submitForm([], 'Delete');
$this->assertSession()
->pageTextContains("Deleted vocabulary {$vocabulary->label()}.");
$this->container
->get('entity_type.manager')
->getStorage('taxonomy_vocabulary')
->resetCache();
$this->assertNull(Vocabulary::load($vid), 'Vocabulary not found.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.