public function testCreate()
 {
     $ticket = $this->createTicket();
     $creator = $this->createDiamanteUser();
     $comment = new Comment(self::COMMENT_CONTENT, $ticket, $creator, false);
     $this->assertEquals(self::COMMENT_CONTENT, $comment->getContent());
     $this->assertEquals($ticket, $comment->getTicket());
     $this->assertEquals($creator, $comment->getAuthor());
 }
 /**
  * @param Comment $comment
  * @return array
  */
 private function getCommentData(Comment $comment)
 {
     $data = ['attachments' => $comment->getAttachments(), 'content' => $comment->getContent(), 'created_at' => $comment->getCreatedAt(), 'updated_at' => $comment->getUpdatedAt(), 'id' => $comment->getId(), 'private' => $comment->isPrivate(), 'ticket' => $comment->getTicketId(), 'author' => $this->userService->fetchUserDetails($comment->getAuthor())];
     return $data;
 }
 /**
  * @param Comment $comment
  * @param Ticket $ticket
  */
 private function dispatchEvents(Comment $comment, Ticket $ticket = null)
 {
     foreach ($comment->getRecordedEvents() as $event) {
         $this->dispatcher->dispatch($event->getEventName(), $event);
     }
     if ($ticket) {
         foreach ($ticket->getRecordedEvents() as $event) {
             $this->dispatcher->dispatch($event->getEventName(), $event);
         }
     }
     $this->notificationDeliveryManager->deliver($this->notifier);
 }
 /**
  * @test
  * @expectedException \RuntimeException
  */
 public function thatAttachmentRemovingThrowsExceptionWhenCommentHasNoAttachment()
 {
     $comment = new Comment(self::DUMMY_COMMENT_CONTENT, $this->_dummyTicket, $this->createDiamanteUser(), false);
     $comment->addAttachment(new Attachment(new File('filename.ext')));
     $this->commentRepository->expects($this->once())->method('get')->with($this->equalTo(self::DUMMY_COMMENT_ID))->will($this->returnValue($comment));
     $this->authorizationService->expects($this->once())->method('isActionPermitted')->with($this->equalTo('EDIT'), $this->equalTo($comment))->will($this->returnValue(true));
     $removeCommentAttachmentCommand = new RemoveCommentAttachmentCommand();
     $removeCommentAttachmentCommand->attachmentId = 1;
     $removeCommentAttachmentCommand->commentId = self::DUMMY_COMMENT_ID;
     $this->service->removeAttachmentFromComment($removeCommentAttachmentCommand);
 }