/** * When the session has results that apply to the quote, the results * stored in the session should be returned and no new quantity results * should be requested. */ public function testGetQuantityResultsForQuoteFromSession() { // Expect the session to return quantity results. $this->_inventorySession->expects($this->any())->method('getQuantityResults')->will($this->returnValue($this->_quantityResults)); // Ensure that no new quantity results are requested. $this->_quantitySdkHelper->expects($this->never())->method('requestQuantityForItems'); // Expect the current sku quantity data to match the data the results // were collected with - allows results to be applied to the current // quote data. $this->_quantityResults->expects($this->any())->method('checkResultsApplyToItems')->with($this->identicalTo($this->_currentItemQuantityData))->will($this->returnValue(true)); $this->assertSame($this->_quantityResults, $this->_quantityCollector->getQuantityResultsForQuote($this->_quote)); }
/** * Script the quantity results mock to return a quantity result by * sku or item id. * * @param array $resultsData Array of arrays, each inner array must contain: * - sku => string * - item_id => int|null * - quantity => EbayEnterprise_Inventory_Model_Quantity */ protected function _mockQuantityResults($resultsData) { $bySku = array_map(function ($result) { return [$result['sku'], $result['quantity']]; }, $resultsData); $byId = array_map(function ($result) { return [$result['item_id'], $result['quantity']]; }, array_filter($resultsData, function ($result) { return (bool) $result['item_id']; })); $this->_quantityResults->expects($this->any())->method('getQuantityBySku')->will($this->returnValueMap($bySku)); $this->_quantityResults->expects($this->any())->method('getQuantityByItemId')->will($this->returnValueMap($byId)); }