Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Api] Tests adding incorrect county code to address order #12671

Merged
merged 4 commits into from May 27, 2021

Conversation

Tomanhez
Copy link
Contributor

Q A
Branch? 1.9
Bug fix? yes
New feature? yes
BC breaks? no
Deprecations? no
License MIT

@Tomanhez Tomanhez requested a review from a team as a code owner May 25, 2021 19:06
@probot-autolabeler probot-autolabeler bot added the API APIs related issues and PRs. label May 25, 2021
@Tomanhez Tomanhez changed the title [Api] Tests for address [Api] Tests adding incorrect county code to address order May 25, 2021
@Tomanhez Tomanhez force-pushed the tests-for-address branch 3 times, most recently from 3ba9c00 to ebc19a9 Compare May 26, 2021 07:39
src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php Outdated Show resolved Hide resolved
/** @var string|null $countryCode */
$countryCode = $address->getCountryCode();

if ($countryCode === null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, isn't it the case for the other validator 😄 We would then have two constraints e.g. CountrySpecified and CountryExisting? Seems as a better separation of responsibilities

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its possible, but IMO it is just addressValidator. I can extract it to other services, but is it too much code to simple address validation? :D And we can add here next points for other address fields.

Comment on lines +17 to +18
And the visitor try to specify the incorrect billing address as "Ankh Morpork", "Frost Alley", "90210", "United Russia" for "Jon Snow"
And the visitor complete the addressing step
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These steps can be merged into one, the second one is not needed for API context

Comment on lines +195 to +197
$addressType = 'billingAddress';

$this->addAddress($addressType, $city, $street, $postcode, $customerName, $countryName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$addressType = 'billingAddress';
$this->addAddress($addressType, $city, $street, $postcode, $customerName, $countryName);
$this->addAddress('billingAddress', $city, $street, $postcode, $customerName, $countryName);

}

/**
* @When /^the visitor try to specify the billing address without country as "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can name the arguments and then merge this method with the one above

Suggested change
* @When /^the visitor try to specify the billing address without country as "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
* @When the visitor try to specify the billing address without country as :city, :street, :postcode for :customerName

@@ -182,6 +182,33 @@ public function iSpecifyTheBillingAddressAs(AddressInterface $address): void
$this->fillAddress('billingAddress', $address);
}

/**
* @When /^the visitor try to specify the incorrect billing address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @When /^the visitor try to specify the incorrect billing address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
* @When the visitor try to specify the incorrect billing address as :city, :street, :postcode, :countryName for :customerName

@GSadee GSadee merged commit f5b2306 into Sylius:1.9 May 27, 2021
@GSadee
Copy link
Member

GSadee commented May 27, 2021

Thank you, Tomasz! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API APIs related issues and PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants