65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Actions\Slides\UpdateSlideInput;
|
|
use App\Models\Slide;
|
|
|
|
describe('UpdateSlideInput', function (): void {
|
|
it('creates a valid UpdateSlideInput instance with existing slide picture', function (): void {
|
|
// GIVEN
|
|
$slide = new Slide();
|
|
$slide->picture = 'storage/modelfiles/slides/existing.jpg';
|
|
$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.');
|
|
});
|
|
});
|