3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Vault \Test \Unit \Observer ;
7
8
8
9
use Magento \Framework \App \DeploymentConfig ;
15
16
use Magento \Sales \Model \Order \Payment ;
16
17
use Magento \Vault \Model \PaymentToken ;
17
18
use Magento \Vault \Model \PaymentTokenManagement ;
19
+ use Magento \Vault \Model \Ui \VaultConfigProvider ;
18
20
use Magento \Vault \Observer \AfterPaymentSaveObserver ;
19
21
use PHPUnit_Framework_MockObject_MockObject as MockObject ;
20
22
23
+ /**
24
+ * Tests for AfterPaymentSaveObserver.
25
+ */
21
26
class AfterPaymentSaveObserverTest extends \PHPUnit \Framework \TestCase
22
27
{
23
28
/**
@@ -93,7 +98,7 @@ protected function setUp()
93
98
94
99
// Sales Order Payment Model
95
100
$ this ->salesOrderPaymentMock = $ this ->getMockBuilder (Payment::class)
96
- ->setMethods (null )
101
+ ->setMethods ([ ' getAdditionalInformation ' ] )
97
102
->disableOriginalConstructor ()
98
103
->getMock ();
99
104
$ this ->salesOrderPaymentMock ->setOrder ($ this ->salesOrderMock );
@@ -122,9 +127,10 @@ protected function setUp()
122
127
* @param string $token
123
128
* @param bool $isActive
124
129
* @param string $method
130
+ * @param array $additionalInfo
125
131
* @dataProvider positiveCaseDataProvider
126
132
*/
127
- public function testPositiveCase ($ customerId , $ createdAt , $ token , $ isActive , $ method )
133
+ public function testPositiveCase ($ customerId , $ createdAt , $ token , $ isActive , $ method, $ additionalInfo )
128
134
{
129
135
$ this ->paymentTokenMock ->setGatewayToken ($ token );
130
136
$ this ->paymentTokenMock ->setCustomerId ($ customerId );
@@ -136,6 +142,8 @@ public function testPositiveCase($customerId, $createdAt, $token, $isActive, $me
136
142
->method ('getVaultPaymentToken ' )
137
143
->willReturn ($ this ->paymentTokenMock );
138
144
145
+ $ this ->salesOrderPaymentMock ->method ('getAdditionalInformation ' )->willReturn ($ additionalInfo );
146
+
139
147
if (!empty ($ token )) {
140
148
$ this ->paymentTokenManagementMock ->expects ($ this ->once ())
141
149
->method ('saveTokenWithPaymentLink ' )
@@ -158,6 +166,10 @@ public function testPositiveCase($customerId, $createdAt, $token, $isActive, $me
158
166
static ::assertEquals ($ token , $ paymentToken ->getGatewayToken ());
159
167
static ::assertEquals ($ isActive , $ paymentToken ->getIsActive ());
160
168
static ::assertEquals ($ createdAt , $ paymentToken ->getCreatedAt ());
169
+ static ::assertEquals (
170
+ $ additionalInfo [VaultConfigProvider::IS_ACTIVE_CODE ] ?? false ,
171
+ $ paymentToken ->getIsVisible ()
172
+ );
161
173
}
162
174
163
175
/**
@@ -171,14 +183,32 @@ public function positiveCaseDataProvider()
171
183
'10\20\2015 ' ,
172
184
'asdfg ' ,
173
185
true ,
174
- 'paypal '
186
+ 'paypal ' ,
187
+ [],
188
+ ],
189
+ [
190
+ 1 ,
191
+ '10\20\2015 ' ,
192
+ 'asdfg ' ,
193
+ true ,
194
+ 'paypal ' ,
195
+ [VaultConfigProvider::IS_ACTIVE_CODE => true ],
196
+ ],
197
+ [
198
+ 1 ,
199
+ '10\20\2015 ' ,
200
+ 'asdfg ' ,
201
+ true ,
202
+ 'paypal ' ,
203
+ [VaultConfigProvider::IS_ACTIVE_CODE => false ],
175
204
],
176
205
[
177
206
null ,
178
207
null ,
179
208
null ,
180
209
false ,
181
- null
210
+ null ,
211
+ [],
182
212
],
183
213
];
184
214
}
0 commit comments