public function VocabularyUiTest::testTaxonomyAdminDeletingVocabulary in Drupal 10
Same name and namespace in other branches
- 8 core/modules/taxonomy/tests/src/Functional/VocabularyUiTest.php \Drupal\Tests\taxonomy\Functional\VocabularyUiTest::testTaxonomyAdminDeletingVocabulary()
- 9 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 139
Class
- VocabularyUiTest
- Tests the taxonomy vocabulary interface.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testTaxonomyAdminDeletingVocabulary() {
// Create a vocabulary.
$vid = mb_strtolower($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.');
}