function it_finds_a_saved_blog(Blog $blog, BlogId $blogId) { $blogId->__toString()->willReturn('***'); $blog->getId()->willReturn($blogId); $this->save($blog); $this->find($blogId)->shouldBe($blog); }
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); }
/** * @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; }
function it_converts_object_values_to_keys(Blog $blog, BlogId $id, Collection $internal) { $key = 'key'; $this->beConstructedWith(BlogId::class, Blog::class, $internal, 'getId'); $blog->getId()->willReturn($id); $id->__toString()->willReturn($key); $internal->add(Argument::any())->shouldNotBeCalled(); $internal->set($key, $blog)->will(function () use($blog, $key) { $this->get($key)->willReturn($blog); }); $internal->contains($blog)->willReturn(false); $internal->offsetGet($key)->willReturn(null); $this->add($blog); $this->get($id)->shouldBe($blog); }
/** * @param Blog $blog */ public function save(Blog $blog) { $this->storage[(string) $blog->getId()] = $blog; }
/** * @param Blog $blog */ public function addBlog(Blog $blog) { $blog->setAuthor($this); $this->blogs->add($blog); }
function it_owns_a_blog(Blog $blog) { $blog->setAuthor($this)->shouldBeCalled(); $this->addBlog($blog); $this->getBlogs()->shouldContain($blog); }