function DependencyTest::testUninstallDependents in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Module/DependencyTest.php \Drupal\system\Tests\Module\DependencyTest::testUninstallDependents()
Tests attempting to uninstall a module that has installed dependents.
File
- core/
modules/ system/ src/ Tests/ Module/ DependencyTest.php, line 161 - Contains \Drupal\system\Tests\Module\DependencyTest.
Class
- DependencyTest
- Enable module without dependency enabled.
Namespace
Drupal\system\Tests\ModuleCode
function testUninstallDependents() {
// Enable the forum module.
$edit = array(
'modules[Core][forum][enable]' => 'forum',
);
$this
->drupalPostForm('admin/modules', $edit, t('Install'));
$this
->drupalPostForm(NULL, array(), t('Continue'));
$this
->assertModules(array(
'forum',
), TRUE);
// Check that the comment module cannot be uninstalled.
$this
->drupalGet('admin/modules/uninstall');
$checkbox = $this
->xpath('//input[@type="checkbox" and @name="uninstall[comment]" and @disabled="disabled"]');
$this
->assert(count($checkbox) == 1, 'Checkbox for uninstalling the comment module is disabled.');
// Delete any forum terms.
$vid = $this
->config('forum.settings')
->get('vocabulary');
// Ensure taxonomy has been loaded into the test-runner after forum was
// enabled.
\Drupal::moduleHandler()
->load('taxonomy');
$terms = entity_load_multiple_by_properties('taxonomy_term', [
'vid' => $vid,
]);
foreach ($terms as $term) {
$term
->delete();
}
// Uninstall the forum module, and check that taxonomy now can also be
// uninstalled.
$edit = array(
'uninstall[forum]' => 'forum',
);
$this
->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this
->drupalPostForm(NULL, NULL, t('Uninstall'));
$this
->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
// Uninstall comment module.
$edit = array(
'uninstall[comment]' => 'comment',
);
$this
->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
$this
->drupalPostForm(NULL, NULL, t('Uninstall'));
$this
->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
}