Issue #2862470 by Jo Fitzgerald, klausi: Add assertOptionByText() to AssertLegacyTrait for better browser test compatibility
parent
fce944dd69
commit
458de4e53b
core/tests/Drupal/FunctionalTests
|
@ -451,6 +451,21 @@ trait AssertLegacyTrait {
|
|||
return $this->assertSession()->optionExists($id, $option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a select option with the visible text exists.
|
||||
*
|
||||
* @param string $id
|
||||
* The ID of the select field to assert.
|
||||
* @param string $text
|
||||
* The text for the option tag to assert.
|
||||
*
|
||||
* @deprecated Scheduled for removal in Drupal 9.0.0.
|
||||
* Use $this->assertSession()->optionExists() instead.
|
||||
*/
|
||||
protected function assertOptionByText($id, $text) {
|
||||
return $this->assertSession()->optionExists($id, $text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that a select option does NOT exist in the current page.
|
||||
*
|
||||
|
|
|
@ -213,6 +213,15 @@ class BrowserTestBaseTest extends BrowserTestBase {
|
|||
catch (ExpectationException $e) {
|
||||
$this->pass('The "name" field was found.');
|
||||
}
|
||||
|
||||
$this->assertOptionByText('options', 'one');
|
||||
try {
|
||||
$this->assertOptionByText('options', 'four');
|
||||
$this->fail('The select option "four" was found.');
|
||||
}
|
||||
catch (ExpectationException $e) {
|
||||
$this->pass($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue