示例#1
0
 /**
  * Iterates over a 3600-second period and tests to ensure that, for each
  * second in the period, the 32-bit and 64-bit versions of the UUID match
  */
 public function test32BitMatch64BitForOneHourPeriod()
 {
     $this->skipIfNoMoontoastMath();
     $this->skip64BitTest();
     $currentTime = strtotime('2012-12-11T00:00:00+00:00');
     $endTime = $currentTime + 3600;
     while ($currentTime <= $endTime) {
         foreach (array(0, 50000, 250000, 500000, 750000, 999999) as $usec) {
             $timeOfDay = array('sec' => $currentTime, 'usec' => $usec, 'minuteswest' => 0, 'dsttime' => 0);
             Uuid::$timeOfDayTest = $timeOfDay;
             Uuid::$force32Bit = true;
             $uuid32 = Uuid::uuid1(0x7ffffffe, 0x1669);
             Uuid::$force32Bit = false;
             $uuid64 = Uuid::uuid1(0x7ffffffe, 0x1669);
             $this->assertTrue($uuid32->equals($uuid64), 'Breaks at ' . gmdate('r', $currentTime) . "; 32-bit: {$uuid32->toString()}, 64-bit: {$uuid64->toString()}");
             // Assert that the time matches
             $testTime = round($currentTime + $usec / 1000000);
             $this->assertEquals($testTime, $uuid64->getDateTime()->getTimestamp());
             $this->assertEquals($testTime, $uuid32->getDateTime()->getTimestamp());
         }
         $currentTime++;
     }
 }