Ejemplo n.º 1
0
 public function it_procesess_nothing(RuleSubjectInterface $subject, RuleRepositoryInterface $ruleRepository, RuleEvaluatorInterface $ruleEvaluator, RuleApplicatorInterface $ruleApplicator)
 {
     $ruleRepository->findBy([], ['priority' => 'desc'])->willReturn([]);
     $ruleEvaluator->evaluate(Argument::type(RuleInterface::class), $subject)->shouldNotBeCalled();
     $ruleApplicator->apply(Argument::type(RuleInterface::class), $subject)->shouldNotBeCalled();
     $this->process($subject);
 }
Ejemplo n.º 2
0
 public function process(RuleSubjectInterface $subject)
 {
     $rules = $this->ruleRepository->findBy([], ['priority' => 'desc']);
     foreach ($rules as $rule) {
         if ($this->ruleEvaluator->evaluate($rule, $subject)) {
             $this->ruleApplicator->apply($rule, $subject);
         }
     }
 }