/**
  * When extracting results from the SDK response, a quantity
  * result model with the quantity data extracted from the
  * response should be returned.
  */
 public function testExtractResponseResultsSuccess()
 {
     // Create an expected result, should be returned when successfully
     // extracting results from a response.
     $sdkResult = $this->getModelMockBuilder('ebayenterprise_inventory/quantity_results')->disableOriginalConstructor()->getMock();
     // Mock the API to return an expected response body as the
     // reply to the SDK request.
     $this->_api->expects($this->any())->method('getResponseBody')->will($this->returnValue($this->_responseBody));
     // Mock up some SDK results - doesn't really matter what these
     // are, just that they can be recognized as the "right" results.
     $quantityRecords = [$this->getModelMockBuilder('ebayenteprirse_inventory/quantity')->disableOriginalConstructor()->getMock()];
     // Create a quote response parser capable of returning the
     // proper results from the quantity response.
     $this->_responseParser->expects($this->any())->method('getQuantityResults')->will($this->returnValue($quantityRecords));
     // Setup the quantity factory to be able to provide the proper quote
     // response parser if given the correct response payload and quote.
     $this->_inventoryFactory->expects($this->any())->method('createResponseParser')->with($this->identicalTo($this->_responseBody))->will($this->returnValue($this->_responseParser));
     // Setup the quantity factory to be able to provide the proper SDK result
     // if given the expected quantity data.
     $this->_inventoryFactory->expects($this->any())->method('createQuantityResults')->with($this->identicalTo($quantityRecords))->will($this->returnValue($sdkResult));
     // Ensure that the correct SDK result is returned when extracting
     // results from the SDK. For now, this will return the exact same
     // instance as is expected. In the future this may not be the case and
     // test could be expected to simply ensure the results available in
     // the returned result model match the expected results.
     $this->assertSame($sdkResult, EcomDev_Utils_Reflection::invokeRestrictedMethod($this->_sdkHelper, '_extractResponseResults', [$this->_api, $this->_items]));
 }
 /**
  * When getting quantity results from a response,
  * an array of quantity models populated from the
  * payload data should be returned.
  */
 public function testGetQuantityResults()
 {
     // Create an expected quantity model - created with data
     // expected to be extracted from the response payload.
     $quantityModel = Mage::getModel('ebayenterprise_inventory/quantity', ['sku' => $this->_quantityItemSku, 'item_id' => $this->_quantityItemItemId, 'quantity' => $this->_quantityItemQuantity]);
     // Set the response payload up to return the item iterable
     // containing a quantity item.
     $this->_responsePayload->expects($this->any())->method('getQuantityItems')->will($this->returnValue($this->_quantityItemIterable));
     // Set the quantity factory to return a correct quantity
     // model if given the proper sku, item id and quantity.
     $this->_quantityFactory->expects($this->any())->method('createQuantity')->with($this->identicalTo($this->_quantityItemSku), $this->identicalTo($this->_quantityItemItemId), $this->identicalTo($this->_quantityItemQuantity))->will($this->returnValue($quantityModel));
     $results = $this->_responseParser->getQuantityResults();
     // Verify the extracted results.
     $this->assertCount(1, $results, 'did not extract correct number of results');
     $resultQuantityModel = $results[0];
     $this->assertSame($this->_quantityItemSku, $resultQuantityModel->getSku(), 'sku of extracted quantity model does not match expected sku');
     $this->assertSame($this->_quantityItemItemId, $resultQuantityModel->getItemId(), 'item id of extracted quantity model does not match expected item id');
     $this->assertSame($this->_quantityItemQuantity, $resultQuantityModel->getQuantity(), 'quantity of extracted quantity model does not match expected quantity');
 }