Пример #1
0
 function it_creates_an_article(Blog $blog, Title $title, Text $teaser, Collection $rawDisplayables, SlugifierInterface $slugifier, Slug $slug)
 {
     $slugifier->slugify($title)->shouldBeCalled()->willReturn($slug);
     $blog->addPost(Argument::that(function ($argument) use($slug) {
         return $argument instanceof Article && $argument->getSlug() === $slug->getWrappedObject();
     }))->shouldBeCalled();
     $rawDisplayables->getIterator()->willReturn(new \ArrayIterator([]));
     $this->create($blog, $title, $teaser, $rawDisplayables)->shouldBeAnInstanceOf(Article::class);
 }
Пример #2
0
 /**
  * @param Blog       $blog
  * @param Title      $title
  * @param Text       $teaser
  * @param Collection $rawDisplayables A collection of raw values that will be converted into displayables that
  *                                    this Post subtype handles.
  *
  * @return Post
  */
 public final function create(Blog $blog, Title $title, Text $teaser, Collection $rawDisplayables)
 {
     $slug = $this->slugifier->slugify($title);
     $postInfo = new PostInfo(new TitleInfo($title, $slug), new DateInfo());
     $displayables = new Displayables();
     foreach ($rawDisplayables as $rawDisplayable) {
         $displayable = $this->doConvertToDisplayable($rawDisplayable);
         $displayables->add($displayable);
     }
     $content = new Content($teaser, $displayables);
     $post = $this->doCreate($postInfo, $content);
     $blog->addPost($post);
     return $post;
 }