public function transform(Entity $comment) : Dto
 {
     /** @var Comment $comment */
     $mentions = $comment->getMentions()->map(function (Mention $mention) {
         return $mention->getUsername();
     })->toArray();
     $avatar = $this->avatarUploadPathResolver->getUploadPath($comment->getAuthor()->getAvatarFilename());
     $commentDto = new CommentDto();
     $commentDto->id = $comment->getId();
     $commentDto->postId = $comment->getPostId();
     $commentDto->createdAt = $comment->getCreatedAt()->format('Y-m-d H:i:s');
     $commentDto->content = $comment->getContent();
     $commentDto->userId = $comment->getAuthor()->getUserId();
     $commentDto->username = $comment->getAuthor()->getUsername();
     $commentDto->mentions = $mentions;
     $commentDto->avatar = $avatar;
     $commentDto->deletable = true;
     return $commentDto;
 }
 public function setUp()
 {
     $this->avatarUploadPathResolver = m::mock(UploadPathResolver::class);
     $this->avatarUploadPathResolver->shouldReceive('getUploadPath')->withArgs(['test.jpg'])->andReturn('/avatars/test.jpg');
     $this->commentMapper = new CommentMapper($this->avatarUploadPathResolver);
     $createdAt = m::mock(\DateTime::class);
     $createdAt->shouldReceive('format')->andReturn('2016-01-25 10:25:00');
     $author = m::mock(Author::class);
     $author->shouldReceive('getUserId')->andReturn(123);
     $author->shouldReceive('getUsername')->andReturn('test_user');
     $author->shouldReceive('getAvatarFilename')->andReturn('test.jpg');
     $mappedMentions = m::mock(ArrayCollection::class);
     $mappedMentions->shouldReceive('toArray')->andReturn(['tester']);
     $mentions = m::mock(ArrayCollection::class);
     $mentions->shouldReceive('map')->andReturn($mappedMentions);
     $this->comment = m::mock(Comment::class);
     $this->comment->shouldReceive('getId')->andReturn(5);
     $this->comment->shouldReceive('getPostId')->andReturn(40);
     $this->comment->shouldReceive('getCreatedAt')->andReturn($createdAt);
     $this->comment->shouldReceive('getContent')->andReturn('test @tester foo bar');
     $this->comment->shouldReceive('getAuthor')->andReturn($author);
     $this->comment->shouldReceive('getMentions')->andReturn($mentions);
 }