@@ -51,40 +51,6 @@ protected function setUp()
51
51
$ this ->customerTokenService = $ objectManager ->get (CustomerTokenServiceInterface::class);
52
52
}
53
53
54
- /**
55
- * Test for general routine of setting a shipping method on shopping cart
56
- *
57
- * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
58
- * @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
59
- */
60
- public function testSetShippingMethodOnCart ()
61
- {
62
- $ shippingCarrierCode = 'flatrate ' ;
63
- $ shippingMethodCode = 'flatrate ' ;
64
- $ this ->quoteResource ->load (
65
- $ this ->quote ,
66
- 'test_order_1 ' ,
67
- 'reserved_order_id '
68
- );
69
- $ shippingAddress = $ this ->quote ->getShippingAddress ();
70
- $ shippingAddressId = $ shippingAddress ->getId ();
71
- $ maskedQuoteId = $ this ->quoteIdToMaskedId ->execute ((int )$ this ->quote ->getId ());
72
-
73
- $ query = $ this ->prepareMutationQuery (
74
- $ maskedQuoteId ,
75
- $ shippingMethodCode ,
76
- $ shippingCarrierCode ,
77
- $ shippingAddressId
78
- );
79
-
80
- $ response = $ this ->sendRequestWithToken ($ query );
81
-
82
- self ::assertArrayHasKey ('setShippingMethodsOnCart ' , $ response );
83
- self ::assertArrayHasKey ('cart ' , $ response ['setShippingMethodsOnCart ' ]);
84
- $ addressesInformation = $ response ['setShippingMethodsOnCart ' ]['cart ' ]['shipping_addresses ' ];
85
- self ::assertCount (1 , $ addressesInformation );
86
- }
87
-
88
54
/**
89
55
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
90
56
* @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
@@ -142,114 +108,6 @@ public function testSetUpsOnCart()
142
108
);
143
109
}
144
110
145
- /**
146
- * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
147
- * @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
148
- */
149
- public function testSetShippingMethodWithWrongCartId ()
150
- {
151
- $ shippingCarrierCode = 'flatrate ' ;
152
- $ shippingMethodCode = 'flatrate ' ;
153
- $ shippingAddressId = '1 ' ;
154
- $ maskedQuoteId = 'invalid ' ;
155
-
156
- $ query = $ this ->prepareMutationQuery (
157
- $ maskedQuoteId ,
158
- $ shippingMethodCode ,
159
- $ shippingCarrierCode ,
160
- $ shippingAddressId
161
- );
162
-
163
- self ::expectExceptionMessage ("Could not find a cart with ID \"$ maskedQuoteId \"" );
164
- $ this ->sendRequestWithToken ($ query );
165
- }
166
-
167
- /**
168
- * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
169
- * @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
170
- */
171
- public function testSetNonExistingShippingMethod ()
172
- {
173
- $ shippingCarrierCode = 'non ' ;
174
- $ shippingMethodCode = 'existing ' ;
175
- $ this ->quoteResource ->load (
176
- $ this ->quote ,
177
- 'test_order_1 ' ,
178
- 'reserved_order_id '
179
- );
180
- $ shippingAddress = $ this ->quote ->getShippingAddress ();
181
- $ shippingAddressId = $ shippingAddress ->getId ();
182
- $ maskedQuoteId = $ this ->quoteIdToMaskedId ->execute ((int )$ this ->quote ->getId ());
183
-
184
- $ query = $ this ->prepareMutationQuery (
185
- $ maskedQuoteId ,
186
- $ shippingMethodCode ,
187
- $ shippingCarrierCode ,
188
- $ shippingAddressId
189
- );
190
-
191
- self ::expectExceptionMessage ("Carrier with such method not found: $ shippingCarrierCode, $ shippingMethodCode " );
192
- $ this ->sendRequestWithToken ($ query );
193
- }
194
-
195
- /**
196
- * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
197
- * @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
198
- */
199
- public function testSetShippingMethodWithNonExistingAddress ()
200
- {
201
- $ shippingCarrierCode = 'flatrate ' ;
202
- $ shippingMethodCode = 'flatrate ' ;
203
- $ this ->quoteResource ->load (
204
- $ this ->quote ,
205
- 'test_order_1 ' ,
206
- 'reserved_order_id '
207
- );
208
- $ maskedQuoteId = $ this ->quoteIdToMaskedId ->execute ((int )$ this ->quote ->getId ());
209
- $ shippingAddressId = '-20 ' ;
210
-
211
- $ query = $ this ->prepareMutationQuery (
212
- $ maskedQuoteId ,
213
- $ shippingMethodCode ,
214
- $ shippingCarrierCode ,
215
- $ shippingAddressId
216
- );
217
-
218
- self ::expectExceptionMessage ("Could not find a cart address with ID \"$ shippingAddressId \"" );
219
- $ this ->sendRequestWithToken ($ query );
220
- }
221
-
222
- /**
223
- * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
224
- * @magentoApiDataFixture Magento/Checkout/_files/enable_all_shipping_methods.php
225
- */
226
- public function testSetShippingMethodByGuestToCustomerCart ()
227
- {
228
- $ shippingCarrierCode = 'flatrate ' ;
229
- $ shippingMethodCode = 'flatrate ' ;
230
- $ this ->quoteResource ->load (
231
- $ this ->quote ,
232
- 'test_order_1 ' ,
233
- 'reserved_order_id '
234
- );
235
- $ shippingAddress = $ this ->quote ->getShippingAddress ();
236
- $ shippingAddressId = $ shippingAddress ->getId ();
237
- $ maskedQuoteId = $ this ->quoteIdToMaskedId ->execute ((int )$ this ->quote ->getId ());
238
-
239
- $ query = $ this ->prepareMutationQuery (
240
- $ maskedQuoteId ,
241
- $ shippingMethodCode ,
242
- $ shippingCarrierCode ,
243
- $ shippingAddressId
244
- );
245
-
246
- self ::expectExceptionMessage (
247
- "The current user cannot perform operations on cart \"$ maskedQuoteId \""
248
- );
249
-
250
- $ this ->graphQlQuery ($ query );
251
- }
252
-
253
111
/**
254
112
* Send request for setting the requested shipping method and check the output
255
113
*
@@ -275,7 +133,7 @@ private function setShippingMethodAndCheckResponse(
275
133
$ shippingAddressId = $ shippingAddress ->getId ();
276
134
$ maskedQuoteId = $ this ->quoteIdToMaskedId ->execute ((int )$ this ->quote ->getId ());
277
135
278
- $ query = $ this ->prepareMutationQuery (
136
+ $ query = $ this ->getQuery (
279
137
$ maskedQuoteId ,
280
138
$ shippingMethodCode ,
281
139
$ shippingCarrierCode ,
@@ -300,7 +158,7 @@ private function setShippingMethodAndCheckResponse(
300
158
* @param string $shippingAddressId
301
159
* @return string
302
160
*/
303
- private function prepareMutationQuery (
161
+ private function getQuery (
304
162
string $ maskedQuoteId ,
305
163
string $ shippingMethodCode ,
306
164
string $ shippingCarrierCode ,
@@ -343,7 +201,6 @@ private function prepareMutationQuery(
343
201
*/
344
202
private function sendRequestWithToken (string $ query ): array
345
203
{
346
-
347
204
$ customerToken = $ this ->customerTokenService ->createCustomerAccessToken ('customer@example.com ' , 'password ' );
348
205
$ headerMap = ['Authorization ' => 'Bearer ' . $ customerToken ];
349
206
0 commit comments