Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreditCardValidationHandlerTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class CreditCardValidationHandlerTest extends \PHPUnit\Framework\TestCase
13 {
15  {
16  $expectedHandleResult = [
18  Info::PAYPAL_AVSZIP => 'X',
19  Info::PAYPAL_AVSADDR => 'X',
20  Info::PAYPAL_IAVS => 'X'
21  ];
22 
23  $paypalInfoManager = $this->getMockBuilder(\Magento\Paypal\Model\Info::class)
24  ->disableOriginalConstructor()
25  ->getMock();
26  $paymentMock = $this->getMockBuilder(\Magento\Payment\Model\InfoInterface::class)
27  ->getMock();
28  $responseMock = $this->getMockBuilder(\Magento\Framework\DataObject::class)
29  ->disableOriginalConstructor()
30  ->getMock();
31 
32  $responseMock->expects($this->exactly(count($expectedHandleResult)*2))
33  ->method('getData')
34  ->willReturnMap(
35  [
36  [Info::PAYPAL_CVV2MATCH, null, 'Y'],
37  [Info::PAYPAL_AVSZIP, null, 'X'],
38  [Info::PAYPAL_AVSADDR, null, 'X'],
39  [Info::PAYPAL_IAVS, null, 'X'],
40  ['Some other key', null, 'Some other value']
41  ]
42  );
43  $paypalInfoManager->expects($this->once())
44  ->method('importToPayment')
45  ->with($expectedHandleResult, $paymentMock);
46 
47  $handler = new CreditCardValidationHandler($paypalInfoManager);
48  $handler->handle($paymentMock, $responseMock);
49  }
50 }
catch(\Exception $e) $handler
Definition: index.php:30