public function testCreate()
 {
     $this->dtoToEntityMapper->shouldReceive('transform')->once()->andReturn($this->comment);
     $this->commentRepository->shouldReceive('add')->once()->withArgs([$this->comment]);
     $this->eventDispatcher->shouldReceive('dispatch');
     $this->entityToDtoMapper->shouldReceive('transform')->once()->withArgs([$this->comment])->andReturn($this->commentDto);
     $this->mention->shouldReceive('getUsername')->andReturn('mentioned_user');
     $this->comment->shouldReceive('getAuthorsUsername')->andReturn('test');
     $this->comment->shouldReceive('getAuthorsAvatarFilename')->andReturn('test.jpg');
     $this->comment->shouldReceive('getPostId')->andReturn(123);
     $this->comment->shouldReceive('getMentions')->andReturn(new ArrayCollection([$this->mention]));
     $createdCommentDto = $this->createCommentHandler->create($this->commentDto);
     $this->assertInstanceOf(CommentDto::class, $createdCommentDto);
 }
 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);
 }