Contenu du slide

'; $period = new DatePeriod(); // WHEN $input = new CreateSlideInput( title: $title, text: $text, period: $period, ); // THEN expect($input->title)->toBe($title) ->and($input->text)->toBe($text) ->and($input->picture)->toBeNull() ->and($input->period)->toBe($period); }); it('creates a valid CreateSlideInput instance with picture', function (): void { // GIVEN $title = 'Nouveau Slide Photo'; $picture = 'storage/modelfiles/slides/picture.jpg'; // WHEN $input = new CreateSlideInput( title: $title, picture: $picture, pictureAlt: 'Description alternative', pictureTitle: 'Titre image', ); // THEN expect($input->title)->toBe($title) ->and($input->picture)->toBe($picture) ->and($input->pictureAlt)->toBe('Description alternative') ->and($input->pictureTitle)->toBe('Titre image'); }); it('throws when title is empty', function (): void { // GIVEN $emptyTitle = ' '; // WHEN expect(fn () => new CreateSlideInput(title: $emptyTitle, text: 'Texte')) // THEN ->toThrow(\InvalidArgumentException::class); }); it('throws when title exceeds 75 characters', function (): void { // GIVEN $tooLongTitle = str_repeat('a', 76); // WHEN expect(fn () => new CreateSlideInput(title: $tooLongTitle, text: 'Texte')) // THEN ->toThrow(\InvalidArgumentException::class); }); it('throws when neither picture nor text is provided', function (): void { // GIVEN $title = 'Slide sans contenu'; // WHEN expect(fn () => new CreateSlideInput(title: $title)) // THEN ->toThrow(\InvalidArgumentException::class, 'A slide must have either a picture or text.'); }); it('throws when picture_alt exceeds 75 characters', function (): void { // GIVEN $tooLongAlt = str_repeat('a', 76); // WHEN expect(fn () => new CreateSlideInput(title: 'Slide', picture: 'pic.jpg', pictureAlt: $tooLongAlt)) // THEN ->toThrow(\InvalidArgumentException::class); }); it('throws when link exceeds 255 characters', function (): void { // GIVEN $tooLongLink = 'https://example.com/' . str_repeat('a', 256); // WHEN expect(fn () => new CreateSlideInput(title: 'Slide', text: 'Texte', link: $tooLongLink)) // THEN ->toThrow(\InvalidArgumentException::class); }); });