/** * When the session has results but they no longer apply to the quote, * a new set of results should be requested and replace the existing * results in the session. */ public function testGetQuantityResultsForQuoteSessionDataOutdated() { $outdatedResults = $this->getModelMockBuilder('ebayenterprise_inventory/quantity_results')->disableOriginalConstructor()->setMethods(['checkResultsApplyToItems'])->getMock(); $outdatedResults->expects($this->any())->method('checkResultsApplyToItems')->with($this->_currentItemQuantityData)->will($this->returnValue(false)); // Expect the session to return quantity results. $this->_inventorySession->expects($this->any())->method('getQuantityResults')->will($this->returnValue($outdatedResults)); // Side-effect test: ensure that new results are requested from the // API via the SDK helper. $this->_quantitySdkHelper->expects($this->once())->method('requestQuantityForItems')->with($this->identicalTo($this->_filteredQuoteItems))->will($this->returnValue($this->_quantityResults)); // Side-effect test: ensure that the newly collected results are put // into the session for later use. $this->_inventorySession->expects($this->once())->method('setQuantityResults')->with($this->identicalTo($this->_quantityResults))->will($this->returnSelf()); $this->assertSame($this->_quantityResults, $this->_quantityCollector->getQuantityResultsForQuote($this->_quote)); }
/** * Get the quantity results for an item. * * @param Mage_Sales_Model_Quote_Item_Abstract * @return EbayEnterprise_Inventory_Model_Quantity|null */ protected function _getQuantityResultForItem(Mage_Sales_Model_Quote_Item_Abstract $item) { return $this->_quantityCollector->getQuantityResultsForQuote($item->getQuote())->getQuantityBySku($this->_inventoryHelper->getRomSku($item->getSku())); }