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_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; }