From 57756ce6ae2f2d8cfea25a612d13db1d1630ca82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 13 Aug 2026 10:24:05 +0200 Subject: [PATCH] test(UuidHelper): add unit tests for UUID version verification Includes tests for checking if UUIDs are v4 or v7 and retrieving their version. --- src/Shared/Helpers/UuidHelper.php | 2 +- .../Shared/Helpers/UuidHelperTest.php | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 tests/Integration/Shared/Helpers/UuidHelperTest.php diff --git a/src/Shared/Helpers/UuidHelper.php b/src/Shared/Helpers/UuidHelper.php index 2a5cb4c..839cf5e 100644 --- a/src/Shared/Helpers/UuidHelper.php +++ b/src/Shared/Helpers/UuidHelper.php @@ -11,7 +11,7 @@ final readonly class UuidHelper { private function __construct() { - // Static class + throw new \LogicException('Static class'); } public static function isV4(UuidInterface $uuid): bool diff --git a/tests/Integration/Shared/Helpers/UuidHelperTest.php b/tests/Integration/Shared/Helpers/UuidHelperTest.php new file mode 100644 index 0000000..0170d78 --- /dev/null +++ b/tests/Integration/Shared/Helpers/UuidHelperTest.php @@ -0,0 +1,46 @@ +toBeTrue(); + }); + + it('can verify an UUID is v7', function (): void { + // GIVEN + $uuidV7 = Uuid::uuid7(); + + // WHEN + $result = UuidHelper::isV7($uuidV7); + + // THEN + expect($result)->toBeTrue(); + }); + + it('can get the version of an UUID', function (): void { + // GIVEN + $uuidV4 = Uuid::uuid4(); + $uuidV7 = Uuid::uuid7(); + + // WHEN + $resultV4 = UuidHelper::version($uuidV4); + $resultV7 = UuidHelper::version($uuidV7); + + // THEN + expect($resultV4)->toBe(4) + ->and($resultV7)->toBe(7); + }); +});