Skip to content

Commit a8b4cc9

Browse files
author
Roman Glushko
committed
#481 Added testRemoveCouponFromCartWithNoCouponApplied case
1 parent 9000000 commit a8b4cc9

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function testRemoveCouponFromCart()
7474
{
7575
$couponCode = '2?ds5!2d';
7676

77-
/* Apply coupon to the customer quote */
77+
/* Assign the quote to the customer */
7878
$this->quoteResource->load(
7979
$this->quote,
8080
'test_order_with_simple_product_without_address',
@@ -85,6 +85,7 @@ public function testRemoveCouponFromCart()
8585
$this->quote->setCustomerId(1);
8686
$this->quoteResource->save($this->quote);
8787

88+
/* Apply coupon to the customer quote */
8889
$queryHeaders = $this->prepareAuthorizationHeaders('[email protected]', 'password');
8990
$query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
9091
$this->graphQlQuery($query, [], '', $queryHeaders);
@@ -106,7 +107,7 @@ public function testRemoveCouponFromCartTwice()
106107
{
107108
$couponCode = '2?ds5!2d';
108109

109-
/* Apply coupon to the customer quote */
110+
/* Assign the quote to the customer */
110111
$this->quoteResource->load(
111112
$this->quote,
112113
'test_order_with_simple_product_without_address',
@@ -117,6 +118,7 @@ public function testRemoveCouponFromCartTwice()
117118
$this->quote->setCustomerId(1);
118119
$this->quoteResource->save($this->quote);
119120

121+
/* Apply coupon to the customer quote */
120122
$queryHeaders = $this->prepareAuthorizationHeaders('[email protected]', 'password');
121123
$query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
122124
$this->graphQlQuery($query, [], '', $queryHeaders);
@@ -136,6 +138,32 @@ public function testRemoveCouponFromCartTwice()
136138
self::assertNull($response['removeCouponFromCart']['cart']['applied_coupon']['code']);
137139
}
138140

141+
/**
142+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
143+
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
144+
*/
145+
public function testRemoveCouponFromCartWithNoCouponApplied()
146+
{
147+
/* Assign the quote to the customer */
148+
$this->quoteResource->load(
149+
$this->quote,
150+
'test_order_with_simple_product_without_address',
151+
'reserved_order_id'
152+
);
153+
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
154+
155+
$this->quote->setCustomerId(1);
156+
$this->quoteResource->save($this->quote);
157+
158+
/* Remove coupon from the quote */
159+
$query = $this->prepareRemoveCouponRequestQuery($maskedQuoteId);
160+
$queryHeaders = $this->prepareAuthorizationHeaders('[email protected]', 'password');
161+
$response = $this->graphQlQuery($query, [], '', $queryHeaders);
162+
163+
self::assertArrayHasKey('removeCouponFromCart', $response);
164+
self::assertNull($response['removeCouponFromCart']['cart']['applied_coupon']['code']);
165+
}
166+
139167
/**
140168
* @magentoApiDataFixture Magento/Customer/_files/customer.php
141169
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php

0 commit comments

Comments
 (0)