public function it_should_transform_package_to_article(PackageInterface $package, ArticleFactoryInterface $articleFactory, ArticleInterface $article)
 {
     $package->getHeadline()->willReturn('headline');
     $package->getSlugline()->willReturn('slug');
     $package->getLanguage()->willReturn('en');
     $article->getTitle()->willReturn('headline');
     $article->getSlug()->willReturn('slug');
     $article->getLocale()->willReturn('en');
     $articleFactory->createFromPackage($package)->willReturn($article);
     $this->transform($package)->shouldReturn($article);
 }
 public function it_should_transform_json_to_package(PackageInterface $package, SerializerInterface $serializer, ValidatorInterface $validator)
 {
     $json = '{
         "language": "en",
         "slugline": "slugline",
         "headline": "headline"
     }';
     $package->getHeadline()->willReturn('headline');
     $package->getSlugline()->willReturn('slugline');
     $package->getLanguage()->willReturn('en');
     $items = new ArrayCollection();
     $package->getItems()->willReturn($items);
     $validator->isValid($json)->willReturn(true);
     $serializer->deserialize($json, Argument::exact(Package::class), Argument::exact('json'))->willReturn($package);
     $this->transform($json)->shouldReturn($package);
 }
 public function it_creates_article_from_package_and_sets_article_slug_from_package_slugline(FactoryInterface $factory, PackageInterface $package, Article $article, RouteInterface $route, RouteProviderInterface $routeProvider)
 {
     $factory->create()->willReturn($article);
     $item = new Item();
     $item->setBody('some item body');
     $item->setType('text');
     $item->setDescription('item lead');
     $package->getHeadline()->shouldBeCalled()->willReturn('item headline');
     $package->getDescription()->shouldBeCalled()->willReturn('package lead');
     $package->getBody()->shouldBeCalled()->willReturn('some package body');
     $package->getItems()->shouldBeCalled()->willReturn(new ArrayCollection([$item]));
     $package->getLanguage()->shouldBeCalled()->willReturn('en');
     $package->getMetadata()->shouldBeCalled()->willReturn(['some' => 'meta']);
     $package->getSlugline()->shouldBeCalled()->willReturn('slugline');
     $article->setTitle('item headline')->shouldBeCalled();
     $article->setBody('some package body some item body')->shouldBeCalled();
     $article->setLead('package lead item lead')->shouldBeCalled();
     $article->setLocale('en')->shouldBeCalled();
     $article->setRoute($route)->shouldBeCalled();
     $article->setMetadata(['some' => 'meta'])->shouldBeCalled();
     $article->setSlug('slugline')->shouldBeCalled();
     $routeProvider->getRouteForArticle($article)->willReturn($route);
     $this->createFromPackage($package)->shouldReturn($article);
 }