ldc-arcadia-api/tests/Unit/Shared/DDD/EntityIdTest.php

37 lines
872 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Tests\Unit\Shared\DDD;
use Shared\DDD\EntityId;
covers(EntityId::class);
describe('EntityId', function (): void {
it('can be instantiated with a valid UUID string', function (): void {
// GIVEN
$validUuid = '550e8400-e29b-41d4-a716-446655440000';
// WHEN
$entityId = new readonly class ($validUuid) extends EntityId
{
};
// THEN
expect($entityId->value)
->toBe($validUuid)
->and((string) $entityId)->toBe($validUuid);
});
it('throws a DomainException when instantiated with an empty string', function (): void {
// GIVEN
$invalidUuid = '';
// WHEN & THEN
expect(fn () => new readonly class ($invalidUuid) extends EntityId
{
})->toThrow(\DomainException::class);
});
});