Chris@18: assertNoText('Errors found'); Chris@18: $this->assertWarningSummaries(['PHP']); Chris@18: $this->clickLink('try again'); Chris@18: $this->checkForMetaRefresh(); Chris@18: } Chris@18: } Chris@18: Chris@18: /** Chris@18: * Continues installation when the expected warnings are found. Chris@18: * Chris@18: * This function is no longer called by any core test, but it is retained for Chris@18: * use by contrib/custom tests. It is not deprecated, because it remains the Chris@18: * recommended function to call for its purpose. Chris@18: * Chris@18: * @param string[] $expected_warnings Chris@18: * A list of warning summaries to expect on the requirements screen (e.g. Chris@18: * 'PHP', 'PHP OPcode caching', etc.). If only the expected warnings Chris@18: * are found, the test will click the "continue anyway" link to go to the Chris@18: * next screen of the installer. If an expected warning is not found, or if Chris@18: * a warning not in the list is present, a fail is raised. Chris@18: */ Chris@18: protected function continueOnExpectedWarnings($expected_warnings = []) { Chris@18: $this->assertNoText('Errors found'); Chris@18: $this->assertWarningSummaries($expected_warnings); Chris@18: $this->clickLink('continue anyway'); Chris@18: $this->checkForMetaRefresh(); Chris@18: } Chris@18: Chris@18: /** Chris@18: * Assert the given warning summaries are present on the page. Chris@18: * Chris@18: * If an expected warning is not found, or if a warning not in the list is Chris@18: * present, a fail is raised. Chris@18: * Chris@18: * @param string[] $warning_summaries Chris@18: * A list of warning summaries to expect on the requirements screen (e.g. Chris@18: * 'PHP', 'PHP OPcode caching', etc.). Chris@18: */ Chris@18: protected function assertWarningSummaries(array $warning_summaries) { Chris@18: // Allow only details elements that are directly after the warning header Chris@18: // or each other. There is no guaranteed wrapper we can rely on across Chris@18: // distributions. When there are multiple warnings, the selectors will be: Chris@18: // - h3#warning+details summary Chris@18: // - h3#warning+details+details summary Chris@18: // - etc. Chris@18: // We add one more selector than expected warnings to confirm that there Chris@18: // isn't any other warning before clicking the link. Chris@18: // @todo Make this more reliable in Chris@18: // https://www.drupal.org/project/drupal/issues/2927345. Chris@18: $selectors = []; Chris@18: for ($i = 0; $i <= count($warning_summaries); $i++) { Chris@18: $selectors[] = 'h3#warning' . implode('', array_fill(0, $i + 1, '+details')) . ' summary'; Chris@18: } Chris@18: $warning_elements = $this->cssSelect(implode(', ', $selectors)); Chris@18: Chris@18: // Confirm that there are only the expected warnings. Chris@18: $warnings = []; Chris@18: foreach ($warning_elements as $warning) { Chris@18: $warnings[] = trim($warning->getText()); Chris@18: } Chris@18: $this->assertEquals($warning_summaries, $warnings); Chris@18: } Chris@18: Chris@18: }