function WebDriverTestBase::getDrupalSettings
Same name in other branches
- 9 core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::getDrupalSettings()
- 8.9.x core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::getDrupalSettings()
- 10 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()
8 calls to WebDriverTestBase::getDrupalSettings()
- ExposedFilterAJAXTest::testExposedFilteringThemeNegotiation in core/
modules/ views/ tests/ src/ FunctionalJavascript/ ExposedFilterAJAXTest.php - Tests if exposed filtering via AJAX theme negotiation works.
- 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.
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php, line 225
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;
$settings = $this->getSession()
->evaluateScript($script) ?: [];
if (isset($settings['ajaxPageState'])) {
$settings['ajaxPageState']['libraries'] = UrlHelper::uncompressQueryParameter($settings['ajaxPageState']['libraries']);
}
return $settings;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.