Skip to content

Commit bb7be7a

Browse files
committed
Add API functional tests for ApplyCouponToCart functionality
1 parent 2bca2aa commit bb7be7a

File tree

3 files changed

+753
-85
lines changed

3 files changed

+753
-85
lines changed

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

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -41,91 +41,6 @@ protected function setUp()
4141
$this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class);
4242
}
4343

44-
/**
45-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
46-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
47-
*/
48-
public function testApplyCouponToGuestCartWithItems()
49-
{
50-
$couponCode = '2?ds5!2d';
51-
52-
$this->quoteResource->load(
53-
$this->quote,
54-
'test_order_with_simple_product_without_address',
55-
'reserved_order_id'
56-
);
57-
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
58-
$query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
59-
$response = $this->graphQlQuery($query);
60-
61-
self::assertArrayHasKey('applyCouponToCart', $response);
62-
self::assertEquals($couponCode, $response['applyCouponToCart']['cart']['applied_coupon']['code']);
63-
}
64-
65-
/**
66-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
67-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
68-
*/
69-
public function testApplyCouponTwice()
70-
{
71-
$couponCode = '2?ds5!2d';
72-
73-
$this->quoteResource->load(
74-
$this->quote,
75-
'test_order_with_simple_product_without_address',
76-
'reserved_order_id'
77-
);
78-
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
79-
$query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
80-
$response = $this->graphQlQuery($query);
81-
82-
self::assertArrayHasKey("applyCouponToCart", $response);
83-
self::assertEquals($couponCode, $response['applyCouponToCart']['cart']['applied_coupon']['code']);
84-
85-
self::expectExceptionMessage('A coupon is already applied to the cart. Please remove it to apply another');
86-
$this->graphQlQuery($query);
87-
}
88-
89-
/**
90-
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
91-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
92-
* @expectedException \Exception
93-
* @expectedExceptionMessage Cart does not contain products.
94-
*/
95-
public function testApplyCouponToCartWithNoItems()
96-
{
97-
$couponCode = '2?ds5!2d';
98-
99-
$this->quoteResource->load($this->quote, 'test_order_1', 'reserved_order_id');
100-
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
101-
$query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
102-
103-
$this->graphQlQuery($query);
104-
}
105-
106-
/**
107-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
108-
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
109-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
110-
*/
111-
public function testGuestCustomerAttemptToChangeCustomerCart()
112-
{
113-
$couponCode = '2?ds5!2d';
114-
115-
$this->quoteResource->load(
116-
$this->quote,
117-
'test_order_with_simple_product_without_address',
118-
'reserved_order_id'
119-
);
120-
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
121-
$this->quote->setCustomerId(1);
122-
$this->quoteResource->save($this->quote);
123-
$query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
124-
125-
self::expectExceptionMessage('The current user cannot perform operations on cart "' . $maskedQuoteId . '"');
126-
$this->graphQlQuery($query);
127-
}
128-
12944
/**
13045
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
13146
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php

0 commit comments

Comments
 (0)