function FilterFormTest::assertOptions
Same name in other branches
- 8.9.x core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::assertOptions()
- 10 core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::assertOptions()
- 11.x core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::assertOptions()
Asserts that a select element has the correct options.
@internal
Parameters
string $id: The HTML ID of the select element.
array $expected_options: An array of option values.
string $selected: The value of the selected option.
3 calls to FilterFormTest::assertOptions()
- FilterFormTest::assertRequiredSelectAndOptions in core/
modules/ filter/ tests/ src/ Functional/ FilterFormTest.php - Asserts that there is a select element with the given ID that is required.
- FilterFormTest::doFilterFormTestAsAdmin in core/
modules/ filter/ tests/ src/ Functional/ FilterFormTest.php - Tests the behavior of the 'text_format' element as an administrator.
- FilterFormTest::doFilterFormTestAsNonAdmin in core/
modules/ filter/ tests/ src/ Functional/ FilterFormTest.php - Tests the behavior of the 'text_format' element as a normal user.
File
-
core/
modules/ filter/ tests/ src/ Functional/ FilterFormTest.php, line 197
Class
- FilterFormTest
- Tests form elements with associated text formats.
Namespace
Drupal\Tests\filter\FunctionalCode
protected function assertOptions(string $id, array $expected_options, string $selected) : void {
$select = $this->assertSession()
->selectExists($id);
$found_options = $select->findAll('css', 'option');
$found_options = array_map(function ($item) {
return $item->getValue();
}, $found_options);
$this->assertEqualsCanonicalizing($expected_options, $found_options);
$this->assertTrue($this->assertSession()
->optionExists($id, $selected)
->isSelected());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.