You are here

protected function BigPipeTest::setCsrfTokenSeedInTestEnvironment in Drupal 10

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()
  2. 9 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.

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