43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\App\Dto;
|
|
|
|
use App\Dto\ProductIncoDto;
|
|
use Domain\Enums\Nutriscore;
|
|
use Domain\Models\ValueObjects\NutritionalValues;
|
|
|
|
describe('ProductIncoDto', function () {
|
|
test('it can be instantiated with all properties', function () {
|
|
// GIVEN
|
|
$nutrition = new NutritionalValues(refWeightG: 100.0, kj: 450.0, kcal: 110.0);
|
|
|
|
// WHEN
|
|
$dto = new ProductIncoDto(
|
|
id: 42,
|
|
no_art: 105,
|
|
product_id: '018f6c40-1234-7123-8123-123456789012',
|
|
ingredients: 'Volaille, sel',
|
|
preparation: 'Au four 30min',
|
|
servings: '4 personnes',
|
|
allergens: 'Aucun',
|
|
selling_argument: 'Origine France',
|
|
nutriscore: Nutriscore::A,
|
|
nutriscore_args: 'Faible en gras',
|
|
nutrition: $nutrition,
|
|
);
|
|
|
|
// THEN
|
|
$array = $dto->toArray();
|
|
|
|
expect($dto->getRouteKey())->toBe(42)
|
|
->and($dto->getRouteKeyName())->toBe('id')
|
|
->and($dto->resolveRouteBinding('some-id'))->toBeNull()
|
|
->and($dto->resolveChildRouteBinding('child', 'some-id', 'field'))->toBeNull()
|
|
->and($array)->toHaveKey('id', 42)
|
|
->and($array)->toHaveKey('no_art', 105)
|
|
->and($array)->toHaveKey('nutriscore', Nutriscore::A->value)
|
|
->and($array['nutrition'])->toHaveKey('nv_ref_weight_g', 100.0);
|
|
});
|
|
});
|