@@ -77,30 +77,53 @@ public function testUpdateCustomerAddress()
77
77
}
78
78
79
79
/**
80
+ * Test case for deprecated `country_id` field.
81
+ *
80
82
* @magentoApiDataFixture Magento/Customer/_files/customer.php
81
83
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php
82
84
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
83
85
*/
84
- public function testUpdateCustomerAddressWithCountryCode ()
86
+ public function testUpdateCustomerAddressWithCountryId ()
85
87
{
86
88
$ userName = 'customer@example.com ' ;
87
89
$ password = 'password ' ;
88
90
$ addressId = 1 ;
89
91
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 ;
91
123
92
124
$ response = $ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password ));
93
125
$ 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 ' ]);
104
127
}
105
128
106
129
/**
@@ -162,12 +185,11 @@ public function testUpdateCustomerAddressWithMissingAttribute()
162
185
*/
163
186
private function assertCustomerAddressesFields (
164
187
AddressInterface $ address ,
165
- $ actualResponse ,
166
- string $ countryFieldName = 'country_id '
188
+ $ actualResponse
167
189
): void {
168
190
/** @var $addresses */
169
191
$ assertionMap = [
170
- ['response_field ' => $ countryFieldName , 'expected_value ' => $ address ->getCountryId ()],
192
+ ['response_field ' => ' country_code ' , 'expected_value ' => $ address ->getCountryId ()],
171
193
['response_field ' => 'street ' , 'expected_value ' => $ address ->getStreet ()],
172
194
['response_field ' => 'company ' , 'expected_value ' => $ address ->getCompany ()],
173
195
['response_field ' => 'telephone ' , 'expected_value ' => $ address ->getTelephone ()],
@@ -218,7 +240,7 @@ public function testUpdateCustomerAddressWithMissingId()
218
240
region_id: {$ updateAddress ['region ' ]['region_id ' ]}
219
241
region_code: " {$ updateAddress ['region ' ]['region_code ' ]}"
220
242
}
221
- country_id : {$ updateAddress ['country_id ' ]}
243
+ country_code : {$ updateAddress ['country_code ' ]}
222
244
street: [" {$ updateAddress ['street ' ][0 ]}"," {$ updateAddress ['street ' ][1 ]}"]
223
245
company: " {$ updateAddress ['company ' ]}"
224
246
telephone: " {$ updateAddress ['telephone ' ]}"
@@ -274,7 +296,7 @@ public function testUpdateCustomerAddressWithInvalidIdType()
274
296
region_id: {$ updateAddress ['region ' ]['region_id ' ]}
275
297
region_code: " {$ updateAddress ['region ' ]['region_code ' ]}"
276
298
}
277
- country_id : {$ updateAddress ['country_id ' ]}
299
+ country_code : {$ updateAddress ['country_code ' ]}
278
300
street: [" {$ updateAddress ['street ' ][0 ]}"," {$ updateAddress ['street ' ][1 ]}"]
279
301
company: " {$ updateAddress ['company ' ]}"
280
302
telephone: " {$ updateAddress ['telephone ' ]}"
@@ -410,35 +432,6 @@ private function getCustomerAuthHeaders(string $email, string $password): array
410
432
* @return array
411
433
*/
412
434
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
442
435
{
443
436
return [
444
437
'region ' => [
@@ -483,7 +476,7 @@ private function getMutation(int $addressId): string
483
476
region_id: {$ updateAddress ['region ' ]['region_id ' ]}
484
477
region_code: " {$ updateAddress ['region ' ]['region_code ' ]}"
485
478
}
486
- country_id : {$ updateAddress ['country_id ' ]}
479
+ country_code : {$ updateAddress ['country_code ' ]}
487
480
street: [" {$ updateAddress ['street ' ][0 ]}"," {$ updateAddress ['street ' ][1 ]}"]
488
481
company: " {$ updateAddress ['company ' ]}"
489
482
telephone: " {$ updateAddress ['telephone ' ]}"
@@ -506,7 +499,7 @@ private function getMutation(int $addressId): string
506
499
region_id
507
500
region_code
508
501
}
509
- country_id
502
+ country_code
510
503
street
511
504
company
512
505
telephone
0 commit comments