function it_creates_only_missing_inventory_units_via_the_factory(InventoryUnitFactoryInterface $inventoryUnitFactory, OrderItemInterface $item, ProductVariantInterface $variant, InventoryUnitInterface $unit1, InventoryUnitInterface $unit2)
 {
     $item->getInventoryUnits()->shouldBeCalled()->willReturn(new ArrayCollection(array($unit1)));
     $unit1->getStockable()->willReturn($variant);
     $unit2->getStockable()->willReturn($variant);
     $item->getVariant()->willReturn($variant);
     $item->getQuantity()->willReturn(2);
     $inventoryUnitFactory->createForStockable($variant, 1, InventoryUnitInterface::STATE_CHECKOUT)->willReturn(array($unit2));
     $item->addInventoryUnit($unit1)->shouldNotBeCalled();
     $item->addInventoryUnit($unit2)->shouldBeCalled();
     $this->processInventoryUnits($item);
 }
 protected function createInventoryUnits(OrderItemInterface $item, $quantity, $state = InventoryUnitInterface::STATE_CHECKOUT)
 {
     $units = $this->inventoryUnitFactory->create($item->getVariant(), $quantity, $state);
     foreach ($units as $unit) {
         $item->addInventoryUnit($unit);
     }
 }