diff -u b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php --- b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumUninstallTest.php @@ -7,12 +7,12 @@ namespace Drupal\forum\Tests; -use Drupal\simpletest\WebTestBase; +use Drupal\system\Tests\Module\ModuleTestBase; /** * Tests forum module uninstallation. */ -class ForumUninstallTest extends WebTestBase { +class ForumUninstallTest extends ModuleTestBase { /** * Modules to enable. @@ -32,7 +32,7 @@ /** * Tests if forum module uninstallation properly deletes the field. */ - function testForumUninstallWithField() { + function testForumUninstallAndReinstallWithField() { // Ensure that the field exists before uninstallation. $field = field_info_field('node', 'taxonomy_forums'); $this->assertNotNull($field, 'The taxonomy_forums field exists.'); @@ -43,6 +43,38 @@ // Check that the field is now deleted. $field = field_info_field('node', 'taxonomy_forums'); $this->assertNull($field, 'The taxonomy_forums field has been deleted.'); + + // Uninstall and reinstall the forum module and its dependencies tests the + // the module installation and uninstallation APIs. + $module_data = system_rebuild_module_data(); + $module_list = array(); + foreach (array_keys($module_data['forum']->requires) as $dependency) { + // Disable all the dependencies if they are not required. + if (empty($module_data[$dependency]->info['required'])) { + $module_list[] = $dependency; + } + } + + $this->container->get('module_handler')->uninstall($module_list); + foreach ($module_list as $module) { + // Check that the module's database tables no longer exist. + $this->assertModuleTablesDoNotExist($module); + // Check that the module's config files no longer exist. + $this->assertNoModuleConfig($module); + } + + $this->container->get('module_handler')->install(array('forum')); + foreach ($module_list as $module) { + // Check that the module's database tables no longer exist. + $this->assertModuleTablesExist($module); + // Check that the module's config files no longer exist. + $this->assertModuleConfig($module); + } + + // Ensure that the field exists after reinstallation. + $field = field_info_field('node', 'taxonomy_forums'); + $this->assertNotNull($field, 'The taxonomy_forums field exists.'); + }