summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-11-01 20:22:40 -0400
committerDavid Rothstein <drothstein@gmail.com>2014-11-01 20:22:40 -0400
commit49a51c70b8dc6417999ed1b99bcae3bcb58a6449 (patch)
treeec844dea6442904088d8d808b9e5041be07441ea /modules/simpletest
parent6b47cbf7d0aa4b0ad3b249a3e16d023fac0b140a (diff)
downloadbrdo-49a51c70b8dc6417999ed1b99bcae3bcb58a6449.tar.gz
brdo-49a51c70b8dc6417999ed1b99bcae3bcb58a6449.tar.bz2
Issue #1452896 by Mile23, marthinal, Freso, kid_icarus, joshi.rohit100, alexpott, tim.plunkett, jhodgdon: Fixed PHP notice in clickLink if link does not exist.
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/drupal_web_test_case.php14
1 files changed, 6 insertions, 8 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index a46e171dd..2a5aae8a9 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -2682,28 +2682,26 @@ class DrupalWebTestCase extends DrupalTestCase {
*
* Will click the first link found with this link text by default, or a later
* one if an index is given. Match is case sensitive with normalized space.
- * The label is translated label. There is an assert for successful click.
+ * The label is translated label.
+ *
+ * If the link is discovered and clicked, the test passes. Fail otherwise.
*
* @param $label
* Text between the anchor tags.
* @param $index
* Link position counting from zero.
* @return
- * Page on success, or FALSE on failure.
+ * Page contents on success, or FALSE on failure.
*/
protected function clickLink($label, $index = 0) {
$url_before = $this->getUrl();
$urls = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
-
if (isset($urls[$index])) {
$url_target = $this->getAbsoluteUrl($urls[$index]['href']);
- }
-
- $this->assertTrue(isset($urls[$index]), t('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), t('Browser'));
-
- if (isset($url_target)) {
+ $this->pass(t('Clicked link %label (@url_target) from @url_before', array('%label' => $label, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser');
return $this->drupalGet($url_target);
}
+ $this->fail(t('Link %label does not exist on @url_before', array('%label' => $label, '@url_before' => $url_before)), 'Browser');
return FALSE;
}