@@ -434,20 +434,24 @@ public function testGetQuote(): void
434
434
$ customerSession = $ this ->createMock (\Magento \Customer \Model \Session::class);
435
435
$ quoteRepository = $ this ->getMockForAbstractClass (CartRepositoryInterface::class);
436
436
$ quoteFactory = $ this ->createMock (QuoteFactory::class);
437
- $ quote = $ this ->createMock (Quote::class);
437
+ $ quote = $ this ->getMockBuilder (Quote::class)
438
+ ->disableOriginalConstructor ()
439
+ ->addMethods (['getQuoteCurrencyCode ' , 'getTotalsCollectedFlag ' ])
440
+ ->onlyMethods (['collectTotals ' , 'setCustomer ' ])
441
+ ->getMock ();
438
442
$ logger = $ this ->getMockForAbstractClass (LoggerInterface::class);
439
443
$ loggerMethods = get_class_methods (LoggerInterface::class);
440
444
441
445
$ quoteFactory ->expects ($ this ->once ())
442
446
->method ('create ' )
443
447
->willReturn ($ quote );
444
- $ customerSession ->expects ($ this ->exactly (3 ))
445
- ->method ('isLoggedIn ' )
446
- ->willReturn (true );
448
+ $ customerSession ->expects ($ this ->exactly (2 ))->method ('isLoggedIn ' )->willReturn (true );
447
449
$ store = $ this ->getMockBuilder (Store::class)
448
450
->disableOriginalConstructor ()
449
- ->onlyMethods (['getWebsiteId ' ])
451
+ ->onlyMethods (['getWebsiteId ' , ' getCurrentCurrencyCode ' ])
450
452
->getMock ();
453
+ $ store ->expects ($ this ->any ())->method ('getWebsiteId ' )->willReturn (1 );
454
+ $ store ->expects ($ this ->any ())->method ('getCurrentCurrencyCode ' )->willReturn ('USD ' );
451
455
$ storeManager ->expects ($ this ->any ())
452
456
->method ('getStore ' )
453
457
->willReturn ($ store );
@@ -457,18 +461,24 @@ public function testGetQuote(): void
457
461
->getMock ();
458
462
$ storage
459
463
->method ('getData ' )
460
- ->willReturnOnConsecutiveCalls (null , null , 1 );
464
+ ->willReturnCallback (function ($ key ) {
465
+ if ($ key === 'quote_id_1 ' ) {
466
+ return 123 ;
467
+ }
468
+ return null ;
469
+ });
461
470
$ quoteRepository ->expects ($ this ->once ())
462
- ->method ('getActiveForCustomer ' )
463
- ->willThrowException (new NoSuchEntityException ());
471
+ ->method ('getActive ' )
472
+ ->with (123 )
473
+ ->willReturn ($ quote );
464
474
465
475
foreach ($ loggerMethods as $ method ) {
466
476
$ logger ->expects ($ this ->never ())->method ($ method );
467
477
}
468
-
469
- $ quote ->expects ($ this ->once ())
470
- -> method ('setCustomer ' )
471
- ->with (null );
478
+ $ quote -> expects ( $ this -> once ())-> method ( ' getQuoteCurrencyCode ' )-> willReturn ( null );
479
+ $ quote ->expects ($ this ->once ())-> method ( ' getTotalsCollectedFlag ' )-> willReturn ( false );
480
+ $ quote -> expects ( $ this -> once ())-> method ('collectTotals ' )-> willReturnSelf ();
481
+ $ quote -> expects ( $ this -> once ())-> method ( ' setCustomer ' ) ->with (null );
472
482
473
483
$ constructArguments = $ this ->helper ->getConstructArguments (
474
484
Session::class,
0 commit comments