You are here

function RandomTest::testRandomTokens in Token 8

File

tests/src/Kernel/RandomTest.php, line 12

Class

RandomTest
Tests random tokens.

Namespace

Drupal\Tests\token\Kernel

Code

function testRandomTokens() {
  $tokens = [
    'number' => '[0-9]{1,}',
    'hash:md5' => '[0-9a-f]{32}',
    'hash:sha1' => '[0-9a-f]{40}',
    'hash:sha256' => '[0-9a-f]{64}',
    'hash:invalid-algo' => NULL,
  ];
  $first_set = $this
    ->assertTokens('random', [], $tokens, [
    'regex' => TRUE,
  ]);
  $second_set = $this
    ->assertTokens('random', [], $tokens, [
    'regex' => TRUE,
  ]);
  foreach ($first_set as $token => $value) {
    $this
      ->assertNotSame($first_set[$token], $second_set[$token]);
  }
}