@@ -77,30 +77,53 @@ public function testUpdateCustomerAddress()
7777 }
7878
7979 /**
80+ * Test case for deprecated `country_id` field.
81+ *
8082 * @magentoApiDataFixture Magento/Customer/_files/customer.php
8183 * @magentoApiDataFixture Magento/Customer/_files/customer_address.php
8284 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
8385 */
84- public function testUpdateCustomerAddressWithCountryCode ()
86+ public function testUpdateCustomerAddressWithCountryId ()
8587 {
86888789 $ password = 'password ' ;
8890 $ addressId = 1 ;
8991
90- $ mutation = $ this ->getMutationWithCountryCode ($ addressId );
92+ $ updateAddress = $ this ->getAddressData ();
93+
94+ $ mutation = $ mutation
95+ = <<<MUTATION
96+ mutation {
97+ updateCustomerAddress(id: {$ addressId }, input: {
98+ region: {
99+ region: " {$ updateAddress ['region ' ]['region ' ]}"
100+ region_id: {$ updateAddress ['region ' ]['region_id ' ]}
101+ region_code: " {$ updateAddress ['region ' ]['region_code ' ]}"
102+ }
103+ country_id: {$ updateAddress ['country_code ' ]}
104+ street: [" {$ updateAddress ['street ' ][0 ]}"," {$ updateAddress ['street ' ][1 ]}"]
105+ company: " {$ updateAddress ['company ' ]}"
106+ telephone: " {$ updateAddress ['telephone ' ]}"
107+ fax: " {$ updateAddress ['fax ' ]}"
108+ postcode: " {$ updateAddress ['postcode ' ]}"
109+ city: " {$ updateAddress ['city ' ]}"
110+ firstname: " {$ updateAddress ['firstname ' ]}"
111+ lastname: " {$ updateAddress ['lastname ' ]}"
112+ middlename: " {$ updateAddress ['middlename ' ]}"
113+ prefix: " {$ updateAddress ['prefix ' ]}"
114+ suffix: " {$ updateAddress ['suffix ' ]}"
115+ vat_id: " {$ updateAddress ['vat_id ' ]}"
116+ default_shipping: true
117+ default_billing: true
118+ }) {
119+ country_id
120+ }
121+ }
122+ MUTATION ;
91123
92124 $ response = $ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password ));
93125 $ this ->assertArrayHasKey ('updateCustomerAddress ' , $ response );
94- $ this ->assertArrayHasKey ('customer_id ' , $ response ['updateCustomerAddress ' ]);
95- $ this ->assertEquals (null , $ response ['updateCustomerAddress ' ]['customer_id ' ]);
96- $ this ->assertArrayHasKey ('id ' , $ response ['updateCustomerAddress ' ]);
97-
98- $ address = $ this ->addressRepository ->getById ($ addressId );
99- $ this ->assertEquals ($ address ->getId (), $ response ['updateCustomerAddress ' ]['id ' ]);
100- $ this ->assertCustomerAddressesFields ($ address , $ response ['updateCustomerAddress ' ], 'country_code ' );
101-
102- $ updateAddress = $ this ->getAddressDataCanadaCountry ();
103- $ this ->assertCustomerAddressesFields ($ address , $ updateAddress , 'country_code ' );
126+ $ this ->assertEquals ($ updateAddress ['country_code ' ], $ response ['updateCustomerAddress ' ]['country_id ' ]);
104127 }
105128
106129 /**
@@ -162,12 +185,11 @@ public function testUpdateCustomerAddressWithMissingAttribute()
162185 */
163186 private function assertCustomerAddressesFields (
164187 AddressInterface $ address ,
165- $ actualResponse ,
166- string $ countryFieldName = 'country_id '
188+ $ actualResponse
167189 ): void {
168190 /** @var $addresses */
169191 $ assertionMap = [
170- ['response_field ' => $ countryFieldName , 'expected_value ' => $ address ->getCountryId ()],
192+ ['response_field ' => ' country_code ' , 'expected_value ' => $ address ->getCountryId ()],
171193 ['response_field ' => 'street ' , 'expected_value ' => $ address ->getStreet ()],
172194 ['response_field ' => 'company ' , 'expected_value ' => $ address ->getCompany ()],
173195 ['response_field ' => 'telephone ' , 'expected_value ' => $ address ->getTelephone ()],
@@ -218,7 +240,7 @@ public function testUpdateCustomerAddressWithMissingId()
218240 region_id: {$ updateAddress ['region ' ]['region_id ' ]}
219241 region_code: " {$ updateAddress ['region ' ]['region_code ' ]}"
220242 }
221- country_id : {$ updateAddress ['country_id ' ]}
243+ country_code : {$ updateAddress ['country_code ' ]}
222244 street: [" {$ updateAddress ['street ' ][0 ]}"," {$ updateAddress ['street ' ][1 ]}"]
223245 company: " {$ updateAddress ['company ' ]}"
224246 telephone: " {$ updateAddress ['telephone ' ]}"
@@ -274,7 +296,7 @@ public function testUpdateCustomerAddressWithInvalidIdType()
274296 region_id: {$ updateAddress ['region ' ]['region_id ' ]}
275297 region_code: " {$ updateAddress ['region ' ]['region_code ' ]}"
276298 }
277- country_id : {$ updateAddress ['country_id ' ]}
299+ country_code : {$ updateAddress ['country_code ' ]}
278300 street: [" {$ updateAddress ['street ' ][0 ]}"," {$ updateAddress ['street ' ][1 ]}"]
279301 company: " {$ updateAddress ['company ' ]}"
280302 telephone: " {$ updateAddress ['telephone ' ]}"
@@ -410,35 +432,6 @@ private function getCustomerAuthHeaders(string $email, string $password): array
410432 * @return array
411433 */
412434 private function getAddressData (): array
413- {
414- return [
415- 'region ' => [
416- 'region ' => 'Alaska ' ,
417- 'region_id ' => 2 ,
418- 'region_code ' => 'AK '
419- ],
420- 'country_id ' => 'US ' ,
421- 'street ' => ['Line 1 Street ' , 'Line 2 ' ],
422- 'company ' => 'Company Name ' ,
423- 'telephone ' => '123456789 ' ,
424- 'fax ' => '123123123 ' ,
425- 'postcode ' => '7777 ' ,
426- 'city ' => 'City Name ' ,
427- 'firstname ' => 'Adam ' ,
428- 'lastname ' => 'Phillis ' ,
429- 'middlename ' => 'A ' ,
430- 'prefix ' => 'Mr. ' ,
431- 'suffix ' => 'Jr. ' ,
432- 'vat_id ' => '1 ' ,
433- 'default_shipping ' => true ,
434- 'default_billing ' => true
435- ];
436- }
437-
438- /**
439- * @return array
440- */
441- private function getAddressDataCanadaCountry (): array
442435 {
443436 return [
444437 'region ' => [
@@ -483,7 +476,7 @@ private function getMutation(int $addressId): string
483476 region_id: {$ updateAddress ['region ' ]['region_id ' ]}
484477 region_code: " {$ updateAddress ['region ' ]['region_code ' ]}"
485478 }
486- country_id : {$ updateAddress ['country_id ' ]}
479+ country_code : {$ updateAddress ['country_code ' ]}
487480 street: [" {$ updateAddress ['street ' ][0 ]}"," {$ updateAddress ['street ' ][1 ]}"]
488481 company: " {$ updateAddress ['company ' ]}"
489482 telephone: " {$ updateAddress ['telephone ' ]}"
@@ -506,7 +499,7 @@ private function getMutation(int $addressId): string
506499 region_id
507500 region_code
508501 }
509- country_id
502+ country_code
510503 street
511504 company
512505 telephone
0 commit comments