Example #1
0
 /**
  * @param bool $responseCode
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @dataProvider checkResponseCodeFailureDataProvider
  */
 public function testCheckResponseCodeFailure($responseCode)
 {
     $reasonText = 'reason text';
     $this->responseMock->expects($this->once())->method('getXResponseCode')->willReturn($responseCode);
     $this->responseMock->expects($this->any())->method('getXResponseReasonText')->willReturn($reasonText);
     $this->dataHelperMock->expects($this->any())->method('wrapGatewayError')->with($reasonText)->willReturn(__('Gateway error: ' . $reasonText));
     $this->directpost->checkResponseCode();
 }
 /**
  * Create mock for response factory
  * @return void
  */
 private function initResponseFactoryMock()
 {
     $this->responseFactoryMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost\\Response\\Factory')->disableOriginalConstructor()->getMock();
     $this->responseMock = $this->getMockBuilder('Magento\\Authorizenet\\Model\\Directpost\\Response')->setMethods(['isValidHash', 'getXTransId', 'getXResponseCode', 'getXResponseReasonCode', 'getXResponseReasonText', 'getXAmount', 'setXResponseCode', 'setXResponseReasonCode', 'setXAvsCode', 'setXResponseReasonText', 'setXTransId', 'setXInvoiceNum', 'setXAmount', 'setXMethod', 'setXType', 'setData', 'setXAccountNumber', '__wakeup'])->disableOriginalConstructor()->getMock();
     $this->responseMock->expects(static::any())->method('setXResponseCode')->willReturnSelf();
     $this->responseMock->expects(static::any())->method('setXResponseReasonCode')->willReturnSelf();
     $this->responseMock->expects(static::any())->method('setXResponseReasonText')->willReturnSelf();
     $this->responseMock->expects(static::any())->method('setXAvsCode')->willReturnSelf();
     $this->responseMock->expects(static::any())->method('setXTransId')->willReturnSelf();
     $this->responseMock->expects(static::any())->method('setXInvoiceNum')->willReturnSelf();
     $this->responseMock->expects(static::any())->method('setXAmount')->willReturnSelf();
     $this->responseMock->expects(static::any())->method('setXMethod')->willReturnSelf();
     $this->responseMock->expects(static::any())->method('setXType')->willReturnSelf();
     $this->responseMock->expects(static::any())->method('setData')->willReturnSelf();
     $this->responseFactoryMock->expects($this->any())->method('create')->willReturn($this->responseMock);
 }