You are here

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

Tests CsrfTokenGenerator::validate().

@covers ::validate

File

core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php, line 123
Contains \Drupal\Tests\Core\Access\CsrfTokenGeneratorTest.

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'));
}