diff --git a/core/modules/simpletest/src/InstallerTestBase.php b/core/modules/simpletest/src/InstallerTestBase.php index 57ca485fdb..593f257a4d 100644 --- a/core/modules/simpletest/src/InstallerTestBase.php +++ b/core/modules/simpletest/src/InstallerTestBase.php @@ -241,13 +241,16 @@ protected function refreshVariables() { /** * Continues installation when an expected warning is found. * - * @param string[] $allowed_warnings - * A list of warning summaries to ignore (e.g. 'PHP', 'PHP OPcode caching', - * etc.). + * @param string[] $expected_warnings + * A list of warning summaries to expect on the requirements screen (e.g. + * 'PHP', 'PHP OPcode caching', etc.). If only the expected warnings + * are found, the test will click the "continue anyway" link to go to the + * next screen of the installer. If an expected warning is not found, or if + * a warning not in the list is present, a fail is raised. */ - protected function continueOnExpectedWarnings($allowed_warnings = []) { + protected function continueOnExpectedWarnings($expected_warnings = []) { // Don't try to continue if there are errors. - if (strpos($this->getTextContent(), 'Errors found')) { + if (strpos($this->getTextContent(), 'Errors found') !== FALSE) { return; } // Allow only details elements that are directly after the warning header @@ -259,16 +262,17 @@ protected function continueOnExpectedWarnings($allowed_warnings = []) { // We add one more selector than expected warnings to confirm that there // isn't any other warning before clicking the link. $selectors = []; - for ($i = 0; $i <= count($allowed_warnings); $i++) { + 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($allowed_warnings, $warnings); + $this->assertEqual($expected_warnings, $warnings); $this->clickLink('continue anyway'); }