diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php index 0414f3b63d..5291c27e16 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeUiTest.php @@ -59,17 +59,16 @@ public function testModulePermissions() { * * @dataProvider providerTestThemeInstallWithModuleDependencies */ - public function testThemeInstallWithModuleDependencies($data) { - $theme_name = $data['theme_name']; + public function testThemeInstallWithModuleDependencies($theme_name, array $first_expected_required_list_items, array $first_module_enable, array $first_confirm_checked, array $second_expected_required_list_items, array $second_module_enable, array $second_confirm_checked, array $module_names, array $required_by_messages, $module_uninstall_message, $base_theme_to_uninstall, array $base_theme_module_names, $base_theme_module_uninstall_message) { $assert_session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->drupalGet('admin/appearance'); - $this->assertUninstallableTheme($data['first_expected_required_list_items'], $theme_name); + $this->assertUninstallableTheme($first_expected_required_list_items, $theme_name); // Enable one of the two required modules. - $this->drupalPostForm('admin/modules', $data['first_module_enable'], 'Install'); - foreach ($data['first_confirm_checked'] as $selector) { + $this->drupalPostForm('admin/modules', $first_module_enable, 'Install'); + foreach ($first_confirm_checked as $selector) { $this->assertSession()->elementExists('css', $selector); } @@ -77,9 +76,9 @@ public function testThemeInstallWithModuleDependencies($data) { // Confirm the theme is still uninstallable due to a remaining module // dependency. - $this->assertUninstallableTheme($data['second_expected_required_list_items'], $theme_name); - $this->drupalPostForm('admin/modules', $data['second_module_enable'], 'Install'); - foreach ($data['second_confirm_checked'] as $selector) { + $this->assertUninstallableTheme($second_expected_required_list_items, $theme_name); + $this->drupalPostForm('admin/modules', $second_module_enable, 'Install'); + foreach ($second_confirm_checked as $selector) { $this->assertSession()->elementExists('css', $selector); } @@ -92,10 +91,10 @@ public function testThemeInstallWithModuleDependencies($data) { // Confirm that the dependee modules can't be uninstalled because an enabled // theme depends on them. $this->drupalGet('admin/modules/uninstall'); - foreach ($data['module_names'] as $attribute) { + foreach ($module_names as $attribute) { $assert_session->elementExists('css', "[name=\"uninstall[$attribute]\"][disabled]"); } - foreach ($data['required_by_messages'] as $selector => $message) { + foreach ($required_by_messages as $selector => $message) { $assert_session->elementTextContains('css', $selector, $message); } @@ -105,14 +104,14 @@ public function testThemeInstallWithModuleDependencies($data) { $this->drupalGet('admin/modules/uninstall'); // Only attempt to uninstall modules not required by the base theme. - $modules_to_uninstall = array_diff($data['module_names'], $data['base_theme_module_names']); - $this->uninstallModules($modules_to_uninstall, $data['module_uninstall_message']); + $modules_to_uninstall = array_diff($module_names, $base_theme_module_names); + $this->uninstallModules($modules_to_uninstall, $module_uninstall_message); - if (!empty($data['base_theme_to_uninstall'])) { - $base_theme_name = $data['base_theme_to_uninstall']; + if (!empty($base_theme_to_uninstall)) { + $base_theme_name = $base_theme_to_uninstall; $this->uninstallTheme($base_theme_name); $this->drupalGet('admin/modules/uninstall'); - $this->uninstallModules($data['base_theme_module_names'], $data['base_theme_module_uninstall_message']); + $this->uninstallModules($base_theme_module_names, $base_theme_module_uninstall_message); } } @@ -161,130 +160,125 @@ protected function uninstallTheme($theme_name) { public function providerTestThemeInstallWithModuleDependencies() { return [ 'test theme with a module dependency and base theme with a different module dependency' => [ - [ - 'theme_name' => 'Test Theme with a Module Dependency and Base Theme with a Different Module Dependency', - 'first_expected_required_list_items' => [ - 'Help (disabled)', - 'Test Module Required by Theme (disabled)', - 'Test Another Module Required by Theme (disabled)', - ], - 'first_module_enable' => [ - 'modules[test_module_required_by_theme][enable]' => 1, - 'modules[test_another_module_required_by_theme][enable]' => 1, - ], - 'first_confirm_checked' => [ - '#edit-modules-test-module-required-by-theme-enable[checked]', - '#edit-modules-test-another-module-required-by-theme-enable[checked]', - ], - 'second_expected_required_list_items' => [ - 'Help (disabled)', - 'Test Module Required by Theme', - 'Test Another Module Required by Theme', - ], - 'second_module_enable' => [ - 'modules[help][enable]' => 1, - ], - 'second_confirm_checked' => [ - '#edit-modules-test-module-required-by-theme-enable[checked]', - '#edit-modules-test-another-module-required-by-theme-enable[checked]', - '#edit-modules-help-enable[checked]', - ], - 'module_names' => [ - 'help', - 'test_module_required_by_theme', - 'test_another_module_required_by_theme', - ], - 'required_by_messages' => [ - '[data-drupal-selector="edit-test-another-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', - '[data-drupal-selector="edit-test-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', - '[data-drupal-selector="edit-help"] .item-list' => 'Required by the theme: Test Theme with a Module Dependency and Base Theme with a Different Module Dependency', - ], - 'module_uninstall_message' => 'help', - 'base_theme_to_uninstall' => 'Test Theme Depending on Modules', - 'base_theme_module_names' => [ - 'test_module_required_by_theme', - 'test_another_module_required_by_theme', - ], - 'base_theme_module_uninstall_message' => 'Test Another Module Required by ThemeTest Module Required by Theme', + 'theme_name' => 'Test Theme with a Module Dependency and Base Theme with a Different Module Dependency', + 'first_expected_required_list_items' => [ + 'Help (disabled)', + 'Test Module Required by Theme (disabled)', + 'Test Another Module Required by Theme (disabled)', + ], + 'first_module_enable' => [ + 'modules[test_module_required_by_theme][enable]' => 1, + 'modules[test_another_module_required_by_theme][enable]' => 1, + ], + 'first_confirm_checked' => [ + '#edit-modules-test-module-required-by-theme-enable[checked]', + '#edit-modules-test-another-module-required-by-theme-enable[checked]', + ], + 'second_expected_required_list_items' => [ + 'Help (disabled)', + 'Test Module Required by Theme', + 'Test Another Module Required by Theme', + ], + 'second_module_enable' => [ + 'modules[help][enable]' => 1, + ], + 'second_confirm_checked' => [ + '#edit-modules-test-module-required-by-theme-enable[checked]', + '#edit-modules-test-another-module-required-by-theme-enable[checked]', + '#edit-modules-help-enable[checked]', ], + 'module_names' => [ + 'help', + 'test_module_required_by_theme', + 'test_another_module_required_by_theme', + ], + 'required_by_messages' => [ + '[data-drupal-selector="edit-test-another-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', + '[data-drupal-selector="edit-test-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', + '[data-drupal-selector="edit-help"] .item-list' => 'Required by the theme: Test Theme with a Module Dependency and Base Theme with a Different Module Dependency', + ], + 'module_uninstall_message' => 'help', + 'base_theme_to_uninstall' => 'Test Theme Depending on Modules', + 'base_theme_module_names' => [ + 'test_module_required_by_theme', + 'test_another_module_required_by_theme', + ], + 'base_theme_module_uninstall_message' => 'Test Another Module Required by ThemeTest Module Required by Theme', ], 'Test Theme Depending on Modules' => [ - [ - 'theme_name' => 'Test Theme Depending on Modules', - 'first_expected_required_list_items' => [ - 'Test Module Required by Theme (disabled)', - 'Test Another Module Required by Theme (disabled)', - ], - 'first_module_enable' => [ - 'modules[test_module_required_by_theme][enable]' => 1, - ], - 'first_confirm_checked' => [ - '#edit-modules-test-module-required-by-theme-enable[checked]', - ], - 'second_expected_required_list_items' => [ - 'Test Module Required by Theme', - 'Test Another Module Required by Theme (disabled)', - ], - 'second_module_enable' => [ - 'modules[test_another_module_required_by_theme][enable]' => 1, - ], - 'second_confirm_checked' => [ - '#edit-modules-test-module-required-by-theme-enable[checked]', - '#edit-modules-test-another-module-required-by-theme-enable[checked]', - ], - 'module_names' => [ - 'test_module_required_by_theme', - 'test_another_module_required_by_theme', - ], - 'required_by_messages' => [ - '[data-drupal-selector="edit-test-another-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', - '[data-drupal-selector="edit-test-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', - ], - 'module_uninstall_message' => 'Test Another Module Required by ThemeTest Module Required by Theme', - 'base_theme_to_uninstall' => '', - 'base_theme_module_names' => [], + 'theme_name' => 'Test Theme Depending on Modules', + 'first_expected_required_list_items' => [ + 'Test Module Required by Theme (disabled)', + 'Test Another Module Required by Theme (disabled)', + ], + 'first_module_enable' => [ + 'modules[test_module_required_by_theme][enable]' => 1, + ], + 'first_confirm_checked' => [ + '#edit-modules-test-module-required-by-theme-enable[checked]', + ], + 'second_expected_required_list_items' => [ + 'Test Module Required by Theme', + 'Test Another Module Required by Theme (disabled)', ], + 'second_module_enable' => [ + 'modules[test_another_module_required_by_theme][enable]' => 1, + ], + 'second_confirm_checked' => [ + '#edit-modules-test-module-required-by-theme-enable[checked]', + '#edit-modules-test-another-module-required-by-theme-enable[checked]', + ], + 'module_names' => [ + 'test_module_required_by_theme', + 'test_another_module_required_by_theme', + ], + 'required_by_messages' => [ + '[data-drupal-selector="edit-test-another-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', + '[data-drupal-selector="edit-test-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', + ], + 'module_uninstall_message' => 'Test Another Module Required by ThemeTest Module Required by Theme', + 'base_theme_to_uninstall' => '', + 'base_theme_module_names' => [], + 'base_theme_module_uninstall_message' => '', ], 'test theme with a base theme depending on modules' => [ - [ - 'theme_name' => 'Test Theme with a Base Theme Depending on Modules', - 'first_expected_required_list_items' => [ - 'Test Module Required by Theme (disabled)', - 'Test Another Module Required by Theme (disabled)', - ], - 'first_module_enable' => [ - 'modules[test_module_required_by_theme][enable]' => 1, - ], - 'first_confirm_checked' => [ - '#edit-modules-test-module-required-by-theme-enable[checked]', - ], - 'second_expected_required_list_items' => [ - 'Test Module Required by Theme', - 'Test Another Module Required by Theme (disabled)', - ], - 'second_module_enable' => [ - 'modules[test_another_module_required_by_theme][enable]' => 1, - ], - 'second_confirm_checked' => [ - '#edit-modules-test-module-required-by-theme-enable[checked]', - '#edit-modules-test-another-module-required-by-theme-enable[checked]', - ], - 'module_names' => [ - 'test_module_required_by_theme', - 'test_another_module_required_by_theme', - ], - 'required_by_messages' => [ - '[data-drupal-selector="edit-test-another-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', - '[data-drupal-selector="edit-test-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', - ], - 'module_uninstall_message' => '', - 'base_theme_to_uninstall' => 'Test Theme Depending on Modules', - 'base_theme_module_names' => [ - 'test_module_required_by_theme', - 'test_another_module_required_by_theme', - ], - 'base_theme_module_uninstall_message' => 'Test Another Module Required by ThemeTest Module Required by Theme', + 'theme_name' => 'Test Theme with a Base Theme Depending on Modules', + 'first_expected_required_list_items' => [ + 'Test Module Required by Theme (disabled)', + 'Test Another Module Required by Theme (disabled)', + ], + 'first_module_enable' => [ + 'modules[test_module_required_by_theme][enable]' => 1, + ], + 'first_confirm_checked' => [ + '#edit-modules-test-module-required-by-theme-enable[checked]', + ], + 'second_expected_required_list_items' => [ + 'Test Module Required by Theme', + 'Test Another Module Required by Theme (disabled)', + ], + 'second_module_enable' => [ + 'modules[test_another_module_required_by_theme][enable]' => 1, + ], + 'second_confirm_checked' => [ + '#edit-modules-test-module-required-by-theme-enable[checked]', + '#edit-modules-test-another-module-required-by-theme-enable[checked]', + ], + 'module_names' => [ + 'test_module_required_by_theme', + 'test_another_module_required_by_theme', + ], + 'required_by_messages' => [ + '[data-drupal-selector="edit-test-another-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', + '[data-drupal-selector="edit-test-module-required-by-theme"] .item-list' => 'Required by the theme: Test Theme Depending on Modules', + ], + 'module_uninstall_message' => '', + 'base_theme_to_uninstall' => 'Test Theme Depending on Modules', + 'base_theme_module_names' => [ + 'test_module_required_by_theme', + 'test_another_module_required_by_theme', ], + 'base_theme_module_uninstall_message' => 'Test Another Module Required by ThemeTest Module Required by Theme', ], ]; }