mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-14 15:56:48 +03:00
feat: add UUIDv7 documentation and customization
This commit is contained in:
@@ -6,6 +6,7 @@ namespace Ramsey\Uuid\Test;
|
||||
|
||||
use Brick\Math\BigDecimal;
|
||||
use Brick\Math\RoundingMode;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
@@ -728,6 +729,20 @@ class UuidTest extends TestCase
|
||||
Uuid::uuid7();
|
||||
}
|
||||
|
||||
public function testUuid7WithDateTime(): void
|
||||
{
|
||||
$dateTime = new DateTimeImmutable('@281474976710.655');
|
||||
|
||||
$uuid = Uuid::uuid7($dateTime);
|
||||
$this->assertInstanceOf(DateTimeInterface::class, $uuid->getDateTime());
|
||||
$this->assertSame(2, $uuid->getVariant());
|
||||
$this->assertSame(7, $uuid->getVersion());
|
||||
$this->assertSame(
|
||||
'10889-08-02T05:31:50.655+00:00',
|
||||
$uuid->getDateTime()->format(DateTimeInterface::RFC3339_EXTENDED),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests known version-3 UUIDs
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user