X-Git-Url: https://yaffs.net/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Ftests%2FDrupal%2FTests%2FWebAssert.php;fp=web%2Fcore%2Ftests%2FDrupal%2FTests%2FWebAssert.php;h=81495517005b24042a5f4b80631b874efc42715b;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=ea425178188e957c07381281afabcf02427c8955;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/tests/Drupal/Tests/WebAssert.php b/web/core/tests/Drupal/Tests/WebAssert.php index ea4251781..814955170 100644 --- a/web/core/tests/Drupal/Tests/WebAssert.php +++ b/web/core/tests/Drupal/Tests/WebAssert.php @@ -231,6 +231,29 @@ class WebAssert extends MinkWebAssert { $this->assert(!empty($links[$index]), $message); } + /** + * Passes if a link with the exactly specified label is found. + * + * An optional link index may be passed. + * + * @param string $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 linkExistsExact($label, $index = 0, $message = '') { + $message = ($message ? $message : strtr('Link with label %label found.', ['%label' => $label])); + $links = $this->session->getPage()->findAll('named_exact', ['link', $label]); + $this->assert(!empty($links[$index]), $message); + } + /** * Passes if a link with the specified label is not found. * @@ -252,6 +275,27 @@ class WebAssert extends MinkWebAssert { $this->assert(empty($links), $message); } + /** + * Passes if a link with the exactly specified label is not found. + * + * An optional link index may be passed. + * + * @param string $label + * Text between the anchor tags. + * @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 linkNotExistsExact($label, $message = '') { + $message = ($message ? $message : strtr('Link with label %label not found.', ['%label' => $label])); + $links = $this->session->getPage()->findAll('named_exact', ['link', $label]); + $this->assert(empty($links), $message); + } + /** * Passes if a link containing a given href (part) is found. * @@ -407,7 +451,7 @@ class WebAssert extends MinkWebAssert { * @throws \Behat\Mink\Exception\ElementNotFoundException * @throws \Behat\Mink\Exception\ExpectationException */ - public function fieldDisabled($field, TraversableElement $container = NULL) { + public function fieldDisabled($field, TraversableElement $container = NULL) { $container = $container ?: $this->session->getPage(); $node = $container->findField($field);