36 lines
878 B
PHP
36 lines
878 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Shared\DDD;
|
|
|
|
use Shared\DDD\Model\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);
|
|
});
|
|
});
|