diff --git a/core/modules/simpletest/src/InstallerTestBase.php b/core/modules/simpletest/src/InstallerTestBase.php index 369c3ab..d51b2e9 100644 --- a/core/modules/simpletest/src/InstallerTestBase.php +++ b/core/modules/simpletest/src/InstallerTestBase.php @@ -8,6 +8,7 @@ use Drupal\Core\Language\Language; use Drupal\Core\Session\UserSession; use Drupal\Core\Site\Settings; +use Drupal\Tests\RequirementsPageTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpFoundation\Request; @@ -22,6 +23,8 @@ */ abstract class InstallerTestBase extends WebTestBase { + use RequirementsPageTrait; + /** * Custom settings.php values to write for a test run. * @@ -213,12 +216,7 @@ protected function setUpSettings() { * @see system_requirements() */ protected function setUpRequirementsProblem() { - // By default, skip the "recommended PHP version" warning on older test - // environments. This allows the installer to be tested consistently on - // both recommended PHP versions and older (but still supported) versions. - if (version_compare(phpversion(), '7.0') < 0) { - $this->continueOnExpectedWarnings(['PHP']); - } + // Do nothing. } /** @@ -255,32 +253,8 @@ protected function refreshVariables() { * a warning not in the list is present, a fail is raised. */ protected function continueOnExpectedWarnings($expected_warnings = []) { - // Don't try to continue if there are errors. - if (strpos($this->getTextContent(), 'Errors found') !== FALSE) { - return; - } - // Allow only details elements that are directly after the warning header - // or each other. There is no guaranteed wrapper we can rely on across - // distributions. When there are multiple warnings, the selectors will be: - // - h3#warning+details summary - // - h3#warning+details+details summary - // - etc. - // We add one more selector than expected warnings to confirm that there - // isn't any other warning before clicking the link. - // @todo Make this more reliable in - // https://www.drupal.org/project/drupal/issues/2927345. - $selectors = []; - for ($i = 0; $i <= count($expected_warnings); $i++) { - $selectors[] = 'h3#warning' . implode('', array_fill(0, $i + 1, '+details')) . ' summary'; - } - $warning_elements = $this->cssSelect(implode(', ', $selectors)); - - // Confirm that there are only the expected warnings. - $warnings = []; - foreach ($warning_elements as $warning) { - $warnings[] = trim((string) $warning); - } - $this->assertEqual($expected_warnings, $warnings); + $this->assertFalse(strpos($this->getTextContent(), 'Errors found')); + $this->assertWarningSummaries($expected_warnings); $this->clickLink('continue anyway'); } diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php index 5ea1e58..6e48b4c 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerTestBase.php @@ -8,6 +8,7 @@ use Drupal\Core\Site\Settings; use Drupal\Core\Test\HttpClientMiddleware\TestHttpClientMiddleware; use Drupal\Tests\BrowserTestBase; +use Drupal\Tests\RequirementsPageTrait; use GuzzleHttp\HandlerStack; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -19,6 +20,8 @@ */ abstract class InstallerTestBase extends BrowserTestBase { + use RequirementsPageTrait; + /** * Custom settings.php values to write for a test run. * @@ -281,32 +284,8 @@ protected function refreshVariables() { * a warning not in the list is present, a fail is raised. */ protected function continueOnExpectedWarnings($expected_warnings = []) { - // Don't try to continue if there are errors. - if (strpos($this->getTextContent(), 'Errors found') !== FALSE) { - return; - } - // Allow only details elements that are directly after the warning header - // or each other. There is no guaranteed wrapper we can rely on across - // distributions. When there are multiple warnings, the selectors will be: - // - h3#warning+details summary - // - h3#warning+details+details summary - // - etc. - // We add one more selector than expected warnings to confirm that there - // isn't any other warning before clicking the link. - // @todo Make this more reliable in - // https://www.drupal.org/project/drupal/issues/2927345. - $selectors = []; - for ($i = 0; $i <= count($expected_warnings); $i++) { - $selectors[] = 'h3#warning' . implode('', array_fill(0, $i + 1, '+details')) . ' summary'; - } - $warning_elements = $this->cssSelect(implode(', ', $selectors)); - - // Confirm that there are only the expected warnings. - $warnings = []; - foreach ($warning_elements as $warning) { - $warnings[] = trim($warning->getText()); - } - $this->assertEquals($expected_warnings, $warnings); + $this->assertFalse(strpos($this->getTextContent(), 'Errors found')); + $this->assertWarningSummaries($expected_warnings); $this->clickLink('continue anyway'); $this->checkForMetaRefresh(); }