/** * @expectedException \Exception */ public function testPostRequestFail() { $configInterfaceMock = $this->getMockBuilder('\\Magento\\Payment\\Model\\Method\\ConfigInterface')->getMockForAbstractClass(); $zendResponseMock = $this->getMockBuilder('\\Zend_Http_Response')->setMethods(['getBody'])->disableOriginalConstructor()->getMock(); $zendResponseMock->expects($this->never())->method('getBody'); $this->zendClientMock->expects($this->once())->method('request')->willThrowException(new \Exception()); $object = new \Magento\Framework\DataObject(); $this->object->postRequest($object, $configInterfaceMock); }
/** * @expectedException \Zend_Http_Client_Exception */ public function testPostRequestFail() { /** @var ConfigInterface|\PHPUnit_Framework_MockObject_MockObject $configInterfaceMock */ $configInterfaceMock = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass(); $zendResponseMock = $this->getMockBuilder(\Zend_Http_Response::class)->setMethods(['getBody'])->disableOriginalConstructor()->getMock(); $zendResponseMock->expects(static::never())->method('getBody'); $this->zendClientMock->expects(static::once())->method('request')->willThrowException(new \Zend_Http_Client_Exception()); $object = new DataObject(); $this->object->postRequest($object, $configInterfaceMock); }