ldc-cocotte/tests/Unit/App/Dto/DiscountProductDtoTest.php

35 lines
862 B
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\App\Dto;
use App\Dto\DiscountProductDto;
describe('DiscountProductDto', function (): void {
it('creates a DTO from constructor and serializes to array and json', function (): void {
// GIVEN
$id = '018f-product-uuid';
$name = 'Poulet Fermier';
$picture = 'image.png';
// WHEN
$dto = new DiscountProductDto(
id: $id,
name: $name,
picture: $picture
);
// THEN
expect($dto->toArray())->toBe([
'id' => $id,
'name' => $name,
'picture' => $picture,
])
->and($dto->jsonSerialize())->toBe([
'id' => $id,
'name' => $name,
'picture' => $picture,
]);
});
});