You are here

function DomainTokenTest::assertTokens in Domain Access 7.3

Function copied from TokenTestHelper::assertTokens().

1 call to DomainTokenTest::assertTokens()
DomainTokenTest::testDomainTokens in tests/domain.test
Test the domain tokens.

File

tests/domain.test, line 1118
Simpletest for Domain Access.

Class

DomainTokenTest

Code

function assertTokens($type, array $data, array $tokens, array $options = array()) {
  $input = $this
    ->mapTokenNames($type, array_keys($tokens));
  $replacements = token_generate($type, $input, $data, $options);
  foreach ($tokens as $name => $expected) {
    $token = $input[$name];
    if (!isset($expected)) {
      $this
        ->assertTrue(!isset($values[$token]), t("Token value for @token was not generated.", array(
        '@type' => $type,
        '@token' => $token,
      )));
    }
    elseif (!isset($replacements[$token])) {
      $this
        ->fail(t("Token value for @token was not generated.", array(
        '@type' => $type,
        '@token' => $token,
      )));
    }
    else {
      $this
        ->assertIdentical($replacements[$token], $expected, t("Token value for @token was '@actual', expected value '@expected'.", array(
        '@type' => $type,
        '@token' => $token,
        '@actual' => $replacements[$token],
        '@expected' => $expected,
      )));
    }
  }
  return $replacements;
}