protected function BrowserTestBase::getDrupalSettings in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/BrowserTestBase.php \Drupal\Tests\BrowserTestBase::getDrupalSettings()
- 9 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.
4 calls to BrowserTestBase::getDrupalSettings()
- AccessDeniedTest::testAccessDenied in core/
modules/ system/ tests/ src/ Functional/ System/ AccessDeniedTest.php - BrowserTestBaseTest::testGoTo in core/
tests/ Drupal/ FunctionalTests/ BrowserTestBaseTest.php - Tests basic page test.
- NoJavaScriptAnonymousTest::assertNoJavaScript in core/
modules/ system/ tests/ src/ Functional/ Common/ NoJavaScriptAnonymousTest.php - Passes if no JavaScript is found on the page.
- ThemeTokenTest::testThemeToken in core/
modules/ system/ tests/ src/ Functional/ Theme/ ThemeTokenTest.php - Tests if the 'theme_token' key of 'ajaxPageState' is computed.
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 631
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 [];
}