Security update for Core, with self-updated composer
[yaffs-website] / web / core / tests / Drupal / Tests / WebAssert.php
index ea425178188e957c07381281afabcf02427c8955..81495517005b24042a5f4b80631b874efc42715b 100644 (file)
@@ -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);