Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CVV2MatchTest.php
Go to the documentation of this file.
1 <?php
7 
11 
17 class CVV2MatchTest extends \PHPUnit\Framework\TestCase
18 {
22  protected $validator;
23 
27  protected $configMock;
28 
32  protected $payflowproFacade;
33 
39  protected function setUp()
40  {
41  $this->configMock = $this->getMockBuilder(ConfigInterface::class)
42  ->getMockForAbstractClass();
43  $this->payflowproFacade = $this->getMockBuilder(Transparent::class)
44  ->disableOriginalConstructor()
45  ->setMethods([])
46  ->getMock();
47 
48  $this->validator = new CVV2Match();
49  }
50 
58  public function testValidation(
59  $expectedResult,
60  \Magento\Framework\DataObject $response,
61  $avsSecurityCodeFlag
62  ) {
63  $this->payflowproFacade->expects(static::once())
64  ->method('getConfig')
65  ->willReturn($this->configMock);
66 
67  $this->configMock->expects($this->once())
68  ->method('getValue')
70  ->willReturn($avsSecurityCodeFlag);
71 
72  $this->assertEquals($expectedResult, $this->validator->validate($response, $this->payflowproFacade));
73 
74  if (!$expectedResult) {
75  $this->assertNotEmpty($response->getRespmsg());
76  }
77  }
78 
82  public function validationDataProvider()
83  {
84  return [
85  [
86  'expectedResult' => true,
87  'response' => new \Magento\Framework\DataObject(
88  [
89  'cvv2match' => 'Y',
90  ]
91  ),
92  'configValue' => '0',
93  ],
94  [
95  'expectedResult' => true,
96  'response' => new \Magento\Framework\DataObject(
97  [
98  'cvv2match' => 'Y',
99  ]
100  ),
101  'configValue' => '1',
102  ],
103  [
104  'expectedResult' => true,
105  'response' => new \Magento\Framework\DataObject(
106  [
107  'cvv2match' => 'X',
108  ]
109  ),
110  'configValue' => '1',
111  ],
112  [
113  'expectedResult' => false,
114  'response' => new \Magento\Framework\DataObject(
115  [
116  'cvv2match' => 'N',
117  ]
118  ),
119  'configValue' => '1',
120  ],
121  [
122  'expectedResult' => true,
123  'response' => new \Magento\Framework\DataObject(
124  [
125  'cvv2match' => null,
126  ]
127  ),
128  'configValue' => '1',
129  ],
130  [
131  'expectedResult' => true,
132  'response' => new \Magento\Framework\DataObject(),
133  'configValue' => '1',
134  ],
135  ];
136  }
137 }
$response
Definition: 404.php:11
testValidation( $expectedResult, \Magento\Framework\DataObject $response, $avsSecurityCodeFlag)