commit 2084dd4545ee96ad0d12f3a9acfb223215dae291 Author: xjm Date: Sat Nov 25 07:50:46 2017 -0600 98 diff --git a/core/modules/simpletest/src/InstallerTestBase.php b/core/modules/simpletest/src/InstallerTestBase.php index 151e9eff00..04e94e82b7 100644 --- a/core/modules/simpletest/src/InstallerTestBase.php +++ b/core/modules/simpletest/src/InstallerTestBase.php @@ -244,16 +244,26 @@ protected function continueOnExpectedWarnings($allowed_warnings = []) { if (strpos($this->getTextContent(), 'Errors found')) { return; } - $warning_elements = $this->cssSelect('h3#warning+details summary'); + // 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. + $selectors = []; + for ($i = 0; $i <= count($allowed_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. - if (count($allowed_warnings) == count($warning_elements)) { - $warnings = []; - foreach ($warning_elements as $warning) { - $warnings[] = trim((string) $warning); - } - $this->assertEqual($allowed_warnings, $warnings); - $this->clickLink('continue anyway'); + $warnings = []; + foreach ($warning_elements as $warning) { + $warnings[] = trim((string) $warning); } + $this->assertEqual($allowed_warnings, $warnings); + $this->clickLink('continue anyway'); } }