protected function DrupalWebTestCase::getSelectedItem

Get the selected value from a select field.

Parameters

$element: SimpleXMLElement select element.

Return value

The selected value or FALSE.

2 calls to DrupalWebTestCase::getSelectedItem()
DrupalWebTestCase::assertFieldByXPath in drupal-7.x/modules/simpletest/drupal_web_test_case.php
Asserts that a field exists in the current page by the given XPath.
DrupalWebTestCase::assertFieldByXPath in drupal-7.x/modules/simpletest/drupal_web_test_case.php
Asserts that a field exists in the current page by the given XPath.

Archivo

drupal-7.x/modules/simpletest/drupal_web_test_case.php, line 3246

Class

DrupalWebTestCase
Test case for typical Drupal tests.

Código

protected function getSelectedItem(SimpleXMLElement $element) {
  foreach ($element->children() as $item) {
    if (isset($item['selected'])) {
      return $item['value'];
    }
    elseif ($item->getName() == 'optgroup') {
      if ($value = $this->getSelectedItem($item)) {
        return $value;
      }
    }
  }
  return FALSE;
}