Skip to content

Commit 7cd347f

Browse files
committed
AC-2901:AC-2901:Vault/Stored Payment Methods are not saved per store
1 parent 1e691ba commit 7cd347f

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

app/code/Magento/Vault/Api/Data/PaymentTokenInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ interface PaymentTokenInterface
5959
/*
6060
* Is vault payment token visible.
6161
*/
62-
const IS_VISIBLE = 'is_visible';
62+
public const IS_VISIBLE = 'is_visible';
6363

6464
/*
6565
* Vault website id

app/code/Magento/Vault/Test/Unit/Model/Ui/Adminhtml/TokensConfigProviderTest.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Magento\Sales\Api\Data\OrderPaymentInterface;
2323
use Magento\Sales\Api\OrderRepositoryInterface;
2424
use Magento\Store\Api\Data\StoreInterface;
25+
use Magento\Store\Api\Data\WebsiteInterface;
2526
use Magento\Store\Model\StoreManagerInterface;
2627
use Magento\Vault\Api\Data\PaymentTokenInterface;
2728
use Magento\Vault\Api\Data\PaymentTokenSearchResultsInterface;
@@ -77,6 +78,11 @@ class TokensConfigProviderTest extends TestCase
7778
*/
7879
private $storeManager;
7980

81+
/**
82+
* @var WebsiteInterface|MockObject
83+
*/
84+
private $websiteMock;
85+
8086
/**
8187
* @var StoreInterface|MockObject
8288
*/
@@ -134,7 +140,7 @@ protected function setUp(): void
134140
->getMock();
135141
$this->session = $this->getMockBuilder(Quote::class)
136142
->disableOriginalConstructor()
137-
->setMethods(['getCustomerId', 'getReordered', 'getStoreId'])
143+
->setMethods(['getCustomerId', 'getReordered', 'getStoreId','getQuote'])
138144
->getMock();
139145
$this->dateTimeFactory = $this->getMockBuilder(DateTimeFactory::class)
140146
->disableOriginalConstructor()
@@ -217,6 +223,19 @@ public function testGetTokensComponentsRegisteredCustomer()
217223
->method('getProviderCode')
218224
->willReturn(self::VAULT_PROVIDER_CODE);
219225

226+
$this->websiteMock = $this->getMockForAbstractClass(WebsiteInterface::class);
227+
$this->storeManager->expects(static::once())
228+
->method('getWebsite')
229+
->willReturn($this->websiteMock);
230+
231+
$this->websiteMock->expects(static::once())
232+
->method('getId')
233+
->willReturn(1);
234+
235+
$this->session->expects(static::once())
236+
->method('getQuote')
237+
->willReturn(null);
238+
220239
/** @var PaymentTokenInterface|MockObject $token */
221240
$token = $this->getMockBuilder(PaymentTokenInterface::class)
222241
->getMockForAbstractClass();
@@ -281,6 +300,14 @@ public function testGetTokensComponentsGuestCustomer()
281300
$this->vaultPayment->expects(static::once())
282301
->method('getProviderCode')
283302
->willReturn(self::VAULT_PROVIDER_CODE);
303+
$this->websiteMock = $this->getMockForAbstractClass(WebsiteInterface::class);
304+
$this->storeManager->expects(static::once())
305+
->method('getWebsite')
306+
->willReturn($this->websiteMock);
307+
308+
$this->websiteMock->expects(static::once())
309+
->method('getId')
310+
->willReturn(1);
284311

285312
/** @var PaymentTokenInterface|MockObject $token */
286313
$token = $this->getMockBuilder(PaymentTokenInterface::class)
@@ -595,13 +622,14 @@ private function getSearchCriteria($customerId, $entityId, $vaultProviderCode)
595622
);
596623

597624
$isVisibleFilter = $this->createExpectedFilter(PaymentTokenInterface::IS_VISIBLE, 1, 4);
625+
$websiteFilter = $this->createExpectedFilter(PaymentTokenInterface::WEBSITE_ID, 1, 5);
598626

599627
$this->filterBuilder->expects(static::once())
600628
->method('setConditionType')
601629
->with('gt')
602630
->willReturnSelf();
603631

604-
$this->searchCriteriaBuilder->expects(self::exactly(5))
632+
$this->searchCriteriaBuilder->expects(self::exactly(6))
605633
->method('addFilters')
606634
->willReturnMap(
607635
[
@@ -610,6 +638,7 @@ private function getSearchCriteria($customerId, $entityId, $vaultProviderCode)
610638
[$expiresAtFilter, $this->searchCriteriaBuilder],
611639
[$isActiveFilter, $this->searchCriteriaBuilder],
612640
[$isVisibleFilter, $this->searchCriteriaBuilder],
641+
[$websiteFilter, $this->searchCriteriaBuilder],
613642
]
614643
);
615644

0 commit comments

Comments
 (0)