From ccba793b4cc57513a8d20d1ca92740d28aacd569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Munsch?= Date: Thu, 13 Aug 2026 12:47:18 +0200 Subject: [PATCH] test(EntityId): add unit tests for EntityId instantiation Includes tests for valid UUID and handling of empty string. --- tests/Unit/Shared/DDD/EntityIdTest.php | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/Unit/Shared/DDD/EntityIdTest.php diff --git a/tests/Unit/Shared/DDD/EntityIdTest.php b/tests/Unit/Shared/DDD/EntityIdTest.php new file mode 100644 index 0000000..256d983 --- /dev/null +++ b/tests/Unit/Shared/DDD/EntityIdTest.php @@ -0,0 +1,36 @@ +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); + }); +});