clear(); $shortDirectory->clear(); }); it('searches full inco sheets matching query and brands', function () use ($directory, $shortDirectory): void { // GIVEN $incoSheet = IncoSheet::hydrate( id: new IncoId('12345'), name: 'Poulet Rôti 1kg', label: 'Poulet Rôti Classe A', description: 'Poulet prêt à cuire', allegations: new Allegations(['Volaille française']), sellArguments: 'Délicieux', preparationAdvices: 'Cuire 45min à 180°C', tips: null, sellFamilly: 'Boucherie', ingredients: new Ingredients(['Ingrédients' => ['Viande de dinde (66%)']]), portions: null, allergens: [], brand: new IncoBrand(new BrandName('Le Gaulois'), new BrandCode('LGL01'), new ArcadiaId('1')), isSeasonal: true, weight: null, nutriscore: null, storageCondition: null, additives: [], compo: null, createdAt: null, updatedAt: null, ); $directory->add($incoSheet); $usecase = new SearchIncoSheets($directory, $shortDirectory); $input = new Input( query: new IncoIdQuery('12%'), short: false, pagination: Pagination::ofPage(new PageNumber(1), new PageSize(10)), brands: new BrandCode('LGL01'), ); // WHEN $result = $usecase->execute($input); // THEN expect($result)->toBeInstanceOf(Output::class) ->and($result->total)->toBe(1) ->and($result->incoSheets)->toHaveCount(1); }); it('searches short inco sheets when short option is true', function () use ($directory, $shortDirectory): void { // GIVEN $shortSheet = IncoShortSheet::hydrate( id: new IncoId('12345'), name: 'Poulet Rôti 1kg', label: 'Poulet Rôti Classe A', description: 'Poulet prêt à cuire', createdAt: null, updatedAt: null, ); $shortDirectory->add($shortSheet); $usecase = new SearchIncoSheets($directory, $shortDirectory); $input = new Input( query: new IncoIdQuery('12%'), short: true, pagination: Pagination::ofPage(new PageNumber(1), new PageSize(10)), ); // WHEN $result = $usecase->execute($input); // THEN expect($result)->toBeInstanceOf(Output::class) ->and($result->total)->toBe(1) ->and($result->incoSheets)->toHaveCount(1); }); });