public function UUIDSyncTestCase::testSync in Universally Unique IDentifier 7
Tests creating UUIDs for entities that don't have them.
File
- ./
uuid.test, line 670 - Test suite for UUID module.
Class
- UUIDSyncTestCase
- Tests for the UUID synchronization.
Code
public function testSync() {
// These entities will not have UUID from the start, since the UUID module
// isn't installed yet.
$user = $this
->drupalCreateUser();
$node = $this
->drupalCreateNode();
$this
->assertTrue(!isset($node->uuid), "Node has no UUID before installation of UUID module.");
$this
->assertTrue(!isset($node->vuuid), "Node has no revision UUID before installation of UUID module.");
$this
->assertTrue(!isset($user->uuid), "User has no UUID before installation of UUID module.");
// Now enable the UUID module.
module_enable(array(
'uuid',
), TRUE);
drupal_flush_all_caches();
drupal_static_reset();
// Check that the UUID column was generated for {node}.
$this
->assertTableColumn('node', 'uuid', 'UUID column was generated for the node table.');
$this
->assertTableColumn('node_revision', 'vuuid', 'Revision UUID column was generated for the node_revision table.');
$this
->assertTableColumn('users', 'uuid', 'UUID column was generated for the user table.');
// Login with a user and click the sync button.
$web_user = $this
->drupalCreateUser(array(
'administer uuid',
));
$this
->drupalLogin($web_user);
$this
->drupalPost('admin/config/system/uuid', array(), t('Create missing UUIDs'));
// Test if UUID was generated for nodes.
$node_test = node_load($node->nid, FALSE, TRUE);
$this
->assertUuid($node_test->uuid, 'Node UUID was generated when clicking the sync button.');
$this
->assertUuid($node_test->vuuid, 'Node revision UUID was generated when clicking the sync button.');
// Test if UUID was generated for users.
$user_test = user_load($user->uid, TRUE);
$this
->assertUuid($user_test->uuid, 'User UUID was generated when clicking the sync button.');
}