protected function DrupalWebTestCase::assertOptionSelected
7.x drupal_web_test_case.php | protected DrupalWebTestCase::assertOptionSelected($id, $option, $message = '') |
Asserts that a select option in the current page is checked.
@todo $id is unusable. Replace with $name.
Parameters
$id: Id of select field to assert.
$option: Option to assert.
$message: Message to display.
Return value
TRUE on pass, FALSE on fail.
4 calls to DrupalWebTestCase::assertOptionSelected()
- FormsTestCase::testRequiredCheckboxesRadio in drupal-7.x/
modules/ simpletest/ tests/ form.test - Tests validation for required checkbox, select, and radio elements.
- MenuNodeTestCase::testMenuNodeFormWidget in drupal-7.x/
modules/ menu/ menu.test - Test creating, editing, deleting menu links via node form widget.
- OptionsWidgetsTestCase::testSelectListMultiple in drupal-7.x/
modules/ field/ modules/ options/ options.test - Tests the 'options_select' widget (multiple select).
- OptionsWidgetsTestCase::testSelectListSingle in drupal-7.x/
modules/ field/ modules/ options/ options.test - Tests the 'options_select' widget (single select).
File
- drupal-7.x/
modules/ simpletest/ drupal_web_test_case.php, line 3442
Class
- DrupalWebTestCase
- Test case for typical Drupal tests.
Code
protected function assertOptionSelected($id, $option, $message = '') {
$elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : t('Option @option for field @id is selected.', array('@option' => $option, '@id' => $id)), t('Browser'));
}