From a84bccb11029deb6521bb784c849084fc95cd1b6 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Sun, 8 Oct 2023 16:38:51 +0100 Subject: [PATCH] test: assert from known time string --- test/phpunit/UlidTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/phpunit/UlidTest.php b/test/phpunit/UlidTest.php index 1a055a4..199df2b 100644 --- a/test/phpunit/UlidTest.php +++ b/test/phpunit/UlidTest.php @@ -108,4 +108,12 @@ public function testGetDateTime():void { $sut->getDateTime()->getTimestamp() ); } + + public function testGetDateTime_constructorInit():void { + $dateTimeString = "1988-05-04 17:24"; + $knownUlid = new Ulid(timestamp: strtotime($dateTimeString) * 1000); + + $sut = new Ulid(init: $knownUlid); + self::assertSame($dateTimeString, $sut->getDateTime()->format("Y-m-d H:i")); + } }