/** * @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(); }
/** * @covers \Magento\Authorizenet\Model\Directpost::refund() * @return void */ public function testSuccessRefund() { $card = 1111; $this->paymentMock->expects(static::exactly(2))->method('getCcLast4')->willReturn($card); $this->paymentMock->expects(static::once())->method('decrypt')->willReturn($card); $this->paymentMock->expects(static::exactly(3))->method('getParentTransactionId')->willReturn(self::TRANSACTION_ID . '-capture'); $this->paymentMock->expects(static::once())->method('getPoNumber')->willReturn(self::INVOICE_NUM); $this->paymentMock->expects(static::once())->method('setIsTransactionClosed')->with(true)->willReturnSelf(); $orderMock = $this->getOrderMock(); $this->paymentMock->expects(static::exactly(2))->method('getOrder')->willReturn($orderMock); $transactionMock = $this->getMockBuilder(Order\Payment\Transaction::class)->disableOriginalConstructor()->setMethods(['getAdditionalInformation'])->getMock(); $transactionMock->expects(static::once())->method('getAdditionalInformation')->with(Directpost::REAL_TRANSACTION_ID_KEY)->willReturn(self::TRANSACTION_ID); $this->transactionRepositoryMock->expects(static::once())->method('getByTransactionId')->willReturn($transactionMock); $response = $this->getRefundResponseBody(Directpost::RESPONSE_CODE_APPROVED, Directpost::RESPONSE_REASON_CODE_APPROVED, 'Successful'); $this->httpClientMock->expects(static::once())->method('getBody')->willReturn($response); $this->responseMock->expects(static::once())->method('getXResponseCode')->willReturn(Directpost::RESPONSE_CODE_APPROVED); $this->responseMock->expects(static::once())->method('getXResponseReasonCode')->willReturn(Directpost::RESPONSE_REASON_CODE_APPROVED); $this->dataHelperMock->expects(static::never())->method('wrapGatewayError'); $this->directpost->refund($this->paymentMock, self::TOTAL_AMOUNT); }