/**
  * @param $from
  * @param $to
  * @return int
  */
 private function getAppropriateBranch($from, $to)
 {
     $branchId = null;
     preg_match('/@(.*)/', $from, $output);
     if (isset($output[1])) {
         $customerDomain = $output[1];
         $branchId = $this->branchEmailConfigurationService->getConfigurationBySupportAddressAndCustomerDomain($to, $customerDomain);
     }
     if (!$branchId) {
         $branchId = $this->emailProcessingSettings->getDefaultBranchId();
     }
     return $branchId;
 }
 public function testProcessWhenMessageWithoutReferenceWithoutDefaultBranch()
 {
     $message = new Message(self::DUMMY_UNIQUE_ID, self::DUMMY_MESSAGE_ID, self::DUMMY_SUBJECT, self::DUMMY_CONTENT, $this->getDummyFrom(), self::DUMMY_MESSAGE_TO);
     $assigneeId = 1;
     $diamanteUser = $this->getReporter(1);
     $this->userService->expects($this->once())->method('getUserByEmail')->with($this->equalTo(self::DUMMY_MESSAGE_FROM))->will($this->returnValue($diamanteUser));
     $reporter = $this->getReporter($diamanteUser->getId());
     preg_match('/@(.*)/', self::DUMMY_MESSAGE_FROM, $output);
     $customerDomain = $output[1];
     $this->branchEmailConfigurationService->expects($this->once())->method('getConfigurationBySupportAddressAndCustomerDomain')->with($this->equalTo(self::DUMMY_MESSAGE_TO), $this->equalTo($customerDomain))->will($this->returnValue(self::DUMMY_BRANCH_ID));
     $this->branchEmailConfigurationService->expects($this->once())->method('getBranchDefaultAssignee')->with($this->equalTo(2))->will($this->returnValue(1));
     $this->messageReferenceService->expects($this->once())->method('createTicket')->with($this->equalTo($message->getMessageId()), self::DUMMY_BRANCH_ID, $message->getSubject(), $message->getContent(), $reporter, $assigneeId);
     $this->ticketStrategy->process($message);
 }