-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔃 [Magento Community Engineering] Community Contributions - GraphQL d…
…aily delivery Accepted Community Pull Requests: - magento/graphql-ce#1013: magento graphql-ce#970 Cannot return several errors for one GraphQL request (by @lenaorobei) - magento/graphql-ce#1012: magento/graphql-ce#: Editorial. Fix CustomerOrder.increment_id description (by @atwixfirster) - magento/graphql-ce#996: magento/graphql-ce#977: [Test coverage] Cover exceptions in AssignShippingAddressToCart, AssignBillingAddressToCart (by @atwixfirster) - magento/graphql-ce#958: graphQl-914: [Customer] Improve consistency of country field in custo… (by @kisroman) Fixed GitHub Issues: - #970: Product reviews list template paging issue. (reported by @tzyganu) has been fixed in magento/graphql-ce#1013 by @lenaorobei in 2.3-develop branch Related commits: 1. a18b0e1 2. 39042ac - #977: Recurring Install Issue (reported by @mattisbusycom) has been fixed in magento/graphql-ce#996 by @atwixfirster in 2.3-develop branch Related commits: 1. 90557f9 2. 5bf67e5 3. f49fe71
- Loading branch information
Showing
13 changed files
with
311 additions
and
40 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
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
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
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 |
---|---|---|
|
@@ -49,7 +49,7 @@ public function testCreateCustomerAddress() | |
'region_id' => 4, | ||
'region_code' => 'AZ' | ||
], | ||
'country_id' => 'US', | ||
'country_code' => 'US', | ||
'street' => ['Line 1 Street', 'Line 2'], | ||
'company' => 'Company name', | ||
'telephone' => '123456789', | ||
|
@@ -75,7 +75,7 @@ public function testCreateCustomerAddress() | |
region_id: {$newAddress['region']['region_id']} | ||
region_code: "{$newAddress['region']['region_code']}" | ||
} | ||
country_id: {$newAddress['country_id']} | ||
country_code: {$newAddress['country_code']} | ||
street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}"] | ||
company: "{$newAddress['company']}" | ||
telephone: "{$newAddress['telephone']}" | ||
|
@@ -98,7 +98,7 @@ public function testCreateCustomerAddress() | |
region_id | ||
region_code | ||
} | ||
country_id | ||
country_code | ||
street | ||
company | ||
telephone | ||
|
@@ -133,6 +133,75 @@ public function testCreateCustomerAddress() | |
$this->assertCustomerAddressesFields($address, $newAddress); | ||
} | ||
|
||
/** | ||
* Test case for deprecated `country_id` field. | ||
* | ||
* @magentoApiDataFixture Magento/Customer/_files/customer_without_addresses.php | ||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) | ||
*/ | ||
public function testCreateCustomerAddressWithCountryId() | ||
{ | ||
$newAddress = [ | ||
'region' => [ | ||
'region' => 'Arizona', | ||
'region_id' => 4, | ||
'region_code' => 'AZ' | ||
], | ||
'country_id' => 'US', | ||
'street' => ['Line 1 Street', 'Line 2'], | ||
'company' => 'Company name', | ||
'telephone' => '123456789', | ||
'fax' => '123123123', | ||
'postcode' => '7777', | ||
'city' => 'City Name', | ||
'firstname' => 'Adam', | ||
'lastname' => 'Phillis', | ||
'middlename' => 'A', | ||
'prefix' => 'Mr.', | ||
'suffix' => 'Jr.', | ||
'vat_id' => '1', | ||
'default_shipping' => true, | ||
'default_billing' => false | ||
]; | ||
|
||
$mutation | ||
= <<<MUTATION | ||
mutation { | ||
createCustomerAddress(input: { | ||
region: { | ||
region: "{$newAddress['region']['region']}" | ||
region_id: {$newAddress['region']['region_id']} | ||
region_code: "{$newAddress['region']['region_code']}" | ||
} | ||
country_id: {$newAddress['country_id']} | ||
street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}"] | ||
company: "{$newAddress['company']}" | ||
telephone: "{$newAddress['telephone']}" | ||
fax: "{$newAddress['fax']}" | ||
postcode: "{$newAddress['postcode']}" | ||
city: "{$newAddress['city']}" | ||
firstname: "{$newAddress['firstname']}" | ||
lastname: "{$newAddress['lastname']}" | ||
middlename: "{$newAddress['middlename']}" | ||
prefix: "{$newAddress['prefix']}" | ||
suffix: "{$newAddress['suffix']}" | ||
vat_id: "{$newAddress['vat_id']}" | ||
default_shipping: true | ||
default_billing: false | ||
}) { | ||
country_id | ||
} | ||
} | ||
MUTATION; | ||
|
||
$userName = '[email protected]'; | ||
$password = 'password'; | ||
|
||
$response = $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password)); | ||
$this->assertArrayHasKey('createCustomerAddress', $response); | ||
$this->assertEquals($newAddress['country_id'], $response['createCustomerAddress']['country_id']); | ||
} | ||
|
||
/** | ||
* @expectedException Exception | ||
* @expectedExceptionMessage The current customer isn't authorized. | ||
|
@@ -153,7 +222,7 @@ public function testCreateCustomerAddressIfUserIsNotAuthorized() | |
region: { | ||
region_id: 1 | ||
} | ||
country_id: US | ||
country_code: US | ||
postcode: "9999" | ||
default_shipping: true | ||
default_billing: false | ||
|
@@ -182,7 +251,7 @@ public function testCreateCustomerAddressWithMissingAttribute() | |
region: { | ||
region_id: 1 | ||
} | ||
country_id: US | ||
country_code: US | ||
street: ["Line 1 Street","Line 2"] | ||
company: "Company name" | ||
telephone: "123456789" | ||
|
@@ -235,7 +304,7 @@ public function testCreateCustomerAddressWithRedundantStreetLine() | |
'region_id' => 4, | ||
'region_code' => 'AZ' | ||
], | ||
'country_id' => 'US', | ||
'country_code' => 'US', | ||
'street' => ['Line 1 Street', 'Line 2', 'Line 3'], | ||
'company' => 'Company name', | ||
'telephone' => '123456789', | ||
|
@@ -261,7 +330,7 @@ public function testCreateCustomerAddressWithRedundantStreetLine() | |
region_id: {$newAddress['region']['region_id']} | ||
region_code: "{$newAddress['region']['region_code']}" | ||
} | ||
country_id: {$newAddress['country_id']} | ||
country_code: {$newAddress['country_code']} | ||
street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}","{$newAddress['street'][2]}"] | ||
company: "{$newAddress['company']}" | ||
telephone: "{$newAddress['telephone']}" | ||
|
@@ -334,12 +403,15 @@ public function invalidInputDataProvider() | |
* | ||
* @param AddressInterface $address | ||
* @param array $actualResponse | ||
* @param string $countryFieldName | ||
*/ | ||
private function assertCustomerAddressesFields(AddressInterface $address, array $actualResponse): void | ||
{ | ||
private function assertCustomerAddressesFields( | ||
AddressInterface $address, | ||
array $actualResponse | ||
): void { | ||
/** @var $addresses */ | ||
$assertionMap = [ | ||
['response_field' => 'country_id', 'expected_value' => $address->getCountryId()], | ||
['response_field' => 'country_code', 'expected_value' => $address->getCountryId()], | ||
['response_field' => 'street', 'expected_value' => $address->getStreet()], | ||
['response_field' => 'company', 'expected_value' => $address->getCompany()], | ||
['response_field' => 'telephone', 'expected_value' => $address->getTelephone()], | ||
|
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 |
---|---|---|
|
@@ -76,6 +76,56 @@ public function testUpdateCustomerAddress() | |
$this->assertCustomerAddressesFields($address, $updateAddress); | ||
} | ||
|
||
/** | ||
* Test case for deprecated `country_id` field. | ||
* | ||
* @magentoApiDataFixture Magento/Customer/_files/customer.php | ||
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php | ||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) | ||
*/ | ||
public function testUpdateCustomerAddressWithCountryId() | ||
{ | ||
$userName = '[email protected]'; | ||
$password = 'password'; | ||
$addressId = 1; | ||
|
||
$updateAddress = $this->getAddressData(); | ||
|
||
$mutation = $mutation | ||
= <<<MUTATION | ||
mutation { | ||
updateCustomerAddress(id: {$addressId}, input: { | ||
region: { | ||
region: "{$updateAddress['region']['region']}" | ||
region_id: {$updateAddress['region']['region_id']} | ||
region_code: "{$updateAddress['region']['region_code']}" | ||
} | ||
country_id: {$updateAddress['country_code']} | ||
street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"] | ||
company: "{$updateAddress['company']}" | ||
telephone: "{$updateAddress['telephone']}" | ||
fax: "{$updateAddress['fax']}" | ||
postcode: "{$updateAddress['postcode']}" | ||
city: "{$updateAddress['city']}" | ||
firstname: "{$updateAddress['firstname']}" | ||
lastname: "{$updateAddress['lastname']}" | ||
middlename: "{$updateAddress['middlename']}" | ||
prefix: "{$updateAddress['prefix']}" | ||
suffix: "{$updateAddress['suffix']}" | ||
vat_id: "{$updateAddress['vat_id']}" | ||
default_shipping: true | ||
default_billing: true | ||
}) { | ||
country_id | ||
} | ||
} | ||
MUTATION; | ||
|
||
$response = $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password)); | ||
$this->assertArrayHasKey('updateCustomerAddress', $response); | ||
$this->assertEquals($updateAddress['country_code'], $response['updateCustomerAddress']['country_id']); | ||
} | ||
|
||
/** | ||
* @expectedException Exception | ||
* @expectedExceptionMessage The current customer isn't authorized. | ||
|
@@ -131,12 +181,15 @@ public function testUpdateCustomerAddressWithMissingAttribute() | |
* | ||
* @param AddressInterface $address | ||
* @param array $actualResponse | ||
* @param string $countryFieldName | ||
*/ | ||
private function assertCustomerAddressesFields(AddressInterface $address, $actualResponse): void | ||
{ | ||
private function assertCustomerAddressesFields( | ||
AddressInterface $address, | ||
$actualResponse | ||
): void { | ||
/** @var $addresses */ | ||
$assertionMap = [ | ||
['response_field' => 'country_id', 'expected_value' => $address->getCountryId()], | ||
['response_field' => 'country_code', 'expected_value' => $address->getCountryId()], | ||
['response_field' => 'street', 'expected_value' => $address->getStreet()], | ||
['response_field' => 'company', 'expected_value' => $address->getCompany()], | ||
['response_field' => 'telephone', 'expected_value' => $address->getTelephone()], | ||
|
@@ -187,7 +240,7 @@ public function testUpdateCustomerAddressWithMissingId() | |
region_id: {$updateAddress['region']['region_id']} | ||
region_code: "{$updateAddress['region']['region_code']}" | ||
} | ||
country_id: {$updateAddress['country_id']} | ||
country_code: {$updateAddress['country_code']} | ||
street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"] | ||
company: "{$updateAddress['company']}" | ||
telephone: "{$updateAddress['telephone']}" | ||
|
@@ -243,7 +296,7 @@ public function testUpdateCustomerAddressWithInvalidIdType() | |
region_id: {$updateAddress['region']['region_id']} | ||
region_code: "{$updateAddress['region']['region_code']}" | ||
} | ||
country_id: {$updateAddress['country_id']} | ||
country_code: {$updateAddress['country_code']} | ||
street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"] | ||
company: "{$updateAddress['company']}" | ||
telephone: "{$updateAddress['telephone']}" | ||
|
@@ -382,11 +435,11 @@ private function getAddressData(): array | |
{ | ||
return [ | ||
'region' => [ | ||
'region' => 'Alaska', | ||
'region_id' => 2, | ||
'region_code' => 'AK' | ||
'region' => 'Alberta', | ||
'region_id' => 66, | ||
'region_code' => 'AB' | ||
], | ||
'country_id' => 'US', | ||
'country_code' => 'CA', | ||
'street' => ['Line 1 Street', 'Line 2'], | ||
'company' => 'Company Name', | ||
'telephone' => '123456789', | ||
|
@@ -423,7 +476,7 @@ private function getMutation(int $addressId): string | |
region_id: {$updateAddress['region']['region_id']} | ||
region_code: "{$updateAddress['region']['region_code']}" | ||
} | ||
country_id: {$updateAddress['country_id']} | ||
country_code: {$updateAddress['country_code']} | ||
street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"] | ||
company: "{$updateAddress['company']}" | ||
telephone: "{$updateAddress['telephone']}" | ||
|
@@ -446,7 +499,7 @@ private function getMutation(int $addressId): string | |
region_id | ||
region_code | ||
} | ||
country_id | ||
country_code | ||
street | ||
company | ||
telephone | ||
|
Oops, something went wrong.