Skip to content

Commit

Permalink
[Promotion] Fixes after PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed May 9, 2019
1 parent fd1d645 commit 07d39f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
21 changes: 16 additions & 5 deletions src/Sylius/Behat/Context/Ui/Admin/ManagingPromotionsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,13 @@ public function iSpecifyThatThisActionShouldBeAppliedToItemsFromCategory($taxonN
}

/**
* @When /^I add the "([^"]+)" action configured with a percentage value of (?:|-)([^"]+)% for ("[^"]+" channel)$/
* @When /^I add the "([^"]+)" action configured with a percentage value of (?:|-)([^"]+)% for ("[^"]+") channel$/
*/
public function iAddTheActionConfiguredWithAPercentageValueForChannel($actionType, $percentage = null, $channelName)
{
public function iAddTheActionConfiguredWithAPercentageValueForChannel(
string $actionType,
string $percentage = null,
string $channelName
): void {
$this->createPage->addAction($actionType);
$this->createPage->fillActionOptionForChannel($channelName, 'Percentage', $percentage);
}
Expand Down Expand Up @@ -408,7 +411,6 @@ public function thePromotionShouldBeApplicableForTheChannel(PromotionInterface $
/**
* @Given I want to modify a :promotion promotion
* @Given /^I want to modify (this promotion)$/
* @Then I should be able to modify a :promotion promotion
*/
public function iWantToModifyAPromotion(PromotionInterface $promotion)
{
Expand Down Expand Up @@ -617,12 +619,22 @@ public function thePromotionsShouldHavePriority(PromotionInterface $promotion, i
Assert::same($this->updatePage->getPriority(), $priority);
}

/**
* @Then I should be able to modify a :promotion promotion
*/
public function iShouldBeAbleToModifyAPromotion(PromotionInterface $promotion): void
{
$this->iWantToModifyAPromotion($promotion);
$this->updatePage->saveChanges();
}

/**
* @Then the :promotion promotion should have :ruleName rule configured
*/
public function thePromotionShouldHaveRuleConfigured(PromotionInterface $promotion, string $ruleName): void
{
$this->iWantToModifyAPromotion($promotion);
$this->updatePage->saveChanges();

Assert::true($this->updatePage->hasRule($ruleName));
}
Expand All @@ -637,7 +649,6 @@ public function thePromotionShouldNotHaveAnyRuleConfigured(PromotionInterface $p
Assert::false($this->updatePage->hasAnyRule());
}


/**
* @param string $element
* @param string $expectedMessage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,7 @@ private function resolveHasTaxonRules(string $taxonCode): void
foreach ($promotionRules as $promotionRule) {
$configuration = $promotionRule->getConfiguration();
if (in_array($taxonCode, $configuration['taxons'])) {
$taxons = array_filter(
$configuration['taxons'],
function (string $code) use ($taxonCode) {
return $taxonCode !== $code;
}
);

$configuration['taxons'] = array_values($taxons);
$configuration['taxons'] = array_values(array_diff($configuration['taxons'], [$taxonCode]));
$promotionRule->setConfiguration($configuration);
}
}
Expand Down

0 comments on commit 07d39f2

Please sign in to comment.