1 system.test ModuleDependencyTestCase::testUninstallDependents()

Tests attempting to uninstall a module that has installed dependents.

File

core/modules/system/tests/system.test, line 483
Tests for system.module.

Class

ModuleDependencyTestCase
Test module dependency functionality.

Code

function testUninstallDependents() {
  // Enable both language and locale modules.
  $edit = array('modules[Translation][language][enable]' => 'language');
  $this->backdropPost('admin/modules', $edit, t('Save configuration'));
  $this->assertModules(array('language'), TRUE);
  $edit = array('modules[Translation][locale][enable]' => 'locale');
  $this->backdropPost('admin/modules', $edit, t('Save configuration'));
  $this->assertModules(array('locale'), TRUE);

  // Disable locale and language. Both should now be installed but disabled.
  $edit = array('modules[Translation][locale][enable]' => FALSE);
  $this->backdropPost('admin/modules', $edit, t('Save configuration'));
  $this->assertModules(array('locale'), FALSE);
  $edit = array('modules[Translation][language][enable]' => FALSE);
  $this->backdropPost('admin/modules', $edit, t('Save configuration'));
  $this->assertModules(array('language'), FALSE);

  // Check that the language module cannot be uninstalled.
  $this->backdropGet('admin/modules/uninstall');
  $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="uninstall[language]"]');
  $this->assert(count($checkbox) == 1, 'Checkbox for uninstalling the language module is disabled.');

  // Uninstall the locale module, check that language then can be uninstalled.
  $edit = array('uninstall[locale]' => 'locale');
  $this->backdropPost('admin/modules/uninstall', $edit, t('Uninstall'));
  $this->backdropPost(NULL, NULL, t('Uninstall'));
  $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
  $edit = array('uninstall[language]' => 'language');
  $this->backdropPost('admin/modules/uninstall', $edit, t('Uninstall'));
  $this->backdropPost(NULL, NULL, t('Uninstall'));
  $this->assertText(t('The selected modules have been uninstalled.'), 'Modules status has been updated.');
}