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('GNUSOCIAL', true);
10 define('STATUSNET', true); // compatibility
12 require_once INSTALLDIR . '/lib/common.php';
14 class UUIDTest extends PHPUnit_Framework_TestCase
16 public function testGenerate()
18 $result = UUID::gen();
19 $this->assertRegExp('/^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/',
21 // Check version number
22 $this->assertEquals(0x4000, hexdec(substr($result, 14, 4)) & 0xF000);
23 $this->assertEquals(0x8000, hexdec(substr($result, 19, 4)) & 0xC000);
26 public function testUnique()
31 for ($i = 0; $i < $reps; $i++) {
35 $this->assertEquals(count($ids), count(array_unique($ids)), "UUIDs must be unique");