42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Application\Security\ValueObjects\Entities;
|
|
|
|
use Application\Security\Models\ValueObjects\Entities\ClientId;
|
|
use Ramsey\Uuid\Uuid;
|
|
use Ramsey\Uuid\UuidInterface;
|
|
use Shared\Helpers\Exceptions\InvalidUuidException;
|
|
|
|
covers(ClientId::class);
|
|
|
|
describe('ClientId Value Object Instantiation', function (): void {
|
|
it('accepts valid UUIDv7 identifier', function (): void {
|
|
// GIVEN
|
|
$uuid7 = Uuid::uuid7();
|
|
|
|
// WHEN
|
|
$clientId = new ClientId($uuid7);
|
|
|
|
// THEN
|
|
expect($clientId->identifier)->toBe($uuid7)
|
|
->and($clientId->value)->toBe($uuid7->toString());
|
|
});
|
|
});
|
|
|
|
describe('ClientId Value Object Validation Rules', function (): void {
|
|
it('throws InvalidUuidException when given a non-v7 UUID identifier', function (UuidInterface $nonV7Uuid): void {
|
|
// GIVEN
|
|
$input = $nonV7Uuid;
|
|
|
|
// WHEN
|
|
$execution = fn () => new ClientId($input);
|
|
|
|
// THEN
|
|
expect($execution)->toThrow(InvalidUuidException::class);
|
|
})->with([
|
|
fn () => Uuid::uuid4(),
|
|
fn () => Uuid::uuid1(),
|
|
]);
|
|
});
|