protected function FilterFormTest::assertOptions in Drupal 9
Same name and namespace in other branches
- 8 core/modules/filter/tests/src/Functional/FilterFormTest.php \Drupal\Tests\filter\Functional\FilterFormTest::assertOptions()
Asserts that a select element has the correct options.
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.
Return value
bool TRUE if the assertion passed; FALSE otherwise.
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 196
Class
- FilterFormTest
- Tests form elements with associated text formats.
Namespace
Drupal\Tests\filter\FunctionalCode
protected function assertOptions($id, array $expected_options, $selected) {
$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());
}