/** * {@inheritdoc} */ public function calculate(ProductVariantInterface $productVariant, array $context) { Assert::keyExists($context, 'channel'); $channelPricing = $productVariant->getChannelPricingForChannel($context['channel']); Assert::notNull($channelPricing); return $channelPricing->getPrice(); }
function it_throws_exception_if_there_is_no_variant_price_for_given_channel(ChannelInterface $channel, ProductVariantInterface $productVariant) { $productVariant->getChannelPricingForChannel($channel)->willReturn(null); $this->shouldThrow(\InvalidArgumentException::class)->during('calculate', [$productVariant, ['chanel' => $channel]]); }