65 lines
2.5 KiB
PHP
65 lines
2.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Domain\Entities\Inco;
|
|
|
|
use Domain\Builders\Inco\IncoSheetBuilder;
|
|
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;
|
|
|
|
covers(IncoSheetBuilder::class);
|
|
|
|
describe('IncoSheetBuilder Unit Tests', function (): void {
|
|
it('builds an IncoSheet entity using builder when all required fields are set', 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::builder()
|
|
->withId($id)
|
|
->withName('Poulet Rôti 1kg')
|
|
->withLabel('Poulet Rôti Classe A')
|
|
->withDescription('Poulet prêt à cuire')
|
|
->withAllegations($allegations)
|
|
->withSellArguments('Délicieux')
|
|
->withPreparationAdvices('Cuire 45min à 180°C')
|
|
->withSellFamilly('Boucherie')
|
|
->withIngredients($ingredients)
|
|
->withBrand($brand)
|
|
->withIsSeasonal(true)
|
|
->build();
|
|
|
|
// THEN
|
|
expect($sheet)->toBeInstanceOf(IncoSheet::class)
|
|
->and($sheet->id())->toBe($id)
|
|
->and($sheet->name)->toBe('Poulet Rôti 1kg')
|
|
->and($sheet->label)->toBe('Poulet Rôti Classe A')
|
|
->and($sheet->description)->toBe('Poulet prêt à cuire')
|
|
->and($sheet->sellFamilly)->toBe('Boucherie')
|
|
->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();
|
|
});
|
|
|
|
it('throws DomainException when required fields are missing', function (): void {
|
|
// GIVEN
|
|
$builder = new IncoSheetBuilder();
|
|
|
|
// WHEN
|
|
expect(fn () => $builder->build())
|
|
|
|
// THEN
|
|
->toThrow(\DomainException::class, 'Cannot build IncoSheet: missing required components.');
|
|
});
|
|
});
|