You are here

public function CsrfTokenGeneratorTest::testGenerateSeedOnGet in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 101
Contains \Drupal\Tests\Core\Access\CsrfTokenGeneratorTest.

Class

CsrfTokenGeneratorTest
Tests the CsrfTokenGenerator class.

Namespace

Drupal\Tests\Core\Access

Code

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