function ModuleDependencyTestCase::testUninstallDependents

Tests attempting to uninstall a module that has installed dependents.

File

modules/system/system.test, line 541

Class

ModuleDependencyTestCase
Test module dependency functionality.

Code

function testUninstallDependents() {
    // Enable the forum module.
    $edit = array(
        'modules[Core][forum][enable]' => 'forum',
    );
    $this->drupalPost('admin/modules', $edit, t('Save configuration'));
    $this->assertModules(array(
        'forum',
    ), TRUE);
    // Disable forum and comment. Both should now be installed but disabled.
    $edit = array(
        'modules[Core][forum][enable]' => FALSE,
    );
    $this->drupalPost('admin/modules', $edit, t('Save configuration'));
    $this->assertModules(array(
        'forum',
    ), FALSE);
    $edit = array(
        'modules[Core][comment][enable]' => FALSE,
    );
    $this->drupalPost('admin/modules', $edit, t('Save configuration'));
    $this->assertModules(array(
        'comment',
    ), FALSE);
    // Check that the taxonomy module cannot be uninstalled.
    $this->drupalGet('admin/modules/uninstall');
    $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="uninstall[comment]"]');
    $this->assert(count($checkbox) == 1, 'Checkbox for uninstalling the comment module is disabled.');
    // Uninstall the forum module, and check that taxonomy now can also be
    // uninstalled.
    $edit = array(
        'uninstall[forum]' => 'forum',
    );
    $this->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
    $this->drupalPost(NULL, NULL, t('Uninstall'));
    $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
    $edit = array(
        'uninstall[comment]' => 'comment',
    );
    $this->drupalPost('admin/modules/uninstall', $edit, t('Uninstall'));
    $this->drupalPost(NULL, NULL, t('Uninstall'));
    $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.