function it_creates_percentage_shipping_discount_action_for_promotion($actionFactory, $objectManager, ActionInterface $action, PromotionInterface $promotion) { $actionFactory->createPercentageShippingDiscount(0.1)->willReturn($action); $promotion->addAction($action)->shouldBeCalled(); $objectManager->flush()->shouldBeCalled(); $this->itGivesPercentageDiscountOnShippingToEveryOrder($promotion, 0.1); }
/** * @param PromotionInterface $promotion * @param ActionInterface $action * @param array $configuration * @param RuleInterface|null $rule */ private function persistPromotion(PromotionInterface $promotion, ActionInterface $action, array $configuration, RuleInterface $rule = null) { $configuration = array_merge($configuration, $action->getConfiguration()); $action->setConfiguration($configuration); $promotion->addAction($action); if (null !== $rule) { $promotion->addRule($rule); } $this->objectManager->flush(); }
/** * @param PromotionInterface $promotion * @param ActionInterface $action * @param array $configuration */ private function persistPromotionWithAction(PromotionInterface $promotion, ActionInterface $action, array $configuration) { $configuration = array_merge($configuration, $action->getConfiguration()); $action->setConfiguration($configuration); $promotion->addAction($action); $this->objectManager->flush(); }
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_item_percentage_discount_action_for_promotion_products_priced_between(ActionFactoryInterface $actionFactory, ActionInterface $action, ObjectManager $objectManager, PromotionInterface $promotion) { $actionFactory->createItemPercentageDiscount(0.1)->willReturn($action); $action->getConfiguration()->willReturn([]); $action->setConfiguration(['filters' => ['price_range' => ['min' => 5000, 'max' => 10000]]])->shouldBeCalled(); $promotion->addAction($action)->shouldBeCalled(); $objectManager->flush()->shouldBeCalled(); $this->thisPromotionPercentageGivesOffOnEveryProductPricedBetween($promotion, 0.1, 5000, 10000); }
/** * @Given /^([^"]+) gives ("[^"]+") percentage discount on shipping to every order$/ */ public function itGivesPercentageDiscountOnShippingToEveryOrder(PromotionInterface $promotion, $discount) { $action = $this->actionFactory->createPercentageShippingDiscount($discount); $promotion->addAction($action); $this->objectManager->flush(); }