toBeInstanceOf(NutritionalValues::class); }); it('throws exception if reference weight is negative', function () { // GIVEN $refWeightG = -10; // WHEN $action = fn () => getNewNutritionalValues(['refWeightG' => $refWeightG]); // THEN expect($action)->toThrow(\DomainException::class); }); it('throws exception if energy (kj) is negative', function () { // GIVEN $kj = -1; // WHEN $action = fn () => getNewNutritionalValues(['kj' => $kj]); // THEN expect($action)->toThrow(\DomainException::class); }); it('throws exception if fat is negative', function () { // GIVEN $fatG = -0.5; // WHEN $action = fn () => getNewNutritionalValues(['fatG' => $fatG]); // THEN expect($action)->toThrow(\DomainException::class); }); it('throws exception if daily energy is negative', function () { // GIVEN $dailyEnergy = -5; // WHEN $action = fn () => getNewNutritionalValues(['dailyEnergy' => $dailyEnergy]); // THEN expect($action)->toThrow(\DomainException::class); }); it('can convert to array', function () { // GIVEN $vo = new NutritionalValues(refWeightG: 100, kj: 500, proteinG: 10.5); // WHEN $array = $vo->toArray(); // THEN expect($array)->toBeArray(); expect($array['nv_ref_weight_g'])->toBe(100.0); expect($array['nv_kj'])->toBe(500.0); expect($array['nv_protein_g'])->toBe(10.5); expect($array['nv_fat_g'])->toBeNull(); }); });