@@ -1963,4 +1963,85 @@ public function testSetNewShippingAddressAndPlaceOrderWithGuestCheckoutDisabled(
1963
1963
{
1964
1964
$ this ->testSetNewShippingAddressAndPlaceOrder ();
1965
1965
}
1966
+
1967
+ /**
1968
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
1969
+ * @magentoApiDataFixture Magento/Customer/_files/attribute_telephone_not_required_address.php
1970
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
1971
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
1972
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
1973
+ */
1974
+ public function testSetNewShippingAddressWithoutTelephone ()
1975
+ {
1976
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
1977
+
1978
+ $ query = <<<QUERY
1979
+ mutation {
1980
+ setShippingAddressesOnCart(
1981
+ input: {
1982
+ cart_id: " $ maskedQuoteId"
1983
+ shipping_addresses: {
1984
+ address: {
1985
+ firstname: "test firstname"
1986
+ lastname: "test lastname"
1987
+ company: "test company"
1988
+ street: ["test street 1", "test street 2"]
1989
+ city: "test city"
1990
+ region: "AZ"
1991
+ postcode: "887766"
1992
+ country_code: "US"
1993
+ telephone: ""
1994
+ }
1995
+ }
1996
+ }
1997
+ ) {
1998
+ cart {
1999
+ shipping_addresses {
2000
+ firstname
2001
+ lastname
2002
+ company
2003
+ street
2004
+ city
2005
+ postcode
2006
+ telephone
2007
+ country {
2008
+ code
2009
+ label
2010
+ }
2011
+ __typename
2012
+ }
2013
+ }
2014
+ }
2015
+ }
2016
+ QUERY ;
2017
+ $ response = $ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ());
2018
+ self ::assertArrayHasKey ('cart ' , $ response ['setShippingAddressesOnCart ' ]);
2019
+ $ cartResponse = $ response ['setShippingAddressesOnCart ' ]['cart ' ];
2020
+ self ::assertArrayHasKey ('shipping_addresses ' , $ cartResponse );
2021
+ $ shippingAddressResponse = current ($ cartResponse ['shipping_addresses ' ]);
2022
+ $ this ->assertNewAddressWithoutTelephone ($ shippingAddressResponse );
2023
+ }
2024
+
2025
+ /**
2026
+ * Verify the all the whitelisted fields for a New Address Object without telephone
2027
+ *
2028
+ * @param array $addressResponse
2029
+ */
2030
+ private function assertNewAddressWithoutTelephone (
2031
+ array $ addressResponse
2032
+ ): void {
2033
+ $ assertionMap = [
2034
+ ['response_field ' => 'firstname ' , 'expected_value ' => 'test firstname ' ],
2035
+ ['response_field ' => 'lastname ' , 'expected_value ' => 'test lastname ' ],
2036
+ ['response_field ' => 'company ' , 'expected_value ' => 'test company ' ],
2037
+ ['response_field ' => 'street ' , 'expected_value ' => [0 => 'test street 1 ' , 1 => 'test street 2 ' ]],
2038
+ ['response_field ' => 'city ' , 'expected_value ' => 'test city ' ],
2039
+ ['response_field ' => 'postcode ' , 'expected_value ' => '887766 ' ],
2040
+ ['response_field ' => 'telephone ' , 'expected_value ' => '' ],
2041
+ ['response_field ' => 'country ' , 'expected_value ' => ['code ' => 'US ' , 'label ' => 'US ' ]],
2042
+ ['response_field ' => '__typename ' , 'expected_value ' => 'ShippingCartAddress ' ]
2043
+ ];
2044
+
2045
+ $ this ->assertResponseFields ($ addressResponse , $ assertionMap );
2046
+ }
1966
2047
}
0 commit comments