@@ -112,9 +112,8 @@ public function testGetCustomerOrdersSimpleProductQuery()
112
112
/** @var \Magento\Sales\Api\Data\OrderInterface[] $items */
113
113
$ orders = $ this ->orderRepository ->getList ($ searchCriteria )->getItems ();
114
114
foreach ($ orders as $ order ) {
115
- $ orderId = $ order ->getEntityId ();
116
115
$ orderNumber = $ order ->getIncrementId ();
117
- $ this ->assertEquals ( $ orderId , $ customerOrderItemsInResponse ['id ' ]);
116
+ $ this ->assertNotEmpty ( $ customerOrderItemsInResponse ['id ' ]);
118
117
$ this ->assertEquals ($ orderNumber , $ customerOrderItemsInResponse ['number ' ]);
119
118
$ this ->assertEquals ('Processing ' , $ customerOrderItemsInResponse ['status ' ]);
120
119
}
@@ -136,13 +135,52 @@ public function testGetCustomerOrdersSimpleProductQuery()
136
135
$ this ->assertEquals ($ expectedOrderTotal , $ actualOrderTotalFromResponse , 'Totals do not match ' );
137
136
}
138
137
138
+ /**
139
+ * Verify the customer order with tax, discount with shipping tax class set for calculation setting
140
+ *
141
+ * @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_url_key.php
142
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
143
+ * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php
144
+ * @magentoApiDataFixture Magento/SalesRule/_files/cart_rule_10_percent_off_with_discount_on_shipping.php
145
+ * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_calculation_shipping_excludeTax_order_display_settings.php
146
+ */
147
+ public function testCustomerOrdersSimpleProductWithTaxesAndDiscounts ()
148
+ {
149
+ $ quantity = 4 ;
150
+ $ sku = 'simple1 ' ;
151
+ $ cartId = $ this ->createEmptyCart ();
152
+ $ this ->addProductToCart ($ cartId , $ quantity , $ sku );
153
+ $ this ->setBillingAddress ($ cartId );
154
+ $ shippingMethod = $ this ->setShippingAddress ($ cartId );
155
+ $ paymentMethod = $ this ->setShippingMethod ($ cartId , $ shippingMethod );
156
+ $ this ->setPaymentMethod ($ cartId , $ paymentMethod );
157
+ $ orderNumber = $ this ->placeOrder ($ cartId );
158
+ $ customerOrderResponse = $ this ->getCustomerOrderQuery ($ orderNumber );
159
+ // Asserting discounts on order item level
160
+ $ this ->assertEquals (
161
+ 4 ,
162
+ $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['amount ' ]['value ' ]
163
+ );
164
+ $ this ->assertEquals (
165
+ 'USD ' ,
166
+ $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['amount ' ]['currency ' ]
167
+ );
168
+ $ this ->assertEquals (
169
+ 'null ' ,
170
+ $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['label ' ]
171
+ );
172
+ $ customerOrderItem = $ customerOrderResponse [0 ];
173
+ $ this ->assertTotalsWithTaxesAndDiscountsOnShippingAndTotal ($ customerOrderItem );
174
+ $ this ->deleteOrder ();
175
+ }
176
+
139
177
/**
140
178
* Test customer order details with bundle product with child items
141
179
*
142
180
* @magentoApiDataFixture Magento/Customer/_files/customer.php
143
181
* @magentoApiDataFixture Magento/Bundle/_files/bundle_product_two_dropdown_options.php
144
182
*/
145
- public function testGetCustomerOrderWithBundleProduct ()
183
+ public function testGetCustomerOrderBundleProduct ()
146
184
{
147
185
$ qty = 1 ;
148
186
$ bundleSku = 'bundle-product-two-dropdown-options ' ;
@@ -211,7 +249,7 @@ public function testGetCustomerOrderWithBundleProduct()
211
249
* @magentoApiDataFixture Magento/SalesRule/_files/cart_rule_10_percent_off_with_discount_on_shipping.php
212
250
* @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_calculation_shipping_excludeTax_order_display_settings.php
213
251
*/
214
- public function testGetCustomerOrderWithBundleProductWithTaxesAndDiscounts ()
252
+ public function testGetCustomerOrderBundleProductWithTaxesAndDiscounts ()
215
253
{
216
254
$ qty = 4 ;
217
255
$ bundleSku = 'bundle-product-two-dropdown-options ' ;
@@ -278,10 +316,16 @@ private function assertTotalsOnBundleProductWithTaxesAndDiscounts(array $custome
278
316
20 ,
279
317
$ customerOrderItem ['total ' ]['total_shipping ' ]['value ' ]
280
318
);
281
- $ this ->assertEquals (
282
- 1.35 ,
283
- $ customerOrderItem ['total ' ]['taxes ' ][0 ]['amount ' ]['value ' ]
284
- );
319
+ $ this ->assertCount (2 , $ customerOrderItem ['total ' ]['taxes ' ]);
320
+ $ expectedProductAndShippingTaxes = [4.05 , 1.35 ];
321
+
322
+ $ totalTaxes = [];
323
+ foreach ($ customerOrderItem ['total ' ]['taxes ' ] as $ totalTaxFromResponse ) {
324
+ array_push ($ totalTaxes , $ totalTaxFromResponse ['amount ' ]['value ' ]);
325
+ }
326
+ foreach ($ totalTaxes as $ value ) {
327
+ $ this ->assertTrue (in_array ($ value , $ expectedProductAndShippingTaxes ));
328
+ }
285
329
$ this ->assertEquals (
286
330
'USD ' ,
287
331
$ customerOrderItem ['total ' ]['taxes ' ][0 ]['amount ' ]['currency ' ]
@@ -294,10 +338,6 @@ private function assertTotalsOnBundleProductWithTaxesAndDiscounts(array $custome
294
338
7.5 ,
295
339
$ customerOrderItem ['total ' ]['taxes ' ][0 ]['rate ' ]
296
340
);
297
- $ this ->assertEquals (
298
- 4.05 ,
299
- $ customerOrderItem ['total ' ]['taxes ' ][1 ]['amount ' ]['value ' ]
300
- );
301
341
$ this ->assertEquals (
302
342
'USD ' ,
303
343
$ customerOrderItem ['total ' ]['taxes ' ][1 ]['amount ' ]['currency ' ]
@@ -462,7 +502,6 @@ public function testGetMatchingOrdersForLowerQueryLength()
462
502
/**
463
503
* @magentoApiDataFixture Magento/Customer/_files/customer.php
464
504
* @magentoApiDataFixture Magento/GraphQl/Sales/_files/orders_with_customer.php
465
- * @magentoApiDataFixture Magento/Sales/_files/orders_with_customer.php
466
505
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
467
506
*/
468
507
public function testGetMultipleCustomerOrdersQueryWithDefaultPagination ()
@@ -482,7 +521,7 @@ public function testGetMultipleCustomerOrdersQueryWithDefaultPagination()
482
521
}
483
522
items
484
523
{
485
- id
524
+
486
525
number
487
526
status
488
527
order_date
@@ -543,9 +582,8 @@ public function testGetMultipleCustomerOrdersQueryWithDefaultPagination()
543
582
$ orders = $ this ->orderRepository ->getList ($ searchCriteria )->getItems ();
544
583
$ key = 0 ;
545
584
foreach ($ orders as $ order ) {
546
- $ orderId = $ order ->getEntityId ();
547
585
$ orderNumber = $ order ->getIncrementId ();
548
- $ this ->assertEquals ( $ orderId , $ customerOrderItemsInResponse [$ key ]['id ' ]);
586
+ $ this ->assertNotEmpty ( $ customerOrderItemsInResponse [$ key ]['id ' ]);
549
587
$ this ->assertEquals ($ orderNumber , $ customerOrderItemsInResponse [$ key ]['number ' ]);
550
588
$ this ->assertEquals ('Processing ' , $ customerOrderItemsInResponse [$ key ]['status ' ]);
551
589
$ this ->assertEquals (
@@ -820,7 +858,9 @@ public function testGetCustomerOrdersTwoStoreViewQuery(string $orderNumber, stri
820
858
'' ,
821
859
array_merge (
822
860
$ this ->customerAuthenticationHeader ->execute (
823
- $ currentEmail , $ currentPassword ),
861
+ $ currentEmail ,
862
+ $ currentPassword
863
+ ),
824
864
['Store ' => $ store ]
825
865
)
826
866
);
@@ -855,45 +895,6 @@ public function dataProviderMultiStores(): array
855
895
];
856
896
}
857
897
858
- /**
859
- * Verify the customer order with tax, discount with shipping tax class set for calculation setting
860
- *
861
- * @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_url_key.php
862
- * @magentoApiDataFixture Magento/Customer/_files/customer.php
863
- * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php
864
- * @magentoApiDataFixture Magento/SalesRule/_files/cart_rule_10_percent_off_with_discount_on_shipping.php
865
- * @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_calculation_shipping_excludeTax_order_display_settings.php
866
- */
867
- public function testCustomerOrderWithTaxesAndDiscountsOnShippingAndTotal ()
868
- {
869
- $ quantity = 4 ;
870
- $ sku = 'simple1 ' ;
871
- $ cartId = $ this ->createEmptyCart ();
872
- $ this ->addProductToCart ($ cartId , $ quantity , $ sku );
873
- $ this ->setBillingAddress ($ cartId );
874
- $ shippingMethod = $ this ->setShippingAddress ($ cartId );
875
- $ paymentMethod = $ this ->setShippingMethod ($ cartId , $ shippingMethod );
876
- $ this ->setPaymentMethod ($ cartId , $ paymentMethod );
877
- $ orderNumber = $ this ->placeOrder ($ cartId );
878
- $ customerOrderResponse = $ this ->getCustomerOrderQuery ($ orderNumber );
879
- // Asserting discounts on order item level
880
- $ this ->assertEquals (
881
- 4 ,
882
- $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['amount ' ]['value ' ]
883
- );
884
- $ this ->assertEquals (
885
- 'USD ' ,
886
- $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['amount ' ]['currency ' ]
887
- );
888
- $ this ->assertEquals (
889
- 'null ' ,
890
- $ customerOrderResponse [0 ]['items ' ][0 ]['discounts ' ][0 ]['label ' ]
891
- );
892
- $ customerOrderItem = $ customerOrderResponse [0 ];
893
- $ this ->assertTotalsWithTaxesAndDiscountsOnShippingAndTotal ($ customerOrderItem );
894
- $ this ->deleteOrder ();
895
- }
896
-
897
898
/**
898
899
* Assert order totals including shipping_handling and taxes
899
900
*
@@ -919,32 +920,29 @@ private function assertTotalsWithTaxesAndDiscountsOnShippingAndTotal(array $cust
919
920
4.05 ,
920
921
$ customerOrderItem ['total ' ]['total_tax ' ]['value ' ]
921
922
);
922
-
923
+ $ this ->assertEquals (
924
+ -6 ,
925
+ $ customerOrderItem ['total ' ]['discounts ' ][0 ]['amount ' ]['value ' ]
926
+ );
927
+ $ this ->assertEquals (
928
+ 'null ' ,
929
+ $ customerOrderItem ['total ' ]['discounts ' ][0 ]['label ' ]
930
+ );
923
931
$ this ->assertEquals (
924
932
20 ,
925
933
$ customerOrderItem ['total ' ]['total_shipping ' ]['value ' ]
926
934
);
927
935
$ this ->assertCount (2 , $ customerOrderItem ['total ' ]['taxes ' ]);
928
- $ expectedProductAndShippingTaxes =
929
- [
930
- [
931
- 'amount ' => [
932
- 'value ' => 2.7 ,
933
- 'currency ' => 'USD ' ,
934
- ],
935
- 'title ' => 'US-TEST-*-Rate-1 ' ,
936
- 'rate ' => 7.5 ,
937
- ],
938
- [
939
- 'amount ' => [
940
- 'value ' => 1.35 ,
941
- 'currency ' => 'USD '
942
- ],
943
- 'title ' => 'US-TEST-*-Rate-1 ' ,
944
- 'rate ' => 7.5 ,
945
- ]
946
- ];
947
- $ this ->assertEquals ($ expectedProductAndShippingTaxes , $ customerOrderItem ['total ' ]['taxes ' ]);
936
+ $ expectedProductAndShippingTaxes = [2.7 , 1.35 ];
937
+
938
+ $ totalTaxes = [];
939
+ foreach ($ customerOrderItem ['total ' ]['taxes ' ] as $ totalTaxFromResponse ) {
940
+ array_push ($ totalTaxes , $ totalTaxFromResponse ['amount ' ]['value ' ]);
941
+ }
942
+ foreach ($ totalTaxes as $ value ) {
943
+ $ this ->assertTrue (in_array ($ value , $ expectedProductAndShippingTaxes ));
944
+ }
945
+
948
946
$ this ->assertEquals (
949
947
21.5 ,
950
948
$ customerOrderItem ['total ' ]['shipping_handling ' ]['amount_including_tax ' ]['value ' ]
@@ -979,14 +977,6 @@ private function assertTotalsWithTaxesAndDiscountsOnShippingAndTotal(array $cust
979
977
'null ' ,
980
978
$ customerOrderItem ['total ' ]['shipping_handling ' ]['discounts ' ][0 ]['label ' ]
981
979
);
982
- $ this ->assertEquals (
983
- -6 ,
984
- $ customerOrderItem ['total ' ]['discounts ' ][0 ]['amount ' ]['value ' ]
985
- );
986
- $ this ->assertEquals (
987
- 'null ' ,
988
- $ customerOrderItem ['total ' ]['discounts ' ][0 ]['label ' ]
989
- );
990
980
}
991
981
992
982
/**
@@ -1040,27 +1030,16 @@ private function assertTotalsAndShippingWithExcludedTaxSetting(array $customerOr
1040
1030
10 ,
1041
1031
$ customerOrderItem ['total ' ]['total_shipping ' ]['value ' ]
1042
1032
);
1043
- $ expectedProductAndShippingTaxes =
1044
- [
1045
- [
1046
- 'amount ' => [
1047
- 'value ' => 1.5 ,
1048
- 'currency ' => 'USD '
1049
- ],
1050
- 'title ' => 'US-TEST-*-Rate-1 ' ,
1051
- 'rate ' => 7.5
1052
- ],
1053
- [
1054
- 'amount ' => [
1055
- 'value ' => 0.75 ,
1056
- 'currency ' => 'USD '
1057
- ],
1058
-
1059
- 'title ' => 'US-TEST-*-Rate-1 ' ,
1060
- 'rate ' => 7.5
1061
- ]
1062
- ];
1063
- $ this ->assertEquals ($ expectedProductAndShippingTaxes , $ customerOrderItem ['total ' ]['taxes ' ]);
1033
+ $ expectedProductAndShippingTaxes = [1.5 , 0.75 ];
1034
+
1035
+ $ totalTaxes = [];
1036
+ foreach ($ customerOrderItem ['total ' ]['taxes ' ] as $ totalTaxFromResponse ) {
1037
+ array_push ($ totalTaxes , $ totalTaxFromResponse ['amount ' ]['value ' ]);
1038
+ }
1039
+ foreach ($ totalTaxes as $ value ) {
1040
+ $ this ->assertTrue (in_array ($ value , $ expectedProductAndShippingTaxes ));
1041
+ }
1042
+
1064
1043
$ this ->assertEquals (
1065
1044
10.75 ,
1066
1045
$ customerOrderItem ['total ' ]['shipping_handling ' ]['amount_including_tax ' ]['value ' ]
@@ -1073,10 +1052,11 @@ private function assertTotalsAndShippingWithExcludedTaxSetting(array $customerOr
1073
1052
10 ,
1074
1053
$ customerOrderItem ['total ' ]['shipping_handling ' ]['total_amount ' ]['value ' ]
1075
1054
);
1055
+ $ this ->assertCount (1 , $ customerOrderItem ['total ' ]['shipping_handling ' ]['taxes ' ], 'Count is incorrect ' );
1076
1056
1077
1057
$ this ->assertEquals (
1078
1058
0.75 ,
1079
- $ customerOrderItem ['total ' ]['shipping_handling ' ]['taxes ' ][1 ]['amount ' ]['value ' ]
1059
+ $ customerOrderItem ['total ' ]['shipping_handling ' ]['taxes ' ][0 ]['amount ' ]['value ' ]
1080
1060
);
1081
1061
$ this ->assertEquals (
1082
1062
'US-TEST-*-Rate-1 ' ,
0 commit comments