Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/simpletest/src/InstallerTestBase.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
6 | 6 |
7 use Drupal\Core\DrupalKernel; | 7 use Drupal\Core\DrupalKernel; |
8 use Drupal\Core\Language\Language; | 8 use Drupal\Core\Language\Language; |
9 use Drupal\Core\Session\UserSession; | 9 use Drupal\Core\Session\UserSession; |
10 use Drupal\Core\Site\Settings; | 10 use Drupal\Core\Site\Settings; |
11 use Drupal\Tests\RequirementsPageTrait; | |
11 use Symfony\Component\DependencyInjection\ContainerBuilder; | 12 use Symfony\Component\DependencyInjection\ContainerBuilder; |
12 use Symfony\Component\DependencyInjection\Reference; | 13 use Symfony\Component\DependencyInjection\Reference; |
13 use Symfony\Component\HttpFoundation\Request; | 14 use Symfony\Component\HttpFoundation\Request; |
14 use Symfony\Component\HttpFoundation\RequestStack; | 15 use Symfony\Component\HttpFoundation\RequestStack; |
15 | 16 |
19 * @deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. | 20 * @deprecated in Drupal 8.6.0 and will be removed before Drupal 9.0.0. |
20 * Use \Drupal\FunctionalTests\Installer\InstallerTestBase. See | 21 * Use \Drupal\FunctionalTests\Installer\InstallerTestBase. See |
21 * https://www.drupal.org/node/2988752 | 22 * https://www.drupal.org/node/2988752 |
22 */ | 23 */ |
23 abstract class InstallerTestBase extends WebTestBase { | 24 abstract class InstallerTestBase extends WebTestBase { |
25 | |
26 use RequirementsPageTrait; | |
24 | 27 |
25 /** | 28 /** |
26 * Custom settings.php values to write for a test run. | 29 * Custom settings.php values to write for a test run. |
27 * | 30 * |
28 * @var array | 31 * @var array |
211 * during the installer. | 214 * during the installer. |
212 * | 215 * |
213 * @see system_requirements() | 216 * @see system_requirements() |
214 */ | 217 */ |
215 protected function setUpRequirementsProblem() { | 218 protected function setUpRequirementsProblem() { |
216 // By default, skip the "recommended PHP version" warning on older test | 219 // Do nothing. |
217 // environments. This allows the installer to be tested consistently on | |
218 // both recommended PHP versions and older (but still supported) versions. | |
219 if (version_compare(phpversion(), '7.0') < 0) { | |
220 $this->continueOnExpectedWarnings(['PHP']); | |
221 } | |
222 } | 220 } |
223 | 221 |
224 /** | 222 /** |
225 * Final installer step: Configure site. | 223 * Final installer step: Configure site. |
226 */ | 224 */ |
242 if ($this->isInstalled) { | 240 if ($this->isInstalled) { |
243 parent::refreshVariables(); | 241 parent::refreshVariables(); |
244 } | 242 } |
245 } | 243 } |
246 | 244 |
247 /** | |
248 * Continues installation when an expected warning is found. | |
249 * | |
250 * @param string[] $expected_warnings | |
251 * A list of warning summaries to expect on the requirements screen (e.g. | |
252 * 'PHP', 'PHP OPcode caching', etc.). If only the expected warnings | |
253 * are found, the test will click the "continue anyway" link to go to the | |
254 * next screen of the installer. If an expected warning is not found, or if | |
255 * a warning not in the list is present, a fail is raised. | |
256 */ | |
257 protected function continueOnExpectedWarnings($expected_warnings = []) { | |
258 // Don't try to continue if there are errors. | |
259 if (strpos($this->getTextContent(), 'Errors found') !== FALSE) { | |
260 return; | |
261 } | |
262 // Allow only details elements that are directly after the warning header | |
263 // or each other. There is no guaranteed wrapper we can rely on across | |
264 // distributions. When there are multiple warnings, the selectors will be: | |
265 // - h3#warning+details summary | |
266 // - h3#warning+details+details summary | |
267 // - etc. | |
268 // We add one more selector than expected warnings to confirm that there | |
269 // isn't any other warning before clicking the link. | |
270 // @todo Make this more reliable in | |
271 // https://www.drupal.org/project/drupal/issues/2927345. | |
272 $selectors = []; | |
273 for ($i = 0; $i <= count($expected_warnings); $i++) { | |
274 $selectors[] = 'h3#warning' . implode('', array_fill(0, $i + 1, '+details')) . ' summary'; | |
275 } | |
276 $warning_elements = $this->cssSelect(implode(', ', $selectors)); | |
277 | |
278 // Confirm that there are only the expected warnings. | |
279 $warnings = []; | |
280 foreach ($warning_elements as $warning) { | |
281 $warnings[] = trim((string) $warning); | |
282 } | |
283 $this->assertEqual($expected_warnings, $warnings); | |
284 $this->clickLink('continue anyway'); | |
285 } | |
286 | |
287 } | 245 } |