本文整理汇总了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);
}
}