Skip to content

Commit 247c642

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-96862' into 2.2-develop-pr17
2 parents 87ebf9d + ce006db commit 247c642

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

app/code/Magento/Persistent/Model/Checkout/GuestPaymentInformationManagementPlugin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ public function beforeSavePaymentInformationAndPlaceOrder(
108108
$this->customerSession->setCustomerId(null);
109109
$this->customerSession->setCustomerGroupId(null);
110110
$this->quoteManager->convertCustomerCartToGuest();
111-
/** @var \Magento\Quote\Api\Data\CartInterface $quote */
112-
$quote = $this->cartRepository->get($this->checkoutSession->getQuote()->getId());
111+
$quoteId = $this->checkoutSession->getQuoteId();
112+
$quote = $this->cartRepository->get($quoteId);
113113
$quote->setCustomerEmail($email);
114114
$quote->getAddressesCollection()->walk('setEmail', ['email' => $email]);
115115
$this->cartRepository->save($quote);

app/code/Magento/Persistent/Model/QuoteManager.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ public function setGuest($checkQuote = false)
108108
*/
109109
public function convertCustomerCartToGuest()
110110
{
111+
$quoteId = $this->checkoutSession->getQuoteId();
111112
/** @var $quote \Magento\Quote\Model\Quote */
112-
$quote = $this->quoteRepository->get($this->checkoutSession->getQuote()->getId());
113+
$quote = $this->quoteRepository->get($quoteId);
113114
if ($quote && $quote->getId()) {
114115
$this->_setQuotePersistent = false;
115116
$quote->setIsActive(true)

app/code/Magento/Persistent/Test/Unit/Model/Checkout/GuestPaymentInformationManagementPluginTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrderCartConvertsToGuest
102102
['setCustomerEmail', 'getAddressesCollection'],
103103
false
104104
);
105-
$this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock);
106-
$quoteMock->expects($this->once())->method('getId')->willReturn($cartId);
105+
$this->checkoutSessionMock->method('getQuoteId')->willReturn($cartId);
107106
$this->cartRepositoryMock->expects($this->once())->method('get')->with($cartId)->willReturn($quoteMock);
108107
$quoteMock->expects($this->once())->method('setCustomerEmail')->with($email);
109108
/** @var \Magento\Framework\Data\Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */

app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ public function testConvertCustomerCartToGuest()
247247
$emailArgs = ['email' => null];
248248

249249
$this->checkoutSessionMock->expects($this->once())
250-
->method('getQuote')->willReturn($this->quoteMock);
251-
$this->quoteMock->expects($this->exactly(2))->method('getId')->willReturn($quoteId);
250+
->method('getQuoteId')->willReturn($quoteId);
251+
$this->quoteMock->expects($this->once())->method('getId')->willReturn($quoteId);
252252
$this->quoteRepositoryMock->expects($this->once())->method('get')->with($quoteId)->willReturn($this->quoteMock);
253253
$this->quoteMock->expects($this->once())
254254
->method('setIsActive')->with(true)->willReturn($this->quoteMock);
@@ -288,18 +288,15 @@ public function testConvertCustomerCartToGuest()
288288
public function testConvertCustomerCartToGuestWithEmptyQuote()
289289
{
290290
$this->checkoutSessionMock->expects($this->once())
291-
->method('getQuote')->willReturn($this->quoteMock);
292-
$this->quoteMock->expects($this->once())->method('getId')->willReturn(null);
291+
->method('getQuoteId')->willReturn(null);
293292
$this->quoteRepositoryMock->expects($this->once())->method('get')->with(null)->willReturn(null);
294-
295293
$this->model->convertCustomerCartToGuest();
296294
}
297295

298296
public function testConvertCustomerCartToGuestWithEmptyQuoteId()
299297
{
300298
$this->checkoutSessionMock->expects($this->once())
301-
->method('getQuote')->willReturn($this->quoteMock);
302-
$this->quoteMock->expects($this->once())->method('getId')->willReturn(1);
299+
->method('getQuoteId')->willReturn(1);
303300
$quoteWithNoId = $this->quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
304301
$quoteWithNoId->expects($this->once())->method('getId')->willReturn(null);
305302
$this->quoteRepositoryMock->expects($this->once())->method('get')->with(1)->willReturn($quoteWithNoId);

0 commit comments

Comments
 (0)