Commit 22078d27 authored by Dries's avatar Dries
Browse files

- Patch #1413888 by anrikun, sun: Move function assertNoOption() from...

- Patch #1413888 by anrikun, sun: Move function assertNoOption() from menu.test to simpletest drupal_web_test_case().php.
parent b55fc012
......@@ -701,24 +701,4 @@ class MenuNodeTestCase extends DrupalWebTestCase {
// Assert that unallowed Management menu is not available in options.
$this->assertNoOption('edit-menu-parent', 'management:0');
}
/**
* Asserts that a select option in the current page does not exist.
*
* @param $id
* Id of select field to assert.
* @param $option
* Option to assert.
* @param $message
* Message to display.
* @return
* TRUE on pass, FALSE on fail.
*
* @todo move to simpletest drupal_web_test_case.php.
*/
protected function assertNoOption($id, $option, $message = '') {
$selects = $this->xpath('//select[@id=:id]', array(':id' => $id));
$options = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : t('Option @option for field @id does not exist.', array('@option' => $option, '@id' => $id)), t('Browser'));
}
}
......@@ -3249,6 +3249,41 @@ protected function assertNoFieldChecked($id, $message = '') {
return $this->assertTrue(isset($elements[0]) && empty($elements[0]['checked']), $message ? $message : t('Checkbox field @id is not checked.', array('@id' => $id)), t('Browser'));
}
/**
* Asserts that a select option in the current page exists.
*
* @param $id
* Id of select field to assert.
* @param $option
* Option to assert.
* @param $message
* Message to display.
* @return
* TRUE on pass, FALSE on fail.
*/
protected function assertOption($id, $option, $message = '') {
$options = $this->xpath('//select[@id=:id]/option[@value=:option]', array(':id' => $id, ':option' => $option));
return $this->assertTrue(isset($options[0]), $message ? $message : t('Option @option for field @id exists.', array('@option' => $option, '@id' => $id)), t('Browser'));
}
/**
* Asserts that a select option in the current page does not exist.
*
* @param $id
* Id of select field to assert.
* @param $option
* Option to assert.
* @param $message
* Message to display.
* @return
* TRUE on pass, FALSE on fail.
*/
protected function assertNoOption($id, $option, $message = '') {
$selects = $this->xpath('//select[@id=:id]', array(':id' => $id));
$options = $this->xpath('//select[@id=:id]/option[@value=:option]', array(':id' => $id, ':option' => $option));
return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : t('Option @option for field @id does not exist.', array('@option' => $option, '@id' => $id)), t('Browser'));
}
/**
* Asserts that a select option in the current page is checked.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment