예제 #1
0
 /**
  * Checks if given Coupon is valid. To determine its validity, this service
  * will evaluate all rules if there are any.
  *
  * @param CartInterface   $cart   Cart
  * @param CouponInterface $coupon Coupon
  *
  * @return boolean Coupon is valid
  */
 public function checkCouponValidity(CartInterface $cart, CouponInterface $coupon)
 {
     $rules = $coupon->getRules();
     return $rules->forAll(function ($_, AbstractRuleInterface $rule) use($cart, $coupon) {
         return $this->ruleManager->evaluateByRule($rule, ['cart' => $cart, 'coupon' => $coupon]);
     });
 }
예제 #2
0
 /**
  * Evaluate rule with variable with exception
  *
  * @var RuleInterface $ruleParameter
  */
 public function testEvaluateRuleParameterException()
 {
     $ruleParameter = $this->getRepository('abstract_rule')->findOneBy(array('code' => 'rule-variables'));
     /**
      * @var AbstractRuleInterface $ruleParameter
      */
     $this->assertFalse($this->ruleManager->evaluateByRule($ruleParameter, array('parameter_another_value' => 'value')));
 }