Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
|
@ -233,7 +233,7 @@ abstract class WebTestBase extends TestBase {
|
|||
/**
|
||||
* Get a node from the database based on its title.
|
||||
*
|
||||
* @param $title
|
||||
* @param string|\Drupal\Component\Render\MarkupInterface $title
|
||||
* A node title, usually generated by $this->randomMachineName().
|
||||
* @param $reset
|
||||
* (optional) Whether to reset the entity cache.
|
||||
|
|
@ -245,6 +245,8 @@ abstract class WebTestBase extends TestBase {
|
|||
if ($reset) {
|
||||
\Drupal::entityManager()->getStorage('node')->resetCache();
|
||||
}
|
||||
// Cast MarkupInterface objects to string.
|
||||
$title = (string) $title;
|
||||
$nodes = entity_load_multiple_by_properties('node', array('title' => $title));
|
||||
// Load the first node returned from the database.
|
||||
$returned_node = reset($nodes);
|
||||
|
|
@ -408,7 +410,6 @@ abstract class WebTestBase extends TestBase {
|
|||
* - region: 'sidebar_first'.
|
||||
* - theme: The default theme.
|
||||
* - visibility: Empty array.
|
||||
* - cache: array('max_age' => Cache::PERMANENT).
|
||||
*
|
||||
* @return \Drupal\block\Entity\Block
|
||||
* The block entity.
|
||||
|
|
@ -425,9 +426,6 @@ abstract class WebTestBase extends TestBase {
|
|||
'label' => $this->randomMachineName(8),
|
||||
'visibility' => array(),
|
||||
'weight' => 0,
|
||||
'cache' => array(
|
||||
'max_age' => Cache::PERMANENT,
|
||||
),
|
||||
);
|
||||
$values = [];
|
||||
foreach (array('region', 'id', 'theme', 'plugin', 'weight', 'visibility') as $key) {
|
||||
|
|
@ -1419,12 +1417,12 @@ abstract class WebTestBase extends TestBase {
|
|||
$this->url = isset($original_url) ? $original_url : curl_getinfo($this->curlHandle, CURLINFO_EFFECTIVE_URL);
|
||||
|
||||
$message_vars = array(
|
||||
'!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'),
|
||||
'@method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'),
|
||||
'@url' => isset($original_url) ? $original_url : $url,
|
||||
'@status' => $status,
|
||||
'!length' => format_size(strlen($this->getRawContent()))
|
||||
'@length' => format_size(strlen($this->getRawContent()))
|
||||
);
|
||||
$message = SafeMarkup::format('!method @url returned @status (!length).', $message_vars);
|
||||
$message = SafeMarkup::format('@method @url returned @status (@length).', $message_vars);
|
||||
$this->assertTrue($this->getRawContent() !== FALSE, $message, 'Browser');
|
||||
return $this->getRawContent();
|
||||
}
|
||||
|
|
@ -1690,6 +1688,14 @@ abstract class WebTestBase extends TestBase {
|
|||
* (e.g., "&extra_var1=hello+world&extra_var2=you%26me").
|
||||
*/
|
||||
protected function drupalPostForm($path, $edit, $submit, array $options = array(), array $headers = array(), $form_html_id = NULL, $extra_post = NULL) {
|
||||
if (is_object($submit)) {
|
||||
// Cast MarkupInterface objects to string.
|
||||
$submit = (string) $submit;
|
||||
}
|
||||
if (is_array($edit)) {
|
||||
$edit = $this->castSafeStrings($edit);
|
||||
}
|
||||
|
||||
$submit_matches = FALSE;
|
||||
$ajax = is_array($submit);
|
||||
if (isset($path)) {
|
||||
|
|
@ -2223,7 +2229,7 @@ abstract class WebTestBase extends TestBase {
|
|||
*/
|
||||
protected function drupalHead($path, array $options = array(), array $headers = array()) {
|
||||
$options['absolute'] = TRUE;
|
||||
$url = $this->container->get('url_generator')->generateFromPath($path, $options);
|
||||
$url = $this->buildUrl($path, $options);
|
||||
$out = $this->curlExec(array(CURLOPT_NOBODY => TRUE, CURLOPT_URL => $url, CURLOPT_HTTPHEADER => $headers));
|
||||
// Ensure that any changes to variables in the other thread are picked up.
|
||||
$this->refreshVariables();
|
||||
|
|
@ -2407,7 +2413,7 @@ abstract class WebTestBase extends TestBase {
|
|||
*
|
||||
* If the link is discovered and clicked, the test passes. Fail otherwise.
|
||||
*
|
||||
* @param string $label
|
||||
* @param string|\Drupal\Component\Render\MarkupInterface $label
|
||||
* Text between the anchor tags.
|
||||
* @param int $index
|
||||
* Link position counting from zero.
|
||||
|
|
@ -2425,7 +2431,7 @@ abstract class WebTestBase extends TestBase {
|
|||
*
|
||||
* If the link is discovered and clicked, the test passes. Fail otherwise.
|
||||
*
|
||||
* @param string $label
|
||||
* @param string|\Drupal\Component\Render\MarkupInterface $label
|
||||
* Text between the anchor tags, uses starts-with().
|
||||
* @param int $index
|
||||
* Link position counting from zero.
|
||||
|
|
@ -2442,7 +2448,7 @@ abstract class WebTestBase extends TestBase {
|
|||
/**
|
||||
* Provides a helper for ::clickLink() and ::clickLinkPartialName().
|
||||
*
|
||||
* @param string $label
|
||||
* @param string|\Drupal\Component\Render\MarkupInterface $label
|
||||
* Text between the anchor tags, uses starts-with().
|
||||
* @param int $index
|
||||
* Link position counting from zero.
|
||||
|
|
@ -2453,6 +2459,8 @@ abstract class WebTestBase extends TestBase {
|
|||
* Page contents on success, or FALSE on failure.
|
||||
*/
|
||||
protected function clickLinkHelper($label, $index, $pattern) {
|
||||
// Cast MarkupInterface objects to string.
|
||||
$label = (string) $label;
|
||||
$url_before = $this->getUrl();
|
||||
$urls = $this->xpath($pattern, array(':label' => $label));
|
||||
if (isset($urls[$index])) {
|
||||
|
|
@ -2662,8 +2670,9 @@ abstract class WebTestBase extends TestBase {
|
|||
* (optional) Any additional options to pass for $path to the url generator.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use format_string() to embed variables in the message text, not
|
||||
* t(). If left blank, a default message will be displayed.
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
* (optional) The group this message is in, which is displayed in a column
|
||||
* in test output. Use 'Debug' to indicate this is debugging output. Do not
|
||||
|
|
@ -2675,12 +2684,18 @@ abstract class WebTestBase extends TestBase {
|
|||
*/
|
||||
protected function assertUrl($path, array $options = array(), $message = '', $group = 'Other') {
|
||||
if ($path instanceof Url) {
|
||||
$url = $path->setAbsolute()->toString();
|
||||
$url_obj = $path;
|
||||
}
|
||||
elseif (UrlHelper::isExternal($path)) {
|
||||
$url_obj = Url::fromUri($path, $options);
|
||||
}
|
||||
else {
|
||||
$options['absolute'] = TRUE;
|
||||
$url = $this->container->get('url_generator')->generateFromPath($path, $options);
|
||||
$uri = $path === '<front>' ? 'base:/' : 'base:/' . $path;
|
||||
// This is needed for language prefixing.
|
||||
$options['path_processing'] = TRUE;
|
||||
$url_obj = Url::fromUri($uri, $options);
|
||||
}
|
||||
$url = $url_obj->setAbsolute()->toString();
|
||||
if (!$message) {
|
||||
$message = SafeMarkup::format('Expected @url matches current URL (@current_url).', array(
|
||||
'@url' => var_export($url, TRUE),
|
||||
|
|
@ -2702,8 +2717,9 @@ abstract class WebTestBase extends TestBase {
|
|||
* of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use format_string() to embed variables in the message text, not
|
||||
* t(). If left blank, a default message will be displayed.
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
* (optional) The group this message is in, which is displayed in a column
|
||||
* in test output. Use 'Debug' to indicate this is debugging output. Do not
|
||||
|
|
@ -2716,7 +2732,7 @@ abstract class WebTestBase extends TestBase {
|
|||
protected function assertResponse($code, $message = '', $group = 'Browser') {
|
||||
$curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
|
||||
$match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
|
||||
return $this->assertTrue($match, $message ? $message : SafeMarkup::format('HTTP response expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), $group);
|
||||
return $this->assertTrue($match, $message ? $message : SafeMarkup::format('HTTP response expected @code, actual @curl_code', array('@code' => $code, '@curl_code' => $curl_code)), $group);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2727,8 +2743,9 @@ abstract class WebTestBase extends TestBase {
|
|||
* of all codes see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use format_string() to embed variables in the message text, not
|
||||
* t(). If left blank, a default message will be displayed.
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
* (optional) The group this message is in, which is displayed in a column
|
||||
* in test output. Use 'Debug' to indicate this is debugging output. Do not
|
||||
|
|
@ -2741,7 +2758,7 @@ abstract class WebTestBase extends TestBase {
|
|||
protected function assertNoResponse($code, $message = '', $group = 'Browser') {
|
||||
$curl_code = curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
|
||||
$match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
|
||||
return $this->assertFalse($match, $message ? $message : SafeMarkup::format('HTTP response not expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), $group);
|
||||
return $this->assertFalse($match, $message ? $message : SafeMarkup::format('HTTP response not expected @code, actual @curl_code', array('@code' => $code, '@curl_code' => $curl_code)), $group);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2756,8 +2773,9 @@ abstract class WebTestBase extends TestBase {
|
|||
* Value of the field to assert.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use format_string() to embed variables in the message text, not
|
||||
* t(). If left blank, a default message will be displayed.
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
* (optional) The group this message is in, which is displayed in a column
|
||||
* in test output. Use 'Debug' to indicate this is debugging output. Do not
|
||||
|
|
@ -2784,8 +2802,9 @@ abstract class WebTestBase extends TestBase {
|
|||
* Number of emails to search for string, starting with most recent.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use format_string() to embed variables in the message text, not
|
||||
* t(). If left blank, a default message will be displayed.
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
* (optional) The group this message is in, which is displayed in a column
|
||||
* in test output. Use 'Debug' to indicate this is debugging output. Do not
|
||||
|
|
@ -2798,6 +2817,8 @@ abstract class WebTestBase extends TestBase {
|
|||
protected function assertMailString($field_name, $string, $email_depth, $message = '', $group = 'Other') {
|
||||
$mails = $this->drupalGetMails();
|
||||
$string_found = FALSE;
|
||||
// Cast MarkupInterface objects to string.
|
||||
$string = (string) $string;
|
||||
for ($i = count($mails) -1; $i >= count($mails) - $email_depth && $i >= 0; $i--) {
|
||||
$mail = $mails[$i];
|
||||
// Normalize whitespace, as we don't know what the mail system might have
|
||||
|
|
@ -2824,8 +2845,9 @@ abstract class WebTestBase extends TestBase {
|
|||
* Pattern to search for.
|
||||
* @param $message
|
||||
* (optional) A message to display with the assertion. Do not translate
|
||||
* messages: use format_string() to embed variables in the message text, not
|
||||
* t(). If left blank, a default message will be displayed.
|
||||
* messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed
|
||||
* variables in the message text, not t(). If left blank, a default message
|
||||
* will be displayed.
|
||||
* @param $group
|
||||
* (optional) The group this message is in, which is displayed in a column
|
||||
* in test output. Use 'Debug' to indicate this is debugging output. Do not
|
||||
|
|
@ -2934,8 +2956,19 @@ abstract class WebTestBase extends TestBase {
|
|||
// The URL generator service is not necessarily available yet; e.g., in
|
||||
// interactive installer tests.
|
||||
else if ($this->container->has('url_generator')) {
|
||||
$options['absolute'] = TRUE;
|
||||
return $this->container->get('url_generator')->generateFromPath($path, $options);
|
||||
$force_internal = isset($options['external']) && $options['external'] == FALSE;
|
||||
if (!$force_internal && UrlHelper::isExternal($path)) {
|
||||
return Url::fromUri($path, $options)->toString();
|
||||
}
|
||||
else {
|
||||
$uri = $path === '<front>' ? 'base:/' : 'base:/' . $path;
|
||||
// Path processing is needed for language prefixing. Skip it when a
|
||||
// path that may look like an external URL is being used as internal.
|
||||
$options['path_processing'] = !$force_internal;
|
||||
return Url::fromUri($uri, $options)
|
||||
->setAbsolute()
|
||||
->toString();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $this->getAbsoluteUrl($path);
|
||||
|
|
|
|||
Reference in a new issue