本文整理汇总了PHP中Sylius\Component\Core\Model\OrderItemInterface::getProduct方法的典型用法代码示例。如果您正苦于以下问题:PHP OrderItemInterface::getProduct方法的具体用法?PHP OrderItemInterface::getProduct怎么用?PHP OrderItemInterface::getProduct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sylius\Component\Core\Model\OrderItemInterface
的用法示例。
在下文中一共展示了OrderItemInterface::getProduct方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
function it_filters_passed_order_items_with_given_configuration(OrderItemInterface $item1, OrderItemInterface $item2, ProductInterface $product1, ProductInterface $product2)
{
$item1->getProduct()->willReturn($product1);
$product1->getCode()->willReturn('product1');
$item2->getProduct()->willReturn($product2);
$product2->getCode()->willReturn('product2');
$this->filter([$item1, $item2], ['filters' => ['products_filter' => ['products' => ['product1']]]])->shouldReturn([$item1]);
}
示例2:
function it_recognizes_a_subject_as_not_eligible_if_a_product_taxon_is_not_matched(OrderInterface $subject, OrderItemInterface $item, ProductInterface $reflexBow, TaxonInterface $bows)
{
$configuration = ['taxons' => ['swords', 'axes']];
$bows->getCode()->willReturn('bows');
$reflexBow->getTaxons()->willReturn([$bows]);
$item->getProduct()->willReturn($reflexBow);
$subject->getItems()->willReturn([$item]);
$this->isEligible($subject, $configuration)->shouldReturn(false);
}
示例3:
function it_returns_false_if_product_is_wrong(OrderInterface $subject, OrderItemInterface $firstOrderItem, OrderItemInterface $secondOrderItem, ProductInterface $shaft, ProductInterface $head)
{
$subject->getItems()->willReturn([$firstOrderItem, $secondOrderItem]);
$firstOrderItem->getProduct()->willReturn($head);
$secondOrderItem->getProduct()->willReturn($shaft);
$head->getCode()->willReturn('LACROSSE_HEAD');
$shaft->getCode()->willReturn('LACROSSE_SHAFT');
$this->isEligible($subject, ['product_code' => 'LACROSSE_STRING'])->shouldReturn(false);
}
示例4:
function it_should_recognize_subject_as_not_eligible_if_product_taxonomy_is_matched_and_exclude_is_set(OrderInterface $subject, OrderItemInterface $item, Taxon $taxon, Product $product, ArrayCollection $collection)
{
$configuration = ['taxons' => $collection, 'exclude' => true];
$collection->contains(2)->willReturn(true);
$taxon->getId()->willReturn(2);
$product->getTaxons()->willReturn([$taxon]);
$item->getProduct()->willReturn($product);
$subject->getItems()->willReturn([$item]);
$this->isEligible($subject, $configuration)->shouldReturn(false);
}
示例5:
function it_does_not_check_an_item_if_its_product_has_no_required_taxon(OrderInterface $order, OrderItemInterface $compositeBowItem, OrderItemInterface $longswordItem, ProductInterface $compositeBow, ProductInterface $longsword, TaxonInterface $bows, TaxonRepositoryInterface $taxonRepository)
{
$order->getItems()->willReturn(new \ArrayIterator([$compositeBowItem->getWrappedObject(), $longswordItem->getWrappedObject()]));
$taxonRepository->findOneBy(['code' => 'bows'])->willReturn($bows);
$compositeBowItem->getProduct()->willReturn($compositeBow);
$compositeBow->hasTaxon($bows)->willReturn(true);
$compositeBowItem->getQuantity()->willReturn(4);
$longswordItem->getProduct()->willReturn($longsword);
$longsword->hasTaxon($bows)->willReturn(false);
$longswordItem->getQuantity()->shouldNotBeCalled();
$this->isEligible($order, ['taxon' => 'bows', 'count' => 5])->shouldReturn(false);
}
示例6:
function it_does_not_recognize_a_subject_as_eligible_if_items_from_required_taxon_has_too_low_total(TaxonRepositoryInterface $taxonRepository, OrderInterface $order, OrderItemInterface $compositeBowItem, OrderItemInterface $longswordItem, ProductInterface $compositeBow, ProductInterface $longsword, TaxonInterface $bows)
{
$order->getItems()->willReturn([$compositeBowItem, $longswordItem]);
$taxonRepository->findOneBy(['code' => 'bows'])->willReturn($bows);
$compositeBowItem->getProduct()->willReturn($compositeBow);
$compositeBow->hasTaxon($bows)->willReturn(true);
$compositeBowItem->getTotal()->willReturn(5000);
$longswordItem->getProduct()->willReturn($longsword);
$longsword->hasTaxon($bows)->willReturn(false);
$longswordItem->getTotal()->willReturn(4000);
$this->isEligible($order, ['taxon' => 'bows', 'amount' => 10000])->shouldReturn(false);
}
示例7:
function it_removes_invalid_cart_items($cartProvider, $restrictedZoneChecker, $session, $translator, $cartManager, OrderItemInterface $item, GenericEvent $event, OrderInterface $cart, ProductInterface $product, AddressInterface $address, FlashBag $flashBag)
{
$event->getSubject()->willReturn($cart);
$cartProvider->getCart()->shouldNotBeCalled();
$item->getProduct()->willReturn($product);
$product->getName()->willReturn('invalid');
$cart->getItems()->willReturn([$item]);
$cart->getShippingAddress()->willReturn($address);
$cart->removeItem($item)->shouldBeCalled();
$restrictedZoneChecker->isRestricted($product, $address)->willReturn(true);
$session->getBag('flashes')->willReturn($flashBag);
$flashBag->add('error', Argument::any())->shouldBeCalled();
$translator->trans('sylius.cart.restricted_zone_removal', ['%product%' => 'invalid'], 'flashes')->shouldBeCalled();
$cartManager->persist($cart)->shouldBeCalled();
$cartManager->flush()->shouldBeCalled();
$this->handleRestrictedZone($event);
}
示例8: ArrayCollection
function it_does_not_recognize_a_subject_as_eligible_if_items_from_required_taxon_has_too_low_total(ChannelInterface $channel, OrderInterface $order, OrderItemInterface $compositeBowItem, OrderItemInterface $longswordItem, ProductInterface $compositeBow, ProductInterface $longsword, ProductTaxonInterface $bowsProductTaxon, TaxonInterface $bows, TaxonRepositoryInterface $taxonRepository)
{
$order->getChannel()->willReturn($channel);
$channel->getCode()->willReturn('WEB_US');
$order->getItems()->willReturn([$compositeBowItem, $longswordItem]);
$taxonRepository->findOneBy(['code' => 'bows'])->willReturn($bows);
$compositeBowItem->getProduct()->willReturn($compositeBow);
$compositeBow->filterProductTaxonsByTaxon($bows)->willReturn(new ArrayCollection([$bowsProductTaxon]));
$compositeBowItem->getTotal()->willReturn(5000);
$longswordItem->getProduct()->willReturn($longsword);
$longsword->filterProductTaxonsByTaxon($bows)->willReturn(new ArrayCollection([]));
$longswordItem->getTotal()->willReturn(4000);
$this->isEligible($order, ['WEB_US' => ['taxon' => 'bows', 'amount' => 10000]])->shouldReturn(false);
}