/**
  * {@inheritdoc}
  */
 public function create()
 {
     /** @var TenantInterface $tenant */
     $tenant = $this->decoratedFactory->create();
     $tenant->setCode($this->generator->generate(6));
     return $tenant;
 }
 public function it_creates_a_new_organization_with_code(FactoryInterface $factory, GeneratorInterface $generator, OrganizationInterface $organization)
 {
     $factory->create()->willReturn($organization);
     $generator->generate(6)->willReturn('123456');
     $organization->setCode('123456')->shouldBeCalled();
     $this->createWithCode()->shouldReturn($organization);
 }
 /**
  * @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);
         }
     }
 }
 public function it_throws_an_exception(FactoryInterface $factory, GeneratorInterface $generator, TenantInterface $tenant, OrganizationInterface $organization, OrganizationRepositoryInterface $organizationRepository)
 {
     $organizationRepository->findOneByCode('123456')->willReturn(null);
     $factory->create()->shouldNotBeCalled();
     $generator->generate(6)->shouldNotBeCalled();
     $tenant->setCode('123456')->shouldNotBeCalled();
     $tenant->setOrganization($organization)->shouldNotBeCalled();
     $this->shouldThrow(\InvalidArgumentException::class)->during('createForOrganization', ['123456']);
 }
 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);
 }
 /**
  * {@inheritdoc}
  */
 public function create()
 {
     return $this->baseFactory->create();
 }
 public function it_creates_new_route_object(FactoryInterface $factory, RouteInterface $route)
 {
     $factory->create()->willReturn($route);
     $this->create()->shouldReturn($route);
 }
 public function it_throws_an_exception_when_item_type_not_allowed(FactoryInterface $factory, PackageInterface $package, Article $article, RouteInterface $route)
 {
     $factory->create()->willReturn($article);
     $item = new Item();
     $item->setBody('some item body');
     $item->setType('fake');
     $package->getHeadline()->shouldNotBeCalled();
     $package->getBody()->shouldBeCalled()->willReturn('some package body');
     $package->getItems()->shouldBeCalled()->willReturn(new ArrayCollection([$item]));
     $package->getLanguage()->shouldNotBeCalled();
     $package->getMetadata()->shouldNotBeCalled();
     $article->setTitle('item headline')->shouldNotBeCalled();
     $article->setBody('some package body some item body')->shouldNotBeCalled();
     $article->setLocale('en')->shouldNotBeCalled();
     $article->setRoute($route)->shouldNotBeCalled();
     $article->setMetadata(['some' => 'meta'])->shouldNotBeCalled();
     $this->shouldThrow(\InvalidArgumentException::class)->duringCreateFromPackage($package);
 }
示例#9
0
 /**
  * {@inheritdoc}
  */
 public function create()
 {
     return $this->decoratedFactory->create();
 }