function CsrfTokenGeneratorTest::testValidate

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

Class

CsrfTokenGeneratorTest
Tests the CsrfTokenGenerator class.

Namespace

Drupal\Tests\Core\Access

Code

public function testValidate() : void {
    $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'));
}

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