function BigPipeTest::setCsrfTokenSeedInTestEnvironment

Same name in other branches
  1. 8.9.x core/modules/big_pipe/tests/src/Functional/BigPipeTest.php \Drupal\Tests\big_pipe\Functional\BigPipeTest::setCsrfTokenSeedInTestEnvironment()
  2. 10 core/modules/big_pipe/tests/src/Functional/BigPipeTest.php \Drupal\Tests\big_pipe\Functional\BigPipeTest::setCsrfTokenSeedInTestEnvironment()
  3. 11.x core/modules/big_pipe/tests/src/Functional/BigPipeTest.php \Drupal\Tests\big_pipe\Functional\BigPipeTest::setCsrfTokenSeedInTestEnvironment()

Ensures CSRF tokens can be generated for the current user's session.

2 calls to BigPipeTest::setCsrfTokenSeedInTestEnvironment()
BigPipeTest::testBigPipe in core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
Tests BigPipe-delivered HTML responses when JavaScript is enabled.
BigPipeTest::testBigPipeNoJs in core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
Tests BigPipe-delivered HTML responses when JavaScript is disabled.

File

core/modules/big_pipe/tests/src/Functional/BigPipeTest.php, line 427

Class

BigPipeTest
Tests BigPipe's no-JS detection & response delivery (with and without JS).

Namespace

Drupal\Tests\big_pipe\Functional

Code

protected function setCsrfTokenSeedInTestEnvironment() {
    $session_data = $this->container
        ->get('session_handler.write_safe')
        ->read($this->getSession()
        ->getCookie($this->getSessionName()));
    $csrf_token_seed = unserialize(explode('_sf2_meta|', $session_data)[1])['s'];
    $this->container
        ->get('session_manager.metadata_bag')
        ->setCsrfTokenSeed($csrf_token_seed);
}

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