@@ -55,20 +55,21 @@ protected function setUp()
55
55
}
56
56
57
57
/**
58
+ * Set "Next Day Air Early AM" UPS shipping method
59
+ *
58
60
* @magentoApiDataFixture Magento/Customer/_files/customer.php
59
- * @magentoApiDataFixture Magento/Catalog/_files/product_simple .php
61
+ * @magentoApiDataFixture Magento/GraphQl/ Catalog/_files/simple_product .php
60
62
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
61
63
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
62
64
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
63
65
* @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
64
- *
65
- * @param string $carrierMethodCode
66
- * @param string $carrierMethodLabel
67
- * @dataProvider availableForCartShippingMethods
68
66
*/
69
- public function testSetAvailableForCartUpsShippingMethod ( string $ carrierMethodCode , string $ carrierMethodLabel )
67
+ public function testSetNextDayAirEarlyAmUpsShippingMethod ( )
70
68
{
71
69
$ quoteReservedId = 'test_quote ' ;
70
+ $ carrierMethodCode = '1DM ' ;
71
+ $ carrierMethodLabel = 'Next Day Air Early AM ' ;
72
+
72
73
$ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ($ quoteReservedId );
73
74
$ shippingAddressId = $ this ->getQuoteShippingAddressIdByReservedQuoteId ->execute ($ quoteReservedId );
74
75
@@ -91,20 +92,21 @@ public function testSetAvailableForCartUpsShippingMethod(string $carrierMethodCo
91
92
}
92
93
93
94
/**
95
+ * Set "Next Day Air" UPS shipping method
96
+ *
94
97
* @magentoApiDataFixture Magento/Customer/_files/customer.php
95
- * @magentoApiDataFixture Magento/Catalog/_files/product_simple .php
98
+ * @magentoApiDataFixture Magento/GraphQl/ Catalog/_files/simple_product .php
96
99
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
97
100
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
98
101
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
99
102
* @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
100
- *
101
- * @param string $carrierMethodCode
102
- * @param string $carrierMethodLabel
103
- * @dataProvider notAvailableForCartShippingMethods
104
103
*/
105
- public function testSetNotAvailableForCartUpsShippingMethod ( string $ carrierMethodCode , string $ carrierMethodLabel )
104
+ public function testSetNextDayAirUpsShippingMethod ( )
106
105
{
107
106
$ quoteReservedId = 'test_quote ' ;
107
+ $ carrierMethodCode = '1DA ' ;
108
+ $ carrierMethodLabel = 'Next Day Air ' ;
109
+
108
110
$ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ($ quoteReservedId );
109
111
$ shippingAddressId = $ this ->getQuoteShippingAddressIdByReservedQuoteId ->execute ($ quoteReservedId );
110
112
@@ -115,8 +117,41 @@ public function testSetNotAvailableForCartUpsShippingMethod(string $carrierMetho
115
117
$ carrierMethodCode
116
118
);
117
119
118
- $ this ->expectExceptionMessage (
119
- "GraphQL response contains errors: Carrier with such method not found: " . self ::CARRIER_CODE . ", " . $ carrierMethodCode
120
+ $ response = $ this ->sendRequestWithToken ($ query );
121
+
122
+ $ addressesInformation = $ response ['setShippingMethodsOnCart ' ]['cart ' ]['shipping_addresses ' ];
123
+ $ expectedResult = [
124
+ 'carrier_code ' => self ::CARRIER_CODE ,
125
+ 'method_code ' => $ carrierMethodCode ,
126
+ 'label ' => self ::CARRIER_LABEL . ' - ' . $ carrierMethodLabel ,
127
+ ];
128
+ self ::assertEquals ($ addressesInformation [0 ]['selected_shipping_method ' ], $ expectedResult );
129
+ }
130
+
131
+ /**
132
+ * Set "2nd Day Air" UPS shipping method
133
+ *
134
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
135
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
136
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
137
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
138
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
139
+ * @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
140
+ */
141
+ public function testSet2ndDayAirUpsShippingMethod ()
142
+ {
143
+ $ quoteReservedId = 'test_quote ' ;
144
+ $ carrierMethodCode = '2DA ' ;
145
+ $ carrierMethodLabel = '2nd Day Air ' ;
146
+
147
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ($ quoteReservedId );
148
+ $ shippingAddressId = $ this ->getQuoteShippingAddressIdByReservedQuoteId ->execute ($ quoteReservedId );
149
+
150
+ $ query = $ this ->getQuery (
151
+ $ maskedQuoteId ,
152
+ $ shippingAddressId ,
153
+ self ::CARRIER_CODE ,
154
+ $ carrierMethodCode
120
155
);
121
156
122
157
$ response = $ this ->sendRequestWithToken ($ query );
@@ -131,56 +166,109 @@ public function testSetNotAvailableForCartUpsShippingMethod(string $carrierMetho
131
166
}
132
167
133
168
/**
134
- * @return array
169
+ * Set "3 Day Select" UPS shipping method
170
+ *
171
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
172
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
173
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
174
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
175
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
176
+ * @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
135
177
*/
136
- public function availableForCartShippingMethods (): array
178
+ public function testSet3DaySelectUpsShippingMethod ()
137
179
{
138
- $ shippingMethods = ['1DM ' , '1DA ' , '2DA ' , '3DS ' , 'GND ' ];
180
+ $ quoteReservedId = 'test_quote ' ;
181
+ $ carrierMethodCode = '3DS ' ;
182
+ $ carrierMethodLabel = '3 Day Select ' ;
139
183
140
- return $ this ->filterShippingMethodsByCodes ($ shippingMethods );
184
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ($ quoteReservedId );
185
+ $ shippingAddressId = $ this ->getQuoteShippingAddressIdByReservedQuoteId ->execute ($ quoteReservedId );
186
+
187
+ $ query = $ this ->getQuery (
188
+ $ maskedQuoteId ,
189
+ $ shippingAddressId ,
190
+ self ::CARRIER_CODE ,
191
+ $ carrierMethodCode
192
+ );
193
+
194
+ $ response = $ this ->sendRequestWithToken ($ query );
195
+
196
+ $ addressesInformation = $ response ['setShippingMethodsOnCart ' ]['cart ' ]['shipping_addresses ' ];
197
+ $ expectedResult = [
198
+ 'carrier_code ' => self ::CARRIER_CODE ,
199
+ 'method_code ' => $ carrierMethodCode ,
200
+ 'label ' => self ::CARRIER_LABEL . ' - ' . $ carrierMethodLabel ,
201
+ ];
202
+ self ::assertEquals ($ addressesInformation [0 ]['selected_shipping_method ' ], $ expectedResult );
141
203
}
142
204
143
205
/**
144
- * @return array
206
+ * Set "Ground" UPS shipping method
207
+ *
208
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
209
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
210
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
211
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
212
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
213
+ * @magentoApiDataFixture Magento/Ups/_files/enable_ups_shipping_method.php
145
214
*/
146
- public function notAvailableForCartShippingMethods (): array
215
+ public function testSetGroundUpsShippingMethod ()
147
216
{
148
- $ shippingMethods = ['1DML ' , '1DAL ' , '1DAPI ' , '1DP ' , '1DPL ' , '2DM ' , '2DML ' , '2DAL ' , 'GNDCOM ' , 'GNDRES ' , 'STD ' , 'XPR ' , 'WXS ' , 'XPRL ' , 'XDM ' , 'XDML ' , 'XPD ' ];
217
+ $ quoteReservedId = 'test_quote ' ;
218
+ $ carrierMethodCode = 'GND ' ;
219
+ $ carrierMethodLabel = 'Ground ' ;
149
220
150
- return $ this ->filterShippingMethodsByCodes ($ shippingMethods );
221
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ($ quoteReservedId );
222
+ $ shippingAddressId = $ this ->getQuoteShippingAddressIdByReservedQuoteId ->execute ($ quoteReservedId );
223
+
224
+ $ query = $ this ->getQuery (
225
+ $ maskedQuoteId ,
226
+ $ shippingAddressId ,
227
+ self ::CARRIER_CODE ,
228
+ $ carrierMethodCode
229
+ );
230
+
231
+ $ response = $ this ->sendRequestWithToken ($ query );
232
+
233
+ $ addressesInformation = $ response ['setShippingMethodsOnCart ' ]['cart ' ]['shipping_addresses ' ];
234
+ $ expectedResult = [
235
+ 'carrier_code ' => self ::CARRIER_CODE ,
236
+ 'method_code ' => $ carrierMethodCode ,
237
+ 'label ' => self ::CARRIER_LABEL . ' - ' . $ carrierMethodLabel ,
238
+ ];
239
+ self ::assertEquals ($ addressesInformation [0 ]['selected_shipping_method ' ], $ expectedResult );
151
240
}
152
241
242
+
243
+
244
+
245
+
153
246
/**
154
- * @param array $filter
155
247
* @return array
156
248
*/
157
- private function filterShippingMethodsByCodes ( array $ filter ): array
249
+ public function notAvailableForCartShippingMethods (): array
158
250
{
159
- $ result = [];
160
- foreach ($ this ->getAllUpsShippingMethods () as $ shippingMethod ) {
161
- if (in_array ($ shippingMethod [0 ], $ filter )) {
162
- $ result [] = $ shippingMethod ;
163
- }
164
- }
165
- return $ result ;
251
+ $ shippingMethods = ['1DML ' , '1DAL ' , '1DAPI ' , '1DP ' , '1DPL ' , '2DM ' , '2DML ' , '2DAL ' , 'GNDCOM ' , 'GNDRES ' , 'STD ' , 'XPR ' , 'WXS ' , 'XPRL ' , 'XDM ' , 'XDML ' , 'XPD ' ];
252
+
253
+ return $ this ->filterShippingMethodsByCodes ($ shippingMethods );
166
254
}
167
255
168
256
private function getAllUpsShippingMethods ():array
169
257
{
170
258
return [
171
- ['1DM ' , 'Next Day Air Early AM ' ],
259
+ ['1DM ' , 'Next Day Air Early AM ' ], //
172
260
['1DML ' , 'Next Day Air Early AM Letter ' ],
173
- ['1DA ' , 'Next Day Air ' ],
261
+ ['1DA ' , 'Next Day Air ' ], //
174
262
['1DAL ' , 'Next Day Air Letter ' ],
175
263
['1DAPI ' , 'Next Day Air Intra (Puerto Rico) ' ],
176
264
['1DP ' , 'Next Day Air Saver ' ],
177
265
['1DPL ' , 'Next Day Air Saver Letter ' ],
178
266
['2DM ' , '2nd Day Air AM ' ],
179
267
['2DML ' , '2nd Day Air AM Letter ' ],
180
- ['2DA ' , '2nd Day Air ' ],
268
+ ['2DA ' , '2nd Day Air ' ], //
181
269
['2DAL ' , '2nd Day Air Letter ' ],
182
- ['3DS ' , '3 Day Select ' ],
183
- ['GND ' , 'Ground ' ],
270
+ ['3DS ' , '3 Day Select ' ], //
271
+ ['GND ' , 'Ground ' ], //
184
272
['GNDCOM ' , 'Ground Commercial ' ],
185
273
['GNDRES ' , 'Ground Residential ' ],
186
274
['STD ' , 'Canada Standard ' ],
0 commit comments