2026-09-29 15:29:43 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-11-16 14:18:42 +01:00
|
|
|
namespace Tests\Unit\App\Cqs\Actions\Slides;
|
|
|
|
|
|
2026-11-10 14:28:00 +01:00
|
|
|
use App\Cqs\Actions\Slides\UpdateSlideInput;
|
2026-09-29 15:29:43 +02:00
|
|
|
use App\Models\Slide;
|
2026-11-16 16:13:14 +01:00
|
|
|
use Uwil\Storage\Lib\ValueObjects\StorageFilePath;
|
2026-09-29 15:29:43 +02:00
|
|
|
|
|
|
|
|
describe('UpdateSlideInput', function (): void {
|
|
|
|
|
it('creates a valid UpdateSlideInput instance with existing slide picture', function (): void {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$slide = new Slide();
|
2026-11-16 16:13:14 +01:00
|
|
|
$slide->picture = new StorageFilePath('storage/modelfiles/slides/existing.jpg');
|
2026-09-29 15:29:43 +02:00
|
|
|
$title = 'Slide Modifié';
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$input = new UpdateSlideInput(
|
|
|
|
|
slide: $slide,
|
|
|
|
|
title: $title,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($input->slide)->toBe($slide)
|
|
|
|
|
->and($input->title)->toBe($title)
|
|
|
|
|
->and($input->picture)->toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('creates a valid UpdateSlideInput instance with new text', function (): void {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$slide = new Slide();
|
|
|
|
|
$title = 'Slide Modifié Texte';
|
|
|
|
|
$text = '<p>Nouveau texte</p>';
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
$input = new UpdateSlideInput(
|
|
|
|
|
slide: $slide,
|
|
|
|
|
title: $title,
|
|
|
|
|
text: $text,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// THEN
|
|
|
|
|
expect($input->slide)->toBe($slide)
|
|
|
|
|
->and($input->title)->toBe($title)
|
|
|
|
|
->and($input->text)->toBe($text);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws when title is empty', function (): void {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$slide = new Slide();
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
expect(fn () => new UpdateSlideInput(slide: $slide, title: ' ', text: 'Texte'))
|
|
|
|
|
// THEN
|
|
|
|
|
->toThrow(\InvalidArgumentException::class);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('throws when neither new nor existing picture nor text exists', function (): void {
|
|
|
|
|
// GIVEN
|
|
|
|
|
$slide = new Slide();
|
|
|
|
|
|
|
|
|
|
// WHEN
|
|
|
|
|
expect(fn () => new UpdateSlideInput(slide: $slide, title: 'Slide'))
|
|
|
|
|
// THEN
|
|
|
|
|
->toThrow(\InvalidArgumentException::class, 'A slide must have either a picture or text.');
|
|
|
|
|
});
|
|
|
|
|
});
|