From 91736cadcb660d1943e5632c6e3e0743d00a21ba Mon Sep 17 00:00:00 2001 From: Chris McCafferty Date: Fri, 10 Feb 2017 16:55:04 -0500 Subject: [PATCH] Issue #2665152 by alexpott, Andrej Galuf, tfranz, longwave, andypost, jsimonis, bojanz: Simplify module form structure and fix bugs when Suhosin is used --- .../comment/src/Tests/CommentFieldsTest.php | 4 +-- .../config/src/Tests/ConfigInstallWebTest.php | 20 ++++++------- .../Tests/ConfigTranslationInstallTest.php | 2 +- .../Tests/ContentTranslationEnableTest.php | 4 +-- .../forum/src/Tests/ForumUninstallTest.php | 2 +- .../Tests/LanguageListModuleInstallTest.php | 2 +- .../src/Tests/LanguageNegotiationInfoTest.php | 2 +- .../LocaleConfigTranslationImportTest.php | 2 +- .../src/Tests/LocaleConfigTranslationTest.php | 6 ++-- .../src/Tests/LocaleLocaleLookupTest.php | 2 +- .../locale/src/Tests/LocaleUpdateTest.php | 6 ++-- .../system/src/Form/ModulesListForm.php | 29 +++++++++---------- ...stallerTranslationMultipleLanguageTest.php | 4 +-- .../Installer/InstallerTranslationTest.php | 2 +- .../src/Tests/Module/ClassLoaderTest.php | 4 +-- .../src/Tests/Module/DependencyTest.php | 24 +++++++-------- .../Tests/Module/ExperimentalModuleTest.php | 16 +++++----- .../src/Tests/Module/HookRequirementsTest.php | 2 +- .../src/Tests/Module/InstallUninstallTest.php | 7 ++--- .../system/src/Tests/Module/RequiredTest.php | 2 +- .../system/src/Tests/Module/VersionTest.php | 2 +- .../Tests/System/MainContentFallbackTest.php | 2 +- .../src/Tests/ToolbarAdminMenuTest.php | 2 +- .../update/src/Tests/UpdateUploadTest.php | 2 +- 24 files changed, 73 insertions(+), 77 deletions(-) diff --git a/core/modules/comment/src/Tests/CommentFieldsTest.php b/core/modules/comment/src/Tests/CommentFieldsTest.php index 46de1bea41c1..4da6e756eee3 100644 --- a/core/modules/comment/src/Tests/CommentFieldsTest.php +++ b/core/modules/comment/src/Tests/CommentFieldsTest.php @@ -208,12 +208,12 @@ class CommentFieldsTest extends CommentTestBase { // Install core content type module (book). $edit = array(); - $edit['modules[Core][book][enable]'] = 'book'; + $edit['modules[book][enable]'] = 'book'; $this->drupalPostForm('admin/modules', $edit, t('Install')); // Now install the comment module. $edit = array(); - $edit['modules[Core][comment][enable]'] = 'comment'; + $edit['modules[comment][enable]'] = 'comment'; $this->drupalPostForm('admin/modules', $edit, t('Install')); $this->rebuildContainer(); $this->assertTrue($this->container->get('module_handler')->moduleExists('comment'), 'Comment module enabled.'); diff --git a/core/modules/config/src/Tests/ConfigInstallWebTest.php b/core/modules/config/src/Tests/ConfigInstallWebTest.php index 4898f70c8c94..8f9e1a1b8f9f 100644 --- a/core/modules/config/src/Tests/ConfigInstallWebTest.php +++ b/core/modules/config/src/Tests/ConfigInstallWebTest.php @@ -122,7 +122,7 @@ class ConfigInstallWebTest extends WebTestBase { // will install the config_test module first because it is a dependency of // config_install_fail_test. // @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, config_test.dynamic.dotted.default already exists in active configuration.'); // Uninstall the config_test module to test the confirm form. @@ -133,7 +133,7 @@ class ConfigInstallWebTest extends WebTestBase { // The user is shown a confirm form because the config_test module is a // dependency. // @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->assertRaw('Unable to install Configuration install fail test, config_test.dynamic.dotted.default already exists in active configuration.'); @@ -147,7 +147,7 @@ class ConfigInstallWebTest extends WebTestBase { ->set('label', 'Je suis Charlie') ->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, config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default already exist in active configuration.'); // Test installing a theme through the UI that has existing configuration. @@ -178,16 +178,16 @@ class ConfigInstallWebTest extends WebTestBase { $this->drupalLogin($this->adminUser); // We need to install separately since config_install_dependency_test does // 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[Testing][config_install_dependency_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', array('modules[config_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install')); $this->assertRaw('Unable to install Config install dependency test due to unmet dependencies: config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)'); - $this->drupalPostForm('admin/modules', array('modules[Testing][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_test_language][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install')); $this->assertRaw('Unable to install Config install dependency test due to unmet dependencies: config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)'); - $this->drupalPostForm('admin/modules', array('modules[Testing][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_other_module_config_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install')); $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.'); } @@ -197,7 +197,7 @@ class ConfigInstallWebTest extends WebTestBase { */ public function testConfigModuleRequirements() { $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); file_unmanaged_delete_recursive($directory); diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationInstallTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationInstallTest.php index 7daa305f95b1..2c8aabcab4f9 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationInstallTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationInstallTest.php @@ -63,7 +63,7 @@ ENDPO; $this->drupalPostForm('admin/config/regional/language/add', ['predefined_langcode' => 'fr'], t('Add custom language')); $edit = [ - 'modules[Multilingual][config_translation][enable]' => TRUE, + 'modules[config_translation][enable]' => TRUE, ]; $this->drupalPostForm('admin/modules', $edit, t('Install')); diff --git a/core/modules/content_translation/src/Tests/ContentTranslationEnableTest.php b/core/modules/content_translation/src/Tests/ContentTranslationEnableTest.php index 26987b4d414f..ded8c1bee4ef 100644 --- a/core/modules/content_translation/src/Tests/ContentTranslationEnableTest.php +++ b/core/modules/content_translation/src/Tests/ContentTranslationEnableTest.php @@ -24,8 +24,8 @@ class ContentTranslationEnableTest extends WebTestBase { // Enable modules and make sure the related config entity type definitions // are installed. $edit = [ - 'modules[Multilingual][content_translation][enable]' => TRUE, - 'modules[Multilingual][language][enable]' => TRUE, + 'modules[content_translation][enable]' => TRUE, + 'modules[language][enable]' => TRUE, ]; $this->drupalPostForm('admin/modules', $edit, t('Install')); diff --git a/core/modules/forum/src/Tests/ForumUninstallTest.php b/core/modules/forum/src/Tests/ForumUninstallTest.php index 1978e6b311b0..ab54299ad68d 100644 --- a/core/modules/forum/src/Tests/ForumUninstallTest.php +++ b/core/modules/forum/src/Tests/ForumUninstallTest.php @@ -118,7 +118,7 @@ class ForumUninstallTest extends WebTestBase { $this->assertFalse((bool) NodeType::load('forum'), 'Node type with machine forum deleted.'); // 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.'); } diff --git a/core/modules/language/src/Tests/LanguageListModuleInstallTest.php b/core/modules/language/src/Tests/LanguageListModuleInstallTest.php index 3df9bdc0b110..43fbd224ab0e 100644 --- a/core/modules/language/src/Tests/LanguageListModuleInstallTest.php +++ b/core/modules/language/src/Tests/LanguageListModuleInstallTest.php @@ -28,7 +28,7 @@ class LanguageListModuleInstallTest extends WebTestBase { $admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules')); $this->drupalLogin($admin_user); $edit = array(); - $edit['modules[Multilingual][language][enable]'] = 'language'; + $edit['modules[language][enable]'] = 'language'; $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.'); diff --git a/core/modules/language/src/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/src/Tests/LanguageNegotiationInfoTest.php index ee4c6d4ce748..0f221d7136a7 100644 --- a/core/modules/language/src/Tests/LanguageNegotiationInfoTest.php +++ b/core/modules/language/src/Tests/LanguageNegotiationInfoTest.php @@ -184,7 +184,7 @@ class LanguageNegotiationInfoTest extends WebTestBase { $this->assertTrue($this->isLanguageTypeConfigurable($test_type), 'Language type is now configurable.'); // 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.'); // After uninstalling the other module, the config should be the same. diff --git a/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php b/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php index 67faa81929b0..9ad620fcf44c 100644 --- a/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php +++ b/core/modules/locale/src/Tests/LocaleConfigTranslationImportTest.php @@ -109,7 +109,7 @@ class LocaleConfigTranslationImportTest extends WebTestBase { ->save(); // 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.'); // Get the front page and ensure that the translated configuration still diff --git a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php index 3ee988a8defc..271f6e2f373a 100644 --- a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php @@ -119,7 +119,7 @@ class LocaleConfigTranslationTest extends WebTestBase { $this->assertFalse($string, 'Configuration strings have been created upon installation.'); // 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(); $string = $this->storage->findString(array('source' => 'Medium (220×220)', 'context' => '', 'type' => 'configuration')); @@ -198,12 +198,12 @@ class LocaleConfigTranslationTest extends WebTestBase { public function testOptionalConfiguration() { $this->assertNodeConfig(FALSE, FALSE); // 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->rebuildContainer(); $this->assertNodeConfig(TRUE, FALSE); // 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->assertNodeConfig(TRUE, TRUE); } diff --git a/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php b/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php index ea4f93705f8b..0e539ab382bf 100644 --- a/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php +++ b/core/modules/locale/src/Tests/LocaleLocaleLookupTest.php @@ -37,7 +37,7 @@ class LocaleLocaleLookupTest extends WebTestBase { */ public function testCircularDependency() { // 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); } diff --git a/core/modules/locale/src/Tests/LocaleUpdateTest.php b/core/modules/locale/src/Tests/LocaleUpdateTest.php index 05cda3619d8e..999f01bb0e12 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateTest.php +++ b/core/modules/locale/src/Tests/LocaleUpdateTest.php @@ -308,7 +308,7 @@ class LocaleUpdateTest extends LocaleUpdateBase { // Enable a module. $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')); @@ -343,7 +343,7 @@ class LocaleUpdateTest extends LocaleUpdateBase { // Enable a module. $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')); @@ -387,7 +387,7 @@ class LocaleUpdateTest extends LocaleUpdateBase { // Enable a module. $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')); diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index e74d898ca45e..d98b8a1251f8 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -150,6 +150,7 @@ class ModulesListForm extends FormBase { if (empty($module->info['hidden'])) { $package = $module->info['package']; $form['modules'][$package][$filename] = $this->buildRow($modules, $module, $distribution); + $form['modules'][$package][$filename]['#parents'] = ['modules', $filename]; } } @@ -357,8 +358,6 @@ class ModulesListForm extends FormBase { * An array of modules to install and their dependencies. */ protected function buildModuleList(FormStateInterface $form_state) { - $packages = $form_state->getValue('modules'); - // Build a list of modules to install. $modules = array( 'install' => array(), @@ -366,24 +365,22 @@ class ModulesListForm extends FormBase { 'experimental' => [], ); - // Required modules have to be installed. - // @todo This should really not be handled here. $data = system_rebuild_module_data(); 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']; } - } - - // First, build a list of all modules that were selected. - foreach ($packages as $package => $items) { - foreach ($items as $name => $checkbox) { - if ($checkbox['enable'] && !$this->moduleHandler->moduleExists($name)) { - $modules['install'][$name] = $data[$name]->info['name']; - // Identify experimental modules. - if ($package == 'Core (Experimental)') { - $modules['experimental'][$name] = $data[$name]->info['name']; - } + // Selected modules should be installed. + elseif (($checkbox = $form_state->getValue(['modules', $name], FALSE)) && $checkbox['enable']) { + $modules['install'][$name] = $data[$name]->info['name']; + // Identify experimental modules. + if ($data[$name]->info['package'] == 'Core (Experimental)') { + $modules['experimental'][$name] = $data[$name]->info['name']; } } } diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php index 84dfad3e91b0..a89a3cb7a2b8 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTranslationMultipleLanguageTest.php @@ -117,8 +117,8 @@ ENDPO; // Activate a module, to make sure that config is not overridden by module // installation. $edit = array( - 'modules[Core][views][enable]' => TRUE, - 'modules[Core][filter][enable]' => TRUE, + 'modules[views][enable]' => TRUE, + 'modules[filter][enable]' => TRUE, ); $this->drupalPostForm('admin/modules', $edit, t('Install')); diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php index fd6e0019b0a5..ade71834b5a4 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTranslationTest.php @@ -84,7 +84,7 @@ class InstallerTranslationTest extends InstallerTestBase { $this->assertEqual($account->language()->getId(), 'de', 'New user is German.'); // 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); // Assert that the theme CSS was added to the page. diff --git a/core/modules/system/src/Tests/Module/ClassLoaderTest.php b/core/modules/system/src/Tests/Module/ClassLoaderTest.php index bc2dfd5fc72d..002d22fa8c94 100644 --- a/core/modules/system/src/Tests/Module/ClassLoaderTest.php +++ b/core/modules/system/src/Tests/Module/ClassLoaderTest.php @@ -76,8 +76,8 @@ class ClassLoaderTest extends WebTestBase { public function testMultipleModules() { $this->drupalLogin($this->rootUser); $edit = [ - "modules[Testing][module_install_class_loader_test1][enable]" => TRUE, - "modules[Testing][module_install_class_loader_test2][enable]" => TRUE, + "modules[module_install_class_loader_test1][enable]" => TRUE, + "modules[module_install_class_loader_test2][enable]" => TRUE, ]; $this->drupalPostForm('admin/modules', $edit, t('Install')); $this->rebuildContainer(); diff --git a/core/modules/system/src/Tests/Module/DependencyTest.php b/core/modules/system/src/Tests/Module/DependencyTest.php index 8b219b27bc2e..6160ef464899 100644 --- a/core/modules/system/src/Tests/Module/DependencyTest.php +++ b/core/modules/system/src/Tests/Module/DependencyTest.php @@ -14,12 +14,12 @@ class DependencyTest extends ModuleTestBase { */ function testProjectNamespaceForDependencies() { $edit = array( - 'modules[Core][filter][enable]' => TRUE, + 'modules[filter][enable]' => TRUE, ); $this->drupalPostForm('admin/modules', $edit, t('Install')); // Enable module with project namespace to ensure nothing breaks. $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->assertModules(array('system_project_namespace_test'), TRUE); @@ -31,7 +31,7 @@ class DependencyTest extends ModuleTestBase { function testEnableWithoutDependency() { // Attempt to enable Content Translation without Language enabled. $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->assertText(t('Some required modules must be enabled'), 'Dependency required.'); @@ -57,7 +57,7 @@ class DependencyTest extends ModuleTestBase { // as missing a dependency. $this->drupalGet('admin/modules'); $this->assertRaw(t('@module (missing)', 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.'); } @@ -72,7 +72,7 @@ class DependencyTest extends ModuleTestBase { '@module' => 'System incompatible module version test (>2.0)', '@version' => '1.0', )), '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.'); } @@ -86,7 +86,7 @@ class DependencyTest extends ModuleTestBase { $this->assertRaw(t('@module (incompatible with this version of Drupal core)', array( '@module' => 'System incompatible core version test', )), '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.'); } @@ -101,8 +101,8 @@ class DependencyTest extends ModuleTestBase { // Attempt to install both modules at the same time. $edit = array(); - $edit['modules[Testing][requirements1_test][enable]'] = 'requirements1_test'; - $edit['modules[Testing][requirements2_test][enable]'] = 'requirements2_test'; + $edit['modules[requirements1_test][enable]'] = 'requirements1_test'; + $edit['modules[requirements2_test][enable]'] = 'requirements2_test'; $this->drupalPostForm('admin/modules', $edit, t('Install')); // Makes sure the modules were NOT installed. @@ -133,15 +133,15 @@ class DependencyTest extends ModuleTestBase { // Enable the modules through the UI, verifying that the dependency chain // is correct. $edit = array(); - $edit['modules[Core][color][enable]'] = 'color'; + $edit['modules[color][enable]'] = 'color'; $this->drupalPostForm('admin/modules', $edit, t('Install')); $this->assertModules(array('color'), FALSE); // Note that dependencies are sorted alphabetically in the confirmation // message. $this->assertText(t('You must enable the Configuration Manager, Help modules to install Color.')); - $edit['modules[Core][config][enable]'] = 'config'; - $edit['modules[Core][help][enable]'] = 'help'; + $edit['modules[config][enable]'] = 'config'; + $edit['modules[help][enable]'] = 'help'; $this->drupalPostForm('admin/modules', $edit, t('Install')); $this->assertModules(array('color', 'config', 'help'), TRUE); @@ -155,7 +155,7 @@ class DependencyTest extends ModuleTestBase { */ function testUninstallDependents() { // 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(NULL, array(), t('Continue')); $this->assertModules(array('forum'), TRUE); diff --git a/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php b/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php index 7b1a376bd030..70a4cd40bf98 100644 --- a/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php +++ b/core/modules/system/src/Tests/Module/ExperimentalModuleTest.php @@ -36,7 +36,7 @@ class ExperimentalModuleTest extends WebTestBase { // First, test installing a non-experimental module with no dependencies. // There should be no confirmation form and no experimental module warning. $edit = []; - $edit["modules[Testing][test_page_test][enable]"] = TRUE; + $edit["modules[test_page_test][enable]"] = TRUE; $this->drupalPostForm('admin/modules', $edit, t('Install')); $this->assertText('Module Test page has been enabled.'); $this->assertNoText('Experimental modules are provided for testing purposes only.'); @@ -48,7 +48,7 @@ class ExperimentalModuleTest extends WebTestBase { // There should be a confirmation form with an experimental warning, but no // list of dependencies. $edit = []; - $edit["modules[Core (Experimental)][experimental_module_test][enable]"] = TRUE; + $edit["modules[experimental_module_test][enable]"] = TRUE; $this->drupalPostForm('admin/modules', $edit, 'Install'); // The module should not be enabled and there should be a warning and a @@ -70,7 +70,7 @@ class ExperimentalModuleTest extends WebTestBase { // Test enabling a module that is not itself experimental, but that depends // on an experimental module. $edit = []; - $edit["modules[Testing][experimental_module_dependency_test][enable]"] = TRUE; + $edit["modules[experimental_module_dependency_test][enable]"] = TRUE; $this->drupalPostForm('admin/modules', $edit, 'Install'); // The module should not be enabled and there should be a warning and a @@ -98,8 +98,8 @@ class ExperimentalModuleTest extends WebTestBase { // still a warning about experimental modules, but no message about // dependencies, since the user specifically enabled the dependency. $edit = []; - $edit["modules[Core (Experimental)][experimental_module_test][enable]"] = TRUE; - $edit["modules[Testing][experimental_module_dependency_test][enable]"] = TRUE; + $edit["modules[experimental_module_test][enable]"] = TRUE; + $edit["modules[experimental_module_dependency_test][enable]"] = TRUE; $this->drupalPostForm('admin/modules', $edit, 'Install'); // The module should not be enabled and there should be a warning and a @@ -110,7 +110,7 @@ class ExperimentalModuleTest extends WebTestBase { $this->assertText('The following modules are experimental: Experimental Test'); // 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'); // There should be no message about enabling dependencies. @@ -118,13 +118,13 @@ class ExperimentalModuleTest extends WebTestBase { // Enable the module and confirm that it worked. $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 // hook_requirements(). \Drupal::state()->set('experimental_module_requirements_test_requirements', TRUE); $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->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.'); diff --git a/core/modules/system/src/Tests/Module/HookRequirementsTest.php b/core/modules/system/src/Tests/Module/HookRequirementsTest.php index ccbbff980e6d..2f4fccad82c0 100644 --- a/core/modules/system/src/Tests/Module/HookRequirementsTest.php +++ b/core/modules/system/src/Tests/Module/HookRequirementsTest.php @@ -16,7 +16,7 @@ class HookRequirementsTest extends ModuleTestBase { // Attempt to install the requirements1_test module. $edit = array(); - $edit['modules[Testing][requirements1_test][enable]'] = 'requirements1_test'; + $edit['modules[requirements1_test][enable]'] = 'requirements1_test'; $this->drupalPostForm('admin/modules', $edit, t('Install')); // Makes sure the module was NOT installed. diff --git a/core/modules/system/src/Tests/Module/InstallUninstallTest.php b/core/modules/system/src/Tests/Module/InstallUninstallTest.php index d8d625babd96..3882013ab6a3 100644 --- a/core/modules/system/src/Tests/Module/InstallUninstallTest.php +++ b/core/modules/system/src/Tests/Module/InstallUninstallTest.php @@ -59,8 +59,7 @@ class InstallUninstallTest extends ModuleTestBase { unset($all_modules['help']); $this->assertModuleNotInstalled('help'); $edit = array(); - $package = $required_modules['help']->info['package']; - $edit["modules[$package][help][enable]"] = TRUE; + $edit["modules[help][enable]"] = TRUE; $this->drupalPostForm('admin/modules', $edit, t('Install')); $this->assertText('has been enabled', 'Modules status has been updated.'); $this->assertText(t('hook_modules_installed fired for help')); @@ -93,7 +92,7 @@ class InstallUninstallTest extends ModuleTestBase { // Install the module. $edit = array(); $package = $module->info['package']; - $edit["modules[$package][$name][enable]"] = TRUE; + $edit['modules[' . $name . '][enable]'] = TRUE; $this->drupalPostForm('admin/modules', $edit, t('Install')); // Handle experimental modules, which require a confirmation screen. @@ -191,7 +190,7 @@ class InstallUninstallTest extends ModuleTestBase { $edit = array(); $experimental = FALSE; foreach ($all_modules as $name => $module) { - $edit['modules[' . $module->info['package'] . '][' . $name . '][enable]'] = TRUE; + $edit['modules[' . $name . '][enable]'] = TRUE; // Track whether there is at least one experimental module. if ($module->info['package'] == 'Core (Experimental)') { $experimental = TRUE; diff --git a/core/modules/system/src/Tests/Module/RequiredTest.php b/core/modules/system/src/Tests/Module/RequiredTest.php index 004854ba2841..a1e648b4a257 100644 --- a/core/modules/system/src/Tests/Module/RequiredTest.php +++ b/core/modules/system/src/Tests/Module/RequiredTest.php @@ -18,7 +18,7 @@ class RequiredTest extends ModuleTestBase { // Check to make sure the checkbox for each required module is disabled // and checked (or absent from the page if the module is also hidden). if (!empty($info['required'])) { - $field_name = "modules[{$info['package']}][$module][enable]"; + $field_name = 'modules[' . $module . '][enable]'; if (empty($info['hidden'])) { $this->assertFieldByXPath("//input[@name='$field_name' and @disabled='disabled' and @checked='checked']", '', format_string('Field @name was disabled and checked.', array('@name' => $field_name))); } diff --git a/core/modules/system/src/Tests/Module/VersionTest.php b/core/modules/system/src/Tests/Module/VersionTest.php index 031d4bad663a..fee684cc62e6 100644 --- a/core/modules/system/src/Tests/Module/VersionTest.php +++ b/core/modules/system/src/Tests/Module/VersionTest.php @@ -48,7 +48,7 @@ class VersionTest extends ModuleTestBase { $n = count($dependencies); for ($i = 0; $i < $n; $i++) { $this->drupalGet('admin/modules'); - $checkbox = $this->xpath('//input[@id="edit-modules-testing-module-test-enable"]'); + $checkbox = $this->xpath('//input[@id="edit-modules-module-test-enable"]'); $this->assertEqual(!empty($checkbox[0]['disabled']), $i % 2, $dependencies[$i]); } } diff --git a/core/modules/system/src/Tests/System/MainContentFallbackTest.php b/core/modules/system/src/Tests/System/MainContentFallbackTest.php index 551e4c744f18..ab488a829c73 100644 --- a/core/modules/system/src/Tests/System/MainContentFallbackTest.php +++ b/core/modules/system/src/Tests/System/MainContentFallbackTest.php @@ -64,7 +64,7 @@ class MainContentFallbackTest extends WebTestBase { // Enable the block module again. $this->drupalLogin($this->adminUser); $edit = array(); - $edit['modules[Core][block][enable]'] = 'block'; + $edit['modules[block][enable]'] = 'block'; $this->drupalPostForm('admin/modules', $edit, t('Install')); $this->assertText(t('Module Block has been enabled.'), 'Modules status has been updated.'); $this->rebuildContainer(); diff --git a/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php b/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php index 56b9d69a1983..dde6b518db74 100644 --- a/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php +++ b/core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php @@ -112,7 +112,7 @@ class ToolbarAdminMenuTest extends WebTestBase { // Enable a module. $edit = array(); - $edit['modules[Core][taxonomy][enable]'] = TRUE; + $edit['modules[taxonomy][enable]'] = TRUE; $this->drupalPostForm('admin/modules', $edit, t('Install')); $this->rebuildContainer(); diff --git a/core/modules/update/src/Tests/UpdateUploadTest.php b/core/modules/update/src/Tests/UpdateUploadTest.php index 39b6944b98e6..9b5296267bb1 100644 --- a/core/modules/update/src/Tests/UpdateUploadTest.php +++ b/core/modules/update/src/Tests/UpdateUploadTest.php @@ -98,7 +98,7 @@ class UpdateUploadTest extends UpdateTestBase { $this->assertEqual($info['version'], '8.x-1.0'); // Enable the module. - $this->drupalPostForm('admin/modules', array('modules[Testing][update_test_new_module][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', array('modules[update_test_new_module][enable]' => TRUE), t('Install')); // Define the update XML such that the new module downloaded above needs an // update from 8.x-1.0 to 8.x-1.1.