You are here

protected function FilterFormTest::assertRequiredSelectAndOptions in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/filter/src/Tests/FilterFormTest.php \Drupal\filter\Tests\FilterFormTest::assertRequiredSelectAndOptions()

Asserts that there is a select element with the given ID that is required.

Parameters

string $id: The HTML ID of the select element.

array $options: An array of option values that are contained in the select element besides the "- Select -" option.

Return value

bool TRUE if the assertion passed; FALSE otherwise.

1 call to FilterFormTest::assertRequiredSelectAndOptions()
FilterFormTest::doFilterFormTestAsAdmin in core/modules/filter/src/Tests/FilterFormTest.php
Tests the behavior of the 'text_format' element as an administrator.

File

core/modules/filter/src/Tests/FilterFormTest.php, line 256
Contains \Drupal\filter\Tests\FilterFormTest.

Class

FilterFormTest
Tests form elements with associated text formats.

Namespace

Drupal\filter\Tests

Code

protected function assertRequiredSelectAndOptions($id, array $options) {
  $select = $this
    ->xpath('//select[@id=:id and contains(@required, "required")]', array(
    ':id' => $id,
  ));
  $select = reset($select);
  $passed = $this
    ->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Required field @id exists.', array(
    '@id' => $id,
  )));

  // A required select element has a "- Select -" option whose key is an empty
  // string.
  $options[] = '';
  return $passed && $this
    ->assertOptions($id, $options, '');
}