Skip to content

Commit 324cced

Browse files
committed
MC-35653:MyAccount :: Order Details :: Payments Methods, shipping address, billing address by Order Number
- Fixed new review comments
1 parent 6742482 commit 324cced

File tree

2 files changed

+73
-125
lines changed

2 files changed

+73
-125
lines changed

app/code/Magento/SalesGraphQl/Model/Order/OrderPayments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function getOrderPaymentMethod(OrderInterface $orderModel): array
2525
$orderPayment = $orderModel->getPayment();
2626
return [
2727
[
28-
'name' => $orderPayment->getAdditionalInformation()['method_title'] ?? ' ',
28+
'name' => $orderPayment->getAdditionalInformation()['method_title'] ?? '',
2929
'type' => $orderPayment->getMethod(),
3030
'additional_data' => []
3131
]

dev/tests/api-functional/testsuite/Magento/GraphQl/Sales/RetrieveOrdersByOrderNumberTest.php

Lines changed: 72 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -74,40 +74,11 @@ public function testGetCustomerOrdersSimpleProductQuery()
7474
}
7575
}
7676
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+
}
11182
items{
11283
quantity_ordered
11384
product_sku
@@ -133,6 +104,24 @@ public function testGetCustomerOrdersSimpleProductQuery()
133104
}
134105
}
135106
}
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+
}
136125
QUERY;
137126

138127
$currentEmail = 'customer@example.com';
@@ -202,29 +191,7 @@ public function testCustomerOrdersSimpleProductWithTaxesAndDiscounts()
202191
$this->setPaymentMethod($cartId, $paymentMethod);
203192
$orderNumber = $this->placeOrder($cartId);
204193
$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 = [
228195
'firstname' => 'John',
229196
'lastname' => 'Smith',
230197
'city' => 'Texas City',
@@ -241,17 +208,8 @@ private function assertOrderBillingAddress(array $customerOrderBillingAddress):
241208
'suffix' => 'John',
242209
'telephone' => '5123456677'
243210
];
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 = [
255213
'firstname' => 'test shipFirst',
256214
'lastname' => 'test shipLast',
257215
'city' => 'Montgomery',
@@ -268,24 +226,25 @@ private function assertOrderShippingAddress(array $customerOrderShippingAddress)
268226
'suffix' => 'test shipFirst',
269227
'telephone' => '3347665522'
270228
];
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 = [
282231
[
283232
'name' => 'Check / Money order',
284233
'type' => 'checkmo',
285234
'additional_data' => []
286235
]
287236
];
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();
289248
}
290249

291250
/**
@@ -1342,50 +1301,21 @@ private function getCustomerOrderQuery($orderNumber): array
13421301
status
13431302
payment_methods
13441303
{
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}}
13891319
total {
13901320
base_grand_total{value currency}
13911321
grand_total{value currency}
@@ -1408,6 +1338,24 @@ private function getCustomerOrderQuery($orderNumber): array
14081338
}
14091339
}
14101340
}
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+
}
14111359
QUERY;
14121360
$currentEmail = 'customer@example.com';
14131361
$currentPassword = 'password';

0 commit comments

Comments
 (0)