Commit 91736cad authored by cilefen's avatar cilefen

Issue #2665152 by alexpott, Andrej Galuf, tfranz, longwave, andypost,...

Issue #2665152 by alexpott, Andrej Galuf, tfranz, longwave, andypost, jsimonis, bojanz: Simplify module form structure and fix bugs when Suhosin is used
parent 758f01b6
...@@ -208,12 +208,12 @@ function testCommentInstallAfterContentModule() { ...@@ -208,12 +208,12 @@ function testCommentInstallAfterContentModule() {
// Install core content type module (book). // Install core content type module (book).
$edit = array(); $edit = array();
$edit['modules[Core][book][enable]'] = 'book'; $edit['modules[book][enable]'] = 'book';
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
// Now install the comment module. // Now install the comment module.
$edit = array(); $edit = array();
$edit['modules[Core][comment][enable]'] = 'comment'; $edit['modules[comment][enable]'] = 'comment';
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->rebuildContainer(); $this->rebuildContainer();
$this->assertTrue($this->container->get('module_handler')->moduleExists('comment'), 'Comment module enabled.'); $this->assertTrue($this->container->get('module_handler')->moduleExists('comment'), 'Comment module enabled.');
......
...@@ -122,7 +122,7 @@ public function testPreExistingConfigInstall() { ...@@ -122,7 +122,7 @@ public function testPreExistingConfigInstall() {
// will install the config_test module first because it is a dependency of // will install the config_test module first because it is a dependency of
// config_install_fail_test. // config_install_fail_test.
// @see \Drupal\system\Form\ModulesListForm::submitForm() // @see \Drupal\system\Form\ModulesListForm::submitForm()
$this->drupalPostForm('admin/modules', array('modules[Testing][config_test][enable]' => TRUE, 'modules[Testing][config_install_fail_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[config_test][enable]' => TRUE, 'modules[config_install_fail_test][enable]' => TRUE), t('Install'));
$this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.'); $this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
// Uninstall the config_test module to test the confirm form. // Uninstall the config_test module to test the confirm form.
...@@ -133,7 +133,7 @@ public function testPreExistingConfigInstall() { ...@@ -133,7 +133,7 @@ public function testPreExistingConfigInstall() {
// The user is shown a confirm form because the config_test module is a // The user is shown a confirm form because the config_test module is a
// dependency. // dependency.
// @see \Drupal\system\Form\ModulesListConfirmForm::submitForm() // @see \Drupal\system\Form\ModulesListConfirmForm::submitForm()
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_fail_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[config_install_fail_test][enable]' => TRUE), t('Install'));
$this->drupalPostForm(NULL, array(), t('Continue')); $this->drupalPostForm(NULL, array(), t('Continue'));
$this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.'); $this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default</em> already exists in active configuration.');
...@@ -147,7 +147,7 @@ public function testPreExistingConfigInstall() { ...@@ -147,7 +147,7 @@ public function testPreExistingConfigInstall() {
->set('label', 'Je suis Charlie') ->set('label', 'Je suis Charlie')
->save(); ->save();
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_fail_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[config_install_fail_test][enable]' => TRUE), t('Install'));
$this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default</em> already exist in active configuration.'); $this->assertRaw('Unable to install Configuration install fail test, <em class="placeholder">config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default</em> already exist in active configuration.');
// Test installing a theme through the UI that has existing configuration. // Test installing a theme through the UI that has existing configuration.
...@@ -178,16 +178,16 @@ public function testUnmetDependenciesInstall() { ...@@ -178,16 +178,16 @@ public function testUnmetDependenciesInstall() {
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
// We need to install separately since config_install_dependency_test does // We need to install separately since config_install_dependency_test does
// not depend on config_test and order is important. // not depend on config_test and order is important.
$this->drupalPostForm('admin/modules', array('modules[Testing][config_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[config_test][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_dependency_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install'));
$this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)</em>'); $this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)</em>');
$this->drupalPostForm('admin/modules', array('modules[Testing][config_test_language][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[config_test_language][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_dependency_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install'));
$this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)</em>'); $this->assertRaw('Unable to install <em class="placeholder">Config install dependency test</em> due to unmet dependencies: <em class="placeholder">config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)</em>');
$this->drupalPostForm('admin/modules', array('modules[Testing][config_other_module_config_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[config_other_module_config_test][enable]' => TRUE), t('Install'));
$this->drupalPostForm('admin/modules', array('modules[Testing][config_install_dependency_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install'));
$this->rebuildContainer(); $this->rebuildContainer();
$this->assertTrue(entity_load('config_test', 'other_module_test_with_dependency'), 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.'); $this->assertTrue(entity_load('config_test', 'other_module_test_with_dependency'), 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.');
} }
...@@ -197,7 +197,7 @@ public function testUnmetDependenciesInstall() { ...@@ -197,7 +197,7 @@ public function testUnmetDependenciesInstall() {
*/ */
public function testConfigModuleRequirements() { public function testConfigModuleRequirements() {
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
$this->drupalPostForm('admin/modules', array('modules[Core][config][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[config][enable]' => TRUE), t('Install'));
$directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY); $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
file_unmanaged_delete_recursive($directory); file_unmanaged_delete_recursive($directory);
......
...@@ -63,7 +63,7 @@ public function testConfigTranslation() { ...@@ -63,7 +63,7 @@ public function testConfigTranslation() {
$this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'fr'], t('Add custom language')); $this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'fr'], t('Add custom language'));
$edit = [ $edit = [
'modules[Multilingual][config_translation][enable]' => TRUE, 'modules[config_translation][enable]' => TRUE,
]; ];
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
......
...@@ -24,8 +24,8 @@ public function testEnable() { ...@@ -24,8 +24,8 @@ public function testEnable() {
// Enable modules and make sure the related config entity type definitions // Enable modules and make sure the related config entity type definitions
// are installed. // are installed.
$edit = [ $edit = [
'modules[Multilingual][content_translation][enable]' => TRUE, 'modules[content_translation][enable]' => TRUE,
'modules[Multilingual][language][enable]' => TRUE, 'modules[language][enable]' => TRUE,
]; ];
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
......
...@@ -118,7 +118,7 @@ public function testForumUninstallWithField() { ...@@ -118,7 +118,7 @@ public function testForumUninstallWithField() {
$this->assertFalse((bool) NodeType::load('forum'), 'Node type with machine forum deleted.'); $this->assertFalse((bool) NodeType::load('forum'), 'Node type with machine forum deleted.');
// Double check everything by reinstalling the forum module again. // Double check everything by reinstalling the forum module again.
$this->drupalPostForm('admin/modules', ['modules[Core][forum][enable]' => 1], 'Install'); $this->drupalPostForm('admin/modules', ['modules[forum][enable]' => 1], 'Install');
$this->assertText('Module Forum has been enabled.'); $this->assertText('Module Forum has been enabled.');
} }
......
...@@ -28,7 +28,7 @@ function testModuleInstallLanguageList() { ...@@ -28,7 +28,7 @@ function testModuleInstallLanguageList() {
$admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules')); $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
$edit = array(); $edit = array();
$edit['modules[Multilingual][language][enable]'] = 'language'; $edit['modules[language][enable]'] = 'language';
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertEqual(\Drupal::state()->get('language_test.language_count_preinstall', 0), 1, 'Using LanguageManager::getLanguages() returns 1 language during Language installation.'); $this->assertEqual(\Drupal::state()->get('language_test.language_count_preinstall', 0), 1, 'Using LanguageManager::getLanguages() returns 1 language during Language installation.');
......
...@@ -184,7 +184,7 @@ public function testConfigLangTypeAlterations() { ...@@ -184,7 +184,7 @@ public function testConfigLangTypeAlterations() {
$this->assertTrue($this->isLanguageTypeConfigurable($test_type), 'Language type is now configurable.'); $this->assertTrue($this->isLanguageTypeConfigurable($test_type), 'Language type is now configurable.');
// After installing another module, the config should be the same. // After installing another module, the config should be the same.
$this->drupalPostForm('admin/modules', ['modules[Testing][test_module][enable]' => 1], t('Install')); $this->drupalPostForm('admin/modules', ['modules[test_module][enable]' => 1], t('Install'));
$this->assertTrue($this->isLanguageTypeConfigurable($test_type), 'Language type is still configurable.'); $this->assertTrue($this->isLanguageTypeConfigurable($test_type), 'Language type is still configurable.');
// After uninstalling the other module, the config should be the same. // After uninstalling the other module, the config should be the same.
......
...@@ -109,7 +109,7 @@ public function testConfigTranslationModuleInstall() { ...@@ -109,7 +109,7 @@ public function testConfigTranslationModuleInstall() {
->save(); ->save();
// Install any module. // Install any module.
$this->drupalPostForm('admin/modules', ['modules[Core][dblog][enable]' => 'dblog'], t('Install')); $this->drupalPostForm('admin/modules', ['modules[dblog][enable]' => 'dblog'], t('Install'));
$this->assertText('Module Database Logging has been enabled.'); $this->assertText('Module Database Logging has been enabled.');
// Get the front page and ensure that the translated configuration still // Get the front page and ensure that the translated configuration still
......
...@@ -119,7 +119,7 @@ public function testConfigTranslation() { ...@@ -119,7 +119,7 @@ public function testConfigTranslation() {
$this->assertFalse($string, 'Configuration strings have been created upon installation.'); $this->assertFalse($string, 'Configuration strings have been created upon installation.');
// Enable the image module. // Enable the image module.
$this->drupalPostForm('admin/modules', array('modules[Field types][image][enable]' => "1"), t('Install')); $this->drupalPostForm('admin/modules', array('modules[image][enable]' => "1"), t('Install'));
$this->rebuildContainer(); $this->rebuildContainer();
$string = $this->storage->findString(array('source' => 'Medium (220×220)', 'context' => '', 'type' => 'configuration')); $string = $this->storage->findString(array('source' => 'Medium (220×220)', 'context' => '', 'type' => 'configuration'));
...@@ -198,12 +198,12 @@ public function testConfigTranslation() { ...@@ -198,12 +198,12 @@ public function testConfigTranslation() {
public function testOptionalConfiguration() { public function testOptionalConfiguration() {
$this->assertNodeConfig(FALSE, FALSE); $this->assertNodeConfig(FALSE, FALSE);
// Enable the node module. // Enable the node module.
$this->drupalPostForm('admin/modules', ['modules[Core][node][enable]' => "1"], t('Install')); $this->drupalPostForm('admin/modules', ['modules[node][enable]' => "1"], t('Install'));
$this->drupalPostForm(NULL, [], t('Continue')); $this->drupalPostForm(NULL, [], t('Continue'));
$this->rebuildContainer(); $this->rebuildContainer();
$this->assertNodeConfig(TRUE, FALSE); $this->assertNodeConfig(TRUE, FALSE);
// Enable the views module (which node provides some optional config for). // Enable the views module (which node provides some optional config for).
$this->drupalPostForm('admin/modules', ['modules[Core][views][enable]' => "1"], t('Install')); $this->drupalPostForm('admin/modules', ['modules[views][enable]' => "1"], t('Install'));
$this->rebuildContainer(); $this->rebuildContainer();
$this->assertNodeConfig(TRUE, TRUE); $this->assertNodeConfig(TRUE, TRUE);
} }
......
...@@ -37,7 +37,7 @@ protected function setUp() { ...@@ -37,7 +37,7 @@ protected function setUp() {
*/ */
public function testCircularDependency() { public function testCircularDependency() {
// Ensure that we can enable early_translation_test on a non-english site. // Ensure that we can enable early_translation_test on a non-english site.
$this->drupalPostForm('admin/modules', array('modules[Testing][early_translation_test][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[early_translation_test][enable]' => TRUE), t('Install'));
$this->assertResponse(200); $this->assertResponse(200);
} }
......
...@@ -308,7 +308,7 @@ public function testEnableUninstallModule() { ...@@ -308,7 +308,7 @@ public function testEnableUninstallModule() {
// Enable a module. // Enable a module.
$edit = array( $edit = array(
'modules[Testing][locale_test_translate][enable]' => 'locale_test_translate', 'modules[locale_test_translate][enable]' => 'locale_test_translate',
); );
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
...@@ -343,7 +343,7 @@ public function testEnableLanguage() { ...@@ -343,7 +343,7 @@ public function testEnableLanguage() {
// Enable a module. // Enable a module.
$edit = array( $edit = array(
'modules[Testing][locale_test_translate][enable]' => 'locale_test_translate', 'modules[locale_test_translate][enable]' => 'locale_test_translate',
); );
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
...@@ -387,7 +387,7 @@ public function testEnableCustomLanguage() { ...@@ -387,7 +387,7 @@ public function testEnableCustomLanguage() {
// Enable a module. // Enable a module.
$edit = array( $edit = array(
'modules[Testing][locale_test_translate][enable]' => 'locale_test_translate', 'modules[locale_test_translate][enable]' => 'locale_test_translate',
); );
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
......
...@@ -150,6 +150,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ...@@ -150,6 +150,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
if (empty($module->info['hidden'])) { if (empty($module->info['hidden'])) {
$package = $module->info['package']; $package = $module->info['package'];
$form['modules'][$package][$filename] = $this->buildRow($modules, $module, $distribution); $form['modules'][$package][$filename] = $this->buildRow($modules, $module, $distribution);
$form['modules'][$package][$filename]['#parents'] = ['modules', $filename];
} }
} }
...@@ -357,8 +358,6 @@ protected function buildRow(array $modules, Extension $module, $distribution) { ...@@ -357,8 +358,6 @@ protected function buildRow(array $modules, Extension $module, $distribution) {
* An array of modules to install and their dependencies. * An array of modules to install and their dependencies.
*/ */
protected function buildModuleList(FormStateInterface $form_state) { protected function buildModuleList(FormStateInterface $form_state) {
$packages = $form_state->getValue('modules');
// Build a list of modules to install. // Build a list of modules to install.
$modules = array( $modules = array(
'install' => array(), 'install' => array(),
...@@ -366,24 +365,22 @@ protected function buildModuleList(FormStateInterface $form_state) { ...@@ -366,24 +365,22 @@ protected function buildModuleList(FormStateInterface $form_state) {
'experimental' => [], 'experimental' => [],
); );
// Required modules have to be installed.
// @todo This should really not be handled here.
$data = system_rebuild_module_data(); $data = system_rebuild_module_data();
foreach ($data as $name => $module) { foreach ($data as $name => $module) {
if (!empty($module->required) && !$this->moduleHandler->moduleExists($name)) { // If the module is installed there is nothing to do.
if ($this->moduleHandler->moduleExists($name)) {
continue;
}
// Required modules have to be installed.
if (!empty($module->required)) {
$modules['install'][$name] = $module->info['name']; $modules['install'][$name] = $module->info['name'];
} }
} // Selected modules should be installed.
elseif (($checkbox = $form_state->getValue(['modules', $name], FALSE)) && $checkbox['enable']) {
// First, build a list of all modules that were selected. $modules['install'][$name] = $data[$name]->info['name'];
foreach ($packages as $package => $items) { // Identify experimental modules.
foreach ($items as $name => $checkbox) { if ($data[$name]->info['package'] == 'Core (Experimental)') {
if ($checkbox['enable'] && !$this->moduleHandler->moduleExists($name)) { $modules['experimental'][$name] = $data[$name]->info['name'];
$modules['install'][$name] = $data[$name]->info['name'];
// Identify experimental modules.
if ($package == 'Core (Experimental)') {
$modules['experimental'][$name] = $data[$name]->info['name'];
}
} }
} }
} }
......
...@@ -117,8 +117,8 @@ public function testTranslationsLoaded() { ...@@ -117,8 +117,8 @@ public function testTranslationsLoaded() {
// Activate a module, to make sure that config is not overridden by module // Activate a module, to make sure that config is not overridden by module
// installation. // installation.
$edit = array( $edit = array(
'modules[Core][views][enable]' => TRUE, 'modules[views][enable]' => TRUE,
'modules[Core][filter][enable]' => TRUE, 'modules[filter][enable]' => TRUE,
); );
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
......
...@@ -84,7 +84,7 @@ public function testInstaller() { ...@@ -84,7 +84,7 @@ public function testInstaller() {
$this->assertEqual($account->language()->getId(), 'de', 'New user is German.'); $this->assertEqual($account->language()->getId(), 'de', 'New user is German.');
// Ensure that we can enable basic_auth on a non-english site. // Ensure that we can enable basic_auth on a non-english site.
$this->drupalPostForm('admin/modules', array('modules[Web services][basic_auth][enable]' => TRUE), t('Install')); $this->drupalPostForm('admin/modules', array('modules[basic_auth][enable]' => TRUE), t('Install'));
$this->assertResponse(200); $this->assertResponse(200);
// Assert that the theme CSS was added to the page. // Assert that the theme CSS was added to the page.
......
...@@ -76,8 +76,8 @@ function testClassLoadingDisabledModules() { ...@@ -76,8 +76,8 @@ function testClassLoadingDisabledModules() {
public function testMultipleModules() { public function testMultipleModules() {
$this->drupalLogin($this->rootUser); $this->drupalLogin($this->rootUser);
$edit = [ $edit = [
"modules[Testing][module_install_class_loader_test1][enable]" => TRUE, "modules[module_install_class_loader_test1][enable]" => TRUE,
"modules[Testing][module_install_class_loader_test2][enable]" => TRUE, "modules[module_install_class_loader_test2][enable]" => TRUE,
]; ];
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->rebuildContainer(); $this->rebuildContainer();
......
...@@ -14,12 +14,12 @@ class DependencyTest extends ModuleTestBase { ...@@ -14,12 +14,12 @@ class DependencyTest extends ModuleTestBase {
*/ */
function testProjectNamespaceForDependencies() { function testProjectNamespaceForDependencies() {
$edit = array( $edit = array(
'modules[Core][filter][enable]' => TRUE, 'modules[filter][enable]' => TRUE,
); );
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
// Enable module with project namespace to ensure nothing breaks. // Enable module with project namespace to ensure nothing breaks.
$edit = array( $edit = array(
'modules[Testing][system_project_namespace_test][enable]' => TRUE, 'modules[system_project_namespace_test][enable]' => TRUE,
); );
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertModules(array('system_project_namespace_test'), TRUE); $this->assertModules(array('system_project_namespace_test'), TRUE);
...@@ -31,7 +31,7 @@ function testProjectNamespaceForDependencies() { ...@@ -31,7 +31,7 @@ function testProjectNamespaceForDependencies() {
function testEnableWithoutDependency() { function testEnableWithoutDependency() {
// Attempt to enable Content Translation without Language enabled. // Attempt to enable Content Translation without Language enabled.
$edit = array(); $edit = array();
$edit['modules[Multilingual][content_translation][enable]'] = 'content_translation'; $edit['modules[content_translation][enable]'] = 'content_translation';
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertText(t('Some required modules must be enabled'), 'Dependency required.'); $this->assertText(t('Some required modules must be enabled'), 'Dependency required.');
...@@ -57,7 +57,7 @@ function testMissingModules() { ...@@ -57,7 +57,7 @@ function testMissingModules() {
// as missing a dependency. // as missing a dependency.
$this->drupalGet('admin/modules'); $this->drupalGet('admin/modules');
$this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', array('@module' => Unicode::ucfirst('_missing_dependency'))), 'A module with missing dependencies is marked as such.'); $this->assertRaw(t('@module (<span class="admin-missing">missing</span>)', array('@module' => Unicode::ucfirst('_missing_dependency'))), 'A module with missing dependencies is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[Testing][system_dependencies_test][enable]"]'); $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.'); $this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
} }
...@@ -72,7 +72,7 @@ function testIncompatibleModuleVersionDependency() { ...@@ -72,7 +72,7 @@ function testIncompatibleModuleVersionDependency() {
'@module' => 'System incompatible module version test (>2.0)', '@module' => 'System incompatible module version test (>2.0)',
'@version' => '1.0', '@version' => '1.0',
)), 'A module that depends on an incompatible version of a module is marked as such.'); )), 'A module that depends on an incompatible version of a module is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[Testing][system_incompatible_module_version_dependencies_test][enable]"]'); $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_module_version_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.'); $this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
} }
...@@ -86,7 +86,7 @@ function testIncompatibleCoreVersionDependency() { ...@@ -86,7 +86,7 @@ function testIncompatibleCoreVersionDependency() {
$this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array( $this->assertRaw(t('@module (<span class="admin-missing">incompatible with</span> this version of Drupal core)', array(
'@module' => 'System incompatible core version test', '@module' => 'System incompatible core version test',
)), 'A module that depends on a module with an incompatible core version is marked as such.'); )), 'A module that depends on a module with an incompatible core version is marked as such.');
$checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[Testing][system_incompatible_core_version_dependencies_test][enable]"]'); $checkbox = $this->xpath('//input[@type="checkbox" and @disabled="disabled" and @name="modules[system_incompatible_core_version_dependencies_test][enable]"]');
$this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.'); $this->assert(count($checkbox) == 1, 'Checkbox for the module is disabled.');
} }
...@@ -101,8 +101,8 @@ function testEnableRequirementsFailureDependency() { ...@@ -101,8 +101,8 @@ function testEnableRequirementsFailureDependency() {
// Attempt to install both modules at the same time. // Attempt to install both modules at the same time.
$edit = array(); $edit = array();
$edit['modules[Testing][requirements1_test][enable]'] = 'requirements1_test'; $edit['modules[requirements1_test][enable]'] = 'requirements1_test';
$edit['modules[Testing][requirements2_test][enable]'] = 'requirements2_test'; $edit['modules[requirements2_test][enable]'] = 'requirements2_test';
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
// Makes sure the modules were NOT installed. // Makes sure the modules were NOT installed.
...@@ -133,15 +133,15 @@ function testModuleEnableOrder() { ...@@ -133,15 +133,15 @@ function testModuleEnableOrder() {
// Enable the modules through the UI, verifying that the dependency chain // Enable the modules through the UI, verifying that the dependency chain
// is correct. // is correct.
$edit = array(); $edit = array();
$edit['modules[Core][color][enable]'] = 'color'; $edit['modules[color][enable]'] = 'color';
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertModules(array('color'), FALSE); $this->assertModules(array('color'), FALSE);
// Note that dependencies are sorted alphabetically in the confirmation // Note that dependencies are sorted alphabetically in the confirmation
// message. // message.
$this->assertText(t('You must enable the Configuration Manager, Help modules to install Color.')); $this->assertText(t('You must enable the Configuration Manager, Help modules to install Color.'));
$edit['modules[Core][config][enable]'] = 'config'; $edit['modules[config][enable]'] = 'config';
$edit['modules[Core][help][enable]'] = 'help'; $edit['modules[help][enable]'] = 'help';
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertModules(array('color', 'config', 'help'), TRUE); $this->assertModules(array('color', 'config', 'help'), TRUE);
...@@ -155,7 +155,7 @@ function testModuleEnableOrder() { ...@@ -155,7 +155,7 @@ function testModuleEnableOrder() {
*/ */
function testUninstallDependents() { function testUninstallDependents() {
// Enable the forum module. // Enable the forum module.
$edit = array('modules[Core][forum][enable]' => 'forum'); $edit = array('modules[forum][enable]' => 'forum');
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->drupalPostForm(NULL, array(), t('Continue')); $this->drupalPostForm(NULL, array(), t('Continue'));
$this->assertModules(array('forum'), TRUE); $this->assertModules(array('forum'), TRUE);
......
...@@ -36,7 +36,7 @@ public function testExperimentalConfirmForm() { ...@@ -36,7 +36,7 @@ public function testExperimentalConfirmForm() {
// First, test installing a non-experimental module with no dependencies. // First, test installing a non-experimental module with no dependencies.
// There should be no confirmation form and no experimental module warning. // There should be no confirmation form and no experimental module warning.
$edit = []; $edit = [];
$edit["modules[Testing][test_page_test][enable]"] = TRUE; $edit["modules[test_page_test][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertText('Module Test page has been enabled.'); $this->assertText('Module Test page has been enabled.');
$this->assertNoText('Experimental modules are provided for testing purposes only.'); $this->assertNoText('Experimental modules are provided for testing purposes only.');
...@@ -48,7 +48,7 @@ public function testExperimentalConfirmForm() { ...@@ -48,7 +48,7 @@ public function testExperimentalConfirmForm() {
// There should be a confirmation form with an experimental warning, but no // There should be a confirmation form with an experimental warning, but no
// list of dependencies. // list of dependencies.
$edit = []; $edit = [];
$edit["modules[Core (Experimental)][experimental_module_test][enable]"] = TRUE; $edit["modules[experimental_module_test][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, 'Install'); $this->drupalPostForm('admin/modules', $edit, 'Install');
// The module should not be enabled and there should be a warning and a // The module should not be enabled and there should be a warning and a
...@@ -70,7 +70,7 @@ public function testExperimentalConfirmForm() { ...@@ -70,7 +70,7 @@ public function testExperimentalConfirmForm() {
// Test enabling a module that is not itself experimental, but that depends // Test enabling a module that is not itself experimental, but that depends
// on an experimental module. // on an experimental module.
$edit = []; $edit = [];
$edit["modules[Testing][experimental_module_dependency_test][enable]"] = TRUE; $edit["modules[experimental_module_dependency_test][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, 'Install'); $this->drupalPostForm('admin/modules', $edit, 'Install');
// The module should not be enabled and there should be a warning and a // The module should not be enabled and there should be a warning and a
...@@ -98,8 +98,8 @@ public function testExperimentalConfirmForm() { ...@@ -98,8 +98,8 @@ public function testExperimentalConfirmForm() {
// still a warning about experimental modules, but no message about // still a warning about experimental modules, but no message about
// dependencies, since the user specifically enabled the dependency. // dependencies, since the user specifically enabled the dependency.
$edit = []; $edit = [];
$edit["modules[Core (Experimental)][experimental_module_test][enable]"] = TRUE; $edit["modules[experimental_module_test][enable]"] = TRUE;
$edit["modules[Testing][experimental_module_dependency_test][enable]"] = TRUE; $edit["modules[experimental_module_dependency_test][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, 'Install'); $this->drupalPostForm('admin/modules', $edit, 'Install');
// The module should not be enabled and there should be a warning and a // The module should not be enabled and there should be a warning and a
...@@ -110,7 +110,7 @@ public function testExperimentalConfirmForm() { ...@@ -110,7 +110,7 @@ public function testExperimentalConfirmForm() {
$this->assertText('The following modules are experimental: Experimental Test'); $this->assertText('The following modules are experimental: Experimental Test');
// Ensure the non-experimental module is not listed as experimental. // Ensure the non-experimental module is not listed as experimental.
$this->assertNoText('The following modules are experimental: Experimental Test, Experimental Dependency Test'); $this->assertNoText('The following modules are experimental: Experimental Dependency Test, Experimental Test');
$this->assertNoText('The following modules are experimental: Experimental Dependency Test'); $this->assertNoText('The following modules are experimental: Experimental Dependency Test');
// There should be no message about enabling dependencies. // There should be no message about enabling dependencies.
...@@ -118,13 +118,13 @@ public function testExperimentalConfirmForm() { ...@@ -118,13 +118,13 @@ public function testExperimentalConfirmForm() {
// Enable the module and confirm that it worked. // Enable the module and confirm that it worked.
$this->drupalPostForm(NULL, [], 'Continue'); $this->drupalPostForm(NULL, [], 'Continue');
$this->assertText('2 modules have been enabled: Experimental Test, Experimental Dependency Test'); $this->assertText('2 modules have been enabled: Experimental Dependency Test, Experimental Test');
// Try to enable an experimental module that can not be due to // Try to enable an experimental module that can not be due to
// hook_requirements(). // hook_requirements().
\Drupal::state()->set('experimental_module_requirements_test_requirements', TRUE); \Drupal::state()->set('experimental_module_requirements_test_requirements', TRUE);
$edit = []; $edit = [];
$edit["modules[Core (Experimental)][experimental_module_requirements_test][enable]"] = TRUE; $edit["modules[experimental_module_requirements_test][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, 'Install'); $this->drupalPostForm('admin/modules', $edit, 'Install');
$this->assertUrl('admin/modules', [], 'If the module can not be installed we are not taken to the confirm form.'); $this->assertUrl('admin/modules', [], 'If the module can not be installed we are not taken to the confirm form.');
$this->assertText('The Experimental Test Requirements module can not be installed.'); $this->assertText('The Experimental Test Requirements module can not be installed.');
......
...@@ -16,7 +16,7 @@ function testHookRequirementsFailure() { ...@@ -16,7 +16,7 @@ function testHookRequirementsFailure() {
// Attempt to install the requirements1_test module. // Attempt to install the requirements1_test module.
$edit = array(); $edit = array();
$edit['modules[Testing][requirements1_test][enable]'] = 'requirements1_test'; $edit['modules[requirements1_test][enable]'] = 'requirements1_test';
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
// Makes sure the module was NOT installed. // Makes sure the module was NOT installed.
......
...@@ -59,8 +59,7 @@ public function testInstallUninstall() { ...@@ -59,8 +59,7 @@ public function testInstallUninstall() {
unset($all_modules['help']); unset($all_modules['help']);
$this->assertModuleNotInstalled('help'); $this->assertModuleNotInstalled('help');
$edit = array(); $edit = array();
$package = $required_modules['help']->info['package']; $edit["modules[help][enable]"] = TRUE;
$edit["modules[$package][help][enable]"] = TRUE;
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
$this->assertText('has been enabled', 'Modules status has been updated.'); $this->assertText('has been enabled', 'Modules status has been updated.');
$this->assertText(t('hook_modules_installed fired for help')); $this->assertText(t('hook_modules_installed fired for help'));
...@@ -93,7 +92,7 @@ public function testInstallUninstall() { ...@@ -93,7 +92,7 @@ public function testInstallUninstall() {
// Install the module. // Install the module.
$edit = array(); $edit = array();
$package = $module->info['package']; $package = $module->info['package'];
$edit["modules[$package][$name][enable]"] = TRUE; $edit['modules[' . $name . '][enable]'] = TRUE;
$this->drupalPostForm('admin/modules', $edit, t('Install')); $this->drupalPostForm('admin/modules', $edit, t('Install'));
// Handle experimental modules, which require a confirmation screen. // Handle experimental modules, which require a confirmation screen.
...@@ -191,7 +190,7 @@ public function testInstallUninstall() { ...@@ -191,7 +190,7 @@ public function testInstallUninstall() {
$edit = array(); $edit = array();
$experimental