alt)->toBeNull() ->and($metadata->title)->toBeNull(); }); test('it can be instantiated with valid alt and title', function () { // GIVEN $alt = 'Belle image de chat'; $title = 'Un chat qui joue'; // WHEN $metadata = new PictureMetadata(alt: $alt, title: $title); // THEN expect($metadata->alt)->toBe($alt) ->and($metadata->title)->toBe($title); }); test('it throws when alt is empty string', function () { // GIVEN $invalidAlt = ' '; // WHEN & THEN expect(fn () => new PictureMetadata(alt: $invalidAlt)) ->toThrow(\InvalidArgumentException::class, 'Picture alt cannot be empty when provided.'); }); test('it throws when alt is shorter than 4 characters', function () { // GIVEN $shortAlt = 'abc'; // WHEN & THEN expect(fn () => new PictureMetadata(alt: $shortAlt)) ->toThrow(\InvalidArgumentException::class, 'Picture alt must be at least 4 characters.'); }); test('it throws when alt exceeds 75 characters', function () { // GIVEN $longAlt = str_repeat('a', 76); // WHEN & THEN expect(fn () => new PictureMetadata(alt: $longAlt)) ->toThrow(\InvalidArgumentException::class, 'Picture alt cannot exceed 75 characters.'); }); test('it throws when title is empty string', function () { // GIVEN $invalidTitle = ' '; // WHEN & THEN expect(fn () => new PictureMetadata(title: $invalidTitle)) ->toThrow(\InvalidArgumentException::class, 'Picture title cannot be empty when provided.'); }); test('it throws when title is shorter than 4 characters', function () { // GIVEN $shortTitle = 'xyz'; // WHEN & THEN expect(fn () => new PictureMetadata(title: $shortTitle)) ->toThrow(\InvalidArgumentException::class, 'Picture title must be at least 4 characters.'); }); test('it throws when title exceeds 75 characters', function () { // GIVEN $longTitle = str_repeat('b', 76); // WHEN & THEN expect(fn () => new PictureMetadata(title: $longTitle)) ->toThrow(\InvalidArgumentException::class, 'Picture title cannot exceed 75 characters.'); }); });