/** * @return string */ public function getRecipientName() { if ($this->recipient instanceof DiamanteUser) { return $this->recipient->getFullName(); } return $this->recipient->getFirstName() . ' ' . $this->recipient->getLastName(); }
public function load(ObjectManager $manager) { for ($i = 1; $i <= 10; $i++) { $email = sprintf("*****@*****.**", $i); $user = new DiamanteUser($email, 'Test', 'User'); $apiUser = new ApiUser($email, UserServiceImpl::generateRandomSequence(20), UserServiceImpl::generateRandomSequence(20)); $apiUser->activate($apiUser->getHash()); $user->setApiUser($apiUser); $user->setDeleted(false); $manager->persist($user); } $manager->flush(); }
/** * Updates DB Schema. * @throws \Exception if there are no changes in entities */ protected function updateDbSchema() { /** * @var $em \Doctrine\ORM\EntityManager */ $em = $this->getContainer()->get('doctrine.orm.entity_manager'); $event = $em->getEventManager(); $sm = $em->getConnection()->getSchemaManager(); $allMetadata = $em->getMetadataFactory()->getAllMetadata(); $schemaTool = new SchemaTool($em); $entitiesMetadata = array($em->getClassMetadata(ApiUser::getClassName()), $em->getClassMetadata(DiamanteUser::getClassName())); $event->disableListeners(); $currentSchema = $sm->createSchema(); $schemaFromMetadata = $schemaTool->getSchemaFromMetadata($allMetadata); $entitiesSchema = $schemaTool->getSchemaFromMetadata($entitiesMetadata); $entitiesTables = $entitiesSchema->getTables(); $entitiesTableName = array_keys($entitiesTables); $currentDiamanteSchema = $this->getTargetSchema($currentSchema, $entitiesTableName); $diamanteSchemaFromMetadata = $this->getTargetSchema($schemaFromMetadata, $entitiesTableName); $comparator = new Comparator(); $diff = $comparator->compare($currentDiamanteSchema, $diamanteSchemaFromMetadata); $toUpdate = $diff->toSql($em->getConnection()->getDatabasePlatform()); if (empty($toUpdate)) { throw new \Exception('No new updates found. Diamante Api Bundle is up to date!'); } $conn = $em->getConnection(); foreach ($toUpdate as $sql) { $conn->executeQuery($sql); } }
/** * @return string */ public function getRecipientName() { return $this->recipient->getFullName(); }
/** * @param DiamanteUser $user */ protected function restoreUser(DiamanteUser $user) { $user->setDeleted(false); $user->updateTimestamp(); $this->diamanteUserRepository->store($user); $this->resetPassword(new User($user->getId(), User::TYPE_DIAMANTE)); }
public function testProcessWhenDiamanteUserNotExists() { $dummyFrom = $this->getDummyFrom(); $message = new Message(self::DUMMY_UNIQUE_ID, self::DUMMY_MESSAGE_ID, self::DUMMY_SUBJECT, self::DUMMY_CONTENT, $dummyFrom, self::DUMMY_MESSAGE_TO); $assigneeId = 1; $this->userService->expects($this->once())->method('getUserByEmail')->with($this->equalTo(self::DUMMY_MESSAGE_FROM))->will($this->returnValue(null)); $diamanteUser = new DiamanteUser('test_email', $dummyFrom->getFirstName(), $dummyFrom->getLastName()); $this->userService->expects($this->once())->method('createDiamanteUser'); $reporter = new User($diamanteUser->getId(), User::TYPE_DIAMANTE); 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(null)); $this->emailProcessingSettings->expects($this->once())->method('getDefaultBranchId')->will($this->returnValue(self::DEFAULT_BRANCH_ID)); $this->messageReferenceService->expects($this->once())->method('createTicket')->with($this->equalTo($message->getMessageId()), self::DEFAULT_BRANCH_ID, $message->getSubject(), $message->getContent(), $reporter, $assigneeId); $this->branchEmailConfigurationService->expects($this->once())->method('getBranchDefaultAssignee')->with($this->equalTo(1))->will($this->returnValue(1)); $this->ticketStrategy->process($message); }
/** * @param Command\RegisterCommand $command * @param DiamanteUser $user */ protected function restoreUser(Command\RegisterCommand $command, DiamanteUser $user) { $user->setEmail($command->email); $user->setFirstName($command->firstName); $user->setLastName($command->lastName); $user->setDeleted(false); $user->getApiUser()->setPassword($command->password); $this->diamanteUserRepository->store($user); }
public function testProcessWhenDiamanteUserNotExists() { $dummyFrom = $this->getDummyFrom(); $message = new Message(self::DUMMY_UNIQUE_ID, self::DUMMY_MESSAGE_ID, self::DUMMY_SUBJECT, self::DUMMY_CONTENT, $dummyFrom, self::DUMMY_MESSAGE_TO); $assigneeId = 1; $this->configManager->expects($this->once())->method('get')->with($this->equalTo('diamante_desk.default_branch'))->will($this->returnValue(1)); $this->branchService->expects($this->once())->method('getBranch')->with($this->equalTo(1))->will($this->returnValue($this->defaultBranch)); $this->defaultBranch->expects($this->any())->method('getDefaultAssigneeId')->will($this->returnValue($assigneeId)); $this->userService->expects($this->once())->method('getUserByEmail')->with($this->equalTo(self::DUMMY_MESSAGE_FROM))->will($this->returnValue(null)); $diamanteUser = new DiamanteUser('test_email', $dummyFrom->getFirstName(), $dummyFrom->getLastName()); $this->userService->expects($this->once())->method('createDiamanteUser'); $reporter = new User($diamanteUser->getId(), User::TYPE_DIAMANTE); $this->messageReferenceService->expects($this->once())->method('createTicket')->with($this->equalTo($message->getMessageId()), self::DEFAULT_BRANCH_ID, $message->getSubject(), $message->getContent(), $reporter, $assigneeId); $this->ticketStrategy->process($message); }