You are here

protected function EntityReferenceAdminTest::assertFieldSelectOptions in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php \Drupal\field\Tests\EntityReference\EntityReferenceAdminTest::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.

2 calls to EntityReferenceAdminTest::assertFieldSelectOptions()
EntityReferenceAdminTest::testAvailableFormatters in core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
Tests the formatters for the Entity References.
EntityReferenceAdminTest::testFieldAdminHandler in core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php
Tests the Entity Reference Admin UI.

File

core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php, line 430
Contains \Drupal\field\Tests\EntityReference\EntityReferenceAdminTest.

Class

EntityReferenceAdminTest
Tests for the administrative UI.

Namespace

Drupal\field\Tests\EntityReference

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