47 lines
983 B
PHP
47 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);
|
||
|
|
});
|
||
|
|
});
|