@@ -176,6 +176,63 @@ public function testUpdateCustomerAddressWithMissingAttribute()
176
176
$ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password ));
177
177
}
178
178
179
+ /**
180
+ * Test custom attributes of the customer's address
181
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
182
+ * @magentoApiDataFixture Magento/Customer/_files/customer_address.php
183
+ * @magentoApiDataFixture Magento/Customer/_files/attribute_user_defined_address_custom_attribute.php
184
+ */
185
+ public function testUpdateCustomerAddressHasCustomAndExtensionAttributes ()
186
+ {
187
+ /** @var AddressRepositoryInterface $addressRepositoryInterface */
188
+ $ addressRepositoryInterface = Bootstrap::getObjectManager ()->get (AddressRepositoryInterface::class);
189
+ /** @var \Magento\Customer\Api\Data\AddressInterface $address */
190
+ $ address = $ addressRepositoryInterface ->getById (1 );
191
+ $ address
192
+ ->setCustomAttribute ('custom_attribute1 ' , '' )
193
+ ->setCustomAttribute ('custom_attribute2 ' , '' );
194
+ $ addressRepositoryInterface ->save ($ address );
195
+
196
+ $ userName = 'customer@example.com ' ;
197
+ $ password = 'password ' ;
198
+ $ addressId = 1 ;
199
+
200
+ $ mutation
201
+ = <<<MUTATION
202
+ mutation {
203
+ updateCustomerAddress(
204
+ id: {$ addressId }
205
+ input: {
206
+ firstname: "John"
207
+ lastname: "Doe"
208
+ custom_attributes: [
209
+ {
210
+ attribute_code: "custom_attribute1"
211
+ value: "[line1,line2]"
212
+ }
213
+ {
214
+ attribute_code: "custom_attribute2"
215
+ value: "line3"
216
+ }
217
+ ]
218
+ }
219
+ ) {
220
+ custom_attributes {
221
+ attribute_code
222
+ value
223
+ }
224
+ }
225
+ }
226
+ MUTATION ;
227
+
228
+ $ response = $ this ->graphQlMutation ($ mutation , [], '' , $ this ->getCustomerAuthHeaders ($ userName , $ password ));
229
+ $ actualCustomAttributes = $ response ['updateCustomerAddress ' ]['custom_attributes ' ];
230
+ $ this ->assertEquals ($ actualCustomAttributes ['0 ' ]['attribute_code ' ], 'custom_attribute1 ' );
231
+ $ this ->assertEquals ($ actualCustomAttributes ['0 ' ]['value ' ], '[line1,line2] ' );
232
+ $ this ->assertEquals ($ actualCustomAttributes ['1 ' ]['attribute_code ' ], 'custom_attribute2 ' );
233
+ $ this ->assertEquals ($ actualCustomAttributes ['1 ' ]['value ' ], 'line3 ' );
234
+ }
235
+
179
236
/**
180
237
* Verify the fields for Customer address
181
238
*
0 commit comments