summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-08-23 07:42:54 +0000
committerDries Buytaert <dries@buytaert.net>2008-08-23 07:42:54 +0000
commit5dee24e73fbd1e735c4e31232ca321ff53462ab1 (patch)
tree57d1b5d01f51d3889e7e22b024bee85f69dc01af /modules
parent71f0176bebd95e98e1704ee920b45862d1d125e3 (diff)
downloadbrdo-5dee24e73fbd1e735c4e31232ca321ff53462ab1.tar.gz
brdo-5dee24e73fbd1e735c4e31232ca321ff53462ab1.tar.bz2
- Patch #297894 by boombatower: two new asserts for link checking.
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/drupal_web_test_case.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index dbb35b49c..ae8121880 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -1113,6 +1113,43 @@ class DrupalWebTestCase {
}
/**
+ * Pass if a link with the specified label is found, and optional with the
+ * specified index.
+ *
+ * @param $label
+ * Text between the anchor tags.
+ * @param $index
+ * Link position counting from zero.
+ * @param $message
+ * Message to display.
+ * @param $group
+ * The group this message belongs to, defaults to 'Other'.
+ */
+ public function assertLink($label, $index = 0, $message = '', $group = 'Other') {
+ $links = $this->xpath('//a[text()="' . $label . '"]');
+ $message = ($message ? $message : t('Link with label "!label" found.', array('!label' => $label)));
+ $this->_assert(isset($links[$index]), $message, $group);
+ }
+
+ /**
+ * Pass if a link with the specified label is not found.
+ *
+ * @param $label
+ * Text between the anchor tags.
+ * @param $index
+ * Link position counting from zero.
+ * @param $message
+ * Message to display.
+ * @param $group
+ * The group this message belongs to, defaults to 'Other'.
+ */
+ public function assertNoLink($label, $message = '', $group = 'Other') {
+ $links = $this->xpath('//a[text()="' . $label . '"]');
+ $message = ($message ? $message : t('Link with label "!label" not found.', array('!label' => $label)));
+ $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