From 8514a7e283b65f1085e0f3a96e1e701157532e88 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 14 Nov 2009 07:58:50 +0000 Subject: - Patch #301902 by TheRec, beeradb, catch, sun, skilip, alpritt, JacobSingh, Senpai: usability improvement: allow more users to see the node admin page. --- modules/simpletest/drupal_web_test_case.php | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'modules/simpletest') 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 @@ -1763,6 +1763,46 @@ class DrupalWebTestCase extends DrupalTestCase { return $this->assert(empty($links), $message, $group); } + /** + * 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. * -- cgit v1.2.3