From f42b84815e1d2836c11eec03531552bb701dfd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederic=20G=2E=20=C3=98stby?= Date: Sat, 31 Aug 2024 10:16:33 +0200 Subject: [PATCH] Update UUIDTest.php --- tests/unit/utility/UUIDTest.php | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/unit/utility/UUIDTest.php b/tests/unit/utility/UUIDTest.php index cb1297a9f..bb62bddbd 100644 --- a/tests/unit/utility/UUIDTest.php +++ b/tests/unit/utility/UUIDTest.php @@ -134,6 +134,24 @@ public function testV4(): void $this->assertTrue(UUID::validate(UUID::v4())); } + /** + * + */ + public function testV4Sequential(): void + { + $prev = UUID::v4Sequential(); + + for ($i = 0; $i < 100; $i++) { + usleep(10); // We need to sleep since they cannot be guaranteed to be 100% sequential due to the time presision + + $uuid = UUID::v4Sequential(); + + $this->assertTrue(strcmp($prev, $uuid) <= 0); + + $prev = $uuid; + } + } + /** * */ @@ -161,22 +179,4 @@ public function testV5WithInvalidNamespace(): void UUID::v5('nope', 'foobar'); } - - /** - * - */ - public function testSequential(): void - { - $prev = UUID::v4Sequential(); - - for ($i = 0; $i < 100; $i++) { - usleep(10); // We need to sleep since they cannot be guaranteed to be 100% sequential due to the time presision - - $uuid = UUID::v4Sequential(); - - $this->assertTrue(strcmp($prev, $uuid) <= 0); - - $prev = $uuid; - } - } }