function it_creates_percentage_discount_action_for_promotion(ActionFactoryInterface $actionFactory, ActionInterface $action, ObjectManager $objectManager, PromotionInterface $promotion, SharedStorageInterface $sharedStorage) { $sharedStorage->get('promotion')->willReturn($promotion); $actionFactory->createPercentageDiscount(0.1)->willReturn($action); $promotion->addAction($action)->shouldBeCalled(); $objectManager->flush()->shouldBeCalled(); $this->itGivesPercentageDiscountToEveryOrder($promotion, 0.1); }
/** * @param PromotionInterface $promotion * @param float $discount * @param array $configuration * @param RuleInterface $rule */ private function createPercentagePromotion(PromotionInterface $promotion, $discount, array $configuration = [], RuleInterface $rule = null) { $this->persistPromotion($promotion, $this->actionFactory->createPercentageDiscount($discount), $configuration, $rule); }
/** * @Given /^([^"]+) gives ("[^"]+%") discount to every order$/ */ public function itGivesPercentageDiscountToEveryOrder(PromotionInterface $promotion, $discount) { $action = $this->actionFactory->createPercentageDiscount($discount); $promotion->addAction($action); $this->objectManager->flush(); }