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] Receiving percentage discount #12083

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,35 @@ Feature: Receiving percentage discount on products from specific price range
And the store has a product "PHP Mug" priced at "$20.00"
And there is a promotion "Christmas sale"

@ui
@ui @api
Scenario: Receiving percentage discount on a single item fulfilling minimum price criteria
Given this promotion gives "10%" off on every product with minimum price at "$50.00"
When I add product "PHP T-Shirt" to the cart
Then its price should be decreased by "$10.00"
And my cart total should be "$90.00"

@ui
@ui @api
Scenario: Receiving percentage discount on a single item with price equal to filter minimum criteria
Given this promotion gives "10%" off on every product with minimum price at "$100.00"
When I add product "PHP T-Shirt" to the cart
Then its price should be decreased by "$10.00"
And my cart total should be "$90.00"

@ui
@ui @api
Scenario: Receiving percentage discount on a single item fulfilling range price criteria
Given this promotion gives "50%" off on every product priced between "$15.00" and "$50.00"
When I add product "PHP Mug" to the cart
Then its price should be decreased by "$10.00"
And my cart total should be "$10.00"

@ui
@ui @api
Scenario: Receiving percentage discount on a single item with price equal to filter range minimum criteria
Given this promotion gives "50%" off on every product priced between "$20.00" and "$50.00"
When I add product "PHP Mug" to the cart
Then its price should be decreased by "$10.00"
And my cart total should be "$10.00"

@ui
@ui @api
Scenario: Receiving percentage discount on a single item with price equal to filter range maximum criteria
Given this promotion gives "50%" off on every product priced between "$15.00" and "$20.00"
When I add product "PHP Mug" to the cart
Expand Down
3 changes: 3 additions & 0 deletions src/Sylius/Behat/Context/Api/Shop/CartContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public function theAdministratorTryToSeeTheSummaryOfCart(?string $tokenValue): v
public function iAddThisProductToTheCart(ProductInterface $product, ?string $tokenValue): void
{
$this->putProductToCart($product, $tokenValue);

$this->sharedStorage->set('product', $product);
}

/**
Expand Down Expand Up @@ -313,6 +315,7 @@ public function thisItemShouldHaveCode(array $item, string $variantCode): void
}

/**
* @Then /^(its|theirs) price should be decreased by ("[^"]+")$/
* @Then /^(product "[^"]+") price should be decreased by ("[^"]+")$/
*/
public function itsPriceShouldBeDecreasedBy(ProductInterface $product, int $amount): void
Expand Down