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
Conversation
Tomanhez
commented
May 25, 2021
Q | A |
---|---|
Branch? | 1.9 |
Bug fix? | yes |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
License | MIT |
bca989c
to
7ad3be8
Compare
features/cart/shopping_cart/allowing_access_only_for_correctly_logged_in_users.feature
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Validator/Constraints/CorrectAddressOrder.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/spec/Validator/Constraints/CorrectAddressOrderValidatorSpec.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/spec/Validator/Constraints/CorrectAddressOrderValidatorSpec.php
Outdated
Show resolved
Hide resolved
3ba9c00
to
ebc19a9
Compare
features/checkout/addressing_order/order_address_validation.feature
Outdated
Show resolved
Hide resolved
features/checkout/addressing_order/order_address_validation.feature
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Validator/Constraints/CorrectOrderAddressValidator.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/Validator/Constraints/CorrectOrderAddressValidator.php
Outdated
Show resolved
Hide resolved
/** @var string|null $countryCode */ | ||
$countryCode = $address->getCountryCode(); | ||
|
||
if ($countryCode === null) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/Sylius/Bundle/ApiBundle/spec/Validator/Constraints/CorrectOrderAddressValidatorSpec.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ApiBundle/spec/Validator/Constraints/CorrectOrderAddressValidatorSpec.php
Outdated
Show resolved
Hide resolved
ebc19a9
to
07f3185
Compare
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 |
There was a problem hiding this comment.
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
$addressType = 'billingAddress'; | ||
|
||
$this->addAddress($addressType, $city, $street, $postcode, $customerName, $countryName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$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 "([^"]+)"$/ |
There was a problem hiding this comment.
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
* @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 "([^"]+)"$/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @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 |
Thank you, Tomasz! 🎉 |