You are here

function UUIDTokenFunctionalityTestCase::testDefaultUserTokens in Universally Unique IDentifier 6

Verify user type token integration.

Create a user and expect the token:

  • uuid

File

./uuid.test, line 773
Functionality tests for UUID module.

Class

UUIDTokenFunctionalityTestCase
Test uuid and token integration.

Code

function testDefaultUserTokens() {

  // Do not continue if token module is not enabled.
  if (!function_exists('token_replace')) {
    $this
      ->pass(t('Token module is not installed. Skipping this test.'));
    return;
  }

  /*
   * Verify behavior when uuid is enabled for users.
   */

  // Set module settings.
  $settings = array(
    'uuid_automatic_for_users' => TRUE,
  );
  $this
    ->uuidSettingsSet($settings);

  // Create a user.
  $object = $this
    ->drupalCreateUser();

  // This is the list of tokens and the expected value.
  $checks = array(
    'uuid' => $object->uuid,
  );
  foreach ($checks as $token => $value) {
    $this
      ->assertEqual(token_replace("[" . $token . "]", 'user', $object), (string) $value, t("Token %token successfully verified.", array(
      '%token' => $token,
    )), t("User tokens"));
  }
}