protected function DrupalWebTestCase::getAllOptions in Drupal 7
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 modules/
simpletest/ drupal_web_test_case.php - Asserts that a field exists in the current page by the given XPath.
- DrupalWebTestCase::handleForm in modules/
simpletest/ 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
- modules/
simpletest/ drupal_web_test_case.php, line 2880
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;
}