You are here

protected function DrupalWebTestCase::getAllOptions in SimpleTest 7

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

Get all option elements, including nested options, in a select.

Parameters

$element: The element for which to get the options.

Return value

Option elements in select.

2 calls to DrupalWebTestCase::getAllOptions()
DrupalWebTestCase::assertFieldByXPath in ./drupal_web_test_case.php
Assert that a field exists in the current page by the given XPath.
DrupalWebTestCase::handleForm in ./drupal_web_test_case.php
Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type.

File

./drupal_web_test_case.php, line 1707

Class

DrupalWebTestCase
Test case for typical Drupal tests.

Code

protected function getAllOptions(SimpleXMLElement $element) {
  $options = array();

  // Add all options items.
  foreach ($element->option as $option) {
    $options[] = $option;
  }

  // Search option group children.
  if (isset($element->optgroup)) {
    foreach ($element->optgroup as $group) {
      $options = array_merge($options, $this
        ->getAllOptions($group));
    }
  }
  return $options;
}