mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-16 16:17:43 +03:00
add test for phptimeconverter
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Ramsey\Uuid\Test\Converter;
|
||||
|
||||
use Ramsey\Uuid\Converter\Time\PhpTimeConverter;
|
||||
|
||||
class PhpTimeConverterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
public function testCalculateTimeReturnsArrayOfTimeSegments()
|
||||
{
|
||||
$seconds = 5;
|
||||
$microSeconds = 3;
|
||||
$calculatedTime = ($seconds * 10000000) + ($microSeconds * 10) + 0x01b21dd213814000;
|
||||
$expectedArray = [
|
||||
'low' => sprintf('%08x', $calculatedTime & 0xffffffff),
|
||||
'mid' => sprintf('%04x', ($calculatedTime >> 32) & 0xffff),
|
||||
'hi' => sprintf('%04x', ($calculatedTime >> 48) & 0x0fff)
|
||||
];
|
||||
|
||||
$converter = new PhpTimeConverter();
|
||||
$returned = $converter->calculateTime($seconds, $microSeconds);
|
||||
$this->assertEquals($expectedArray, $returned);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user