43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Dto\RangeDto;
|
|
|
|
describe('RangeDto', function () {
|
|
test('it can be instantiated directly and converts to array', function () {
|
|
// GIVEN
|
|
$data = [
|
|
'id' => 1,
|
|
'name' => 'Gamme Découverte',
|
|
'slug' => 'gamme-decouverte',
|
|
'description' => '<p>Description</p>',
|
|
'picture' => 'ranges/pic.jpg',
|
|
'picture_alt' => 'Alt text',
|
|
'picture_title' => 'Title text',
|
|
'order' => 2,
|
|
'status' => true,
|
|
];
|
|
|
|
// WHEN
|
|
$dto = new RangeDto(...$data);
|
|
|
|
// THEN
|
|
expect($dto->id)->toBe(1)
|
|
->and($dto->name)->toBe('Gamme Découverte')
|
|
->and($dto->slug)->toBe('gamme-decouverte')
|
|
->and($dto->getRouteKey())->toBe('gamme-decouverte')
|
|
->and($dto->getRouteKeyName())->toBe('slug')
|
|
->and($dto->toArray())->toBe([
|
|
'id' => 1,
|
|
'name' => 'Gamme Découverte',
|
|
'slug' => 'gamme-decouverte',
|
|
'description' => '<p>Description</p>',
|
|
'picture' => 'ranges/pic.jpg',
|
|
'picture_alt' => 'Alt text',
|
|
'picture_title' => 'Title text',
|
|
'order' => 2,
|
|
'status' => true,
|
|
]);
|
|
});
|
|
});
|