-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Promotion] Contains product promotion fix #6451
[Promotion] Contains product promotion fix #6451
Conversation
@@ -540,6 +542,16 @@ public function theCouponWasUsed(PromotionCouponInterface $coupon) | |||
} | |||
|
|||
/** | |||
* @Given /^([^"]+) gives ("(?:€|£|\$)[^"]+") off if order contains [a|an] ("[^"]*" product)$/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[a|an]
matches a
, |
or n
, you probably meant (?:a|an)
@@ -540,6 +542,16 @@ public function theCouponWasUsed(PromotionCouponInterface $coupon) | |||
} | |||
|
|||
/** | |||
* @Given /^([^"]+) gives ("(?:€|£|\$)[^"]+") off if order contains [a|an] ("[^"]*" product)$/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
("[^"]*" product)
-> ("[^"]+" product)
@@ -62,4 +62,11 @@ public function createContainsTaxon($taxonCode, $count); | |||
* @return PromotionRuleInterface | |||
*/ | |||
public function createNthOrder($nth); | |||
|
|||
/** | |||
* @param int $productCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int
-> string
->add('variant', 'sylius_product_variant_from_identifier', [ | ||
'label' => 'sylius.form.promotion_action.add_product_configuration.variant', | ||
'class' => $this->variantRepository->getClassName(), | ||
->add('product', 'sylius_product_from_identifier', [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
product
-> product_code
?
if ($configuration['variant'] != $item->getVariant()->getId()) { | ||
continue; | ||
} | ||
if ($configuration['product'] === $item->getVariant()->getProduct()->getCode()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you typehint on Core's OrderItemInterface
, you can use $item->getProduct()
instead of $item->getVariant()->getProduct()
.
} | ||
|
||
function it_returns_true_if_variant_is_right_and_exclude_is_not_set( | ||
function it_returns_true_if_product_is_right( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have two products here and the wanted one as the second so we will be sure that we are checking every item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
0ea249a
to
1b171eb
Compare
@@ -11,12 +11,14 @@ | |||
|
|||
namespace Sylius\Behat\Context\Setup; | |||
|
|||
use Behat\Behat\Tester\Exception\PendingException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed
@@ -11,13 +11,15 @@ | |||
|
|||
namespace Sylius\Behat\Context\Ui\Admin; | |||
|
|||
use Behat\Behat\Tester\Exception\PendingException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
if ($configuration['variant'] != $item->getVariant()->getId()) { | ||
continue; | ||
} | ||
if ($configuration['product_code'] === $item->getProduct()->getCode()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -34,14 +37,13 @@ public function isEligible(PromotionSubjectInterface $subject, array $configurat | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not visible, but above this line we should use Assert::instanceOf
instead of if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, I guess. There is a custom exception thrown. Similar to all others rule checkers
When I add product "PHP T-Shirt" to the cart | ||
Then my cart total should be "$80.00" | ||
And my discount should be "-$20.00" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're missing one more case, if I buy 2 units of "PHP T-Shirt" should I receive -$20
discount or -$40
discount?
|
||
@ui | ||
Scenario: Receiving no discount on order while buying product different then discounted | ||
Given the promotion gives "$20.00" off if order contains a "PHP T-Shirt" product |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be moved to the background.
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store has a product "PHP T-Shirt" priced at "$100.00" | ||
And the store has a product "PHP Mug" priced at "$20.00" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be placed in the second scenario only
7a36310
to
6d3cb29
Compare
6d3cb29
to
265867d
Compare
Thanks Łukasz! |
I have added few tests and fix current implementation of contains product promotion.