@@ -50,89 +50,8 @@ protected function setUp():void
5050 */
5151 public function testGetCustomerOrdersSimpleProductQuery ()
5252 {
53- $ query =
54- <<<QUERY
55- {
56- customer
57- {
58- orders(filter:{number:{eq:"100000002"}}){
59- total_count
60- items
61- {
62- id
63- number
64- status
65- order_date
66- payment_methods
67- {
68- name
69- type
70- additional_data
71- {
72- name
73- value
74- }
75- }
76- shipping_address {
77- ... address
78- }
79- billing_address {
80- ... address
81- }
82- items{
83- quantity_ordered
84- product_sku
85- product_name
86- product_sale_price{currency value}
87- }
88- total {
89- base_grand_total {
90- value
91- currency
92- }
93- grand_total {
94- value
95- currency
96- }
97- subtotal {
98- value
99- currency
100- }
101-
102- }
103- }
104- }
105- }
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- }
125- QUERY ;
126-
127- $ currentEmail = 'customer@example.com ' ;
128- $ currentPassword = 'password ' ;
129- $ response = $ this ->graphQlQuery (
130- $ query ,
131- [],
132- '' ,
133- $ this ->customerAuthenticationHeader ->execute ($ currentEmail , $ currentPassword )
134- );
135-
53+ $ orderNumber = '100000002 ' ;
54+ $ response = $ this ->getCustomerOrderQueryOnSimpleProducts ($ orderNumber );
13655 $ this ->assertArrayHasKey ('orders ' , $ response ['customer ' ]);
13756 $ this ->assertArrayHasKey ('items ' , $ response ['customer ' ]['orders ' ]);
13857 $ this ->assertNotEmpty ($ response ['customer ' ]['orders ' ]['items ' ]);
@@ -198,14 +117,12 @@ public function testCustomerOrdersSimpleProductWithTaxesAndDiscounts()
198117 'company ' => 'Test company ' ,
199118 'country_code ' => 'US ' ,
200119 'postcode ' => '78717 ' ,
201- 'prefix ' => 'John ' ,
202120 'region ' => 'Texas ' ,
203121 'region_id ' => '57 ' ,
204122 'street ' => [
205123 0 => 'test street 1 ' ,
206124 1 => 'test street 2 ' ,
207125 ],
208- 'suffix ' => 'John ' ,
209126 'telephone ' => '5123456677 '
210127 ];
211128 $ this ->assertResponseFields ($ customerOrderResponse [0 ]["billing_address " ], $ billingAssertionMap );
@@ -216,14 +133,12 @@ public function testCustomerOrdersSimpleProductWithTaxesAndDiscounts()
216133 'company ' => 'test company ' ,
217134 'country_code ' => 'US ' ,
218135 'postcode ' => '36013 ' ,
219- 'prefix ' => 'test shipFirst ' ,
220136 'street ' => [
221137 0 => 'test street 1 ' ,
222138 1 => 'test street 2 ' ,
223139 ],
224140 'region_id ' => '1 ' ,
225141 'region ' => 'Alabama ' ,
226- 'suffix ' => 'test shipFirst ' ,
227142 'telephone ' => '3347665522 '
228143 ];
229144 $ this ->assertResponseFields ($ customerOrderResponse [0 ]["shipping_address " ], $ shippingAssertionMap );
@@ -1348,11 +1263,9 @@ private function getCustomerOrderQuery($orderNumber): array
13481263 fax
13491264 middlename
13501265 postcode
1351- prefix
13521266 street
13531267 region
13541268 region_id
1355- suffix
13561269 telephone
13571270 vat_id
13581271 }
@@ -1371,6 +1284,98 @@ private function getCustomerOrderQuery($orderNumber): array
13711284 return $ response ['customer ' ]['orders ' ]['items ' ];
13721285 }
13731286
1287+ /**
1288+ * Get customer order query
1289+ *
1290+ * @param string $orderNumber
1291+ * @return array
1292+ */
1293+ private function getCustomerOrderQueryOnSimpleProducts ($ orderNumber ): array
1294+ {
1295+ $ query =
1296+ <<<QUERY
1297+ {
1298+ customer
1299+ {
1300+ orders(filter:{number:{eq:" {$ orderNumber }"}}) {
1301+ total_count
1302+ items
1303+ {
1304+ id
1305+ number
1306+ status
1307+ order_date
1308+ payment_methods
1309+ {
1310+ name
1311+ type
1312+ additional_data
1313+ {
1314+ name
1315+ value
1316+ }
1317+ }
1318+ shipping_address {
1319+ ... address
1320+ }
1321+ billing_address {
1322+ ... address
1323+ }
1324+ items{
1325+ quantity_ordered
1326+ product_sku
1327+ product_name
1328+ product_sale_price{currency value}
1329+ }
1330+ total {
1331+ base_grand_total {
1332+ value
1333+ currency
1334+ }
1335+ grand_total {
1336+ value
1337+ currency
1338+ }
1339+ subtotal {
1340+ value
1341+ currency
1342+ }
1343+ }
1344+ }
1345+ }
1346+ }
1347+ }
1348+
1349+ fragment address on OrderAddress {
1350+ firstname
1351+ lastname
1352+ city
1353+ company
1354+ country_code
1355+ fax
1356+ middlename
1357+ postcode
1358+ street
1359+ region
1360+ region_id
1361+ telephone
1362+ vat_id
1363+ }
1364+ QUERY ;
1365+ $ currentEmail = 'customer@example.com ' ;
1366+ $ currentPassword = 'password ' ;
1367+ $ response = $ this ->graphQlQuery (
1368+ $ query ,
1369+ [],
1370+ '' ,
1371+ $ this ->customerAuthenticationHeader ->execute ($ currentEmail , $ currentPassword )
1372+ );
1373+
1374+ $ this ->assertArrayHasKey ('orders ' , $ response ['customer ' ]);
1375+ $ this ->assertArrayHasKey ('items ' , $ response ['customer ' ]['orders ' ]);
1376+ return $ response ;
1377+ }
1378+
13741379 /**
13751380 * Clean up orders
13761381 *
0 commit comments