예제 #1
0
 /**
  * @param bool $expectedResult
  * @param \Magento\Framework\DataObject $response
  * @param array $configMap
  * @param int $exactlyCount
  *
  * @dataProvider validationDataProvider
  */
 public function testValidation($expectedResult, \Magento\Framework\DataObject $response, array $configMap, $exactlyCount)
 {
     $this->payflowproFacade->expects(static::once())->method('getConfig')->willReturn($this->configMock);
     $this->configMock->expects(static::exactly($exactlyCount))->method('getValue')->willReturnMap($configMap);
     static::assertEquals($expectedResult, $this->validator->validate($response, $this->payflowproFacade));
     if (!$expectedResult) {
         static::assertNotEmpty($response->getRespmsg());
     }
 }
예제 #2
0
 /**
  * @param bool $expectedResult
  * @param \Magento\Framework\DataObject $response
  * @param string $avsSecurityCodeFlag
  *
  * @dataProvider validationDataProvider
  */
 public function testValidation($expectedResult, \Magento\Framework\DataObject $response, $avsSecurityCodeFlag)
 {
     $this->payflowproFacade->expects(static::once())->method('getConfig')->willReturn($this->configMock);
     $this->configMock->expects($this->once())->method('getValue')->with(CVV2Match::CONFIG_NAME)->willReturn($avsSecurityCodeFlag);
     $this->assertEquals($expectedResult, $this->validator->validate($response, $this->payflowproFacade));
     if (!$expectedResult) {
         $this->assertNotEmpty($response->getRespmsg());
     }
 }
 public function testGetResponseObject()
 {
     $gatewayTransactionResponse = [];
     $result = new \Magento\Framework\DataObject();
     $this->transparent->expects($this->once())->method('getDebugReplacePrivateDataKeys')->willReturn(['key1', 'key2']);
     $this->transparent->expects($this->once())->method('getDebugFlag')->willReturn(true);
     $this->transparent->expects($this->once())->method('mapGatewayResponse')->with($gatewayTransactionResponse, $result)->willReturn($result);
     $this->loggerMock->expects($this->once())->method('debug')->with($gatewayTransactionResponse, ['key1', 'key2'], true);
     $this->assertEquals($result, $this->model->getResponseObject($gatewayTransactionResponse));
 }
예제 #4
0
 public function testRequestToken()
 {
     $request = new Object();
     $secureTokenID = 'Sdj46hDokds09c8k2klaGJdKLl032ekR';
     $this->transparent->expects($this->once())->method('buildBasicRequest')->willReturn($request);
     $this->transparent->expects($this->once())->method('fillCustomerContacts');
     $this->transparent->expects($this->once())->method('getConfig')->willReturn($this->getMock('Magento\\Paypal\\Model\\PayflowConfig', [], [], '', false));
     $this->transparent->expects($this->once())->method('postRequest')->willReturn(new Object());
     $this->mathRandom->expects($this->once())->method('getUniqueHash')->willReturn($secureTokenID);
     $this->url->expects($this->exactly(3))->method('getUrl');
     $quote = $this->getMock('Magento\\Quote\\Model\\Quote', [], [], '', false);
     $this->model->requestToken($quote);
     $this->assertEquals($secureTokenID, $request->getSecuretokenid());
 }
예제 #5
0
 /**
  * Run test execute method
  *
  * @param array $result
  * @param array $resultExpectation
  *
  * @dataProvider executeDataProvider
  */
 public function testExecute(array $result, array $resultExpectation)
 {
     $quoteId = 99;
     $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
     $tokenMock = $this->getMockBuilder('Magento\\Framework\\Object')->setMethods(['getData', 'getSecuretoken'])->disableOriginalConstructor()->getMock();
     $jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
     $this->sessionManagerMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($quoteMock);
     $quoteMock->expects($this->once())->method('getId')->willReturn($quoteId);
     $this->sessionTransparentMock->expects($this->once())->method('setQuoteId')->with($quoteId);
     $this->secureTokenServiceMock->expects($this->once())->method('requestToken')->with($quoteMock)->willReturn($tokenMock);
     $this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
     $tokenMock->expects($this->once())->method('getData')->willReturn($result['transparent']['fields']);
     $tokenMock->expects($this->once())->method('getSecuretoken')->willReturn($result['success']);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock);
     $jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
     $this->assertEquals($jsonMock, $this->controller->execute());
 }
 public function testExecuteSuccess()
 {
     $quoteId = 99;
     $tokenFields = ['fields-1', 'fields-2', 'fields-3'];
     $secureToken = 'token_hash';
     $resultExpectation = ['transparent' => ['fields' => ['fields-1', 'fields-2', 'fields-3']], 'success' => true, 'error' => false];
     $quoteMock = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->getMock();
     $tokenMock = $this->getMockBuilder('Magento\\Framework\\DataObject')->disableOriginalConstructor()->getMock();
     $jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock();
     $this->sessionManagerMock->expects($this->atLeastOnce())->method('getQuote')->willReturn($quoteMock);
     $quoteMock->expects($this->once())->method('getId')->willReturn($quoteId);
     $this->sessionTransparentMock->expects($this->once())->method('setQuoteId')->with($quoteId);
     $this->secureTokenServiceMock->expects($this->once())->method('requestToken')->with($quoteMock)->willReturn($tokenMock);
     $this->transparentMock->expects($this->once())->method('getCode')->willReturn('transparent');
     $tokenMock->expects($this->atLeastOnce())->method('getData')->willReturnMap([['', null, $tokenFields], ['securetoken', null, $secureToken]]);
     $this->resultJsonFactoryMock->expects($this->once())->method('create')->willReturn($jsonMock);
     $jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf();
     $this->assertEquals($jsonMock, $this->controller->execute());
 }