function CsrfTokenGeneratorTest::setUp

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php \Drupal\Tests\Core\Access\CsrfTokenGeneratorTest::setUp()
  2. 10 core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php \Drupal\Tests\Core\Access\CsrfTokenGeneratorTest::setUp()
  3. 11.x 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);
}

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