function EntityReferenceAdminTest::assertFieldSelectOptions
Same name in this branch
- 10 core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php \Drupal\Tests\field\Functional\EntityReference\EntityReferenceAdminTest::assertFieldSelectOptions()
Same name in other branches
- 9 core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php \Drupal\Tests\field\FunctionalJavascript\EntityReference\EntityReferenceAdminTest::assertFieldSelectOptions()
- 9 core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php \Drupal\Tests\field\Functional\EntityReference\EntityReferenceAdminTest::assertFieldSelectOptions()
- 8.9.x core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php \Drupal\Tests\field\FunctionalJavascript\EntityReference\EntityReferenceAdminTest::assertFieldSelectOptions()
- 8.9.x core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php \Drupal\Tests\field\Functional\EntityReference\EntityReferenceAdminTest::assertFieldSelectOptions()
- 11.x core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php \Drupal\Tests\field\FunctionalJavascript\EntityReference\EntityReferenceAdminTest::assertFieldSelectOptions()
- 11.x core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAdminTest.php \Drupal\Tests\field\Functional\EntityReference\EntityReferenceAdminTest::assertFieldSelectOptions()
Checks if a select element contains the specified options.
@internal
Parameters
string $name: The field name.
array $expected_options: An array of expected options.
1 call to EntityReferenceAdminTest::assertFieldSelectOptions()
- EntityReferenceAdminTest::testFieldAdminHandler in core/
modules/ field/ tests/ src/ FunctionalJavascript/ EntityReference/ EntityReferenceAdminTest.php - Tests the Entity Reference Admin UI.
File
-
core/
modules/ field/ tests/ src/ FunctionalJavascript/ EntityReference/ EntityReferenceAdminTest.php, line 352
Class
- EntityReferenceAdminTest
- Tests for the administrative UI.
Namespace
Drupal\Tests\field\FunctionalJavascript\EntityReferenceCode
protected function assertFieldSelectOptions(string $name, array $expected_options) : void {
$field = $this->assertSession()
->selectExists($name);
$options = $field->findAll('xpath', 'option');
$optgroups = $field->findAll('xpath', 'optgroup');
$nested_options = [];
foreach ($optgroups as $optgroup) {
$nested_options[] = $optgroup->findAll('xpath', 'option');
}
$options = array_merge($options, ...$nested_options);
array_walk($options, function (NodeElement &$option) {
$option = $option->getAttribute('value');
});
$this->assertEqualsCanonicalizing($expected_options, $options);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.