Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AVSResponseTest.php
Go to the documentation of this file.
1 <?php
7 
11 use PHPUnit_Framework_MockObject_MockObject as MockObject;
12 
13 class AVSResponseTest extends \PHPUnit\Framework\TestCase
14 {
18  private $validator;
19 
23  private $config;
24 
28  private $payflowproFacade;
29 
33  protected function setUp()
34  {
35  $this->config = $this->getMockBuilder(ConfigInterface::class)
36  ->getMockForAbstractClass();
37 
38  $this->payflowproFacade = $this->getMockBuilder(Transparent::class)
39  ->disableOriginalConstructor()
40  ->getMock();
41 
42  $this->validator = new AVSResponse();
43  }
44 
52  public function testValidation(
53  $expectedResult,
54  \Magento\Framework\DataObject $response,
55  array $configMap
56  ) {
57  $this->payflowproFacade->method('getConfig')
58  ->willReturn($this->config);
59 
60  $this->config->method('getValue')
61  ->willReturnMap($configMap);
62 
63  static::assertEquals($expectedResult, $this->validator->validate($response, $this->payflowproFacade));
64 
65  if (!$expectedResult) {
66  static::assertNotEmpty($response->getRespmsg());
67  }
68  }
69 
75  public function validationDataProvider()
76  {
77  return [
78  [
79  'expectedResult' => true,
80  'response' => new \Magento\Framework\DataObject(
81  [
82  'avsaddr' => 'Y',
83  'avszip' => 'Y',
84  ]
85  ),
86  'configMap' => [
87  ['avs_street', null, '0'],
88  ['avs_zip', null, '0'],
89  ],
90  ],
91  [
92  'expectedResult' => true,
93  'response' => new \Magento\Framework\DataObject(
94  [
95  'avsaddr' => 'Y',
96  'avszip' => 'Y',
97  ]
98  ),
99  'configMap' => [
100  ['avs_street', null, '1'],
101  ['avs_zip', null, '1'],
102  ],
103  ],
104  [
105  'expectedResult' => false,
106  'response' => new \Magento\Framework\DataObject(
107  [
108  'avsaddr' => 'Y',
109  'avszip' => 'N',
110  ]
111  ),
112  'configMap' => [
113  ['avs_street', null, '1'],
114  ['avs_zip', null, '1'],
115  ],
116  ],
117  [
118  'expectedResult' => true,
119  'response' => new \Magento\Framework\DataObject(
120  [
121  'avsaddr' => 'Y',
122  'avszip' => 'N',
123  ]
124  ),
125  'configMap' => [
126  ['avs_street', null, '1'],
127  ['avs_zip', null, '0'],
128  ],
129  ],
130  [
131  'expectedResult' => true,
132  'response' => new \Magento\Framework\DataObject(
133  [
134  'avsaddr' => 'Y',
135  'avszip' => 'N',
136  ]
137  ),
138  'configMap' => [
139  ['avs_street', null, '0'],
140  ['avs_zip', null, '0'],
141  ],
142  ],
143  [
144  'expectedResult' => true,
145  'response' => new \Magento\Framework\DataObject(
146  [
147  'avsaddr' => 'X',
148  'avszip' => 'Y',
149  ]
150  ),
151  'configMap' => [
152  ['avs_street', null, '1'],
153  ['avs_zip', null, '1'],
154  ],
155  ],
156  [
157  'expectedResult' => true,
158  'response' => new \Magento\Framework\DataObject(
159  [
160  'avsaddr' => 'X',
161  'avszip' => 'Y',
162  ]
163  ),
164  'configMap' => [
165  ['avs_street', null, '1'],
166  ['avs_zip', null, '0'],
167  ],
168  ],
169  ];
170  }
171 }
$response
Definition: 404.php:11
testValidation( $expectedResult, \Magento\Framework\DataObject $response, array $configMap)