Skip to content

Commit 8d634f7

Browse files
committed
Merge remote-tracking branch 'magento-l3/ACP2E-288' into L3_PR_21-12-13
2 parents 06f0224 + ae9fdd2 commit 8d634f7

File tree

3 files changed

+123
-64
lines changed

3 files changed

+123
-64
lines changed

app/code/Magento/SalesGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type OrderAddress @doc(description: "Contains detailed information about an orde
6969
country_code: CountryCodeEnum @doc(description: "The customer's country.")
7070
street: [String!]! @doc(description: "An array of strings that define the street number and name.")
7171
company: String @doc(description: "The customer's company.")
72-
telephone: String! @doc(description: "The telephone number.")
72+
telephone: String @doc(description: "The telephone number.")
7373
fax: String @doc(description: "The fax number.")
7474
postcode: String @doc(description: "The customer's ZIP or postal code.")
7575
city: String! @doc(description: "The city or town.")

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,19 @@ public function __construct(
6464
*
6565
* @param array $customerLogin
6666
* @param array $productData
67+
* @param array|null $addressData
6768
* @return array
6869
*/
69-
public function placeOrderWithBundleProduct(array $customerLogin, array $productData): array
70-
{
70+
public function placeOrderWithBundleProduct(
71+
array $customerLogin,
72+
array $productData,
73+
?array $addressData = null
74+
): array {
7175
$this->customerLogin = $customerLogin;
7276
$this->createCustomerCart();
7377
$this->addBundleProduct($productData);
74-
$this->setBillingAddress();
75-
$shippingMethod = $this->setShippingAddress();
78+
$this->setBillingAddress($addressData);
79+
$shippingMethod = $this->setShippingAddress($addressData);
7680
$paymentMethod = $this->setShippingMethod($shippingMethod);
7781
$this->setPaymentMethod($paymentMethod);
7882
return $this->doPlaceOrder();
@@ -198,11 +202,13 @@ private function addBundleProduct(array $productData)
198202
/**
199203
* Set the billing address on the cart
200204
*
205+
* @param array $addressData
201206
* @return array
202207
*/
203-
private function setBillingAddress(): array
208+
private function setBillingAddress(?array $addressData = null): array
204209
{
205-
$setBillingAddress = <<<QUERY
210+
$telephone = $addressData['telephone'] ?? '5123456677';
211+
$setBillingAddress = <<<QUERY
206212
mutation {
207213
setBillingAddressOnCart(
208214
input: {
@@ -215,7 +221,7 @@ private function setBillingAddress(): array
215221
street: ["test street 1", "test street 2"]
216222
city: "Texas City"
217223
postcode: "78717"
218-
telephone: "5123456677"
224+
telephone: "{$telephone}"
219225
region: "TX"
220226
country_code: "US"
221227
}
@@ -236,10 +242,12 @@ private function setBillingAddress(): array
236242
/**
237243
* Set the shipping address on the cart and return an available shipping method
238244
*
245+
* @param array|null $addressData
239246
* @return array
240247
*/
241-
private function setShippingAddress(): array
248+
private function setShippingAddress(?array $addressData): array
242249
{
250+
$telephone = $addressData['telephone'] ?? '5123456677';
243251
$setShippingAddress = <<<QUERY
244252
mutation {
245253
setShippingAddressesOnCart(
@@ -256,7 +264,7 @@ private function setShippingAddress(): array
256264
region: "AL"
257265
postcode: "36013"
258266
country_code: "US"
259-
telephone: "3347665522"
267+
telephone: "{$telephone}"
260268
}
261269
}
262270
]
@@ -283,10 +291,10 @@ private function setShippingAddress(): array
283291
/**
284292
* Set the shipping method on the cart and return an available payment method
285293
*
286-
* @param array $shippingMethod
294+
* @param array|null $shippingMethod
287295
* @return array
288296
*/
289-
private function setShippingMethod(array $shippingMethod): array
297+
private function setShippingMethod(?array $shippingMethod): array
290298
{
291299
$setShippingMethod = <<<QUERY
292300
mutation {

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

Lines changed: 103 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,35 @@ public function testGetCustomerOrderBundleProduct()
117117
$this->assertEquals($expectedBundleOptions, $bundleOptionsFromResponse);
118118
}
119119

120+
/**
121+
* Test customer order with bundle product and no telephone in address
122+
*
123+
* @magentoApiDataFixture Magento/Customer/_files/attribute_telephone_not_required_address.php
124+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
125+
* @magentoApiDataFixture Magento/Bundle/_files/bundle_product_two_dropdown_options.php
126+
*/
127+
public function testOrderBundleProductWithNoTelephoneInAddress()
128+
{
129+
//Place order with bundled product
130+
$qty = 1;
131+
$bundleSku = 'bundle-product-two-dropdown-options';
132+
/** @var CustomerPlaceOrder $bundleProductOrderFixture */
133+
$bundleProductOrderFixture = Bootstrap::getObjectManager()->create(CustomerPlaceOrder::class);
134+
$orderResponse = $bundleProductOrderFixture->placeOrderWithBundleProduct(
135+
['email' => 'customer@example.com', 'password' => 'password'],
136+
['sku' => $bundleSku, 'quantity' => $qty],
137+
['telephone' => '']
138+
);
139+
$orderNumber = $orderResponse['placeOrder']['order']['order_number'];
140+
$customerOrderResponse = $this->getCustomerOrderQueryBundleProduct($orderNumber);
141+
$customerOrderItems = $customerOrderResponse[0];
142+
$this->assertEquals("Pending", $customerOrderItems['status']);
143+
$billingAddress = $customerOrderItems['billing_address'];
144+
$shippingAddress = $customerOrderItems['shipping_address'];
145+
$this->assertNull($billingAddress['telephone']);
146+
$this->assertNull($shippingAddress['telephone']);
147+
}
148+
120149
/**
121150
* Test customer order details with bundle products
122151
* @magentoApiDataFixture Magento/Customer/_files/customer.php
@@ -220,59 +249,81 @@ private function getCustomerOrderQueryBundleProduct($orderNumber)
220249
$query =
221250
<<<QUERY
222251
{
223-
customer {
224-
orders(filter:{number:{eq:"{$orderNumber}"}}) {
225-
total_count
226-
items {
227-
id
228-
number
229-
order_date
230-
status
231-
items{
232-
__typename
233-
product_sku
234-
product_name
235-
product_url_key
236-
product_sale_price{value}
237-
quantity_ordered
238-
discounts{amount{value} label}
239-
... on BundleOrderItem{
240-
bundle_options{
241-
__typename
242-
label
243-
values {
244-
product_sku
245-
product_name
246-
quantity
247-
price {
248-
value
249-
currency
250-
}
252+
customer {
253+
orders(filter:{number:{eq:"{$orderNumber}"}}) {
254+
total_count
255+
items {
256+
id
257+
number
258+
order_date
259+
status
260+
items{
261+
__typename
262+
product_sku
263+
product_name
264+
product_url_key
265+
product_sale_price{value}
266+
quantity_ordered
267+
discounts{amount{value} label}
268+
... on BundleOrderItem{
269+
bundle_options{
270+
__typename
271+
label
272+
values {
273+
product_sku
274+
product_name
275+
quantity
276+
price {
277+
value
278+
currency
279+
}
280+
}
281+
}
282+
}
251283
}
252-
}
253-
}
254-
}
255-
total {
256-
base_grand_total{value currency}
257-
grand_total{value currency}
258-
subtotal {value currency }
259-
total_tax{value currency}
260-
taxes {amount{value currency} title rate}
261-
total_shipping{value currency}
262-
shipping_handling
263-
{
264-
amount_including_tax{value}
265-
amount_excluding_tax{value}
266-
total_amount{value}
267-
discounts{amount{value}}
268-
taxes {amount{value} title rate}
269-
}
270-
discounts {amount{value currency} label}
271-
}
272-
}
273-
}
274-
}
275-
}
284+
total {
285+
base_grand_total{value currency}
286+
grand_total{value currency}
287+
subtotal {value currency }
288+
total_tax{value currency}
289+
taxes {amount{value currency} title rate}
290+
total_shipping{value currency}
291+
shipping_handling
292+
{
293+
amount_including_tax{value}
294+
amount_excluding_tax{value}
295+
total_amount{value}
296+
discounts{amount{value}}
297+
taxes {amount{value} title rate}
298+
}
299+
discounts {amount{value currency} label}
300+
}
301+
billing_address {
302+
firstname
303+
lastname
304+
street
305+
city
306+
region
307+
region_id
308+
postcode
309+
telephone
310+
country_code
311+
}
312+
shipping_address {
313+
firstname
314+
lastname
315+
street
316+
city
317+
region
318+
region_id
319+
postcode
320+
telephone
321+
country_code
322+
}
323+
}
324+
}
325+
}
326+
}
276327
QUERY;
277328
$currentEmail = 'customer@example.com';
278329
$currentPassword = 'password';

0 commit comments

Comments
 (0)