/** * @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(); }
/** * @param PromotionInterface $promotion * @param int $discount * @param array $configuration * @param RuleInterface $rule */ private function createFixedPromotion(PromotionInterface $promotion, $discount, array $configuration = [], RuleInterface $rule = null) { $this->persistPromotion($promotion, $this->actionFactory->createFixedDiscount($discount), $configuration, $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); }
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); }