toString())->toBe('my-awesome-page'); expect((string) $slug)->toBe('my-awesome-page'); }); it('accepts lowercase letters, numbers, hyphens, and underscores', function () { $validSlugs = ['page', 'blog-post', 'product_123', 'my-content-slug']; foreach ($validSlugs as $slugStr) { $slug = ContentSlug::fromString($slugStr); expect($slug->toString())->toBe($slugStr); } }); it('throws exception for empty string', function () { expect(fn () => ContentSlug::fromString('')) ->toThrow(InvalidArgumentException::class, 'Content slug cannot be empty'); }); it('throws exception for uppercase letters', function () { expect(fn () => ContentSlug::fromString('My-Page')) ->toThrow(InvalidArgumentException::class, 'Content slug must contain only lowercase letters, numbers, hyphens, and underscores'); }); it('throws exception for spaces', function () { expect(fn () => ContentSlug::fromString('my page')) ->toThrow(InvalidArgumentException::class); }); it('throws exception for special characters', function () { expect(fn () => ContentSlug::fromString('my@page')) ->toThrow(InvalidArgumentException::class); }); it('can compare two ContentSlugs for equality', function () { $slug1 = ContentSlug::fromString('my-page'); $slug2 = ContentSlug::fromString('my-page'); $slug3 = ContentSlug::fromString('other-page'); expect($slug1->equals($slug2))->toBeTrue(); expect($slug1->equals($slug3))->toBeFalse(); }); });