summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/drupal_web_test_case.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 98f4445ba..05d4e5828 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -1764,6 +1764,46 @@ class DrupalWebTestCase extends DrupalTestCase {
}
/**
+ * Pass if a link containing a given href (part) is found.
+ *
+ * @param $href
+ * The full or partial value of the 'href' attribute of the anchor tag.
+ * @param $index
+ * Link position counting from zero.
+ * @param $message
+ * Message to display.
+ * @param $group
+ * The group this message belongs to, defaults to 'Other'.
+ *
+ * @return
+ * TRUE if the assertion succeeded, FALSE otherwise.
+ */
+ protected function assertLinkByHref($href, $index = 0, $message = '', $group = 'Other') {
+ $links = $this->xpath('//a[contains(@href, "' . $href . '")]');
+ $message = ($message ? $message : t('Link containing href %href found.', array('%href' => $href)));
+ return $this->assert(isset($links[$index]), $message, $group);
+ }
+
+ /**
+ * Pass if a link containing a given href (part) is not found.
+ *
+ * @param $href
+ * The full or partial value of the 'href' attribute of the anchor tag.
+ * @param $message
+ * Message to display.
+ * @param $group
+ * The group this message belongs to, defaults to 'Other'.
+ *
+ * @return
+ * TRUE if the assertion succeeded, FALSE otherwise.
+ */
+ protected function assertNoLinkByHref($href, $message = '', $group = 'Other') {
+ $links = $this->xpath('//a[contains(@href, "' . $href . '")]');
+ $message = ($message ? $message : t('No link containing href %href found.', array('%href' => $href)));
+ return $this->assert(empty($links), $message, $group);
+ }
+
+ /**
* Follows a link by name.
*
* Will click the first link found with this link text by default, or a