From b2de9ae4ebf14602c412343f2e3ce162e67ff758 Mon Sep 17 00:00:00 2001 From: Marius Date: Wed, 6 Apr 2022 16:16:10 +0200 Subject: [PATCH] Full coverage after refactor --- src/Test/Unit/Service/CustomerQuoteTest.php | 46 ++++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/src/Test/Unit/Service/CustomerQuoteTest.php b/src/Test/Unit/Service/CustomerQuoteTest.php index f119824..e042e37 100644 --- a/src/Test/Unit/Service/CustomerQuoteTest.php +++ b/src/Test/Unit/Service/CustomerQuoteTest.php @@ -103,15 +103,32 @@ public function testGetQuoteGuestWithExistingCart(): void ->method('isLoggedIn') ->willReturn(false); - $quoteMock = $this->createQuote(); - $quoteMock + $quoteMockNotFullyLoaded = $this->createQuote(); + $quoteMockNotFullyLoaded ->expects(self::exactly(2)) ->method('getId') - ->willReturn(1); + ->willReturn(null, 456); $this->checkoutSession ->expects(self::once()) ->method('getQuote') + ->willReturn($quoteMockNotFullyLoaded); + + $this->quoteRepository + ->expects(self::once()) + ->method('save') + ->with($quoteMockNotFullyLoaded); + + $quoteMock = $this->createQuote(); + $quoteMock + ->expects(self::once()) + ->method('getId') + ->willReturn(456); + + $this->quoteRepository + ->expects(self::once()) + ->method('get') + ->with(456) ->willReturn($quoteMock); $quote = $customerQuote->getQuote(); @@ -177,15 +194,32 @@ public function testGetQuoteCustomerWithExistingCart(): void ->method('isLoggedIn') ->willReturn(true); - $quoteMock = $this->createQuote(); - $quoteMock + $quoteMockNotFullyLoaded = $this->createQuote(); + $quoteMockNotFullyLoaded ->expects(self::exactly(2)) ->method('getId') - ->willReturn(1); + ->willReturn(null, 456); $this->checkoutSession ->expects(self::once()) ->method('getQuote') + ->willReturn($quoteMockNotFullyLoaded); + + $this->quoteRepository + ->expects(self::once()) + ->method('save') + ->with($quoteMockNotFullyLoaded); + + $quoteMock = $this->createQuote(); + $quoteMock + ->expects(self::once()) + ->method('getId') + ->willReturn(456); + + $this->quoteRepository + ->expects(self::once()) + ->method('get') + ->with(456) ->willReturn($quoteMock); $quote = $customerQuote->getQuote();