public function testSend() { $httpClientResponseMock = $this->getMockBuilder('Zend\\Http\\Response')->disableOriginalConstructor()->getMock(); $httpClientResponseMock->expects($this->once())->method('getBody')->will($this->returnValue('<xmlrequest/>')); // Create Zend\Http\Client mock $httpClientMock = $this->getMockBuilder('Zend\\Http\\Client')->disableOriginalConstructor()->getMock(); $httpClientMock->expects($this->once())->method('getResponse')->will($this->returnValue($httpClientResponseMock)); $response = new BaseResponse(); $response->setStatus(BaseResponse::SUCCESS); $responseMock = $this->getMockBuilder('ZF2XmlApiSendeffect\\Api\\Response\\BaseResponse')->getMock(); $responseMock->expects($this->once())->method('create')->will($this->returnValue($response)); $request = new HttpRequest('http://a-dummy-url.com', $httpClientMock, $responseMock, new XmlConverter()); $response = $request->send([]); $this->assertTrue($response->isSuccess()); }
/** * Test the response in case of a error api response */ public function testCreationWithInvalidData() { $fakeData = <<<EOF <responseee> <status>NOT A VALID XML STRING</status> </responseee> EOF; /** @var BaseResponse $response */ $this->assertFalse($this->response->create($this->converter->reconvert($fakeData))); }