function BrowserTestBase::getDrupalSettings
Same name in other branches
- 9 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getDrupalSettings()
- 10 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getDrupalSettings()
- 11.x core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getDrupalSettings()
Gets the JavaScript drupalSettings variable for the currently-loaded page.
Return value
array The JSON decoded drupalSettings value from the current page.
21 calls to BrowserTestBase::getDrupalSettings()
- AccessDeniedTest::testAccessDenied in core/
modules/ system/ tests/ src/ Functional/ System/ AccessDeniedTest.php - BigPipeTest::testBigPipe in core/
modules/ big_pipe/ tests/ src/ Functional/ BigPipeTest.php - Tests BigPipe-delivered HTML responses when JavaScript is enabled.
- BrowserTestBaseTest::testGoTo in core/
tests/ Drupal/ FunctionalTests/ BrowserTestBaseTest.php - Tests basic page test.
- CKEditorAdminTest::testExistingFormat in core/
modules/ ckeditor/ tests/ src/ Functional/ CKEditorAdminTest.php - Tests configuring a text editor for an existing text format.
- CKEditorAdminTest::testNewFormat in core/
modules/ ckeditor/ tests/ src/ Functional/ CKEditorAdminTest.php - Tests configuring a text editor for a new text format.
1 method overrides BrowserTestBase::getDrupalSettings()
- WebDriverTestBase::getDrupalSettings in core/
tests/ Drupal/ FunctionalJavascriptTests/ WebDriverTestBase.php - Gets the current Drupal javascript settings and parses into an array.
File
-
core/
tests/ Drupal/ Tests/ BrowserTestBase.php, line 691
Class
- BrowserTestBase
- Provides a test case for functional Drupal tests.
Namespace
Drupal\TestsCode
protected function getDrupalSettings() {
$html = $this->getSession()
->getPage()
->getContent();
if (preg_match('@<script type="application/json" data-drupal-selector="drupal-settings-json">([^<]*)</script>@', $html, $matches)) {
return Json::decode($matches[1]);
}
return [];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.