You are here

protected function WebDriverTestBase::getDrupalSettings in Drupal 8

Same name and namespace in other branches
  1. 9 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()

4 calls to WebDriverTestBase::getDrupalSettings()
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 232

Class

WebDriverTestBase
Runs a browser test using a driver that supports Javascript.

Namespace

Drupal\FunctionalJavascriptTests

Code

protected function getDrupalSettings() {
  $script = <<<EndOfScript
(function () {
  if (typeof drupalSettings !== 'undefined') {
    return drupalSettings;
  }
})();
EndOfScript;
  return $this
    ->getSession()
    ->evaluateScript($script) ?: [];
}