@@ -184,37 +184,27 @@ public function testUpdateCustomerAddressWithMissingAttribute()
184
184
*/
185
185
public function testUpdateCustomerAddressHasCustomAttributes ()
186
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
187
$ userName = 'customer@example.com ' ;
197
188
$ password = 'password ' ;
198
189
$ addressId = 1 ;
199
-
190
+ $ attributes = [
191
+ [
192
+ 'attribute_code ' => 'custom_attribute1 ' ,
193
+ 'value ' => '[new-value1,new-value2] '
194
+ ],
195
+ [
196
+ 'attribute_code ' => 'custom_attribute2 ' ,
197
+ 'value ' => '"new-value3" '
198
+ ]
199
+ ];
200
+ $ attributesFragment = preg_replace ('/"([^"]+)"\s*:\s*/ ' , '$1: ' , json_encode ($ attributes ));
200
201
$ mutation
201
202
= <<<MUTATION
202
203
mutation {
203
204
updateCustomerAddress(
204
205
id: {$ addressId }
205
206
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
- ]
207
+ custom_attributes: {$ attributesFragment }
218
208
}
219
209
) {
220
210
custom_attributes {
@@ -226,11 +216,7 @@ public function testUpdateCustomerAddressHasCustomAttributes()
226
216
MUTATION ;
227
217
228
218
$ 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 ' );
219
+ $ this ->assertEquals ($ attributes , $ response ['updateCustomerAddress ' ]['custom_attributes ' ]);
234
220
}
235
221
236
222
/**
0 commit comments