reverted: --- b/core/tests/Drupal/Tests/BrowserTestBase.php +++ a/core/tests/Drupal/Tests/BrowserTestBase.php @@ -795,11 +795,6 @@ // Edit the form values. foreach ($edit as $name => $value) { - // Provide support for 1, 0 for checkboxes instead of TRUE and FALSE. - if (strpos($name, 'name[') === 0) { - $value = (bool) $value; - } - $field = $assert_session->fieldExists($name, $form); // Provide support for the values '1' and '0' for checkboxes instead of reverted: --- b/core/tests/Drupal/Tests/WebAssert.php +++ a/core/tests/Drupal/Tests/WebAssert.php @@ -349,150 +349,6 @@ } /** - * Passes if a link with the specified label is not found. - * - * An optional link index may be passed. - * - * @param string|\Drupal\Component\Render\MarkupInterface $label - * Text between the anchor tags. - * @param int $index - * Link position counting from zero. - * @param string $message - * (optional) A message to display with the assertion. Do not translate - * messages: use strtr() to embed variables in the message text, not - * t(). If left blank, a default message will be displayed. - * - * @throws \Behat\Mink\Exception\ExpectationException - * Thrown when element doesn't exist, or the link label is a different one. - */ - public function linkNotExists($label, $message = '') { - // Cast MarkupInterface objects to string. - $label = (string) $label; - $message = ($message ? $message : strtr('Link with label %label found.', ['%label' => $label])); - $links = $this->session->getPage()->findAll('named', ['link', $label]); - if (!empty($links)) { - throw new ExpectationException($message); - } - $this->assert(TRUE, $message); - } - - /** - * {@inheritdoc} - */ - public function fieldValueEquals($field, $value, TraversableElement $container = NULL) { - parent::fieldValueEquals($field, (string) $value, $container); - } - - /** - * Passes if a link containing a given href (part) is found. - * - * @param string $href - * The full or partial value of the 'href' attribute of the anchor tag. - * @param int $index - * Link position counting from zero. - * @param string $message - * (optional) A message to display with the assertion. Do not translate - * 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. - * - * @throws \Behat\Mink\Exception\ExpectationException - * Thrown when element doesn't exist, or the link label is a different one. - */ - public function linkByHrefExists($href, $index = 0, $message = '') { - // Cast MarkupInterface objects to string. - $xpath = $this->buildXPathQuery('//a[contains(@href, :href)]', [':href' => $href]); - $message = ($message ? $message : strtr('Link containing href %href found.', ['%href' => $href])); - $links = $this->session->getPage()->findAll('xpath', $xpath); - if (empty($links[$index])) { - throw new ExpectationException($message); - } - $this->assert($links[$index] !== NULL, $message); - } - - /** - * Passes if a link containing a given href (part) is not found. - * - * @param string $href - * The full or partial value of the 'href' attribute of the anchor tag. - * @param int $index - * Link position counting from zero. - * @param string $message - * (optional) A message to display with the assertion. Do not translate - * 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. - * - * @throws \Behat\Mink\Exception\ExpectationException - * Thrown when element doesn't exist, or the link label is a different one. - */ - public function linkByHrefNotExists($href, $index = 0, $message = '') { - // Cast MarkupInterface objects to string. - $xpath = $this->buildXPathQuery('//a[contains(@href, :href)]', [':href' => $href]); - $message = ($message ? $message : strtr('Link containing href %href found.', ['%href' => $href])); - $links = $this->session->getPage()->findAll('xpath', $xpath); - if (!empty($links[$index])) { - throw new ExpectationException($message); - } - else { - $this->assert(TRUE, $message); - } - } - - /** - * Builds an XPath query. - * - * Builds an XPath query by replacing placeholders in the query by the value - * of the arguments. - * - * XPath 1.0 (the version supported by libxml2, the underlying XML library - * used by PHP) doesn't support any form of quotation. This function - * simplifies the building of XPath expression. - * - * @param string $xpath - * An XPath query, possibly with placeholders in the form ':name'. - * @param array $args - * An array of arguments with keys in the form ':name' matching the - * placeholders in the query. The values may be either strings or numeric - * values. - * - * @return string - * An XPath query with arguments replaced. - */ - public function buildXPathQuery($xpath, array $args = array()) { - // Replace placeholders. - foreach ($args as $placeholder => $value) { - // Cast MarkupInterface objects to string. - if (is_object($value)) { - $value = (string) $value; - } - // XPath 1.0 doesn't support a way to escape single or double quotes in a - // string literal. We split double quotes out of the string, and encode - // them separately. - if (is_string($value)) { - // Explode the text at the quote characters. - $parts = explode('"', $value); - - // Quote the parts. - foreach ($parts as &$part) { - $part = '"' . $part . '"'; - } - - // Return the string. - $value = count($parts) > 1 ? 'concat(' . implode(', \'"\', ', $parts) . ')' : $parts[0]; - } - - // Use preg_replace_callback() instead of preg_replace() to prevent the - // regular expression engine from trying to substitute backreferences. - $replacement = function ($matches) use ($value) { - return $value; - }; - $xpath = preg_replace_callback('/' . preg_quote($placeholder) . '\b/', $replacement, $xpath); - } - return $xpath; - } - - /** * Passes if the raw text IS NOT found escaped on the loaded page. * * Raw text refers to the raw HTML that the page generated.