function CsrfTokenGeneratorTest::testGenerateSeedOnGet

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php \Drupal\Tests\Core\Access\CsrfTokenGeneratorTest::testGenerateSeedOnGet()
  2. 8.9.x core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php \Drupal\Tests\Core\Access\CsrfTokenGeneratorTest::testGenerateSeedOnGet()
  3. 10 core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php \Drupal\Tests\Core\Access\CsrfTokenGeneratorTest::testGenerateSeedOnGet()

Tests that a new token seed is generated upon first use.

@covers ::get

File

core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php, line 98

Class

CsrfTokenGeneratorTest
Tests the CsrfTokenGenerator class.

Namespace

Drupal\Tests\Core\Access

Code

public function testGenerateSeedOnGet() : void {
    $key = Crypt::randomBytesBase64();
    $this->privateKey
        ->expects($this->any())
        ->method('get')
        ->willReturn($key);
    $this->sessionMetadata
        ->expects($this->once())
        ->method('getCsrfTokenSeed')
        ->willReturn(NULL);
    $this->sessionMetadata
        ->expects($this->once())
        ->method('setCsrfTokenSeed')
        ->with($this->isType('string'));
    $this->assertIsString($this->generator
        ->get());
}

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