You are here

function UUIDTokenFunctionalityTestCase::testDefaultNodeTokens in Universally Unique IDentifier 6

Verify node type token integration (by content-type).

Configure the module settings to support uuid for a content type. Create a node of that content type and expect the tokens:

  • uuid
  • revision-uuid
  • author-uuid

File

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

Class

UUIDTokenFunctionalityTestCase
Test uuid and token integration.

Code

function testDefaultNodeTokens() {

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

  /*
   * Verify the behaviour when the node UUID and revision UUID fields.
   */

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

  // Create a user.
  $account = $this
    ->drupalCreateUser(array(
    'create page content',
  ));

  // Create a node with that user.
  $options = array(
    'uid' => $account->uid,
    'type' => 'page',
  );
  $object = $this
    ->drupalCreateNode($options);

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