function ManageDisplayTest::getAllOptionsList

Same name and namespace in other branches
  1. 8.9.x core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php \Drupal\Tests\field_ui\Functional\ManageDisplayTest::getAllOptionsList()
  2. 10 core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php \Drupal\Tests\field_ui\Functional\ManageDisplayTest::getAllOptionsList()
  3. 11.x core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php \Drupal\Tests\field_ui\Functional\ManageDisplayTest::getAllOptionsList()

Extracts all options from a select element.

Parameters

Behat\Mink\Element\NodeElement $element: The select element field information.

Return value

array An array of option values as strings.

1 call to ManageDisplayTest::getAllOptionsList()
ManageDisplayTest::assertFieldSelectOptions in core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
Checks if a select element contains the specified options.

File

core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php, line 339

Class

ManageDisplayTest
Tests the Field UI "Manage display" and "Manage form display" screens.

Namespace

Drupal\Tests\field_ui\Functional

Code

protected function getAllOptionsList(NodeElement $element) {
    $options = [];
    // Add all options items.
    foreach ($element->option as $option) {
        $options[] = $option->getValue();
    }
    // Loops trough all the option groups
    foreach ($element->optgroup as $optgroup) {
        $options = array_merge($this->getAllOptionsList($optgroup), $options);
    }
    return $options;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.