本文整理匯總了PHP中Uuid::timeOfDayTest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uuid::timeOfDayTest方法的具體用法?PHP Uuid::timeOfDayTest怎麽用?PHP Uuid::timeOfDayTest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Uuid
的用法示例。
在下文中一共展示了Uuid::timeOfDayTest方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test32BitMatch64BitForOneHourPeriod
/**
* 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++;
}
}