product)->toBe($product) ->and($input->no_art)->toBe(12) ->and($input->ingredients)->toBe('Poulet, sel') ->and($input->preparation)->toBe('Au four') ->and($input->servings)->toBe('4 pers') ->and($input->allergens)->toBe('Aucun') ->and($input->selling_argument)->toBe('Top qualité') ->and($input->nutriscore)->toBe(Nutriscore::B) ->and($input->nutriscore_args)->toBe('Faible teneur en sel') ->and($input->nutrition)->toBe($nutrition); }); test('it defaults nutrition to empty NutritionalValues', function () { // GIVEN $product = new Product(); // WHEN $input = new CreateProductIncoInput( product: $product, ); // THEN expect($input->nutrition)->toBeInstanceOf(NutritionalValues::class) ->and($input->no_art)->toBeNull(); }); test('it throws when no_art is less than 1', function () { // GIVEN $product = new Product(); // WHEN & THEN expect(fn () => new CreateProductIncoInput( product: $product, no_art: 0, ))->toThrow(\InvalidArgumentException::class, 'Article number must be greater than or equal to 1.'); }); test('it throws when servings exceeds 20 characters', function () { // GIVEN $product = new Product(); // WHEN & THEN expect(fn () => new CreateProductIncoInput( product: $product, servings: str_repeat('a', 21), ))->toThrow(\InvalidArgumentException::class, 'Servings cannot exceed 20 characters.'); }); });