51 lines
2.1 KiB
PHP
51 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Dto\SlideDto;
|
|
use App\Models\Slide;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
describe('SlideDto integration', function (): void {
|
|
it('creates a DTO from Slide model with booted application', function (): void {
|
|
// GIVEN
|
|
$dateStart = Carbon::parse('2026-06-01 10:00:00');
|
|
$dateEnd = Carbon::parse('2026-06-30 20:00:00');
|
|
|
|
$slide = new Slide();
|
|
$slide->id = 42;
|
|
$slide->title = 'Bannière Été';
|
|
$slide->text = '<p>Découvrez notre nouvelle collection</p>';
|
|
$slide->picture = 'storage/modelfiles/slides/26/06/01/ab/summer.jpg';
|
|
$slide->picture_alt = 'Collection Été';
|
|
$slide->picture_title = 'Bannière promotionnelle été';
|
|
$slide->link = 'https://example.com/ete';
|
|
$slide->link_label = 'Voir les offres';
|
|
$slide->link_new_tab = true;
|
|
$slide->connected = false;
|
|
$slide->date_start = $dateStart;
|
|
$slide->date_end = $dateEnd;
|
|
$slide->order = 3;
|
|
$slide->status = true;
|
|
|
|
// WHEN
|
|
$dto = SlideDto::fromModel($slide);
|
|
|
|
// THEN
|
|
expect($dto->id)->toBe(42)
|
|
->and($dto->title)->toBe('Bannière Été')
|
|
->and($dto->text)->toBe('<p>Découvrez notre nouvelle collection</p>')
|
|
->and($dto->picture)->toBe('storage/modelfiles/slides/26/06/01/ab/summer.jpg')
|
|
->and($dto->picture_alt)->toBe('Collection Été')
|
|
->and($dto->picture_title)->toBe('Bannière promotionnelle été')
|
|
->and($dto->link)->toBe('https://example.com/ete')
|
|
->and($dto->link_label)->toBe('Voir les offres')
|
|
->and($dto->link_new_tab)->toBeTrue()
|
|
->and($dto->connected)->toBeFalse()
|
|
->and($dto->date_start)->toEqual($dateStart)
|
|
->and($dto->date_end)->toEqual($dateEnd)
|
|
->and($dto->order)->toBe(3)
|
|
->and($dto->status)->toBeTrue()
|
|
->and($dto->isVisible())->toBeFalse();
|
|
});
|
|
});
|