public function testAggregation(IdsCollection
$ids): void
{ try { $criteria =
new Criteria(array_values($ids->
all()));
$criteria->
addAggregation(new StatsAggregation('price', 'product.cheapestPrice'
));
$context =
$this->
getContainer()->
get(SalesChannelContextFactory::
class) ->
create(Uuid::
randomHex(), TestDefaults::SALES_CHANNEL
);
$cases =
$this->
providerAggregation();
foreach ($cases as $message =>
$case) { $context->
setRuleIds($ids->
getList($case['rules'
]));
$result =
$this->
getContainer()->
get('sales_channel.product.repository'
) ->
aggregate($criteria,
$context);
$aggregation =
$result->
get('price'
);
static::
assertInstanceOf(StatsResult::
class,
$aggregation);
static::
assertEquals($case['min'
],
$aggregation->
getMin(),
sprintf('Case `%s` failed',
$message));
static::
assertEquals($case['max'
],
$aggregation->
getMax(),
sprintf('Case `%s` failed',
$message));
}