15
15
use Magento \Sales \Model \Order \Payment ;
16
16
use Magento \Vault \Model \PaymentToken ;
17
17
use Magento \Vault \Model \PaymentTokenManagement ;
18
+ use Magento \Vault \Model \Ui \VaultConfigProvider ;
18
19
use Magento \Vault \Observer \AfterPaymentSaveObserver ;
19
20
use PHPUnit_Framework_MockObject_MockObject as MockObject ;
20
21
@@ -93,7 +94,7 @@ protected function setUp()
93
94
94
95
// Sales Order Payment Model
95
96
$ this ->salesOrderPaymentMock = $ this ->getMockBuilder (Payment::class)
96
- ->setMethods (null )
97
+ ->setMethods ([ ' getAdditionalInformation ' ] )
97
98
->disableOriginalConstructor ()
98
99
->getMock ();
99
100
$ this ->salesOrderPaymentMock ->setOrder ($ this ->salesOrderMock );
@@ -122,9 +123,10 @@ protected function setUp()
122
123
* @param string $token
123
124
* @param bool $isActive
124
125
* @param string $method
126
+ * @param array $additionalInfo
125
127
* @dataProvider positiveCaseDataProvider
126
128
*/
127
- public function testPositiveCase ($ customerId , $ createdAt , $ token , $ isActive , $ method )
129
+ public function testPositiveCase ($ customerId , $ createdAt , $ token , $ isActive , $ method, $ additionalInfo )
128
130
{
129
131
$ this ->paymentTokenMock ->setGatewayToken ($ token );
130
132
$ this ->paymentTokenMock ->setCustomerId ($ customerId );
@@ -136,6 +138,8 @@ public function testPositiveCase($customerId, $createdAt, $token, $isActive, $me
136
138
->method ('getVaultPaymentToken ' )
137
139
->willReturn ($ this ->paymentTokenMock );
138
140
141
+ $ this ->salesOrderPaymentMock ->method ('getAdditionalInformation ' )->willReturn ($ additionalInfo );
142
+
139
143
if (!empty ($ token )) {
140
144
$ this ->paymentTokenManagementMock ->expects ($ this ->once ())
141
145
->method ('saveTokenWithPaymentLink ' )
@@ -158,6 +162,7 @@ public function testPositiveCase($customerId, $createdAt, $token, $isActive, $me
158
162
static ::assertEquals ($ token , $ paymentToken ->getGatewayToken ());
159
163
static ::assertEquals ($ isActive , $ paymentToken ->getIsActive ());
160
164
static ::assertEquals ($ createdAt , $ paymentToken ->getCreatedAt ());
165
+ static ::assertEquals ($ additionalInfo [VaultConfigProvider::IS_ACTIVE_CODE ] ?? false , $ paymentToken ->getIsVisible ());
161
166
}
162
167
163
168
/**
@@ -171,14 +176,32 @@ public function positiveCaseDataProvider()
171
176
'10\20\2015 ' ,
172
177
'asdfg ' ,
173
178
true ,
174
- 'paypal '
179
+ 'paypal ' ,
180
+ [],
181
+ ],
182
+ [
183
+ 1 ,
184
+ '10\20\2015 ' ,
185
+ 'asdfg ' ,
186
+ true ,
187
+ 'paypal ' ,
188
+ [VaultConfigProvider::IS_ACTIVE_CODE => true ],
189
+ ],
190
+ [
191
+ 1 ,
192
+ '10\20\2015 ' ,
193
+ 'asdfg ' ,
194
+ true ,
195
+ 'paypal ' ,
196
+ [VaultConfigProvider::IS_ACTIVE_CODE => false ],
175
197
],
176
198
[
177
199
null ,
178
200
null ,
179
201
null ,
180
202
false ,
181
- null
203
+ null ,
204
+ [],
182
205
],
183
206
];
184
207
}
0 commit comments