This repository has been archived by the owner on Dec 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- cover \Magento\CustomerGraphQl\Model\Customer\Address\ExtractCustomerAddressData Signed-off-by: Tomash Khamlai <[email protected]>
- Loading branch information
1 parent
cc599e5
commit 56382f1
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,6 +176,63 @@ public function testUpdateCustomerAddressWithMissingAttribute() | |
$this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password)); | ||
} | ||
|
||
/** | ||
* Test custom attributes of the customer's address | ||
* @magentoApiDataFixture Magento/Customer/_files/customer.php | ||
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php | ||
* @magentoApiDataFixture Magento/Customer/_files/attribute_user_defined_address_custom_attribute.php | ||
*/ | ||
public function testUpdateCustomerAddressHasCustomAndExtensionAttributes() | ||
{ | ||
/** @var AddressRepositoryInterface $addressRepositoryInterface */ | ||
$addressRepositoryInterface = Bootstrap::getObjectManager()->get(AddressRepositoryInterface::class); | ||
/** @var \Magento\Customer\Api\Data\AddressInterface $address */ | ||
$address = $addressRepositoryInterface->getById(1); | ||
$address | ||
->setCustomAttribute('custom_attribute1', '') | ||
->setCustomAttribute('custom_attribute2', ''); | ||
$addressRepositoryInterface->save($address); | ||
|
||
$userName = '[email protected]'; | ||
$password = 'password'; | ||
$addressId = 1; | ||
|
||
$mutation | ||
= <<<MUTATION | ||
mutation { | ||
updateCustomerAddress( | ||
id: {$addressId} | ||
input: { | ||
firstname: "John" | ||
lastname: "Doe" | ||
custom_attributes: [ | ||
{ | ||
attribute_code: "custom_attribute1" | ||
value: "[line1,line2]" | ||
} | ||
{ | ||
attribute_code: "custom_attribute2" | ||
value: "line3" | ||
} | ||
] | ||
} | ||
) { | ||
custom_attributes { | ||
attribute_code | ||
value | ||
} | ||
} | ||
} | ||
MUTATION; | ||
|
||
$response = $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password)); | ||
$actualCustomAttributes = $response['updateCustomerAddress']['custom_attributes']; | ||
$this->assertEquals($actualCustomAttributes['0']['attribute_code'], 'custom_attribute1'); | ||
$this->assertEquals($actualCustomAttributes['0']['value'], '[line1,line2]'); | ||
$this->assertEquals($actualCustomAttributes['1']['attribute_code'], 'custom_attribute2'); | ||
$this->assertEquals($actualCustomAttributes['1']['value'], 'line3'); | ||
} | ||
|
||
/** | ||
* Verify the fields for Customer address | ||
* | ||
|