function BrowserTestBaseTest::testDrupalSettings

Same name in other branches
  1. 10 core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php \Drupal\FunctionalTests\BrowserTestBaseTest::testDrupalSettings()

Tests that JavaScript Drupal settings can be read.

File

core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php, line 47

Class

BrowserTestBaseTest
Tests BrowserTestBase functionality.

Namespace

Drupal\FunctionalTests

Code

public function testDrupalSettings() : void {
    // Trigger a 403 because those pages have very little else going on.
    $this->drupalGet('admin');
    $this->assertSame([], $this->getDrupalSettings());
    // Now try the same 403 as an authenticated user and verify that Drupal
    // settings do show up.
    $account = $this->drupalCreateUser();
    $this->drupalLogin($account);
    $this->drupalGet('admin');
    $this->assertNotSame([], $this->getDrupalSettings());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.