- Patch #297894 by boombatower: two new asserts for link checking.
parent
71f0176beb
commit
5dee24e73f
|
@ -1112,6 +1112,43 @@ class DrupalWebTestCase {
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Follows a link by name.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue