diff --git a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php index d88fd445fc7..3657f96911e 100644 --- a/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php +++ b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php @@ -27,13 +27,14 @@ class ModulesListFormWebTest extends BrowserTestBase { protected function setUp() { parent::setUp(); \Drupal::state()->set('system_test.module_hidden', FALSE); + $this->drupalLogin($this->drupalCreateUser(['administer modules', 'administer permissions'])); } /** * Tests the module list form. */ public function testModuleListForm() { - $this->createUserAdministerModules(); + $this->drupalGet('admin/modules'); // Check that system_test's configure link was rendered correctly. $this->assertFieldByXPath("//a[contains(@href, '/system-test/configure/bar') and text()='Configure ']/span[contains(@class, 'visually-hidden') and text()='the System test module']"); @@ -86,7 +87,6 @@ public function testModulesListFormWithInvalidInfoFile() { 'expected_error' => "'core: 9.x' is not supported. Use 'core_version_requirement' to specify core compatibility. Only 'core: 8.x' is supported to provide backwards compatibility for Drupal 8 when needed in $file_path", ], ]; - $this->createUserAdministerModules(); foreach ($broken_infos as $broken_info) { file_put_contents($file_path, $broken_info['yml']); @@ -114,7 +114,7 @@ public function testModulesListFormWithInvalidInfoFile() { * Confirm that module 'Required By' descriptions include dependent themes. */ public function testRequiredByThemeMessage() { - $this->createUserAdministerModules(); + $this->drupalGet('admin/modules'); $module_theme_depends_on_description = $this->getSession()->getPage()->findAll('css', '#edit-modules-test-module-required-by-theme-enable-description .admin-requirements li:contains("Test Theme Depending on Modules (theme) (disabled)")'); // Confirm that that 'Test Theme Depending on Modules' is listed as being // required by the module 'Test Module Required by Theme'. @@ -123,12 +123,4 @@ public function testRequiredByThemeMessage() { $this->assertSession()->pageTextContains('Test Theme Depending on Modules (Theme) (Disabled)'); } - /** - * Creates user that can administer modules then visits `admin/modules`. - */ - protected function createUserAdministerModules() { - $this->drupalLogin($this->drupalCreateUser(['administer modules', 'administer permissions'])); - $this->drupalGet('admin/modules'); - } - }