Skip to content

Commit 5390b10

Browse files
committed
ACP2E-1445: Customer data in Local Storage not reset when session file lost
- Fixed the CR comments.
1 parent 2b09c4e commit 5390b10

File tree

2 files changed

+89
-54
lines changed

2 files changed

+89
-54
lines changed

app/code/Magento/Customer/Test/Mftf/Test/StorefrontValidateMiniCartEmptyAfterClearingSessionTest.xml

Lines changed: 0 additions & 54 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Controller;
8+
9+
use Magento\Checkout\Model\Session as CheckoutSession;
10+
use Magento\Customer\Api\CustomerRepositoryInterface;
11+
use Magento\Framework\Exception\FileSystemException;
12+
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Framework\Exception\NoSuchEntityException;
14+
use Magento\Framework\Exception\StateException;
15+
use Magento\Framework\Filesystem;
16+
use Magento\Framework\App\Filesystem\DirectoryList;
17+
use Magento\Framework\ObjectManagerInterface;
18+
use Magento\Quote\Api\CartManagementInterface;
19+
use Magento\TestFramework\Helper\Bootstrap;
20+
use Magento\TestFramework\Quote\Model\GetQuoteByReservedOrderId;
21+
22+
class ValidateMinicartEmptyAfterClearingSessionTest extends \Magento\TestFramework\TestCase\AbstractController
23+
{
24+
/**
25+
* @var ObjectManagerInterface
26+
*/
27+
private $objectManager;
28+
29+
/**
30+
* @var Filesystem
31+
*/
32+
private $filesystem;
33+
34+
/**
35+
* @var CartManagementInterface
36+
*/
37+
private $cartManagement;
38+
39+
/**
40+
* @var GetQuoteByReservedOrderId
41+
*/
42+
private $getQuoteByReservedOrderId;
43+
44+
/**
45+
* @var CustomerRepositoryInterface
46+
*/
47+
private $customerRepository;
48+
49+
/** @var CheckoutSession */
50+
private $checkoutSession;
51+
52+
/**
53+
* @inheritdoc
54+
*/
55+
protected function setUp(): void
56+
{
57+
parent::setUp();
58+
59+
$this->objectManager = Bootstrap::getObjectManager();
60+
$this->filesystem = $this->objectManager->get(Filesystem::class);
61+
$this->getQuoteByReservedOrderId = $this->objectManager->get(GetQuoteByReservedOrderId::class);
62+
$this->customerRepository = $this->objectManager->get(CustomerRepositoryInterface::class);
63+
$this->cartManagement = $this->objectManager->get(CartManagementInterface::class);
64+
$this->checkoutSession = $this->objectManager->get(CheckoutSession::class);
65+
}
66+
67+
/**
68+
* @magentoDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
69+
* @magentoDataFixture Magento/Customer/_files/customer.php
70+
*
71+
* @return void
72+
* @throws FileSystemException
73+
* @throws LocalizedException
74+
* @throws NoSuchEntityException
75+
* @throws StateException
76+
*/
77+
public function testValidateEmptyMinicartAfterSessionClear(): void
78+
{
79+
$customer = $this->customerRepository->get('customer@example.com');
80+
$quote = $this->getQuoteByReservedOrderId->execute('test_order_with_simple_product_without_address');
81+
$result = $this->cartManagement->assignCustomer($quote->getId(), $customer->getId(), $customer->getStoreId());
82+
$this->assertTrue($result);
83+
$customerQuote = $this->cartManagement->getCartForCustomer($customer->getId());
84+
$this->checkoutSession->setQuoteId($customerQuote->getId());
85+
$this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR)->delete(DirectoryList::SESSION);
86+
$this->dispatch('backend/admin/cache/flushAll');
87+
$this->assertEquals(0, $this->checkoutSession->getQuote()->getItemsCount());
88+
}
89+
}

0 commit comments

Comments
 (0)