Skip to content

Commit

Permalink
Receiving no discount for already used coupon promotion
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jun 9, 2021
1 parent 4f2a5d9 commit 274554c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ Feature: Receiving no discount if coupon promotion is not eligible
And I use coupon with code "SANTA2016"
Then I should be notified that the promotion is invalid
And my cart total should be "$100.00"

@api
Scenario: Receiving no discount if promotion's usage for the applied coupon is already exceeded
Given this promotion has usage limit equal to 100
And this promotion usage limit is already reached
When I add product "PHP T-Shirt" to the cart
And I use coupon with code "SANTA2016"
Then I should be notified that the promotion is invalid
And my cart total should be "$100.00"
20 changes: 20 additions & 0 deletions src/Sylius/Behat/Context/Setup/PromotionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,26 @@ public function thisPromotionIsNotAvailableInAnyChannel(PromotionInterface $prom
$this->objectManager->flush();
}

/**
* @Given /^(this promotion) has usage limit equal to (\d+)$/
*/
public function thisPromotionHasUsageLimitEqualTo(PromotionInterface $promotion, int $usageLimit): void
{
$promotion->setUsageLimit($usageLimit);

$this->objectManager->flush();
}

/**
* @Given /^(this promotion) usage limit is already reached$/
*/
public function thisPromotionUsageLimitIsAlreadyReached(PromotionInterface $promotion): void
{
$promotion->setUsed($promotion->getUsageLimit());

$this->objectManager->flush();
}

private function getTaxonFilterConfiguration(array $taxonCodes): array
{
return ['filters' => ['taxons_filter' => ['taxons' => $taxonCodes]]];
Expand Down

0 comments on commit 274554c

Please sign in to comment.