protected function RequirementsPageTrait::assertWarningSummaries in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/RequirementsPageTrait.php \Drupal\Tests\RequirementsPageTrait::assertWarningSummaries()
Assert the given warning summaries are present on the page.
If an expected warning is not found, or if a warning not in the list is present, a fail is raised.
Parameters
string[] $warning_summaries: A list of warning summaries to expect on the requirements screen (e.g. 'PHP', 'PHP OPcode caching', etc.).
2 calls to RequirementsPageTrait::assertWarningSummaries()
- RequirementsPageTrait::continueOnExpectedWarnings in core/
tests/ Drupal/ Tests/ RequirementsPageTrait.php - Continues installation when the expected warnings are found.
- RequirementsPageTrait::updateRequirementsProblem in core/
tests/ Drupal/ Tests/ RequirementsPageTrait.php - Handles the update requirements page.
File
- core/
tests/ Drupal/ Tests/ RequirementsPageTrait.php, line 55
Class
- RequirementsPageTrait
- Provides helper methods for the requirements page.
Namespace
Drupal\TestsCode
protected function assertWarningSummaries(array $warning_summaries) {
// 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($warning_summaries); $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($warning_summaries, $warnings);
}