public function ForumUninstallTest::testForumUninstallWithoutFieldStorage in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/forum/src/Tests/ForumUninstallTest.php \Drupal\forum\Tests\ForumUninstallTest::testForumUninstallWithoutFieldStorage()
Tests uninstallation if the field storage has been deleted beforehand.
File
- core/
modules/ forum/ src/ Tests/ ForumUninstallTest.php, line 127 - Contains \Drupal\forum\Tests\ForumUninstallTest.
Class
- ForumUninstallTest
- Tests forum module uninstallation.
Namespace
Drupal\forum\TestsCode
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 = entity_load_multiple_by_properties('taxonomy_term', array(
'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(array(
'forum',
));
}