71 lines
2.9 KiB
PHP
71 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Dto\SlideDto;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
describe('SlideDto', function (): void {
|
|
it('creates a DTO from Slide model', function (): void {
|
|
// GIVEN
|
|
$dateStart = Carbon::parse('2026-06-01 10:00:00');
|
|
$dateEnd = Carbon::parse('2026-06-30 20:00:00');
|
|
|
|
// WHEN
|
|
$dto = new SlideDto(
|
|
id: 42,
|
|
title: 'Bannière Été',
|
|
text: '<p>Découvrez notre nouvelle collection</p>',
|
|
picture: 'storage/modelfiles/slides/26/06/01/ab/summer.jpg',
|
|
picture_alt: 'Collection Été',
|
|
picture_title: 'Bannière promotionnelle été',
|
|
link: 'https://example.com/ete',
|
|
link_label: 'Voir les offres',
|
|
link_new_tab: true,
|
|
connected: false,
|
|
date_start: $dateStart,
|
|
date_end: $dateEnd,
|
|
order: 3,
|
|
status: true,
|
|
isVisible: true,
|
|
);
|
|
|
|
// 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())->toBeTrue()
|
|
->and($dto->getRouteKey())->toBe(42)
|
|
->and($dto->getRouteKeyName())->toBe('id')
|
|
->and($dto->resolveRouteBinding(42))->toBeNull()
|
|
->and($dto->resolveChildRouteBinding('child', 'val', 'field'))->toBeNull()
|
|
->and($dto->toArray())->toBe([
|
|
'id' => 42,
|
|
'title' => 'Bannière Été',
|
|
'text' => '<p>Découvrez notre nouvelle collection</p>',
|
|
'picture' => 'storage/modelfiles/slides/26/06/01/ab/summer.jpg',
|
|
'picture_alt' => 'Collection Été',
|
|
'picture_title' => 'Bannière promotionnelle été',
|
|
'link' => 'https://example.com/ete',
|
|
'link_label' => 'Voir les offres',
|
|
'link_new_tab' => true,
|
|
'connected' => false,
|
|
'date_start' => $dateStart,
|
|
'date_end' => $dateEnd,
|
|
'order' => 3,
|
|
'status' => true,
|
|
'is_visible' => true,
|
|
]);
|
|
});
|
|
});
|