diff --git a/includes/common.inc b/includes/common.inc index 1e287f8..10a587b 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -4911,6 +4911,7 @@ function _drupal_bootstrap_full() { require_once DRUPAL_ROOT . '/includes/ajax.inc'; require_once DRUPAL_ROOT . '/includes/token.inc'; require_once DRUPAL_ROOT . '/includes/errors.inc'; + require_once DRUPAL_ROOT . '/includes/uuid.inc'; // Detect string handling method unicode_check(); diff --git a/includes/uuid.inc b/includes/uuid.inc new file mode 100644 index 0000000..42739cc --- /dev/null +++ b/includes/uuid.inc @@ -0,0 +1,83 @@ + 'UUID handling', + 'description' => "Test the handling of universally unique identifiers.", + 'group' => 'System', + ); + } + + /** + * Test UUID handling. + */ + function testUuidHandling() { + // This is a valid UUID, we know that. + $valid_uuid = '0ab26e6b-f074-4e44-9da6-1205fa0e9761'; + $invalid_uuid1 = '0ab26e6b-f074-4e44-9da6-1205fa0e976'; + $invalid_uuid2 = '0ab26e6b-f074-4e44-9da-1205fa0e9761'; + // Test the uuid_is_valid() function. + $test = ( + uuid_is_valid($valid_uuid) + && !uuid_is_valid($invalid_uuid1) + && !uuid_is_valid($invalid_uuid2) + ); + $this->assertTrue($test, 'UUID validation works.'); + + // Test generating a UUID. + $uuid1 = uuid_generate(); + $this->assertTrue(uuid_is_valid($uuid1), 'UUID generation works.'); + + // Just to demonstrate the purpose of the UUID functionality. + $uuid2 = uuid_generate(); + $this->assertNotEqual($uuid1, $uuid2, 'Same UUID was not generated twice.'); + } +}