Skip to content

Commit be99728

Browse files
committed
AC-2901:AC-2901:Vault/Stored Payment Methods are not saved per store
1 parent 0bf6112 commit be99728

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

app/code/Magento/Vault/Test/Unit/Observer/AfterPaymentSaveObserverTest.php

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Sales\Api\Data\OrderPaymentExtension;
1515
use Magento\Sales\Model\Order;
1616
use Magento\Sales\Model\Order\Payment;
17+
use Magento\Store\Model\Store;
1718
use Magento\Vault\Model\PaymentToken;
1819
use Magento\Vault\Model\PaymentTokenManagement;
1920
use Magento\Vault\Model\Ui\VaultConfigProvider;
@@ -66,6 +67,11 @@ class AfterPaymentSaveObserverTest extends TestCase
6667
*/
6768
protected $salesOrderPaymentMock;
6869

70+
/**
71+
* @var Store|MockObject
72+
*/
73+
protected $storeMock;
74+
6975
/**
7076
* @inheritdoc
7177
*/
@@ -101,6 +107,11 @@ protected function setUp(): void
101107
// Sales Order Model
102108
$this->salesOrderMock = $this->createMock(Order::class);
103109

110+
$this->storeMock = $this->getMockBuilder(Store::class)
111+
->setMethods(['getWebsiteId'])
112+
->disableOriginalConstructor()
113+
->getMock();
114+
104115
// Sales Order Payment Model
105116
$this->salesOrderPaymentMock = $this->getMockBuilder(Payment::class)
106117
->setMethods(['getAdditionalInformation'])
@@ -137,18 +148,27 @@ protected function setUp(): void
137148
* @param array $additionalInfo
138149
* @dataProvider positiveCaseDataProvider
139150
*/
140-
public function testPositiveCase($customerId, $createdAt, $token, $isActive, $method, $additionalInfo)
151+
public function testPositiveCase($customerId, $createdAt, $token, $isActive, $method, $websiteId, $additionalInfo)
141152
{
142153
$this->paymentTokenMock->setGatewayToken($token);
143154
$this->paymentTokenMock->setCustomerId($customerId);
144155
$this->paymentTokenMock->setCreatedAt($createdAt);
145156
$this->paymentTokenMock->setPaymentMethodCode($method);
146157
$this->paymentTokenMock->setIsActive($isActive);
158+
$this->paymentTokenMock->setWebsiteId($websiteId);
147159

148160
$this->paymentExtension->expects($this->exactly(2))
149161
->method('getVaultPaymentToken')
150162
->willReturn($this->paymentTokenMock);
151163

164+
$this->salesOrderMock->expects($this->any())
165+
->method('getStore')
166+
->willReturn($this->storeMock);
167+
168+
$this->storeMock->expects($this->any())
169+
->method('getWebsiteId')
170+
->willReturn($websiteId);
171+
152172
$this->salesOrderPaymentMock->method('getAdditionalInformation')->willReturn($additionalInfo);
153173

154174
if (!empty($token)) {
@@ -193,6 +213,7 @@ public function positiveCaseDataProvider()
193213
'asdfg',
194214
true,
195215
'paypal',
216+
1,
196217
[],
197218
],
198219
[
@@ -201,6 +222,7 @@ public function positiveCaseDataProvider()
201222
'asdfg',
202223
true,
203224
'paypal',
225+
1,
204226
[VaultConfigProvider::IS_ACTIVE_CODE => true],
205227
],
206228
[
@@ -209,14 +231,34 @@ public function positiveCaseDataProvider()
209231
'asdfg',
210232
true,
211233
'paypal',
234+
1,
212235
[VaultConfigProvider::IS_ACTIVE_CODE => false],
213236
],
237+
[
238+
1,
239+
'10\20\2015',
240+
'asdfg',
241+
true,
242+
'braintree_cc_vault',
243+
2,
244+
[VaultConfigProvider::IS_ACTIVE_CODE => true],
245+
],
246+
[
247+
1,
248+
'10\20\2015',
249+
'asdfg',
250+
true,
251+
'braintree_cc_vault',
252+
1,
253+
[VaultConfigProvider::IS_ACTIVE_CODE => true],
254+
],
214255
[
215256
null,
216257
null,
217258
null,
218259
false,
219260
null,
261+
1,
220262
[],
221263
],
222264
];

0 commit comments

Comments
 (0)