ldc-arcadia-api/tests/Integration/Shared/Helpers/UuidHelperTest.php
Jérémy Munsch 57756ce6ae
test(UuidHelper): add unit tests for UUID version verification
Includes tests for checking if UUIDs are v4 or v7 and retrieving their version.
2026-08-13 10:24:05 +02:00

46 lines
983 B
PHP

<?php
declare(strict_types=1);
use Ramsey\Uuid\Uuid;
use Shared\Helpers\UuidHelper;
covers(UuidHelper::class);
describe('Uuid Helper', function (): void {
it('can verify an UUID is v4', function (): void {
// GIVEN
$uuidV4 = Uuid::uuid4();
// WHEN
$result = UuidHelper::isV4($uuidV4);
// THEN
expect($result)->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);
});
});