You are here

public function PathautoTestHelperTrait::assertToken in Pathauto 8

File

tests/src/Functional/PathautoTestHelperTrait.php, line 75

Class

PathautoTestHelperTrait
Helper test class with some added functions for testing.

Namespace

Drupal\Tests\pathauto\Functional

Code

public function assertToken($type, $object, $token, $expected) {
  $bubbleable_metadata = new BubbleableMetadata();
  $tokens = \Drupal::token()
    ->generate($type, [
    $token => $token,
  ], [
    $type => $object,
  ], [], $bubbleable_metadata);
  $tokens += [
    $token => '',
  ];
  $this
    ->assertSame($tokens[$token], $expected, t("Token value for [@type:@token] was '@actual', expected value '@expected'.", [
    '@type' => $type,
    '@token' => $token,
    '@actual' => $tokens[$token],
    '@expected' => $expected,
  ]));
}