protected function AddressDefaultWidgetTest::assertOptionSelected in Address 8
Asserts that a select field has a selected option.
Parameters
string $id: ID of select field to assert.
string $option: Option to assert.
string $message: (optional) A message to display with the assertion. Do not translate messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed variables in the message text, not t(). If left blank, a default message will be displayed.
Overrides AssertLegacyTrait::assertOptionSelected
2 calls to AddressDefaultWidgetTest::assertOptionSelected()
- AddressDefaultWidgetTest::testCountries in tests/
src/ FunctionalJavascript/ AddressDefaultWidgetTest.php - Tests the country field.
- AddressDefaultWidgetTest::testSubdivisions in tests/
src/ FunctionalJavascript/ AddressDefaultWidgetTest.php - Tests the presence of subdivision dropdowns where expected.
File
- tests/
src/ FunctionalJavascript/ AddressDefaultWidgetTest.php, line 540
Class
- AddressDefaultWidgetTest
- Tests the default address widget.
Namespace
Drupal\Tests\address\FunctionalJavascriptCode
protected function assertOptionSelected($id, $option, $message = '') {
$elements = $this
->xpath('//select[@name=:id]//option[@value=:option]', [
':id' => $id,
':option' => $option,
]);
foreach ($elements as $element) {
$this
->assertNotEmpty($element
->isSelected(), $message ? $message : new FormattableMarkup('Option @option for field @id is selected.', [
'@option' => $option,
'@id' => $id,
]));
}
}