3 if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
4 print "This script must be run from the command line\n";
8 define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
9 define('STATUSNET', true);
11 require_once INSTALLDIR . '/lib/common.php';
13 class UUIDTest extends PHPUnit_Framework_TestCase
15 public function testGenerate()
17 $result = UUID::gen();
18 $this->assertRegExp('/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/',
20 // Check version number
21 $this->assertEquals(0x4000, hexdec(substr($result, 14, 4)) & 0xF000);
22 $this->assertEquals(0x8000, hexdec(substr($result, 19, 4)) & 0xC000);
25 public function testUnique()
30 for ($i = 0; $i < $reps; $i++) {
34 $this->assertEquals(count($ids), count(array_unique($ids)), "UUIDs must be unique");