function ToolbarIntegrationTest::waitAndAssertAriaPressedState
Asserts that an element's `aria-pressed` attribute matches expected state.
Uses `waitFor()` to pause until either the condition is met or the timeout of `1` second has passed.
Parameters
\Behat\Mink\Element\NodeElement $element: The element to be tested.
bool $expected: The expected value of `aria-pressed`, as a boolean.
Throws
ExpectationFailedException
1 call to ToolbarIntegrationTest::waitAndAssertAriaPressedState()
- ToolbarIntegrationTest::testToolbarToggling in core/
modules/ toolbar/ tests/ src/ FunctionalJavascript/ ToolbarIntegrationTest.php - Tests if the toolbar can be toggled with JavaScript.
File
-
core/
modules/ toolbar/ tests/ src/ FunctionalJavascript/ ToolbarIntegrationTest.php, line 114
Class
- ToolbarIntegrationTest
- Tests the JavaScript functionality of the toolbar.
Namespace
Drupal\Tests\toolbar\FunctionalJavascriptCode
private function waitAndAssertAriaPressedState(NodeElement $element, bool $expected) : void {
$this->assertTrue($this->getSession()
->getPage()
->waitFor(1, function () use ($element, $expected) : bool {
// Get boolean representation of `aria-pressed`.
// TRUE if `aria-pressed="true"`, FALSE otherwise.
$actual = $element->getAttribute('aria-pressed') == 'true';
// Exit `waitFor()` when $actual == $expected.
return $actual == $expected;
}));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.