From e0adcf23823563f16bc835d614bd1a080ab4b091 Mon Sep 17 00:00:00 2001 From: tuka217 Date: Mon, 9 Jan 2017 11:53:36 +0100 Subject: [PATCH] [Behat] Add scenario about seeing shipping promotion on order summary --- ...ing_discount_on_order_summary_page.feature | 23 +++++++++++++++++++ .../Behat/Context/Ui/CheckoutContext.php | 8 +++++++ .../Behat/Page/Shop/Checkout/CompletePage.php | 10 ++++++++ .../Shop/Checkout/CompletePageInterface.php | 7 ++++++ 4 files changed, 48 insertions(+) create mode 100644 features/checkout/seeing_order_summary/seeing_shipping_discount_on_order_summary_page.feature diff --git a/features/checkout/seeing_order_summary/seeing_shipping_discount_on_order_summary_page.feature b/features/checkout/seeing_order_summary/seeing_shipping_discount_on_order_summary_page.feature new file mode 100644 index 000000000000..29536a2cd629 --- /dev/null +++ b/features/checkout/seeing_order_summary/seeing_shipping_discount_on_order_summary_page.feature @@ -0,0 +1,23 @@ +@checkout +Feature: Seeing shipping discount on order summary + In order to be certain that the shipping discount was applied to my order + As a Customer + I want to be able to see shipping promotion on the order summary + + Background: + Given the store operates on a single channel in "United States" + And the store has a product "PHP T-Shirt" priced at "$19.99" + And the store has "DHL" shipping method with "$50.00" fee + And there is a promotion "Holiday promotion" + And the promotion gives "10%" discount on shipping to every order + And the store allows paying offline + And I am a logged in customer + + @ui + Scenario: Seeing order shipping discount on the order summary page + Given I have product "PHP T-Shirt" in the cart + And I am at the checkout addressing step + When I specified the shipping address as "Ankh Morpork", "Frost Alley", "90210", "United States" for "Jon Snow" + And I proceed with "DHL" shipping method and "Offline" payment + Then I should be on the checkout summary step + And "Holiday promotion" should be applied to my order shipping diff --git a/src/Sylius/Behat/Context/Ui/CheckoutContext.php b/src/Sylius/Behat/Context/Ui/CheckoutContext.php index 3740cddb265f..df0f7058534c 100644 --- a/src/Sylius/Behat/Context/Ui/CheckoutContext.php +++ b/src/Sylius/Behat/Context/Ui/CheckoutContext.php @@ -908,6 +908,14 @@ public function shouldBeAppliedToMyOrder($promotionName) ); } + /** + * @Then :promotionName should be applied to my order shipping + */ + public function shouldBeAppliedToMyOrderShipping($promotionName) + { + Assert::true($this->completePage->hasShippingPromotion($promotionName)); + } + /** * @Given my tax total should be :taxTotal */ diff --git a/src/Sylius/Behat/Page/Shop/Checkout/CompletePage.php b/src/Sylius/Behat/Page/Shop/Checkout/CompletePage.php index 006b4b38d9e7..17ab40e7a233 100644 --- a/src/Sylius/Behat/Page/Shop/Checkout/CompletePage.php +++ b/src/Sylius/Behat/Page/Shop/Checkout/CompletePage.php @@ -183,6 +183,15 @@ public function hasPromotion($promotionName) return false !== stripos($this->getElement('promotion_discounts')->getText(), $promotionName); } + /** + * {@inheritdoc} + */ + public function hasShippingPromotion($promotionName) + { + return false !== stripos($this->getElement('promotion_shipping_discounts')->getText(), $promotionName); + } + + /** * {@inheritdoc} */ @@ -293,6 +302,7 @@ protected function getDefinedElements() 'payment_step_label' => '.steps a:contains("Payment")', 'product_row' => 'tbody tr:contains("%name%")', 'promotion_discounts' => '#promotion-discounts', + 'promotion_shipping_discounts' => '#promotion-shipping-discounts', 'promotion_total' => '#promotion-total', 'shipping_address' => '#sylius-shipping-address', 'shipping_method' => '#sylius-shipping-method', diff --git a/src/Sylius/Behat/Page/Shop/Checkout/CompletePageInterface.php b/src/Sylius/Behat/Page/Shop/Checkout/CompletePageInterface.php index c33fb621a937..233c98aaa454 100644 --- a/src/Sylius/Behat/Page/Shop/Checkout/CompletePageInterface.php +++ b/src/Sylius/Behat/Page/Shop/Checkout/CompletePageInterface.php @@ -97,6 +97,13 @@ public function hasPromotionTotal($promotionTotal); */ public function hasPromotion($promotionName); + /** + * @param string $promotionName + * + * @return bool + */ + public function hasShippingPromotion($promotionName); + /** * @param string $taxTotal *