function it_creates_fixed_discount_promotion_for_cart_with_specified_items_total($actionFactory, $ruleFactory, $objectManager, ActionInterface $action, RuleInterface $rule, PromotionInterface $promotion)
 {
     $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);
 }
Beispiel #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();
 }
 /**
  * @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();
 }
 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);
 }