You are here

protected function ManageDisplayTest::assertFieldSelectOptions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field_ui/src/Tests/ManageDisplayTest.php \Drupal\field_ui\Tests\ManageDisplayTest::assertFieldSelectOptions()

Checks if a select element contains the specified options.

Parameters

string $name: The field name.

array $expected_options: An array of expected options.

Return value

bool TRUE if the assertion succeeded, FALSE otherwise.

1 call to ManageDisplayTest::assertFieldSelectOptions()
ManageDisplayTest::testWidgetUI in core/modules/field_ui/src/Tests/ManageDisplayTest.php
Tests widget settings.

File

core/modules/field_ui/src/Tests/ManageDisplayTest.php, line 502
Contains \Drupal\field_ui\Tests\ManageDisplayTest.

Class

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

Namespace

Drupal\field_ui\Tests

Code

protected function assertFieldSelectOptions($name, array $expected_options) {
  $xpath = $this
    ->buildXPathQuery('//select[@name=:name]', array(
    ':name' => $name,
  ));
  $fields = $this
    ->xpath($xpath);
  if ($fields) {
    $field = $fields[0];
    $options = $this
      ->getAllOptionsList($field);
    sort($options);
    sort($expected_options);
    return $this
      ->assertIdentical($options, $expected_options);
  }
  else {
    return $this
      ->fail('Unable to find field ' . $name);
  }
}