Added Behat scenarios

This commit is contained in:
Gorka Laucirica 2017-03-06 22:14:26 +01:00 committed by Kamil Kokot
parent 1375a87e37
commit c19fee797a
No known key found for this signature in database
GPG key ID: 7BD76F7054D93C89
2 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,28 @@
@receiving_discount
Feature: Receiving stacked promotion with changing context
In order to pay proper amount while buying promoted goods
As a Customer
I want to receive discount for my purchase
Background:
Given the store operates on a single channel in "United States"
And the store has "DHL" shipping method with "$10.00" fee
And the store has a product "PHP T-Shirt" priced at "$120.00"
And there is a promotion "Holiday promotion" with priority 1
And it gives "50%" discount to every order
And there is a promotion "Free shiping over" with priority 0
And it gives free shipping to every order over "$100"
@ui
Scenario: Receiving only the "Holiday promotion"
When I add product "PHP T-Shirt" to the cart
Then my cart total should be "$70.00"
And my discount should be "-$60.00"
And my cart shipping total should be "$10.00"
@ui
Scenario: Receiving the "Holiday promotion" and the free shipping discount
When I add 2 products "PHP T-Shirt" to the cart
Then my cart total should be "$120.00"
And my discount should be "-$120.00"
And my cart shipping total should be "$0.00"

View file

@ -673,6 +673,30 @@ final class PromotionContext implements Context
$this->createPercentagePromotion($promotion, $discount, [], $rule); $this->createPercentagePromotion($promotion, $discount, [], $rule);
} }
/**
* @Given /^([^"]+) gives ("[^"]+%") discount on shipping to every order over ("(?:€|£|\$)[^"]+")$/
*/
public function itGivesDiscountOnShippingToEveryOrderOver(
PromotionInterface $promotion,
$discount,
$itemTotal
)
{
$channelCode = $this->sharedStorage->get('channel')->getCode();
$rule = $this->ruleFactory->createItemTotal($channelCode, $itemTotal);
$action = $this->actionFactory->createShippingPercentageDiscount($discount);
$this->persistPromotion($promotion, $action, [], $rule);
}
/**
* @Given /^([^"]+) gives free shipping to every order over ("(?:|£|\$)[^"]+")$/
*/
public function itGivesFreeShippingToEveryOrderOver(PromotionInterface $promotion, $itemTotal)
{
$this->itGivesDiscountOnShippingToEveryOrderOver($promotion, 1, $itemTotal);
}
/** /**
* @param array $taxonCodes * @param array $taxonCodes
* *