當前位置: 首頁>>代碼示例>>PHP>>正文


PHP OrderItemInterface::addUnit方法代碼示例

本文整理匯總了PHP中Sylius\Component\Core\Model\OrderItemInterface::addUnit方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderItemInterface::addUnit方法的具體用法?PHP OrderItemInterface::addUnit怎麽用?PHP OrderItemInterface::addUnit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sylius\Component\Core\Model\OrderItemInterface的用法示例。


在下文中一共展示了OrderItemInterface::addUnit方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: ArrayCollection

 function it_creates_only_missing_inventory_units_via_the_factory($orderItemUnitFactory, OrderItemInterface $item, ProductVariantInterface $variant, OrderItemUnitInterface $unit1, OrderItemUnitInterface $unit2)
 {
     $item->getUnits()->shouldBeCalled()->willReturn(new ArrayCollection(array($unit1)));
     $unit1->getStockable()->willReturn($variant);
     $unit2->getStockable()->willReturn($variant);
     $item->getVariant()->willReturn($variant);
     $item->getQuantity()->willReturn(2);
     $item->getUnits()->willReturn(new ArrayCollection());
     $orderItemUnitFactory->createNew()->willReturn($unit2);
     $unit1->setInventoryState(InventoryUnitInterface::STATE_CHECKOUT)->shouldNotBeCalled();
     $unit2->setInventoryState(InventoryUnitInterface::STATE_CHECKOUT)->shouldBeCalled();
     $item->addUnit($unit1)->shouldNotBeCalled();
     $item->addUnit($unit2)->shouldBeCalled();
     $this->processInventoryUnits($item);
 }
開發者ID:Hsidhu,項目名稱:Sylius,代碼行數:15,代碼來源:InventoryHandlerSpec.php

示例2:

 function it_does_nothing_if_target_quantity_is_below_0($orderItemUnitFactory, OrderItemInterface $orderItem)
 {
     $orderItem->getQuantity()->willReturn(3);
     $orderItemUnitFactory->createForItem(Argument::any())->shouldNotBeCalled();
     $orderItem->addUnit(Argument::any())->shouldNotBeCalled();
     $orderItem->removeUnit(Argument::any())->shouldNotBeCalled();
     $this->modify($orderItem, -10);
 }
開發者ID:benakacha,項目名稱:Sylius,代碼行數:8,代碼來源:OrderItemQuantityModifierSpec.php

示例3: let

 function let(OrderItemInterface $orderItem)
 {
     $orderItem->getUnitPrice()->willReturn(1000);
     $orderItem->addUnit(Argument::type(OrderItemUnitInterface::class))->shouldBeCalled();
     $this->beConstructedWith($orderItem);
 }
開發者ID:TheMadeleine,項目名稱:Sylius,代碼行數:6,代碼來源:OrderItemUnitSpec.php

示例4: createInventoryUnits

 /**
  * @param OrderItemInterface $item
  * @param int $quantity
  * @param string $state
  */
 protected function createInventoryUnits(OrderItemInterface $item, $quantity, $state = InventoryUnitInterface::STATE_CHECKOUT)
 {
     if ($quantity < 1) {
         throw new \InvalidArgumentException('Quantity of units must be greater than 0.');
     }
     for ($i = 0; $i < $quantity; $i++) {
         $unit = $this->orderItemUnitFactory->createNew();
         $unit->setInventoryState($state);
         $item->addUnit($unit);
     }
 }
開發者ID:Hsidhu,項目名稱:Sylius,代碼行數:16,代碼來源:InventoryHandler.php


注:本文中的Sylius\Component\Core\Model\OrderItemInterface::addUnit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。