Skip to content

Commit 80603ff

Browse files
akaashakaash
authored andcommitted
Feedbacks
1 parent 2958372 commit 80603ff

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

dev/tests/integration/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Quote\Model;
99

10+
use Magento\Customer\Api\CustomerRepositoryInterface;
1011
use Magento\Framework\Api\FilterBuilder;
1112
use Magento\Framework\Api\SearchCriteria;
1213
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -95,6 +96,11 @@ class QuoteRepositoryTest extends TestCase
9596
*/
9697
private $store;
9798

99+
/**
100+
* @var CustomerRepositoryInterface
101+
*/
102+
private $customerRepository;
103+
98104
/**
99105
* @inheritdoc
100106
*/
@@ -113,6 +119,7 @@ protected function setUp(): void
113119
$this->itemFactory = $this->objectManager->get(CartItemInterfaceFactory::class);
114120
$this->quoteFactorys = $this->objectManager->get(\Magento\Quote\Model\QuoteFactory::class);
115121
$this->store = $this->objectManager->get(\Magento\Store\Model\Store::class);
122+
$this->customerRepository = $this->objectManager->get(CustomerRepositoryInterface::class);
116123
}
117124

118125
/**
@@ -298,7 +305,7 @@ private function performAssertions(CartSearchResultsInterface $searchResult): vo
298305
* @return void
299306
* @throws \Exception
300307
*/
301-
public function testDeleteAllQuotesRelatedToCustomerIfWeDeleteStoreView(): void
308+
public function testDeleteAllQuotesOnStoreViewDeletion(): void
302309
{
303310
$storeData = [
304311
[
@@ -329,22 +336,31 @@ public function testDeleteAllQuotesRelatedToCustomerIfWeDeleteStoreView(): void
329336
$firstStoreId = $this->store->load('store1')->getId();
330337
$secondStoreId = $this->store->load('store2')->getId();
331338

332-
// Create a quote with store id 2
339+
// Create a quote for guest user with store id 2
333340
$quote = $this->quoteFactorys->create();
334341
$quote->setStoreId($firstStoreId);
335342
$quote->save();
336343

337344
// Assert that quote is created successfully.
338345
$this->assertNotNull($quote->getId());
339346

340-
// Create a quote with store id 3
347+
// Create a quote for guest user with store id 3
341348
$secondQuote = $this->quoteFactorys->create();
342349
$secondQuote->setStoreId($secondStoreId);
343350
$secondQuote->save();
344351

345352
// Assert that second quote is created successfully.
346353
$this->assertNotNull($secondQuote->getId());
347354

355+
// load customer by id
356+
$customer = $this->customerRepository->getById(1);
357+
358+
// Create a quote for customer with store id 3
359+
$thirdQuote = $this->quoteFactorys->create();
360+
$thirdQuote->setStoreId($secondStoreId);
361+
$thirdQuote->setCustomer($customer);
362+
$thirdQuote->save();
363+
348364
// Loading the second store from the data fixture
349365
$this->store->load('store2', 'code');
350366
/** @var \Magento\TestFramework\Helper\Bootstrap $registry */
@@ -357,8 +373,12 @@ public function testDeleteAllQuotesRelatedToCustomerIfWeDeleteStoreView(): void
357373
// Deleting the second store.
358374
$this->store->delete();
359375

360-
// asserting that quote is also deleted when store is deleted
376+
// asserting that quote associated with guest user is also deleted when store is deleted
361377
$afterDeletionQuote = $this->quoteFactorys->create()->load($secondQuote->getId());
362378
$this->assertNull($afterDeletionQuote->getId());
379+
380+
// asserting that quote associated with customer is also deleted when store is deleted
381+
$afterDeletionQuote = $this->quoteFactorys->create()->load($thirdQuote->getId());
382+
$this->assertNull($afterDeletionQuote->getId());
363383
}
364384
}

0 commit comments

Comments
 (0)