$resolverContext =
new ResolverContext($salesChannelContext,
new Request());
$result =
new ElementDataCollection();
$result->
add('product_id',
new EntitySearchResult( 'product',
1,
new ProductCollection([clone $product]),
null,
new Criteria(),
$resolverContext->
getSalesChannelContext()->
getContext() ));
$slot =
$this->
enrichProductWithCmsConfig($product);
$this->productBoxResolver->
enrich($slot,
$resolverContext,
$result);
/** @var ProductBoxStruct|null $productBoxStruct */
$productBoxStruct =
$slot->
getData();
static::
assertInstanceOf(ProductBoxStruct::
class,
$productBoxStruct);
/*
* conditional assertions depending on if a product should be returned or not
*/
if ($closeout &&
$hidden &&
$availableStock === 0
) { static::
assertNull($productBoxStruct->
getProductId());
}