protected function setUp()
 {
     $this->paymentToken = $this->getMock(PaymentTokenInterface::class);
     $this->paymentTokenFactory = $this->getMockBuilder(PaymentTokenInterfaceFactory::class)->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $this->paymentTokenFactory->expects(self::once())->method('create')->willReturn($this->paymentToken);
     $this->paymentExtension = $this->getMockBuilder(OrderPaymentExtensionInterface::class)->setMethods(['setVaultPaymentToken', 'getVaultPaymentToken'])->disableOriginalConstructor()->getMock();
     $this->paymentExtensionFactory = $this->getMockBuilder(OrderPaymentExtensionInterfaceFactory::class)->disableOriginalConstructor()->setMethods(['create'])->getMock();
     $this->paymentExtensionFactory->expects(self::once())->method('create')->willReturn($this->paymentExtension);
     $this->payment = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->setMethods(['__wakeup'])->getMock();
     $this->subjectReader = $this->getMockBuilder(SubjectReader::class)->disableOriginalConstructor()->getMock();
     $mapperArray = ["american-express" => "AE", "discover" => "DI", "jcb" => "JCB", "mastercard" => "MC", "master-card" => "MC", "visa" => "VI", "maestro" => "MI", "diners-club" => "DN", "unionpay" => "CUP"];
     $this->config = $this->getMockBuilder(Config::class)->setMethods(['getCctypesMapper'])->disableOriginalConstructor()->getMock();
     $this->config->expects(self::once())->method('getCctypesMapper')->willReturn($mapperArray);
     $this->paymentHandler = new VaultDetailsHandler($this->paymentTokenFactory, $this->paymentExtensionFactory, $this->config, $this->subjectReader);
 }
示例#2
0
 /**
  * Test method
  * with resultCode = RESPONSE_CODE_APPROVED and Origresult != RESPONSE_CODE_FRAUDSERVICE_FILTER
  */
 public function testAuthorize()
 {
     $this->initializationAuthorizeMock();
     $this->buildRequestData();
     $paymentTokenMock = $this->getMock(PaymentTokenInterface::class);
     $extensionAttributes = $this->getMockBuilder('Magento\\Sales\\Api\\Data\\OrderPaymentExtensionInterface')->disableOriginalConstructor()->setMethods(['setVaultPaymentToken'])->getMock();
     $ccDetails = ['cc_type' => 'VI', 'cc_number' => '1111'];
     $this->responseMock->setData('result_code', Payflowpro::RESPONSE_CODE_APPROVED);
     $this->responseMock->setData('origresult', 0);
     $this->responseMock->setData('pnref', 'test-pnref');
     $this->gatewayMock->expects($this->once())->method('postRequest')->willReturn($this->responseMock);
     $this->responseValidator->expects($this->once())->method('validate')->with($this->responseMock);
     $this->paymentMock->expects($this->once())->method('setTransactionId')->with('test-pnref')->willReturnSelf();
     $this->paymentMock->expects($this->once())->method('setIsTransactionClosed')->with(0);
     $this->paymentMock->expects($this->once())->method('getCcExpYear')->willReturn('2017');
     $this->paymentMock->expects($this->once())->method('getCcExpMonth')->willReturn('12');
     $this->paymentMock->expects(static::any())->method('getAdditionalInformation')->willReturnMap([[Transparent::CC_DETAILS, $ccDetails], [Transparent::PNREF, 'test-pnref']]);
     $this->paymentTokenFactory->expects(static::once())->method('create')->willReturn($paymentTokenMock);
     $paymentTokenMock->expects(static::once())->method('setGatewayToken')->with('test-pnref');
     $paymentTokenMock->expects(static::once())->method('setTokenDetails')->with(json_encode($ccDetails));
     $paymentTokenMock->expects(static::once())->method('setExpiresAt')->with('2018-01-01 00:00:00');
     $this->paymentMock->expects(static::once())->method('getExtensionAttributes')->willReturn($extensionAttributes);
     $extensionAttributes->expects(static::once())->method('setVaultPaymentToken')->with($paymentTokenMock);
     $this->assertSame($this->object, $this->object->authorize($this->paymentMock, 33));
 }