function it_recalculates_prices_without_adding_anything_to_the_context_if_its_not_needed(DelegatingCalculatorInterface $priceCalculator, OrderInterface $order, OrderItemInterface $item, PriceableInterface $variant) { $order->getCustomer()->willReturn(null); $order->getChannel()->willReturn(null); $order->getItems()->willReturn([$item]); $item->isImmutable()->willReturn(false); $item->getQuantity()->willReturn(5); $item->getVariant()->willReturn($variant); $priceCalculator->calculate($variant, ['quantity' => 5])->willReturn(10); $item->setUnitPrice(10)->shouldBeCalled(); $this->process($order); }
function it_recalculates_prices_adding_customer_to_the_context(ChannelInterface $channel, CustomerGroupInterface $group, CustomerInterface $customer, OrderInterface $order, OrderItemInterface $item, ProductVariantInterface $variant, ProductVariantPriceCalculatorInterface $productVariantPriceCalculator) { $order->getCustomer()->willReturn($customer); $order->getChannel()->willReturn(null); $order->getItems()->willReturn([$item]); $order->getCurrencyCode()->willReturn(null); $customer->getGroup()->willReturn($group); $item->isImmutable()->willReturn(false); $item->getQuantity()->willReturn(5); $item->getVariant()->willReturn($variant); $order->getChannel()->willReturn($channel); $productVariantPriceCalculator->calculate($variant, ['channel' => $channel])->willReturn(10); $item->setUnitPrice(10)->shouldBeCalled(); $this->process($order); }
function it_recalculates_prices_adding_all_context(GenericEvent $event, OrderInterface $order, OrderItemInterface $item, DelegatingCalculatorInterface $priceCalculator, GroupableInterface $customer, ArrayCollection $groups, ChannelInterface $channel, PriceableInterface $variant) { $event->getSubject()->shouldBeCalled()->willReturn($order); $order->getCustomer()->shouldBeCalled()->willReturn($customer); $order->getChannel()->shouldBeCalled()->willReturn($channel); $order->getItems()->shouldBeCalled()->willReturn(array($item)); $order->calculateTotal()->shouldBeCalled(); $customer->getGroups()->shouldBeCalled()->willReturn($groups); $groups->toArray()->shouldBeCalled()->willReturn(array('group1', 'group2')); $item->isImmutable()->shouldBeCalled()->willReturn(false); $item->getQuantity()->shouldBeCalled()->willReturn(5); $item->setUnitPrice(10)->shouldBeCalled(); $item->getVariant()->shouldBeCalled()->willReturn($variant); $priceCalculator->calculate($variant, array('customer' => $customer, 'groups' => array('group1', 'group2'), 'channel' => array($channel), 'quantity' => 5))->shouldBeCalled()->willReturn(10); $this->recalculatePrices($event); }