function TokenTestHelper::assertTokens in Token 6
Same name and namespace in other branches
- 7 token.test \TokenTestHelper::assertTokens()
7 calls to TokenTestHelper::assertTokens()
File
- ./
token.test, line 26 - Tests for the token module.
Class
- TokenTestHelper
- Helper test class with some added functions for testing.
Code
function assertTokens($type, $object, array $tokens, array $options = array()) {
$values = token_get_values($type, $object, FALSE, $options);
$values = array_combine($values->tokens, $values->values);
foreach ($tokens as $token => $expected) {
if (!isset($expected)) {
$this
->assertTrue(!isset($values[$token]), t("Token value for [@token] was not generated.", array(
'@token' => $token,
)));
}
elseif (!isset($values[$token])) {
$this
->fail(t("Token value for [@token] was not generated.", array(
'@token' => $token,
)));
}
else {
$this
->assertIdentical($values[$token], $expected, t("Token value for [@token] was '@actual', expected value '@expected'.", array(
'@token' => $token,
'@actual' => $values[$token],
'@expected' => $expected,
)));
}
}
}