function it_partially_fills_backordered_units_and_updates_stock_accordingly(StockableInterface $stockable, InventoryUnitInterface $inventoryUnit1, InventoryUnitInterface $inventoryUnit2, ObjectRepository $repository)
 {
     $stockable->getOnHand()->shouldBeCalled()->willReturn(5);
     $stockable->setOnHand(3)->shouldBeCalled();
     $inventoryUnit1->setInventoryState(InventoryUnitInterface::STATE_SOLD)->shouldBeCalled();
     $inventoryUnit2->setInventoryState(InventoryUnitInterface::STATE_SOLD)->shouldBeCalled();
     $repository->findBy(['stockable' => $stockable, 'inventoryState' => InventoryUnitInterface::STATE_BACKORDERED], ['createdAt' => 'ASC'])->willReturn([$inventoryUnit1, $inventoryUnit2]);
     $this->fillBackorders($stockable);
 }
 function it_decreases_stockable_on_hand_and_ignores_backordered_units($availabilityChecker, $backordersHandler, StockableInterface $stockable, InventoryUnitInterface $inventoryUnit1, InventoryUnitInterface $inventoryUnit2, InventoryUnitInterface $inventoryUnit3)
 {
     $inventoryUnit1->getStockable()->willReturn($stockable);
     $inventoryUnit2->getStockable()->willReturn($stockable);
     $inventoryUnit3->getStockable()->willReturn($stockable);
     $availabilityChecker->isStockSufficient($stockable, 3)->shouldBeCalled()->willReturn(true);
     $backordersHandler->processBackorders(array($inventoryUnit1, $inventoryUnit2, $inventoryUnit3))->shouldBeCalled();
     $inventoryUnit1->getInventoryState()->shouldBeCalled()->willReturn(InventoryUnitInterface::STATE_SOLD);
     $inventoryUnit2->getInventoryState()->shouldBeCalled()->willReturn(InventoryUnitInterface::STATE_BACKORDERED);
     $inventoryUnit3->getInventoryState()->shouldBeCalled()->willReturn(InventoryUnitInterface::STATE_BACKORDERED);
     $stockable->getOnHand()->shouldBeCalled()->willReturn(1);
     $stockable->setOnHand(0)->shouldBeCalled();
     $this->decrease(array($inventoryUnit1, $inventoryUnit2, $inventoryUnit3));
 }
Example #3
0
 function it_not_a_backorder_if_contains_no_backordered_units(InventoryUnitInterface $unit1, InventoryUnitInterface $unit2, OrderItemInterface $item)
 {
     $unit1->getInventoryState()->willReturn(InventoryUnitInterface::STATE_SOLD);
     $unit2->getInventoryState()->willReturn(InventoryUnitInterface::STATE_SOLD);
     $item->getUnits()->willReturn(array($unit1, $unit2));
     $item->setOrder($this)->shouldBeCalled();
     $this->addItem($item);
     $this->shouldNotBeBackorder();
 }