function WebDriverTestBase::getDrupalSettings
Same name in other branches
- 8.9.x core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::getDrupalSettings()
- 10 core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::getDrupalSettings()
- 11.x core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::getDrupalSettings()
Gets the current Drupal javascript settings and parses into an array.
Unlike BrowserTestBase::getDrupalSettings(), this implementation reads the current values of drupalSettings, capturing all changes made via javascript after the page was loaded.
Return value
array The Drupal javascript settings array.
Overrides BrowserTestBase::getDrupalSettings
See also
\Drupal\Tests\BrowserTestBase::getDrupalSettings()
5 calls to WebDriverTestBase::getDrupalSettings()
- ExposedFilterAJAXTest::testExposedFilteringWithButtonElement in core/
modules/ views/ tests/ src/ FunctionalJavascript/ ExposedFilterAJAXTest.php - Tests exposed filtering via AJAX with a button element.
- FrameworkTest::testCurrentPathChange in core/
modules/ system/ tests/ src/ FunctionalJavascript/ FrameworkTest.php - Tests that drupalSettings.currentPath is not updated on AJAX requests.
- FrameworkTest::testLazyLoad in core/
modules/ system/ tests/ src/ FunctionalJavascript/ FrameworkTest.php - Tests that new JavaScript and CSS files are lazy-loaded on an AJAX request.
- JavascriptGetDrupalSettingsTest::testGetDrupalSettings in core/
tests/ Drupal/ FunctionalJavascriptTests/ JavascriptGetDrupalSettingsTest.php - Tests retrieval of Drupal settings.
- PaginationAJAXTest::testBasicPagination in core/
modules/ views/ tests/ src/ FunctionalJavascript/ PaginationAJAXTest.php - Tests if pagination via AJAX works for the "Content" View.
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php, line 204
Class
- WebDriverTestBase
- Runs a browser test using a driver that supports JavaScript.
Namespace
Drupal\FunctionalJavascriptTestsCode
protected function getDrupalSettings() {
$script = <<<EndOfScript
(function () {
if (typeof drupalSettings !== 'undefined') {
return drupalSettings;
}
})();
EndOfScript;
return $this->getSession()
->evaluateScript($script) ?: [];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.