public function testDelete() { $comment = m::mock(Comment::class); $this->commentRepository->shouldReceive('getById')->with(self::COMMENT_ID)->andReturn($comment); $this->commentRepository->shouldReceive('remove')->with($comment)->once(); $this->deleteCommentHandler->delete(self::COMMENT_ID); }
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); }