Skip to content

Commit 1daadb8

Browse files
committed
GraphQL-408: mutations add<Product Type>ProductsToCart dosn't check if the cart is active
1 parent a984663 commit 1daadb8

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForUser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ public function execute(string $cartHash, ?int $customerId): Quote
6969
);
7070
}
7171

72-
if (!$cart->getIsActive()) {
72+
if (false === (bool)$cart->getIsActive()) {
7373
throw new GraphQlNoSuchEntityException(
74-
__('Current customer does not have an active cart.')
74+
__('Current user does not have an active cart.')
7575
);
7676
}
7777

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function testGetNonExistentCart()
118118
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
119119
* @magentoApiDataFixture Magento/Customer/_files/customer.php
120120
* @expectedException \Exception
121-
* @expectedExceptionMessage Current customer does not have an active cart.
121+
* @expectedExceptionMessage Current user does not have an active cart.
122122
*/
123123
public function testGetInactiveCart()
124124
{
@@ -127,7 +127,7 @@ public function testGetInactiveCart()
127127
$quote->setCustomerId(1);
128128
$quote->setIsActive(false);
129129
$this->quoteResource->save($quote);
130-
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$quote->getId());
130+
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$quote->getId());
131131

132132
$query = $this->getCartQuery($maskedQuoteId);
133133

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetCartTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,24 @@ public function testGetNonExistentCart()
9797
$this->graphQlQuery($query);
9898
}
9999

100+
/**
101+
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
102+
* @expectedException \Exception
103+
* @expectedExceptionMessage Current user does not have an active cart.
104+
*/
105+
public function testGetInactiveCart()
106+
{
107+
$quote = $this->quoteFactory->create();
108+
$this->quoteResource->load($quote, 'test_order_with_simple_product_without_address', 'reserved_order_id');
109+
$quote->setIsActive(false);
110+
$this->quoteResource->save($quote);
111+
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$quote->getId());
112+
113+
$query = $this->getCartQuery($maskedQuoteId);
114+
115+
$this->graphQlQuery($query);
116+
}
117+
100118
/**
101119
* @param string $maskedQuoteId
102120
* @return string

0 commit comments

Comments
 (0)