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)); }
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(); }