public function it_should_not_add_article_to_list(ArticleEvent $event, Article $article, ContentListRepositoryInterface $listRepository, ContentListInterface $list, FactoryInterface $ruleFactory, RuleInterface $rule, RuleEvaluatorInterface $ruleEvaluator, FactoryInterface $listItemFactory, ContentListItemInterface $listItem)
 {
     $event->getArticle()->willReturn($article);
     $list->getExpression()->willReturn('article.getLocale() == "en"');
     $listRepository->findByType(ContentListInterface::TYPE_AUTOMATIC)->willReturn([$list]);
     $ruleFactory->create()->willReturn($rule);
     $rule->setExpression('article.getLocale() == "en"')->shouldBeCalled();
     $ruleEvaluator->evaluate($rule, $article)->willReturn(false);
     $listItemFactory->create()->shouldNotBeCalled();
     $listItem->setContent($article)->shouldNotBeCalled();
     $list->addItem($listItem)->shouldNotBeCalled();
     $this->addArticleToList($event);
 }
 /**
  * @param ArticleEvent $event
  */
 public function addArticleToList(ArticleEvent $event)
 {
     $article = $event->getArticle();
     /** @var ContentListInterface[] $contentLists */
     $contentLists = $this->listRepository->findByType(ContentListInterface::TYPE_AUTOMATIC);
     /** @var RuleInterface $rule */
     $rule = $this->ruleFactory->create();
     foreach ($contentLists as $contentList) {
         $rule->setExpression($contentList->getExpression());
         if ($this->ruleEvaluator->evaluate($rule, $article)) {
             /** @var ContentListItemInterface $contentListItem */
             $contentListItem = $this->listItemFactory->create();
             $contentListItem->setContent($article);
             $contentList->addItem($contentListItem);
         }
     }
 }