/** * {@inheritdoc} */ public function transform($package) { if (!$package instanceof PackageInterface) { throw new TransformationFailedException(sprintf('Expected a %s!', PackageInterface::class)); } $article = $this->articleFactory->createFromPackage($package); return $article; }
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); }