function FilterFormTest::assertRequiredSelectAndOptions

Same name in other branches
  1. 8.9.x core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::assertRequiredSelectAndOptions()
  2. 10 core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::assertRequiredSelectAndOptions()
  3. 11.x core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::assertRequiredSelectAndOptions()

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

@internal

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.

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

File

core/modules/filter/tests/src/Functional/FilterFormTest.php, line 218

Class

FilterFormTest
Tests form elements with associated text formats.

Namespace

Drupal\Tests\filter\Functional

Code

protected function assertRequiredSelectAndOptions(string $id, array $options) : void {
    $select = $this->assertSession()
        ->selectExists($id);
    $this->assertSame('required', $select->getAttribute('required'));
    // A required select element has a "- Select -" option whose key is an empty
    // string.
    $options[] = '';
    $this->assertOptions($id, $options, '');
}

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