22
22
use Magento \Sales \Api \Data \OrderPaymentInterface ;
23
23
use Magento \Sales \Api \OrderRepositoryInterface ;
24
24
use Magento \Store \Api \Data \StoreInterface ;
25
+ use Magento \Store \Api \Data \WebsiteInterface ;
25
26
use Magento \Store \Model \StoreManagerInterface ;
26
27
use Magento \Vault \Api \Data \PaymentTokenInterface ;
27
28
use Magento \Vault \Api \Data \PaymentTokenSearchResultsInterface ;
@@ -77,6 +78,11 @@ class TokensConfigProviderTest extends TestCase
77
78
*/
78
79
private $ storeManager ;
79
80
81
+ /**
82
+ * @var WebsiteInterface|MockObject
83
+ */
84
+ private $ websiteMock ;
85
+
80
86
/**
81
87
* @var StoreInterface|MockObject
82
88
*/
@@ -134,7 +140,7 @@ protected function setUp(): void
134
140
->getMock ();
135
141
$ this ->session = $ this ->getMockBuilder (Quote::class)
136
142
->disableOriginalConstructor ()
137
- ->setMethods (['getCustomerId ' , 'getReordered ' , 'getStoreId ' ])
143
+ ->setMethods (['getCustomerId ' , 'getReordered ' , 'getStoreId ' , ' getQuote ' ])
138
144
->getMock ();
139
145
$ this ->dateTimeFactory = $ this ->getMockBuilder (DateTimeFactory::class)
140
146
->disableOriginalConstructor ()
@@ -217,6 +223,19 @@ public function testGetTokensComponentsRegisteredCustomer()
217
223
->method ('getProviderCode ' )
218
224
->willReturn (self ::VAULT_PROVIDER_CODE );
219
225
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
+
220
239
/** @var PaymentTokenInterface|MockObject $token */
221
240
$ token = $ this ->getMockBuilder (PaymentTokenInterface::class)
222
241
->getMockForAbstractClass ();
@@ -281,6 +300,14 @@ public function testGetTokensComponentsGuestCustomer()
281
300
$ this ->vaultPayment ->expects (static ::once ())
282
301
->method ('getProviderCode ' )
283
302
->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 );
284
311
285
312
/** @var PaymentTokenInterface|MockObject $token */
286
313
$ token = $ this ->getMockBuilder (PaymentTokenInterface::class)
@@ -595,13 +622,14 @@ private function getSearchCriteria($customerId, $entityId, $vaultProviderCode)
595
622
);
596
623
597
624
$ isVisibleFilter = $ this ->createExpectedFilter (PaymentTokenInterface::IS_VISIBLE , 1 , 4 );
625
+ $ websiteFilter = $ this ->createExpectedFilter (PaymentTokenInterface::WEBSITE_ID , 1 , 5 );
598
626
599
627
$ this ->filterBuilder ->expects (static ::once ())
600
628
->method ('setConditionType ' )
601
629
->with ('gt ' )
602
630
->willReturnSelf ();
603
631
604
- $ this ->searchCriteriaBuilder ->expects (self ::exactly (5 ))
632
+ $ this ->searchCriteriaBuilder ->expects (self ::exactly (6 ))
605
633
->method ('addFilters ' )
606
634
->willReturnMap (
607
635
[
@@ -610,6 +638,7 @@ private function getSearchCriteria($customerId, $entityId, $vaultProviderCode)
610
638
[$ expiresAtFilter , $ this ->searchCriteriaBuilder ],
611
639
[$ isActiveFilter , $ this ->searchCriteriaBuilder ],
612
640
[$ isVisibleFilter , $ this ->searchCriteriaBuilder ],
641
+ [$ websiteFilter , $ this ->searchCriteriaBuilder ],
613
642
]
614
643
);
615
644
0 commit comments