/**
  * Creates Ticket and Message Reference fot it
  *
  * @param $messageId
  * @param $branchId
  * @param $subject
  * @param $description
  * @param $reporter
  * @param $assigneeId
  * @param array|null $attachments
  * @return \Diamante\DeskBundle\Model\Ticket\Ticket
  * @throws \RuntimeException if unable to load required branch, reporter, assignee
  */
 public function createTicket($messageId, $branchId, $subject, $description, $reporter, $assigneeId, array $attachments = null)
 {
     if (empty($subject)) {
         $subject = self::EMPTY_SUBJECT_PLACEHOLDER;
     }
     $command = new CreateTicketCommand();
     $command->subject = $subject;
     $command->description = $description;
     $command->branch = $branchId;
     $command->reporter = $reporter;
     $command->assignee = $assigneeId;
     $command->source = Source::EMAIL;
     $command->attachmentsInput = $this->convertAttachments($attachments);
     $command->priority = Priority::PRIORITY_LOW;
     $command->status = Status::NEW_ONE;
     $ticket = $this->ticketService->createTicket($command);
     $this->createMessageReference($messageId, $ticket);
     return $ticket;
 }
 /**
  * @test
  */
 public function thatTicketCreatesWithAttachments()
 {
     $branchId = 1;
     $assigneeId = 3;
     $reporter = $this->createReporter();
     $this->ticketService->expects($this->once())->method('createTicket')->will($this->returnValue($this->ticket));
     $messageReference = new MessageReference(self::DUMMY_MESSAGE_ID, $this->ticket);
     $this->messageReferenceRepository->expects($this->once())->method('store')->with($this->equalTo($messageReference));
     $this->messageReferenceService->createTicket(self::DUMMY_MESSAGE_ID, $branchId, self::SUBJECT, self::DESCRIPTION, $reporter, $assigneeId, $this->attachments());
 }