diff --git a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php index 33eea7f..c57bc94 100644 --- a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php @@ -207,8 +207,6 @@ protected function assertLink($label, $index = 0) { /** * 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. * @@ -239,14 +237,12 @@ protected function assertLinkByHref($href, $index = 0) { * * @param string $href * The full or partial value of the 'href' attribute of the anchor tag. - * @param int $index - * Link position counting from zero. * * @deprecated Scheduled for removal in Drupal 9.0.0. * Use $this->assertSession()->linkByHrefNotExists() instead. */ - protected function assertNoLinkByHref($href, $index = 0) { - $this->assertSession()->linkByHrefNotExists($href, $index); + protected function assertNoLinkByHref($href) { + $this->assertSession()->linkByHrefNotExists($href); } /** diff --git a/core/tests/Drupal/Tests/WebAssert.php b/core/tests/Drupal/Tests/WebAssert.php index 972d086..c0744a8 100644 --- a/core/tests/Drupal/Tests/WebAssert.php +++ b/core/tests/Drupal/Tests/WebAssert.php @@ -8,6 +8,7 @@ use Behat\Mink\Exception\ElementNotFoundException; use Behat\Mink\Session; use Drupal\Component\Utility\Html; +use Drupal\Core\Url; /** * Defines a class with methods for asserting presence of elements during tests. @@ -38,6 +39,9 @@ public function __construct(Session $session, $base_url = '') { * {@inheritdoc} */ protected function cleanUrl($url) { + if ($url instanceof Url) { + $url = $url->setAbsolute()->toString(); + } // Strip the base URL from the beginning for absolute URLs. if ($this->baseUrl !== '' && strpos($url, $this->baseUrl) === 0) { $url = substr($url, strlen($this->baseUrl)); @@ -191,7 +195,7 @@ public function titleEquals($expected_title) { * * An optional link index may be passed. * - * @param string|\Drupal\Component\Render\MarkupInterface $label + * @param string $label * Text between the anchor tags. * @param int $index * Link position counting from zero. @@ -204,8 +208,6 @@ public function titleEquals($expected_title) { * Thrown when element doesn't exist, or the link label is a different one. */ public function linkExists($label, $index = 0, $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]); $this->assert(!empty($links[$index]), $message); @@ -216,7 +218,7 @@ public function linkExists($label, $index = 0, $message = '') { * * An optional link index may be passed. * - * @param string|\Drupal\Component\Render\MarkupInterface $label + * @param string $label * Text between the anchor tags. * @param string $message * (optional) A message to display with the assertion. Do not translate @@ -233,13 +235,6 @@ public function linkNotExists($label, $message = '') { } /** - * {@inheritdoc} - */ - public function fieldValueEquals($field, $value, TraversableElement $container = NULL) { - parent::fieldValueEquals($field, $value, $container); - } - - /** * Passes if a link containing a given href (part) is found. * * @param string $href @@ -267,8 +262,6 @@ public function linkByHrefExists($href, $index = 0, $message = '') { * * @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 @@ -278,12 +271,11 @@ public function linkByHrefExists($href, $index = 0, $message = '') { * @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. + public function linkByHrefNotExists($href, $message = '') { $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); - $this->assert(empty($links[$index]), $message); + $this->assert(empty($links), $message); } /** @@ -309,7 +301,6 @@ public function linkByHrefNotExists($href, $index = 0, $message = '') { public function buildXPathQuery($xpath, array $args = array()) { // Replace placeholders. foreach ($args as $placeholder => $value) { - // Cast MarkupInterface objects to string. if (is_object($value)) { throw new \InvalidArgumentException('Just pass in scalar values.'); }