You are here

protected function CsrfTokenGeneratorTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 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()

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() {
  parent::setUp();
  $this->privateKey = $this
    ->getMockBuilder('Drupal\\Core\\PrivateKey')
    ->disableOriginalConstructor()
    ->setMethods([
    '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);
}