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); }
public function it_is_not_supportable(RuleSubjectInterface $subject, RuleApplicatorInterface $applicator) { $applicator->isSupported($subject)->willReturn(false); $this->addApplicator($applicator); $subject->getSubjectType()->willReturn('article'); $this->isSupported($subject)->shouldReturn(false); }
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); } } }