Skip to content

Commit 461763e

Browse files
committed
magento/graphql-ce#1011: [Test Coverage] Extend coverage for CustomerGraphQL
1 parent a97ef07 commit 461763e

File tree

1 file changed

+13
-27
lines changed

1 file changed

+13
-27
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -184,37 +184,27 @@ public function testUpdateCustomerAddressWithMissingAttribute()
184184
*/
185185
public function testUpdateCustomerAddressHasCustomAttributes()
186186
{
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-
196187
$userName = 'customer@example.com';
197188
$password = 'password';
198189
$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));
200201
$mutation
201202
= <<<MUTATION
202203
mutation {
203204
updateCustomerAddress(
204205
id: {$addressId}
205206
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}
218208
}
219209
) {
220210
custom_attributes {
@@ -226,11 +216,7 @@ public function testUpdateCustomerAddressHasCustomAttributes()
226216
MUTATION;
227217

228218
$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']);
234220
}
235221

236222
/**

0 commit comments

Comments
 (0)