/** * @Given /^([^"]+) gives ("[^"]+%") off on every product (classified as "[^"]+") and a ("(?:€|£|\$)[^"]+") discount to every order with items total equal at least ("(?:€|£|\$)[^"]+")$/ */ public function itGivesOffOnEveryProductClassifiedAsAndAFixedDiscountToEveryOrderWithItemsTotalEqualAtLeast(PromotionInterface $promotion, $taxonDiscount, TaxonInterface $taxon, $orderDiscount, $targetAmount) { $orderDiscountAction = $this->actionFactory->createFixedDiscount($orderDiscount); $promotion->addAction($orderDiscountAction); $rule = $this->ruleFactory->createItemTotal($targetAmount); $this->createUnitPercentagePromotion($promotion, $taxonDiscount, $this->getTaxonFilterConfiguration([$taxon->getCode()]), $rule); }
/** * @Given /^([^"]+) gives ("(?:€|£|\$)[^"]+") 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(); }
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); }