/** * When clearing collected results, any stored quantity results should * be removed from storage, preventing them from being reused. */ public function testClearResults() { // Side-effect test: results currently stored in session, setting the // sessions quantity results to null will remove any existing results // from being reused. $this->_inventorySession->expects($this->once())->method('setQuantityResults')->with($this->identicalTo(null))->will($this->returnSelf()); $this->assertSame($this->_quantityCollector, $this->_quantityCollector->clearResults()); }
/** * Check the inventory status of each item in the quote. Will add errors * to the quote and items if any are not currently available at the * requested quantity. Will throw an exception if any item not yet added * to the quote should be prevented from being added. * * @param Mage_Sales_Model_Quote * @return self * @throws EbayEnterprise_Inventory_Exception_Quantity_Unavailable_Exception If any items should not be added to the quote. */ public function checkQuoteInventory(Mage_Sales_Model_Quote $quote) { $inventoryItems = $this->_inventoryItemSelection->selectFrom($quote->getAllItems()); if (empty($inventoryItems)) { $this->_quantityCollector->clearResults(); } foreach ($inventoryItems as $item) { if (!$this->isItemAvailable($item)) { $this->_handleUnavailableItem($item); } else { $this->_notifyCustomerIfItemBackorderable($item); } } return $this; }
/** * Check the inventory status of each item in the quote. Will add errors * to the quote and items if any are not currently available at the * requested quantity. Will throw an exception if any item not yet added * to the quote should be prevented from being added. * * @param Mage_Sales_Model_Quote * @return self * @throws EbayEnterprise_Inventory_Exception_Quantity_Unavailable_Exception If any items should not be added to the quote. */ public function checkQuoteInventory(Mage_Sales_Model_Quote $quote) { $inventoryItems = $this->_inventoryItemSelection->selectFrom($quote->getAllItems()); if (empty($inventoryItems)) { $this->_logger->debug('no items to check, clearing collected quantities', $this->_logContext->getMetaData(__CLASS__)); $this->_quantityCollector->clearResults(); } foreach ($inventoryItems as $item) { if (!$this->isItemAvailable($item)) { $this->_handleUnavailableItem($item); } else { $this->_notifyCustomerIfItemBackorderable($item); } } return $this; }