You are here

public function UUIDEntityTestCase::testEntityApiFunctions in Universally Unique IDentifier 7

Tests Entity API's UUID functions.

File

./uuid.test, line 188
Test suite for UUID module.

Class

UUIDEntityTestCase
Tests the Entity API functions.

Code

public function testEntityApiFunctions() {

  // Create some entities that we will work with.
  $user = $this
    ->drupalCreateUser();
  $node = $this
    ->drupalCreateNode(array(
    'title' => 'original title',
    'uid' => $user->uid,
  ));

  // Test entity_get_id_by_uuid().
  $nids = entity_get_id_by_uuid('node', array(
    $node->uuid,
  ), FALSE);
  $this
    ->assertTrue(in_array($node->nid, $nids), 'Lookup of entity ID works.');
  $vids = entity_get_id_by_uuid('node', array(
    $node->vuuid,
  ), TRUE);
  $this
    ->assertTrue(in_array($node->vid, $vids), 'Lookup of entity revision ID works.');

  // Test entity_get_uuid_by_id().
  $uuids = entity_get_uuid_by_id('node', array(
    $node->nid,
  ), FALSE);
  $this
    ->assertTrue(in_array($node->uuid, $uuids), 'Lookup of entity UUID works.');
  $vuuids = entity_get_uuid_by_id('node', array(
    $node->vid,
  ), TRUE);
  $this
    ->assertTrue(in_array($node->vuuid, $vuuids), 'Lookup of entity revision UUID works.');
}