clear(); }); function createComposition(string $compoIdStr, string $incoIdStr): IncoComposition { $compoId = new IncoCompositionId($compoIdStr); $incoId = new IncoId($incoIdStr); $identification = new Identification('Poulet RĂ´ti 1kg Test', $incoIdStr, 'LDC'); $energyValues = new EnergyValues('100g', '0', '0'); $energy = new Energy($energyValues, $energyValues); $nutrient = new NutrientValue('0'); $refMacro = new ReferenceMacronutrients($nutrient, $nutrient, $nutrient, $nutrient, $nutrient, $nutrient, $nutrient); $porMacro = new PortionMacronutrients($nutrient, $nutrient, $nutrient, $nutrient, $nutrient, $nutrient, $nutrient); $fnAmount = new FruitAndNutAmount(); $pct = new PercentageValue('0'); $fresh = new FreshProduceAndNuts($fnAmount, $fnAmount, $pct, $pct); $refIntakes = new ReferenceIntakes($pct, $pct, $pct, $pct, $pct, $pct, $pct, $pct, '100g'); $nutriScore = new NutriScore('0', '0', 'A'); $nutriScorePoints = new NutriScorePoints('0', '0', '0', '0', '0', '0', '0'); $minerals = new Minerals('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'); $vitamins = new Vitamins('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'); $carbs = new CarbohydratesDetail('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'); $fatty = new FattyAcids('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'); $amino = new AminoAcids('0', '0', '0'); $special = new SpecialCompounds('0', '0', '0', '0'); return new IncoComposition( id: $compoId, idInco: $incoId, identification: $identification, energy: $energy, referenceMacronutrients: $refMacro, portionMacronutrients: $porMacro, freshProduceAndNuts: $fresh, referenceIntakes: $refIntakes, nutriScore: $nutriScore, nutriScorePoints: $nutriScorePoints, minerals: $minerals, vitamins: $vitamins, carbohydratesDetail: $carbs, fattyAcids: $fatty, aminoAcids: $amino, specialCompounds: $special, ); } it('executes successfully and returns Output when composition exists', function () use ($directory): void { // GIVEN $incoId = new IncoId('12345'); $composition = createComposition('67890', '12345'); $directory->add($composition); $usecase = new FindIncoComposition($directory); $input = new Input($incoId); // WHEN $output = $usecase->execute($input); // THEN expect($output)->toBeInstanceOf(Output::class) ->and($output->id->value)->toBe('67890') ->and($output->idInco->value)->toBe('12345'); }); it('throws NotFoundException when composition does not exist', function () use ($directory): void { // GIVEN $incoId = new IncoId('99999'); $usecase = new FindIncoComposition($directory); $input = new Input($incoId); // WHEN & THEN expect(fn () => $usecase->execute($input))->toThrow(IncoCompositionNotFoundException::class); }); });