本文整理匯總了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);
}
示例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);
}
示例3: let
function let(OrderItemInterface $orderItem)
{
$orderItem->getUnitPrice()->willReturn(1000);
$orderItem->addUnit(Argument::type(OrderItemUnitInterface::class))->shouldBeCalled();
$this->beConstructedWith($orderItem);
}
示例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);
}
}