Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -70,6 +70,13 @@ abstract class WebTestBase extends TestBase {
*/
protected $curlHandle;
/**
* Whether or not to assert the presence of the X-Drupal-Ajax-Token.
*
* @var bool
*/
protected $assertAjaxHeader = TRUE;
/**
* The headers of the page currently loaded in the internal browser.
*
@ -166,6 +173,21 @@ abstract class WebTestBase extends TestBase {
*/
protected $redirectCount;
/**
* The number of meta refresh redirects to follow, or NULL if unlimited.
*
* @var null|int
*/
protected $maximumMetaRefreshCount = NULL;
/**
* The number of meta refresh redirects followed during ::drupalGet().
*
* @var int
*/
protected $metaRefreshCount = 0;
/**
* The kernel used in this test.
*
@ -711,7 +733,6 @@ abstract class WebTestBase extends TestBase {
// Not using File API; a potential error must trigger a PHP warning.
$directory = DRUPAL_ROOT . '/' . $this->siteDirectory;
copy(DRUPAL_ROOT . '/sites/default/default.settings.php', $directory . '/settings.php');
copy(DRUPAL_ROOT . '/sites/default/default.services.yml', $directory . '/services.yml');
// All file system paths are created by System module during installation.
// @see system_requirements()
@ -753,10 +774,12 @@ abstract class WebTestBase extends TestBase {
file_put_contents($directory . '/settings.php', "\n\$test_class = '" . get_class($this) ."';\n" . 'include DRUPAL_ROOT . \'/\' . $site_path . \'/settings.testing.php\';' ."\n", FILE_APPEND);
}
$settings_services_file = DRUPAL_ROOT . '/' . $this->originalSite . '/testing.services.yml';
if (file_exists($settings_services_file)) {
// Copy the testing-specific service overrides in place.
copy($settings_services_file, $directory . '/services.yml');
if (!file_exists($settings_services_file)) {
// Otherwise, use the default services as a starting point for overrides.
$settings_services_file = DRUPAL_ROOT . '/sites/default/default.services.yml';
}
// Copy the testing-specific service overrides in place.
copy($settings_services_file, $directory . '/services.yml');
if ($this->strictConfigSchema) {
// Add a listener to validate configuration schema on save.
$yaml = new \Symfony\Component\Yaml\Yaml();
@ -831,6 +854,15 @@ abstract class WebTestBase extends TestBase {
->set('css.preprocess', FALSE)
->set('js.preprocess', FALSE)
->save();
// Set an explicit time zone to not rely on the system one, which may vary
// from setup to setup. The Australia/Sydney time zone is chosen so all
// tests are run using an edge case scenario (UTC+10 and DST). This choice
// is made to prevent time zone related regressions and reduce the
// fragility of the testing system in general.
$config->getEditable('system.date')
->set('timezone.default', 'Australia/Sydney')
->save();
}
/**
@ -1206,6 +1238,9 @@ abstract class WebTestBase extends TestBase {
}
parent::tearDown();
// Ensure that the maximum meta refresh count is reset.
$this->maximumMetaRefreshCount = NULL;
// Ensure that internal logged in variable and cURL options are reset.
$this->loggedInUser = FALSE;
$this->additionalCurlOptions = array();
@ -1248,6 +1283,8 @@ abstract class WebTestBase extends TestBase {
CURLOPT_SSL_VERIFYHOST => FALSE,
CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'),
CURLOPT_USERAGENT => $this->databasePrefix,
// Disable support for the @ prefix for uploading files.
CURLOPT_SAFE_UPLOAD => TRUE,
);
if (isset($this->httpAuthCredentials)) {
$curl_options[CURLOPT_HTTPAUTH] = $this->httpAuthMethod;
@ -1493,6 +1530,8 @@ abstract class WebTestBase extends TestBase {
// Replace original page output with new output from redirected page(s).
if ($new = $this->checkForMetaRefresh()) {
$out = $new;
// We are finished with all meta refresh redirects, so reset the counter.
$this->metaRefreshCount = 0;
}
if ($path instanceof Url) {
@ -1502,7 +1541,7 @@ abstract class WebTestBase extends TestBase {
$verbose = 'GET request to: ' . $path .
'<hr />Ending URL: ' . $this->getUrl();
if ($this->dumpHeaders) {
$verbose .= '<hr />Headers: <pre>' . SafeMarkup::checkPlain(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
$verbose .= '<hr />Headers: <pre>' . Html::escape(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
}
$verbose .= '<hr />' . $out;
@ -1609,9 +1648,6 @@ abstract class WebTestBase extends TestBase {
* $edit = array();
* $edit['name[]'] = array('value1', 'value2');
* @endcode
*
* Note that when a form contains file upload fields, other
* fields cannot start with the '@' character.
* @param $submit
* Value of the submit button whose click is to be emulated. For example,
* t('Save'). The processing of the request depends on this value. For
@ -1729,7 +1765,7 @@ abstract class WebTestBase extends TestBase {
$verbose = 'POST request to: ' . $path;
$verbose .= '<hr />Ending URL: ' . $this->getUrl();
if ($this->dumpHeaders) {
$verbose .= '<hr />Headers: <pre>' . SafeMarkup::checkPlain(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
$verbose .= '<hr />Headers: <pre>' . Html::escape(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
}
$verbose .= '<hr />Fields: ' . highlight_string('<?php ' . var_export($post_array, TRUE), TRUE);
$verbose .= '<hr />' . $out;
@ -1867,6 +1903,9 @@ abstract class WebTestBase extends TestBase {
// Submit the POST request.
$return = Json::decode($this->drupalPostForm(NULL, $edit, array('path' => $ajax_path, 'triggering_element' => $triggering_element), $options, $headers, $form_html_id, $extra_post));
if ($this->assertAjaxHeader) {
$this->assertIdentical($this->drupalGetHeader('X-Drupal-Ajax-Token'), '1', 'Ajax response header found.');
}
// Change the page content by applying the returned commands.
if (!empty($ajax_settings) && !empty($return)) {
@ -2154,12 +2193,13 @@ abstract class WebTestBase extends TestBase {
* Either the new page content or FALSE.
*/
protected function checkForMetaRefresh() {
if (strpos($this->getRawContent(), '<meta ') && $this->parse()) {
if (strpos($this->getRawContent(), '<meta ') && $this->parse() && (!isset($this->maximumMetaRefreshCount) || $this->metaRefreshCount < $this->maximumMetaRefreshCount)) {
$refresh = $this->xpath('//meta[@http-equiv="Refresh"]');
if (!empty($refresh)) {
// Parse the content attribute of the meta tag for the format:
// "[delay]: URL=[page_to_redirect_to]".
if (preg_match('/\d+;\s*URL=(?<url>.*)/i', $refresh[0]['content'], $match)) {
$this->metaRefreshCount++;
return $this->drupalGet($this->getAbsoluteUrl(Html::decodeEntities($match['url'])));
}
}
@ -2191,7 +2231,7 @@ abstract class WebTestBase extends TestBase {
if ($this->dumpHeaders) {
$this->verbose('GET request to: ' . $path .
'<hr />Ending URL: ' . $this->getUrl() .
'<hr />Headers: <pre>' . SafeMarkup::checkPlain(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>');
'<hr />Headers: <pre>' . Html::escape(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>');
}
return $out;
@ -2465,7 +2505,7 @@ abstract class WebTestBase extends TestBase {
$path = substr($path, $length);
}
// Ensure that we have an absolute path.
if ($path[0] !== '/') {
if (empty($path) || $path[0] !== '/') {
$path = '/' . $path;
}
// Finally, prepend the $base_url.