function ManageDisplayTest::assertFieldSelectOptions
Same name in this branch
- 11.x core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageDisplayTest::assertFieldSelectOptions()
Same name in other branches
- 9 core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageDisplayTest::assertFieldSelectOptions()
- 9 core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php \Drupal\Tests\field_ui\Functional\ManageDisplayTest::assertFieldSelectOptions()
- 8.9.x core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageDisplayTest::assertFieldSelectOptions()
- 8.9.x core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php \Drupal\Tests\field_ui\Functional\ManageDisplayTest::assertFieldSelectOptions()
- 10 core/modules/field_ui/tests/src/FunctionalJavascript/ManageDisplayTest.php \Drupal\Tests\field_ui\FunctionalJavascript\ManageDisplayTest::assertFieldSelectOptions()
- 10 core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php \Drupal\Tests\field_ui\Functional\ManageDisplayTest::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.
File
-
core/
modules/ field_ui/ tests/ src/ Functional/ ManageDisplayTest.php, line 375
Class
- ManageDisplayTest
- Tests the Field UI "Manage display" and "Manage form display" screens.
Namespace
Drupal\Tests\field_ui\FunctionalCode
protected function assertFieldSelectOptions(string $name, array $expected_options) : void {
$xpath = $this->assertSession()
->buildXPathQuery('//select[@name=:name]', [
':name' => $name,
]);
$fields = $this->xpath($xpath);
if ($fields) {
$field = $fields[0];
$options = $this->getAllOptionsList($field);
sort($options);
sort($expected_options);
$this->assertSame($expected_options, $options);
}
else {
$this->fail('Unable to find field ' . $name);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.