feat: add UUIDv7 documentation and customization

This commit is contained in:
Ben Ramsey
2022-09-14 18:21:10 -05:00
parent 28f509bd91
commit 4f4deb1dd6
17 changed files with 348 additions and 31 deletions
+15
View File
@@ -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
*