You are here

public function CsrfTokenGeneratorTest::testValidate 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::testValidate()

Tests CsrfTokenGenerator::validate().

@covers ::validate

File

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

Class

CsrfTokenGeneratorTest
Tests the CsrfTokenGenerator class.

Namespace

Drupal\Tests\Core\Access

Code

public function testValidate() {
  $this
    ->setupDefaultExpectations();
  $token = $this->generator
    ->get();
  $this
    ->assertTrue($this->generator
    ->validate($token));
  $this
    ->assertFalse($this->generator
    ->validate($token, 'foo'));
  $token = $this->generator
    ->get('bar');
  $this
    ->assertTrue($this->generator
    ->validate($token, 'bar'));
}