You are here

protected function CsrfTokenGeneratorTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php \Drupal\Tests\Core\Access\CsrfTokenGeneratorTest::setUp()
  2. 9 core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php \Drupal\Tests\Core\Access\CsrfTokenGeneratorTest::setUp()

Overrides UnitTestCase::setUp

File

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

Class

CsrfTokenGeneratorTest
Tests the CsrfTokenGenerator class.

Namespace

Drupal\Tests\Core\Access

Code

protected function setUp() : void {
  parent::setUp();
  $this->privateKey = $this
    ->getMockBuilder('Drupal\\Core\\PrivateKey')
    ->disableOriginalConstructor()
    ->onlyMethods([
    'get',
  ])
    ->getMock();
  $this->sessionMetadata = $this
    ->getMockBuilder('Drupal\\Core\\Session\\MetadataBag')
    ->disableOriginalConstructor()
    ->getMock();
  $settings = [
    'hash_salt' => $this
      ->randomMachineName(),
  ];
  new Settings($settings);
  $this->generator = new CsrfTokenGenerator($this->privateKey, $this->sessionMetadata);
}