You are here

protected function BigPipeTest::setCsrfTokenSeedInTestEnvironment in Drupal 9

Same name and namespace in other branches
  1. 8 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 425

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);
}