Commit 458de4e5 authored by alexpott's avatar alexpott

Issue #2862470 by Jo Fitzgerald, klausi: Add assertOptionByText() to...

Issue #2862470 by Jo Fitzgerald, klausi: Add assertOptionByText() to AssertLegacyTrait for better browser test compatibility
parent fce944dd
......@@ -451,6 +451,21 @@ protected function assertOption($id, $option) {
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 @@ public function testLegacyFieldAsserts() {
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());
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment