Skip to content

Commit

Permalink
magento/graphql-ce#1029: Add Postcode as required depending of the co…
Browse files Browse the repository at this point in the history
…untry Mutation createCustomerAddress

- added test
  • Loading branch information
lenaorobei committed Nov 8, 2019
1 parent 127835e commit 891e5a4
Showing 1 changed file with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,67 @@ public function testCreateCustomerAddressWithRedundantStreetLine()
$this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer_without_addresses.php
* @magentoConfigFixture default_store general/country/optional_zip_countries UA
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testCreateCustomerAddressWithOptionalZipCode()
{
$newAddress = [
'country_code' => 'UA',
'street' => ['Line 1 Street', 'Line 2'],
'company' => 'Company name',
'telephone' => '123456789',
'fax' => '123123123',
'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: {
country_code: {$newAddress['country_code']}
street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}"]
company: "{$newAddress['company']}"
telephone: "{$newAddress['telephone']}"
fax: "{$newAddress['fax']}"
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
}) {
id
}
}
MUTATION;

$userName = 'customer@example.com';
$password = 'password';

$response = $this->graphQlMutation(
$mutation,
[],
'',
$this->getCustomerAuthHeaders($userName, $password)
);
$this->assertNotEmpty($response['createCustomerAddress']['id']);
}

/**
* Create new address with invalid input
*
Expand Down

0 comments on commit 891e5a4

Please sign in to comment.