コード例 #1
0
 function it_recognizes_a_subject_as_not_eligible_if_a_product_taxon_is_not_matched(OrderInterface $subject, OrderItemInterface $item, ProductInterface $reflexBow, TaxonInterface $bows)
 {
     $configuration = ['taxons' => ['swords', 'axes']];
     $bows->getCode()->willReturn('bows');
     $reflexBow->getTaxons()->willReturn([$bows]);
     $item->getProduct()->willReturn($reflexBow);
     $subject->getItems()->willReturn([$item]);
     $this->isEligible($subject, $configuration)->shouldReturn(false);
 }
コード例 #2
0
 function it_filters_passed_order_items_with_given_configuration(OrderItemInterface $item1, OrderItemInterface $item2, ProductInterface $product1, ProductInterface $product2, TaxonInterface $taxon1, TaxonInterface $taxon2)
 {
     $item1->getProduct()->willReturn($product1);
     $product1->getTaxons()->willReturn([$taxon1]);
     $taxon1->getCode()->willReturn('taxon1');
     $item2->getProduct()->willReturn($product2);
     $product2->getTaxons()->willReturn([$taxon2]);
     $taxon2->getCode()->willReturn('taxon2');
     $this->filter([$item1, $item2], ['filters' => ['taxons' => ['taxon1']]])->shouldReturn([$item1]);
 }
コード例 #3
0
 /**
  * @Then /^the ("[^"]+" taxon) should appear in the registry$/
  */
 public function theTaxonShouldAppearInTheRegistry(TaxonInterface $taxon)
 {
     $this->updatePage->open(['id' => $taxon->getId()]);
     Assert::true($this->updatePage->hasResourceValues(['code' => $taxon->getCode()]), sprintf('Taxon %s should be in the registry.', $taxon->getName()));
 }
コード例 #4
0
 /**
  * @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);
 }
コード例 #5
0
 /**
  * @Given /^([^"]+) gives ("(?:€|£|\$)[^"]+") off if order contains (\d+) products (classified as "[^"]+")$/
  */
 public function thePromotionGivesOffIfOrderContainsNumberOfProductsClassifiedAs(PromotionInterface $promotion, $discount, $count, TaxonInterface $taxon)
 {
     $rule = $this->ruleFactory->createContainsTaxon($taxon->getCode(), $count);
     $this->createFixedPromotion($promotion, $discount, [], $rule);
 }
コード例 #6
0
 function it_reverse_transforms_into_array_of_taxons_codes(TaxonInterface $axes, TaxonInterface $shields)
 {
     $axes->getCode()->willReturn('axes');
     $shields->getCode()->willReturn('shields');
     $this->reverseTransform(new ArrayCollection(['taxons' => [$axes->getWrappedObject(), $shields->getWrappedObject()]]))->shouldReturn(['taxons' => ['axes', 'shields']]);
 }
コード例 #7
0
ファイル: PromotionContext.php プロジェクト: Mozan/Sylius
 /**
  * @Given /^([^"]+) gives ("(?:€|£|\$)[^"]+") off on every product (classified as "[^"]+")$/
  */
 public function itGivesFixedOffEveryProductClassifiedAs(PromotionInterface $promotion, $discount, TaxonInterface $taxon)
 {
     $action = $this->actionFactory->createItemFixedDiscount($discount);
     $promotion->addAction($this->configureActionTaxonFilter($action, [$taxon->getCode()]));
     $this->objectManager->flush();
 }
コード例 #8
0
 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);
 }
コード例 #9
0
ファイル: PromotionContextSpec.php プロジェクト: Mozan/Sylius
 function it_creates_item_percentage_discount_action_for_promotion_products_with_specific_taxon(ActionFactoryInterface $actionFactory, ActionInterface $action, ObjectManager $objectManager, PromotionInterface $promotion, TaxonInterface $taxon)
 {
     $taxon->getCode()->willReturn('scottish_kilts');
     $actionFactory->createItemPercentageDiscount(0.1)->willReturn($action);
     $action->getConfiguration()->willReturn(['percentage' => 0.1]);
     $action->setConfiguration(['percentage' => 0.1, 'filters' => ['taxons' => ['scottish_kilts']]])->shouldBeCalled();
     $promotion->addAction($action)->shouldBeCalled();
     $objectManager->flush()->shouldBeCalled();
     $this->itGivesPercentageOffEveryProductClassifiedAs($promotion, 0.1, $taxon);
 }