/** * 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])); }