ldc-arcadia-api/tests/Unit/Domain/Entities/IncoSheetEntityTest.php

61 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Unit\Domain\Entities;
use Domain\Models\Entities\Inco\IncoSheet;
use Domain\Models\ValueObjects\Brand\ArcadiaId;
use Domain\Models\ValueObjects\Brand\BrandCode;
use Domain\Models\ValueObjects\Brand\BrandName;
use Domain\Models\ValueObjects\Inco\Allegations;
use Domain\Models\ValueObjects\Inco\IncoBrand;
use Domain\Models\ValueObjects\Inco\IncoId;
use Domain\Models\ValueObjects\Inco\Ingredients;
use Shared\DDD\Model\Entity;
covers(IncoSheet::class);
describe('IncoSheet Domain Entity Unit Tests', function (): void {
it('instantiates IncoSheet entity and returns correct id', function (): void {
// GIVEN
$id = new IncoId('12345');
$allegations = new Allegations(['Volaille française']);
$ingredients = new Ingredients(['Ingrédients' => ['Viande de dinde (66%)']]);
$brand = new IncoBrand(new BrandName('Le Gaulois'), new BrandCode('LGL01'), new ArcadiaId('504'));
// WHEN
$sheet = IncoSheet::hydrate(
id: $id,
name: 'Poulet Rôti 1kg',
label: 'Poulet Rôti Classe A',
description: 'Poulet prêt à cuire',
allegations: $allegations,
sellArguments: 'Délicieux',
preparationAdvices: 'Cuire 45min à 180°C',
tips: null,
sellFamilly: 'Boucherie',
ingredients: $ingredients,
portions: null,
allergens: [],
brand: $brand,
isSeasonal: true,
weight: null,
nutriscore: null,
storageCondition: null,
additives: [],
compo: null,
createdAt: null,
updatedAt: null,
);
// THEN
expect($sheet)->toBeInstanceOf(Entity::class)
->and($sheet->id())->toBe($id)
->and($sheet->name)->toBe('Poulet Rôti 1kg')
->and($sheet->brand->name->value)->toBe('Le Gaulois')
->and($sheet->brand->code->value)->toBe('LGL01')
->and($sheet->brand->arcadiaBrandCode->value)->toBe('504')
->and($sheet->isSeasonal)->toBeTrue();
});
});