You are here

protected function DrupalWebTestCase::assertOptionSelected in SimpleTest 6.2

Same name and namespace in other branches
  1. 7.2 drupal_web_test_case.php \DrupalWebTestCase::assertOptionSelected()

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.

File

./drupal_web_test_case.php, line 2870

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'));
}