toString())->toBe($validUlid); expect((string) $contentId)->toBe($validUlid); }); it('throws exception for invalid ULID format', function () { expect(fn () => ContentId::fromString('invalid-id')) ->toThrow(InvalidArgumentException::class, 'Invalid Content ID format'); }); it('throws exception for empty string', function () { expect(fn () => ContentId::fromString('')) ->toThrow(InvalidArgumentException::class); }); it('can generate new ContentId with Clock', function () { $clock = new SystemClock(); $contentId = ContentId::generate($clock); expect($contentId)->toBeInstanceOf(ContentId::class); expect($contentId->toString())->toMatch('/^[0-9A-Z]{26}$/'); }); it('generates unique IDs', function () { $clock = new SystemClock(); $id1 = ContentId::generate($clock); $id2 = ContentId::generate($clock); expect($id1->toString())->not->toBe($id2->toString()); }); it('can compare two ContentIds for equality', function () { $id1 = ContentId::fromString('01ARZ3NDEKTSV4RRFFQ69G5FAV'); $id2 = ContentId::fromString('01ARZ3NDEKTSV4RRFFQ69G5FAV'); $id3 = ContentId::fromString('01ARZ3NDEKTSV4RRFFQ69G5FAW'); expect($id1->equals($id2))->toBeTrue(); expect($id1->equals($id3))->toBeFalse(); }); });