public function ForumUninstallTest::testForumUninstallWithoutFieldStorage in Drupal 9
Same name and namespace in other branches
- 8 core/modules/forum/tests/src/Functional/ForumUninstallTest.php \Drupal\Tests\forum\Functional\ForumUninstallTest::testForumUninstallWithoutFieldStorage()
- 10 core/modules/forum/tests/src/Functional/ForumUninstallTest.php \Drupal\Tests\forum\Functional\ForumUninstallTest::testForumUninstallWithoutFieldStorage()
Tests uninstallation if the field storage has been deleted beforehand.
File
- core/
modules/ forum/ tests/ src/ Functional/ ForumUninstallTest.php, line 140
Class
- ForumUninstallTest
- Tests forum module uninstallation.
Namespace
Drupal\Tests\forum\FunctionalCode
public function testForumUninstallWithoutFieldStorage() {
// Manually delete the taxonomy_forums field before module uninstallation.
$field_storage = FieldStorageConfig::loadByName('node', 'taxonomy_forums');
$this
->assertNotNull($field_storage, 'The taxonomy_forums field storage exists.');
$field_storage
->delete();
// Check that the field is now deleted.
$field_storage = FieldStorageConfig::loadByName('node', 'taxonomy_forums');
$this
->assertNull($field_storage, 'The taxonomy_forums field storage has been deleted.');
// Delete all terms in the Forums vocabulary. Uninstalling the forum module
// will fail unless this is done.
$terms = \Drupal::entityTypeManager()
->getStorage('taxonomy_term')
->loadByProperties([
'vid' => 'forums',
]);
foreach ($terms as $term) {
$term
->delete();
}
// Ensure that uninstallation succeeds even if the field has already been
// deleted manually beforehand.
$this->container
->get('module_installer')
->uninstall([
'forum',
]);
}