@@ -81,6 +81,66 @@ public function testRemoveCouponFromCart()
81
81
self ::assertNull ($ response ['removeCouponFromCart ' ]['cart ' ]['applied_coupon ' ]['code ' ]);
82
82
}
83
83
84
+ /**
85
+ * @magentoApiDataFixture Magento/Customer/_files/two_customers.php
86
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
87
+ * @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
88
+ */
89
+ public function testRemoveCouponFromAonotherCustomerCart ()
90
+ {
91
+ $ couponCode = '2?ds5!2d ' ;
92
+
93
+ /* Apply coupon to the quote */
94
+ $ this ->quoteResource ->load (
95
+ $ this ->quote ,
96
+ 'test_order_with_simple_product_without_address ' ,
97
+ 'reserved_order_id '
98
+ );
99
+ $ maskedQuoteId = $ this ->quoteIdToMaskedId ->execute ((int )$ this ->quote ->getId ());
100
+
101
+ $ this ->quote ->setCustomerId (1 );
102
+ $ this ->quoteResource ->save ($ this ->quote );
103
+
104
+ $ query = $ this ->prepareAddCouponRequestQuery ($ maskedQuoteId , $ couponCode );
105
+ $ queryHeaders =
$ this ->
prepareAuthorizationHeaders (
'[email protected] ' ,
'password ' );
106
+ $ this ->graphQlQuery ($ query , [], '' , $ queryHeaders );
107
+
108
+ /* Remove coupon from quote */
109
+ $ query = $ this ->prepareRemoveCouponRequestQuery ($ maskedQuoteId );
110
+ $ queryHeaders =
$ this ->
prepareAuthorizationHeaders (
'[email protected] ' ,
'password ' );
111
+
112
+ $ this ->expectExceptionMessage ("The current user cannot perform operations on cart \"$ maskedQuoteId \"" );
113
+ $ this ->graphQlQuery ($ query , [], '' , $ queryHeaders );
114
+ }
115
+
116
+ /**
117
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
118
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
119
+ * @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
120
+ */
121
+ public function testRemoveCouponFromGuestCart ()
122
+ {
123
+ $ couponCode = '2?ds5!2d ' ;
124
+
125
+ /* Apply coupon to the quote */
126
+ $ this ->quoteResource ->load (
127
+ $ this ->quote ,
128
+ 'test_order_with_simple_product_without_address ' ,
129
+ 'reserved_order_id '
130
+ );
131
+ $ maskedQuoteId = $ this ->quoteIdToMaskedId ->execute ((int )$ this ->quote ->getId ());
132
+
133
+ $ query = $ this ->prepareAddCouponRequestQuery ($ maskedQuoteId , $ couponCode );
134
+ $ this ->graphQlQuery ($ query );
135
+
136
+ /* Remove coupon from quote */
137
+ $ query = $ this ->prepareRemoveCouponRequestQuery ($ maskedQuoteId );
138
+ $ queryHeaders =
$ this ->
prepareAuthorizationHeaders (
'[email protected] ' ,
'password ' );
139
+
140
+ $ this ->expectExceptionMessage ("The current user cannot perform operations on cart \"$ maskedQuoteId \"" );
141
+ $ this ->graphQlQuery ($ query , [], '' , $ queryHeaders );
142
+ }
143
+
84
144
/**
85
145
* Retrieve customer authorization headers
86
146
*
0 commit comments