@@ -74,40 +74,11 @@ public function testGetCustomerOrdersSimpleProductQuery()
74
74
}
75
75
}
76
76
shipping_address {
77
- firstname
78
- lastname
79
- city
80
- company
81
- country_code
82
- fax
83
- middlename
84
- postcode
85
- prefix
86
- street
87
- region
88
- region_id
89
- suffix
90
- telephone
91
- vat_id
92
- }
93
- billing_address
94
- {
95
- firstname
96
- lastname
97
- city
98
- company
99
- country_code
100
- fax
101
- middlename
102
- postcode
103
- prefix
104
- region
105
- region_id
106
- street
107
- suffix
108
- telephone
109
- vat_id
110
- }
77
+ ... address
78
+ }
79
+ billing_address {
80
+ ... address
81
+ }
111
82
items{
112
83
quantity_ordered
113
84
product_sku
@@ -133,6 +104,24 @@ public function testGetCustomerOrdersSimpleProductQuery()
133
104
}
134
105
}
135
106
}
107
+
108
+ fragment address on OrderAddress {
109
+ firstname
110
+ lastname
111
+ city
112
+ company
113
+ country_code
114
+ fax
115
+ middlename
116
+ postcode
117
+ prefix
118
+ street
119
+ region
120
+ region_id
121
+ suffix
122
+ telephone
123
+ vat_id
124
+ }
136
125
QUERY ;
137
126
138
127
$ currentEmail = 'customer@example.com ' ;
@@ -202,29 +191,7 @@ public function testCustomerOrdersSimpleProductWithTaxesAndDiscounts()
202
191
$ this ->setPaymentMethod ($ cartId , $ paymentMethod );
203
192
$ orderNumber = $ this ->placeOrder ($ cartId );
204
193
$ customerOrderResponse = $ this ->getCustomerOrderQuery ($ orderNumber );
205
- $ this ->assertOrderBillingAddress ($ customerOrderResponse [0 ]["billing_address " ]);
206
- $ this ->assertOrderShippingAddress ($ customerOrderResponse [0 ]["shipping_address " ]);
207
- $ this ->assertOrderPaymentMethod ($ customerOrderResponse [0 ]["payment_methods " ]);
208
- // Asserting discounts on order item level
209
- $ this ->assertEquals (4 , $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['amount ' ]['value ' ]);
210
- $ this ->assertEquals ('USD ' , $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['amount ' ]['currency ' ]);
211
- $ this ->assertEquals (
212
- 'Discount Label for 10% off ' ,
213
- $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['label ' ]
214
- );
215
- $ customerOrderItem = $ customerOrderResponse [0 ];
216
- $ this ->assertTotalsWithTaxesAndDiscounts ($ customerOrderItem ['total ' ]);
217
- $ this ->deleteOrder ();
218
- }
219
-
220
- /**
221
- * Check order billing address
222
- *
223
- * @param array $customerOrderBillingAddress
224
- */
225
- private function assertOrderBillingAddress (array $ customerOrderBillingAddress ): void
226
- {
227
- $ assertionMap = [
194
+ $ billingAssertionMap = [
228
195
'firstname ' => 'John ' ,
229
196
'lastname ' => 'Smith ' ,
230
197
'city ' => 'Texas City ' ,
@@ -241,17 +208,8 @@ private function assertOrderBillingAddress(array $customerOrderBillingAddress):
241
208
'suffix ' => 'John ' ,
242
209
'telephone ' => '5123456677 '
243
210
];
244
- $ this ->assertResponseFields ($ customerOrderBillingAddress , $ assertionMap );
245
- }
246
-
247
- /**
248
- * Check order shipping address
249
- *
250
- * @param array $customerOrderShippingAddress
251
- */
252
- private function assertOrderShippingAddress (array $ customerOrderShippingAddress ): void
253
- {
254
- $ assertionMap = [
211
+ $ this ->assertResponseFields ($ customerOrderResponse [0 ]["billing_address " ], $ billingAssertionMap );
212
+ $ shippingAssertionMap = [
255
213
'firstname ' => 'test shipFirst ' ,
256
214
'lastname ' => 'test shipLast ' ,
257
215
'city ' => 'Montgomery ' ,
@@ -268,24 +226,25 @@ private function assertOrderShippingAddress(array $customerOrderShippingAddress)
268
226
'suffix ' => 'test shipFirst ' ,
269
227
'telephone ' => '3347665522 '
270
228
];
271
- $ this ->assertResponseFields ($ customerOrderShippingAddress , $ assertionMap );
272
- }
273
-
274
- /**
275
- * Check order payment method
276
- *
277
- * @param array $customerOrderPaymentMethod
278
- */
279
- private function assertOrderPaymentMethod (array $ customerOrderPaymentMethod ): void
280
- {
281
- $ assertionMap = [
229
+ $ this ->assertResponseFields ($ customerOrderResponse [0 ]["shipping_address " ], $ shippingAssertionMap );
230
+ $ paymentMethodAssertionMap = [
282
231
[
283
232
'name ' => 'Check / Money order ' ,
284
233
'type ' => 'checkmo ' ,
285
234
'additional_data ' => []
286
235
]
287
236
];
288
- $ this ->assertResponseFields ($ customerOrderPaymentMethod , $ assertionMap );
237
+ $ this ->assertResponseFields ($ customerOrderResponse [0 ]["payment_methods " ], $ paymentMethodAssertionMap );
238
+ // Asserting discounts on order item level
239
+ $ this ->assertEquals (4 , $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['amount ' ]['value ' ]);
240
+ $ this ->assertEquals ('USD ' , $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['amount ' ]['currency ' ]);
241
+ $ this ->assertEquals (
242
+ 'Discount Label for 10% off ' ,
243
+ $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['label ' ]
244
+ );
245
+ $ customerOrderItem = $ customerOrderResponse [0 ];
246
+ $ this ->assertTotalsWithTaxesAndDiscounts ($ customerOrderItem ['total ' ]);
247
+ $ this ->deleteOrder ();
289
248
}
290
249
291
250
/**
@@ -1342,50 +1301,21 @@ private function getCustomerOrderQuery($orderNumber): array
1342
1301
status
1343
1302
payment_methods
1344
1303
{
1345
- name
1346
- type
1347
- additional_data
1348
- {
1349
- name
1350
- value
1351
- }
1352
- }
1353
- shipping_address {
1354
- firstname
1355
- lastname
1356
- city
1357
- company
1358
- country_code
1359
- fax
1360
- middlename
1361
- postcode
1362
- prefix
1363
- street
1364
- region
1365
- region_id
1366
- suffix
1367
- telephone
1368
- vat_id
1369
- }
1370
- billing_address
1371
- {
1372
- firstname
1373
- lastname
1374
- city
1375
- company
1376
- country_code
1377
- fax
1378
- middlename
1379
- postcode
1380
- prefix
1381
- region
1382
- region_id
1383
- street
1384
- suffix
1385
- telephone
1386
- vat_id
1387
- }
1388
- items{product_name product_sku quantity_ordered discounts {amount{value currency} label}}
1304
+ name
1305
+ type
1306
+ additional_data
1307
+ {
1308
+ name
1309
+ value
1310
+ }
1311
+ }
1312
+ shipping_address {
1313
+ ... address
1314
+ }
1315
+ billing_address {
1316
+ ... address
1317
+ }
1318
+ items{product_name product_sku quantity_ordered discounts {amount{value currency} label}}
1389
1319
total {
1390
1320
base_grand_total{value currency}
1391
1321
grand_total{value currency}
@@ -1408,6 +1338,24 @@ private function getCustomerOrderQuery($orderNumber): array
1408
1338
}
1409
1339
}
1410
1340
}
1341
+
1342
+ fragment address on OrderAddress {
1343
+ firstname
1344
+ lastname
1345
+ city
1346
+ company
1347
+ country_code
1348
+ fax
1349
+ middlename
1350
+ postcode
1351
+ prefix
1352
+ street
1353
+ region
1354
+ region_id
1355
+ suffix
1356
+ telephone
1357
+ vat_id
1358
+ }
1411
1359
QUERY ;
1412
1360
$ currentEmail = 'customer@example.com ' ;
1413
1361
$ currentPassword = 'password ' ;
0 commit comments