protected function AssertLegacyTrait::assertOptionSelected in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php \Drupal\FunctionalTests\AssertLegacyTrait::assertOptionSelected()
Asserts that a select option in the current page is checked.
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 with t(). If left blank, a default message will be displayed.
Deprecated
in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->optionExists() instead and check the "selected" attribute yourself.
See also
https://www.drupal.org/node/3129738
2 calls to AssertLegacyTrait::assertOptionSelected()
- AssertLegacyTraitTest::testAssertOptionSelected in core/tests/ Drupal/ Tests/ Core/ Assert/ AssertLegacyTraitTest.php 
- @covers ::assertOptionSelected
- AssertLegacyTraitTest::testAssertOptionSelectedFail in core/tests/ Drupal/ Tests/ Core/ Assert/ AssertLegacyTraitTest.php 
- @covers ::assertOptionSelected
File
- core/tests/ Drupal/ FunctionalTests/ AssertLegacyTrait.php, line 617 
Class
- AssertLegacyTrait
- Provides convenience methods for assertions in browser tests.
Namespace
Drupal\FunctionalTestsCode
protected function assertOptionSelected($id, $option, $message = NULL) {
  @trigger_error('AssertLegacyTrait::assertOptionSelected() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->optionExists() instead and check the "selected" attribute. See https://www.drupal.org/node/3129738', E_USER_DEPRECATED);
  $option_field = $this
    ->assertSession()
    ->optionExists($id, $option);
  $message = $message ?: "Option {$option} for field {$id} is selected.";
  $this
    ->assertTrue($option_field
    ->hasAttribute('selected'), $message);
}