Skip to content

Commit

Permalink
feature #13098 [CatalogPromotions] Add product to cart with discounte…
Browse files Browse the repository at this point in the history
…d catalog price (Tomanhez, arti0090)

This PR was merged into the 1.11-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.9 or 1.10 branch (the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

b77b125 Add behat scenarios
5c748dc Change behat scenario to be more descriptive and remove unneded one
  • Loading branch information
Zales0123 authored Sep 14, 2021
2 parents dcfea96 + 5c748dc commit 0c96399
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@shopping_cart
Feature: Adding a simple product with discounted catalog price to the cart
In order to select products with proper price
As a Visitor
I want to be able to add simple products with discounted catalog price to the cart

Background:
Given the store operates on a single channel in "United States"
And the store has a product "Mug" priced at "$40"
And the store has a product "T-Shirt" priced at "$20"
And there is a catalog promotion "Winter sale" that reduces price by "25%" and applies on "T-Shirt" variant

@todo
Scenario: Adding a simple product with discounted catalog price to the cart
When I add product "T-Shirt" to the cart
And I add product "Mug" to the cart
Then I should be on my cart summary page
And I should be notified that the product has been successfully added
And I should see "T-Shirt" with unit price "$15.00" in my cart
And I should see "T-Shirt" with original price "$20.00" in my cart
And I should see also "Mug" with unit price "$40.00" in my cart
And I should see "Mug" with original price "$40.00" in my cart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@shopping_cart
Feature: Adding a product with selected variant with discounted catalog price to the cart
In order to select products with proper price
As a Visitor
I want to be able to add products with selected variants to cart

Background:
Given the store operates on a single channel in "United States"
And the store has a product "T-Shirt"
And this product has "PHP T-Shirt" variant priced at "$20"
And the store has a product "Keyboard"
And this product has "RGB Keyboard" variant priced at "$40"
And there is a catalog promotion "Winter sale" that reduces price by "25%" and applies on "PHP T-Shirt" variant

@todo
Scenario: Adding multiple product variants with discounted price by catalog promotion catalog to the cart
Given I add product "PHP T-Shirt" to the cart
And I add product "RGB Keyboard" to the cart
When I check details of my cart
Then I should see "PHP T-Shirt" with unit price "$15.00" in my cart
And I should see "RGB Keyboard" with unit price "$40.00" in my cart
20 changes: 19 additions & 1 deletion src/Sylius/Behat/Context/Api/Shop/CartContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public function iShouldBeNotifiedThatQuantityOfAddedProductCannotBeLowerThan1():
}

/**
* @Then /^I should see "([^"]+)" with unit price ("[^"]+") in my cart$/
* @Then /^I should see(?:| also) "([^"]+)" with unit price ("[^"]+") in my cart$/
*/
public function iShouldSeeProductWithUnitPriceInMyCart(string $productName, int $unitPrice): void
{
Expand Down Expand Up @@ -814,4 +814,22 @@ private function getExpectedPriceOfProductTimesQuantity(ProductInterface $produc

throw new \InvalidArgumentException(sprintf('Price for product %s had not been found', $product->getName()));
}

/**
* @Then /^I should see "([^"]+)" with original price ("[^"]+") in my cart$/
*/
public function iShouldSeeWithOriginalPriceInMyCart(string $productName, int $originalPrice): void
{
$response = $this->cartsClient->getLastResponse();

foreach ($this->responseChecker->getValue($response, 'items') as $item) {
if ($item['productName'] === $productName) {
Assert::same($item['originalPrice'], $originalPrice);

return;
}
}

throw new \InvalidArgumentException(sprintf('The product %s does not exist', $productName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ default:
- sylius.behat.context.setup.shipping_category
- sylius.behat.context.setup.shop_api_security
- sylius.behat.context.setup.user
- Sylius\Behat\Context\Setup\CatalogPromotionContext

- sylius.behat.context.transform.cart
- sylius.behat.context.transform.channel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ default:
- sylius.behat.context.setup.taxation
- sylius.behat.context.setup.user
- sylius.behat.context.setup.zone
- Sylius\Behat\Context\Setup\CatalogPromotionContext

- sylius.behat.context.ui.channel
- sylius.behat.context.ui.shop.cart
Expand Down

0 comments on commit 0c96399

Please sign in to comment.