You are here

protected function AssertContentTrait::getAllOptions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/AssertContentTrait.php \Drupal\simpletest\AssertContentTrait::getAllOptions()

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

Parameters

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

Return value

\SimpleXmlElement[] Option elements in select.

6 calls to AssertContentTrait::getAllOptions()
AssertContentTrait::assertFieldsByValue in core/modules/simpletest/src/AssertContentTrait.php
Asserts that a field exists in the current page with a given Xpath result.
ConfigSingleImportExportTest::testExport in core/modules/config/src/Tests/ConfigSingleImportExportTest.php
Tests exporting a single configuration file.
FilterFormTest::assertOptions in core/modules/filter/src/Tests/FilterFormTest.php
Asserts that a select element has the correct options.
HandlerTest::testRelationshipUI in core/modules/views/src/Tests/Handler/HandlerTest.php
Tests the relationship ui for field/filter/argument/relationship.
WebTestBase::handleForm in core/modules/simpletest/src/WebTestBase.php
Handles form input related to drupalPostForm().

... See full list

File

core/modules/simpletest/src/AssertContentTrait.php, line 267
Contains \Drupal\simpletest\AssertContentTrait.

Class

AssertContentTrait
Provides test methods to assert content.

Namespace

Drupal\simpletest

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