Issue by Jo Fitzgerald, klausi: Add assertOptionByText() to AssertLegacyTrait for better browser test compatibility

8.4.x
Alex Pott 2017-03-22 22:45:01 +00:00
parent fce944dd69
commit 458de4e53b
2 changed files with 24 additions and 0 deletions
core/tests/Drupal/FunctionalTests

View File

@ -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.
*

View File

@ -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());
}
}
/**