/** * @covers \Magento\BraintreeTwo\Gateway\Response\PaymentDetailsHandler::handle */ public function testHandle() { $paymentData = $this->getPaymentDataObjectMock(); $transaction = $this->getBraintreeTransaction(); $subject = ['payment' => $paymentData]; $response = ['object' => $transaction]; $this->subjectReader->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData); $this->subjectReader->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction); $this->paymentHandler->handle($subject, $response); }
/** * @covers \Magento\BraintreeTwo\Gateway\Response\VaultDetailsHandler::handle */ public function testHandle() { $this->paymentExtension->expects(self::once())->method('setVaultPaymentToken')->with($this->paymentToken); $this->paymentExtension->expects(self::once())->method('getVaultPaymentToken')->willReturn($this->paymentToken); $paymentData = $this->getPaymentDataObjectMock(); $transaction = $this->getBraintreeTransaction(); $subject = ['payment' => $paymentData]; $response = ['object' => $transaction]; $this->subjectReader->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData); $this->subjectReader->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction); $this->paymentToken->expects(static::once())->method('setGatewayToken')->with('rh3gd4'); $this->paymentToken->expects(static::once())->method('setExpiresAt')->with('2022-01-01 00:00:00'); $this->paymentHandler->handle($subject, $response); $this->assertSame($this->paymentToken, $this->payment->getExtensionAttributes()->getVaultPaymentToken()); }
/** * @covers \Magento\BraintreeTwo\Gateway\Response\VaultDetailsHandler::handle */ public function testHandle() { $this->vaultPaymentMock->expects(self::once())->method('isActiveForPayment')->willReturn(true); $this->paymentExtension->expects(self::once())->method('setVaultPaymentToken')->with($this->paymentTokenMock); $this->paymentExtension->expects(self::once())->method('getVaultPaymentToken')->willReturn($this->paymentTokenMock); $paymentData = $this->getPaymentDataObjectMock(); $transaction = $this->getBraintreeTransaction(); $subject = ['payment' => $paymentData]; $response = ['object' => $transaction]; $this->subjectReaderMock->expects(self::once())->method('readPayment')->with($subject)->willReturn($paymentData); $this->subjectReaderMock->expects(self::once())->method('readTransaction')->with($response)->willReturn($transaction); $this->salesOrderMock->setCustomerId(10); $this->paymentHandler->handle($subject, $response); $this->assertEquals('rh3gd4', $this->paymentTokenMock->getGatewayToken()); $this->assertEquals('10', $this->paymentTokenMock->getCustomerId()); $this->assertSame($this->paymentTokenMock, $this->payment->getExtensionAttributes()->getVaultPaymentToken()); }