From 1a5dcd22e34fb991e83b421fd528dc6ea2bc9c01 Mon Sep 17 00:00:00 2001 From: Mateusz Zalewski Date: Mon, 1 Jul 2019 14:46:59 +0200 Subject: [PATCH] PR review fixes --- .../coupon_generate_validation.feature | 30 +++++----- .../generating_coupon.feature | 28 +++++----- ...ting_coupon_with_prefix_and_suffix.feature | 56 +++++++++---------- .../Admin/ManagingPromotionCouponsContext.php | 32 ++++++----- 4 files changed, 75 insertions(+), 71 deletions(-) diff --git a/features/promotion/managing_coupons/coupon_generate_validation.feature b/features/promotion/managing_coupons/coupon_generate_validation.feature index 5e1a85fe6f97..3ebd3b9a1c27 100644 --- a/features/promotion/managing_coupons/coupon_generate_validation.feature +++ b/features/promotion/managing_coupons/coupon_generate_validation.feature @@ -11,34 +11,34 @@ Feature: Coupon generate instruction validation And I am logged in as an administrator @ui - Scenario: Trying to generate a new coupons without specifying its amount - Given I want to generate a new coupons for this promotion - When I do not specify its amount - And I specify its code length as 6 + Scenario: Trying to generate new coupons without specifying their amount + When I want to generate new coupons for this promotion + And I do not specify its amount + And I specify their code length as 6 And I limit generated coupons usage to 25 times And I make generated coupons valid until "26.03.2017" - And I try to generate it + And I try to generate these coupons Then I should be notified that generate amount is required And there should be 0 coupon related to this promotion @ui - Scenario: Trying to generate a new coupons without specifying its code length - Given I want to generate a new coupons for this promotion - When I do not specify its code length - And I specify its amount as 4 + Scenario: Trying to generate a new coupons without specifying their code length + When I want to generate new coupons for this promotion + And I do not specify their code length + And I choose the amount of 4 coupons to be generated And I limit generated coupons usage to 25 times And I make generated coupons valid until "26.03.2017" - And I try to generate it + And I try to generate these coupons Then I should be notified that generate code length is required And there should be 0 coupon related to this promotion @ui - Scenario: Trying to generate a new coupons with amount and code length impossible to generate - Given I want to generate a new coupons for this promotion - When I specify its code length as 1 - And I specify its amount as 20 + Scenario: Trying to generate new coupons with amount and code length impossible to generate + When I want to generate new coupons for this promotion + And I specify their code length as 1 + And I choose the amount of 20 coupons to be generated And I limit generated coupons usage to 25 times And I make generated coupons valid until "26.03.2017" - And I try to generate it + And I try to generate these coupons Then I should be notified that generating 20 coupons with code length equal to 1 is not possible And there should be 0 coupon related to this promotion diff --git a/features/promotion/managing_coupons/generating_coupon.feature b/features/promotion/managing_coupons/generating_coupon.feature index 9feaaa3db199..6e7fb4a70abd 100644 --- a/features/promotion/managing_coupons/generating_coupon.feature +++ b/features/promotion/managing_coupons/generating_coupon.feature @@ -1,5 +1,5 @@ @managing_promotion_coupons -Feature: Generating a new coupons +Feature: Generating new coupons In order to quickly create specific number of coupons for my promotions As an Administrator I want to be able to generate coupons for promotion @@ -12,21 +12,21 @@ Feature: Generating a new coupons @ui Scenario: Generating a new coupons - Given I want to generate a new coupons for this promotion - When I specify its amount as 5 - And I specify its code length as 6 + When I want to generate new coupons for this promotion + And I choose the amount of 5 coupons to be generated + And I specify their code length as 6 And I limit generated coupons usage to 25 times And I make generated coupons valid until "26.03.2017" - And I generate it - Then I should be notified that it has been successfully generated - And there should be 5 coupon related to this promotion + And I generate these coupons + Then I should be notified that they have been successfully generated + And there should be 5 coupons related to this promotion @ui - Scenario: Generating a new coupons without expiration date - Given I want to generate a new coupons for this promotion - When I specify its amount as 5 - And I specify its code length as 6 + Scenario: Generating new coupons without expiration date + When I want to generate new coupons for this promotion + And I choose the amount of 5 coupons to be generated + And I specify their code length as 6 And I limit generated coupons usage to 25 times - And I generate it - Then I should be notified that it has been successfully generated - And there should be 5 coupon related to this promotion + And I generate these coupons + Then I should be notified that they have been successfully generated + And there should be 5 coupons related to this promotion diff --git a/features/promotion/managing_coupons/generating_coupon_with_prefix_and_suffix.feature b/features/promotion/managing_coupons/generating_coupon_with_prefix_and_suffix.feature index 433ceb199c75..bc75f77e7661 100644 --- a/features/promotion/managing_coupons/generating_coupon_with_prefix_and_suffix.feature +++ b/features/promotion/managing_coupons/generating_coupon_with_prefix_and_suffix.feature @@ -1,8 +1,8 @@ @managing_promotion_coupons -Feature: Generating a new coupons with prefix and suffi +Feature: Generating new coupons with prefix and suffix In order to quickly create specific number of tailored coupons for my promotions As an Administrator - I want to be able to generate coupons for promotion with prefix and suffix + I want to be able to generate promotion coupons with prefix and suffix Background: Given the store operates on a single channel in "United States" @@ -12,35 +12,35 @@ Feature: Generating a new coupons with prefix and suffi @ui Scenario: Generating new coupons with prefix - Given I want to generate a new coupons for this promotion - When I specify its amount as 5 - And I specify its prefix as "CHRISTMAS_" - And I specify its code length as 6 - And I generate it - Then I should be notified that it has been successfully generated - And there should be 5 coupon related to this promotion - And all of the coupons codes should be prefixed with "CHRISTMAS_" + Given I want to generate new coupons for this promotion + When I choose the amount of 5 coupons to be generated + And I specify their prefix as "CHRISTMAS_" + And I specify their code length as 6 + And I generate these coupons + Then I should be notified that they have been successfully generated + And there should be 5 coupons related to this promotion + And all of the coupon codes should be prefixed with "CHRISTMAS_" @ui Scenario: Generating new coupons with suffix - Given I want to generate a new coupons for this promotion - When I specify its amount as 5 - And I specify its suffix as "_CHRISTMAS" - And I specify its code length as 6 - And I generate it - Then I should be notified that it has been successfully generated - And there should be 5 coupon related to this promotion - And all of the coupons codes should be suffixed with "_CHRISTMAS" + Given I want to generate new coupons for this promotion + When I choose the amount of 5 coupons to be generated + And I specify their suffix as "_CHRISTMAS" + And I specify their code length as 6 + And I generate these coupons + Then I should be notified that they have been successfully generated + And there should be 5 coupons related to this promotion + And all of the coupon codes should be suffixed with "_CHRISTMAS" @ui Scenario: Generating new coupons with prefix and suffix - Given I want to generate a new coupons for this promotion - When I specify its amount as 5 - And I specify its prefix as "CHRISTMAS_" - And I specify its suffix as "_SALE" - And I specify its code length as 6 - And I generate it - Then I should be notified that it has been successfully generated - And there should be 5 coupon related to this promotion - And all of the coupons codes should be prefixed with "CHRISTMAS_" - And all of the coupons codes should be suffixed with "_SALE" + Given I want to generate new coupons for this promotion + When I choose the amount of 5 coupons to be generated + And I specify their prefix as "CHRISTMAS_" + And I specify their suffix as "_SALE" + And I specify their code length as 6 + And I generate these coupons + Then I should be notified that they have been successfully generated + And there should be 5 coupons related to this promotion + And all of the coupon codes should be prefixed with "CHRISTMAS_" + And all of the coupon codes should be suffixed with "_SALE" diff --git a/src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionCouponsContext.php b/src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionCouponsContext.php index f0065152e25e..24470b016ca7 100644 --- a/src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionCouponsContext.php +++ b/src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionCouponsContext.php @@ -88,24 +88,24 @@ public function iWantToModifyTheCoupon(PromotionCouponInterface $coupon, Promoti } /** - * @Given /^I want to generate a new coupons for (this promotion)$/ + * @When /^I want to generate new coupons for (this promotion)$/ */ - public function iWantToGenerateANewCouponsForThisPromotion(PromotionInterface $promotion) + public function iWantToGenerateNewCouponsForThisPromotion(PromotionInterface $promotion) { $this->generatePage->open(['promotionId' => $promotion->getId()]); } /** - * @When /^I specify its code length as (\d+)$/ - * @When I do not specify its code length + * @When /^I specify their code length as (\d+)$/ + * @When I do not specify their code length */ - public function iSpecifyItsCodeLengthAs($codeLength = null) + public function iSpecifyTheirCodeLengthAs($codeLength = null) { $this->generatePage->specifyCodeLength($codeLength ?? ''); } /** - * @When I specify its prefix as :prefix + * @When I specify their prefix as :prefix */ public function specifyPrefixAs(string $prefix): void { @@ -113,7 +113,7 @@ public function specifyPrefixAs(string $prefix): void } /** - * @When I specify its suffix as :prefix + * @When I specify their suffix as :suffix */ public function specifySuffixAs(string $suffix): void { @@ -164,6 +164,7 @@ public function iChangeItsUsageLimitTo($limit) /** * @When I specify its amount as :amount * @When I do not specify its amount + * @When I choose the amount of :amount coupons to be generated */ public function iSpecifyItsAmountAs($amount = null) { @@ -221,7 +222,9 @@ public function iSaveMyChanges() /** * @When I generate it + * @When I generate these coupons * @When I try to generate it + * @When I try to generate these coupons */ public function iGenerateIt() { @@ -255,7 +258,8 @@ public function iDeleteThem(): void } /** - * @Then /^there should be (\d+) coupon related to (this promotion)$/ + * @Then /^there should be (0|1) coupon related to (this promotion)$/ + * @Then /^there should be (\b(?![01]\b)\d{1,9}\b) coupons related to (this promotion)$/ */ public function thereShouldBeCouponRelatedTo($number, PromotionInterface $promotion) { @@ -265,9 +269,9 @@ public function thereShouldBeCouponRelatedTo($number, PromotionInterface $promot } /** - * @Then all of the coupons codes should be prefixed with :prefix + * @Then all of the coupon codes should be prefixed with :prefix */ - public function allOfTheCouponsShouldBePrefixedWith(string $prefix): void + public function allOfTheCouponCodesShouldBePrefixedWith(string $prefix): void { foreach ($this->indexPage->getCouponCodes() as $couponCode) { Assert::startsWith($couponCode, $prefix); @@ -275,9 +279,9 @@ public function allOfTheCouponsShouldBePrefixedWith(string $prefix): void } /** - * @Then all of the coupons codes should be suffixed with :prefix + * @Then all of the coupon codes should be suffixed with :suffix */ - public function allOfTheCouponsShouldBeSuffixedWith(string $suffix): void + public function allOfTheCouponCodesShouldBeSuffixedWith(string $suffix): void { foreach ($this->indexPage->getCouponCodes() as $couponCode) { Assert::endsWith($couponCode, $suffix); @@ -408,9 +412,9 @@ public function couponShouldNotExistInTheRegistry(PromotionCouponInterface $coup } /** - * @Then I should be notified that it has been successfully generated + * @Then I should be notified that they have been successfully generated */ - public function iShouldBeNotifiedThatItHasBeenSuccessfullyGenerated() + public function iShouldBeNotifiedThatTheyHaveBeenSuccessfullyGenerated(): void { $this->notificationChecker->checkNotification('Success Promotion coupons have been successfully generated.', NotificationType::success()); }