### Eclipse Workspace Patch 1.0 #P simpletest Index: drupal_test_case.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/drupal_test_case.php,v retrieving revision 1.85 diff -u -r1.85 drupal_test_case.php --- drupal_test_case.php 10 Apr 2008 00:39:01 -0000 1.85 +++ drupal_test_case.php 14 Apr 2008 04:15:17 -0000 @@ -612,7 +612,8 @@ $new_value = $edit[$name]; $index = 0; $key = preg_replace('/\[\]$/', '', $name); - foreach ($element->option as $option) { + $options = $this->getAllOptions($element); + foreach ($options as $option) { if (is_array($new_value)) { $option_value= (string)$option['value']; if (in_array($option_value, $new_value)) { @@ -644,7 +645,8 @@ $first = TRUE; $index = 0; $key = preg_replace('/\[\]$/', '', $name); - foreach ($element->option as $option) { + $options = $this->getAllOptions($element); + foreach ($options as $option) { // For single select, we load the first option, if there is a // selected option that will overwrite it later. if ($option['selected'] || ($first && $single)) { @@ -682,6 +684,26 @@ } /** + * Get all option elements, including nested options, in a select. + * + * @param SimpleXMLElement $element + * @return array Option elements in select. + */ + private 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)) { + $options = array_merge($options, $this->getAllOptions($element->optgroup)); + } + return $options; + } + + /** * Follows a link by name. * * Will click the first link found with this link text by default, or a