/**
  * @Given /^([^"]+) gives ("[^"]+%") off on every product (classified as "[^"]+" or "[^"]+") if order contains any product (classified as "[^"]+" or "[^"]+")$/
  */
 public function itGivesOffOnEveryProductClassifiedAsOrIfOrderContainsAnyProductClassifiedAsOr(PromotionInterface $promotion, $discount, array $discountTaxons, array $targetTaxons)
 {
     $discountTaxonsCodes = [$discountTaxons[0]->getCode(), $discountTaxons[1]->getCode()];
     $targetTaxonsCodes = [$targetTaxons[0]->getCode(), $targetTaxons[1]->getCode()];
     $rule = $this->ruleFactory->createTaxon($targetTaxonsCodes);
     $this->createUnitPercentagePromotion($promotion, $discount, $this->getTaxonFilterConfiguration($discountTaxonsCodes), $rule);
 }
Exemple #2
0
 /**
  * @Given /^([^"]+) gives ("[^"]+") fixed discount to every order with items total at least ("[^"]+")$/
  */
 public function itGivesFixedDiscountToEveryOrderWithItemsTotalAtLeast(PromotionInterface $promotion, $amount, $targetAmount)
 {
     $action = $this->actionFactory->createFixedDiscount($amount);
     $promotion->addAction($action);
     $rule = $this->ruleFactory->createItemTotal($targetAmount);
     $promotion->addRule($rule);
     $this->objectManager->flush();
 }
 /**
  * @Given /^([^"]+) gives ("(?:€|£|\$)[^"]+") off if order contains (\d+) products (classified as "[^"]+")$/
  */
 public function thePromotionGivesOffIfOrderContainsNumberOfProductsClassifiedAs(PromotionInterface $promotion, $discount, $count, TaxonInterface $taxon)
 {
     $rule = $this->ruleFactory->createContainsTaxon($taxon->getCode(), $count);
     $this->createFixedPromotion($promotion, $discount, [], $rule);
 }
 function it_creates_a_fixed_discount_promotion_which_contains_a_taxon_rule(ActionFactoryInterface $actionFactory, ActionInterface $action, ObjectManager $objectManager, PromotionInterface $promotion, RuleFactoryInterface $ruleFactory, RuleInterface $rule, TaxonInterface $tanks)
 {
     $tanks->getCode()->willReturn('tanks');
     $ruleFactory->createContainsTaxon('tanks', 10)->willReturn($rule);
     $actionFactory->createFixedDiscount(500)->willReturn($action);
     $action->getConfiguration()->willReturn([]);
     $action->setConfiguration([])->shouldBeCalled();
     $promotion->addAction($action)->shouldBeCalled();
     $promotion->addRule($rule)->shouldBeCalled();
     $objectManager->flush()->shouldBeCalled();
     $this->thePromotionGivesOffIfOrderContainsNumberOfProductsClassifiedAs($promotion, 500, 10, $tanks);
 }
Exemple #5
0
 /**
  * @Given /^([^"]+) gives ("(?:€|£|\$)[^"]+") off customer's (\d)(?:st|nd|rd|th) order$/
  */
 public function itGivesOffCustomersNthOrder(PromotionInterface $promotion, $discount, $nth)
 {
     $rule = $this->ruleFactory->createNthOrder((int) $nth);
     $this->createFixedPromotion($promotion, $discount, [], $rule);
 }
 function it_creates_fixed_discount_promotion_for_cart_with_specified_items_total(ActionFactoryInterface $actionFactory, ActionInterface $action, ObjectManager $objectManager, PromotionInterface $promotion, RuleFactoryInterface $ruleFactory, RuleInterface $rule)
 {
     $actionFactory->createFixedDiscount(1000)->willReturn($action);
     $promotion->addAction($action)->shouldBeCalled();
     $ruleFactory->createItemTotal(5000)->willReturn($rule);
     $promotion->addRule($rule)->shouldBeCalled();
     $objectManager->flush()->shouldBeCalled();
     $this->itGivesFixedDiscountToEveryOrderWithItemsTotalAtLeast($promotion, 1000, 5000);
 }