comparison core/modules/simpletest/src/InstallerTestBase.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
119 // Select language. 119 // Select language.
120 $this->setUpLanguage(); 120 $this->setUpLanguage();
121 121
122 // Select profile. 122 // Select profile.
123 $this->setUpProfile(); 123 $this->setUpProfile();
124
125 // Address the requirements problem screen, if any.
126 $this->setUpRequirementsProblem();
124 127
125 // Configure settings. 128 // Configure settings.
126 $this->setUpSettings(); 129 $this->setUpSettings();
127 130
128 // @todo Allow test classes based on this class to act on further installer 131 // @todo Allow test classes based on this class to act on further installer
194 $edit = $this->translatePostValues($this->parameters['forms']['install_settings_form']); 197 $edit = $this->translatePostValues($this->parameters['forms']['install_settings_form']);
195 $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']); 198 $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
196 } 199 }
197 200
198 /** 201 /**
202 * Installer step: Requirements problem.
203 *
204 * Override this method to test specific requirements warnings or errors
205 * during the installer.
206 *
207 * @see system_requirements()
208 */
209 protected function setUpRequirementsProblem() {
210 // By default, skip the "recommended PHP version" warning on older test
211 // environments. This allows the installer to be tested consistently on
212 // both recommended PHP versions and older (but still supported) versions.
213 if (version_compare(phpversion(), '7.0') < 0) {
214 $this->continueOnExpectedWarnings(['PHP']);
215 }
216 }
217
218 /**
199 * Final installer step: Configure site. 219 * Final installer step: Configure site.
200 */ 220 */
201 protected function setUpSite() { 221 protected function setUpSite() {
202 $edit = $this->translatePostValues($this->parameters['forms']['install_configure_form']); 222 $edit = $this->translatePostValues($this->parameters['forms']['install_configure_form']);
203 $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']); 223 $this->drupalPostForm(NULL, $edit, $this->translations['Save and continue']);
216 if ($this->isInstalled) { 236 if ($this->isInstalled) {
217 parent::refreshVariables(); 237 parent::refreshVariables();
218 } 238 }
219 } 239 }
220 240
241 /**
242 * Continues installation when an expected warning is found.
243 *
244 * @param string[] $expected_warnings
245 * A list of warning summaries to expect on the requirements screen (e.g.
246 * 'PHP', 'PHP OPcode caching', etc.). If only the expected warnings
247 * are found, the test will click the "continue anyway" link to go to the
248 * next screen of the installer. If an expected warning is not found, or if
249 * a warning not in the list is present, a fail is raised.
250 */
251 protected function continueOnExpectedWarnings($expected_warnings = []) {
252 // Don't try to continue if there are errors.
253 if (strpos($this->getTextContent(), 'Errors found') !== FALSE) {
254 return;
255 }
256 // Allow only details elements that are directly after the warning header
257 // or each other. There is no guaranteed wrapper we can rely on across
258 // distributions. When there are multiple warnings, the selectors will be:
259 // - h3#warning+details summary
260 // - h3#warning+details+details summary
261 // - etc.
262 // We add one more selector than expected warnings to confirm that there
263 // isn't any other warning before clicking the link.
264 // @todo Make this more reliable in
265 // https://www.drupal.org/project/drupal/issues/2927345.
266 $selectors = [];
267 for ($i = 0; $i <= count($expected_warnings); $i++) {
268 $selectors[] = 'h3#warning' . implode('', array_fill(0, $i + 1, '+details')) . ' summary';
269 }
270 $warning_elements = $this->cssSelect(implode(', ', $selectors));
271
272 // Confirm that there are only the expected warnings.
273 $warnings = [];
274 foreach ($warning_elements as $warning) {
275 $warnings[] = trim((string) $warning);
276 }
277 $this->assertEqual($expected_warnings, $warnings);
278 $this->clickLink('continue anyway');
279 }
280
221 } 281 }