@@ -434,20 +434,24 @@ public function testGetQuote(): void
434434 $ customerSession = $ this ->createMock (\Magento \Customer \Model \Session::class);
435435 $ quoteRepository = $ this ->getMockForAbstractClass (CartRepositoryInterface::class);
436436 $ 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 ();
438442 $ logger = $ this ->getMockForAbstractClass (LoggerInterface::class);
439443 $ loggerMethods = get_class_methods (LoggerInterface::class);
440444
441445 $ quoteFactory ->expects ($ this ->once ())
442446 ->method ('create ' )
443447 ->willReturn ($ quote );
444- $ customerSession ->expects ($ this ->exactly (3 ))
445- ->method ('isLoggedIn ' )
446- ->willReturn (true );
448+ $ customerSession ->expects ($ this ->exactly (2 ))->method ('isLoggedIn ' )->willReturn (true );
447449 $ store = $ this ->getMockBuilder (Store::class)
448450 ->disableOriginalConstructor ()
449- ->onlyMethods (['getWebsiteId ' ])
451+ ->onlyMethods (['getWebsiteId ' , ' getCurrentCurrencyCode ' ])
450452 ->getMock ();
453+ $ store ->expects ($ this ->any ())->method ('getWebsiteId ' )->willReturn (1 );
454+ $ store ->expects ($ this ->any ())->method ('getCurrentCurrencyCode ' )->willReturn ('USD ' );
451455 $ storeManager ->expects ($ this ->any ())
452456 ->method ('getStore ' )
453457 ->willReturn ($ store );
@@ -457,18 +461,24 @@ public function testGetQuote(): void
457461 ->getMock ();
458462 $ storage
459463 ->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+ });
461470 $ quoteRepository ->expects ($ this ->once ())
462- ->method ('getActiveForCustomer ' )
463- ->willThrowException (new NoSuchEntityException ());
471+ ->method ('getActive ' )
472+ ->with (123 )
473+ ->willReturn ($ quote );
464474
465475 foreach ($ loggerMethods as $ method ) {
466476 $ logger ->expects ($ this ->never ())->method ($ method );
467477 }
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 );
472482
473483 $ constructArguments = $ this ->helper ->getConstructArguments (
474484 Session::class,
0 commit comments