1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* Test the UUID handling without the UUID module being present.
|
5
|
*/
|
6
|
class CtoolsUUIDWithoutUUID extends DrupalWebTestCase {
|
7
|
|
8
|
/**
|
9
|
* {@inheritDoc}
|
10
|
*/
|
11
|
public static function getInfo() {
|
12
|
return array(
|
13
|
'name' => 'UUID handing, without UUID module',
|
14
|
'description' => 'Check that the CTools UUID functions behave correctly when the UUID module is not installed.',
|
15
|
'group' => 'ctools',
|
16
|
'dependencies' => array('ctools'),
|
17
|
);
|
18
|
}
|
19
|
|
20
|
/**
|
21
|
* {@inheritDoc}
|
22
|
*/
|
23
|
function setUp(array $modules = array()) {
|
24
|
$modules[] = 'ctools';
|
25
|
parent::setUp($modules);
|
26
|
}
|
27
|
|
28
|
/**
|
29
|
* Check the UUID_PATTERN constant exists.
|
30
|
*
|
31
|
* @todo Fix this so testbot doesn't fail.
|
32
|
*/
|
33
|
public function DISABLED_testHaveUUIDpattern() {
|
34
|
ctools_include('uuid');
|
35
|
$this->assertTrue(defined('UUID_PATTERN'), 'The UUID_PATTERN constant exists.');
|
36
|
$this->assertTrue(is_string(UUID_PATTERN) && strlen(UUID_PATTERN) > 12, 'The UUID_PATTERN has an appropriate value.');
|
37
|
}
|
38
|
|
39
|
/**
|
40
|
* Check we can get a UUID when .
|
41
|
*
|
42
|
* NB: This test will use one (and only one) of the mechanisms available
|
43
|
* from pear,
|
44
|
*
|
45
|
* @todo Fix this so testbot doesn't fail.
|
46
|
*/
|
47
|
public function DISABLED_testMakeNewUUIDRaw() {
|
48
|
// drupal_get_filename will report even if the module is disabled.
|
49
|
if (drupal_get_filename('module', 'uuid') && module_exists('uuid')) {
|
50
|
module_disable(array('uuid'));
|
51
|
}
|
52
|
|
53
|
ctools_include('uuid');
|
54
|
$uuid = _ctools_uuid_generate_php();
|
55
|
$this->assertTrue(ctools_uuid_is_valid($uuid), 'UUID generated (ctoolsphp): ' . $uuid);
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* Check we can get a UUID when .
|
60
|
*
|
61
|
* NB: This test will use one (and only one) of the mechanisms available
|
62
|
* from pear,
|
63
|
*
|
64
|
* @todo Fix this so testbot doesn't fail.
|
65
|
*/
|
66
|
public function DISABLED_testMakeNewUUIDWrapper() {
|
67
|
// drupal_get_filename will report even if the module is disabled.
|
68
|
if (drupal_get_filename('module', 'uuid') && module_exists('uuid')) {
|
69
|
module_disable(array('uuid'));
|
70
|
}
|
71
|
|
72
|
$uuid = ctools_uuid_generate();
|
73
|
$this->assertTrue(ctools_uuid_is_valid($uuid), 'UUID generated (ctools): ' . $uuid);
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* Check we can verify that a string looks like a UUID.
|
78
|
*
|
79
|
* @todo Fix this so testbot doesn't fail.
|
80
|
*/
|
81
|
public function DISABLED_testVerifyUUID() {
|
82
|
$checks = array(
|
83
|
NULL => FALSE,
|
84
|
'' => FALSE,
|
85
|
'0' => FALSE,
|
86
|
'b5827a5cadd311e69a1f936389a27663' => FALSE, // version 1, no dashes
|
87
|
'15ff2566-add3-11e6-b98f' => FALSE, // incomplete
|
88
|
|
89
|
'15ff2566-add3-11e6-b98f-080027dc4f7a' => TRUE, // version 1
|
90
|
'b5827a5c-add3-11e6-9a1f-936389a27663' => TRUE, // version 1
|
91
|
'02d9e6d5-9467-382e-8f9b-9300a64ac3cd' => TRUE, // version 3 url-based
|
92
|
'5e330afb-50c6-45c2-a292-99c3168696d2' => TRUE, // version 4 uuid
|
93
|
'8f4ca4fd-154e-5063-b6db-aa91af137037' => TRUE, // version 5
|
94
|
);
|
95
|
|
96
|
foreach ($checks as $uuid => $exp) {
|
97
|
$this->assertEqual(ctools_uuid_is_valid($uuid), $exp, 'Is Valid: UUIDs match expectations: ' . $uuid);
|
98
|
}
|
99
|
}
|
100
|
|
101
|
}
|