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); }
/** * @param OrderItemInterface $orderItem * @param int $decreaseBy */ private function decreaseUnitsNumber(OrderItemInterface $orderItem, $decreaseBy) { foreach ($orderItem->getUnits() as $unit) { if (0 >= $decreaseBy--) { break; } $orderItem->removeUnit($unit); } }