Ejemplo n.º 1
0
 public function testEmail()
 {
     $user = new User();
     $mail = '*****@*****.**';
     $this->assertNull($user->getEmail());
     $user->setEmail($mail);
     $this->assertEquals($mail, $user->getEmail());
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider sendEmailResultProvider
  *
  * @param User $user
  * @param string $emailType
  * @param string $expectedEmailType
  */
 public function testSendEmail(User $user, $emailType, $expectedEmailType)
 {
     $templateName = 'email_template_name';
     $templateParams = ['entity' => $user];
     $expectedMessage = $this->buildMessage($user->getEmail(), 'email subject', 'email body', $expectedEmailType);
     $this->assertSendCalled($templateName, $templateParams, $expectedMessage, $emailType);
     $this->mailProcessor->getEmailTemplateAndSendEmail($user, $templateName, $templateParams);
 }
Ejemplo n.º 3
0
 /**
  * @param User $user
  *
  * @return string
  */
 public function buildFullEmailAddress(User $user)
 {
     return $this->emailAddressHelper->buildFullEmailAddress($user->getEmail(), $this->entityNameResolver->getName($user));
 }
Ejemplo n.º 4
0
 /**
  * Send invite email to new user
  *
  * @param User   $user
  * @param string $plainPassword
  *
  * @throws \RuntimeException
  */
 protected function sendInviteMail(User $user, $plainPassword)
 {
     if (in_array(null, [$this->cm, $this->mailer, $this->templating], true)) {
         throw new \RuntimeException('Unable to send invitation email, unmet dependencies detected.');
     }
     $senderEmail = $this->cm->get('oro_notification.email_notification_sender_email');
     $senderName = $this->cm->get('oro_notification.email_notification_sender_name');
     $message = \Swift_Message::newInstance()->setSubject('Invite user')->setFrom($senderEmail, $senderName)->setTo($user->getEmail())->setBody($this->templating->render('OroUserBundle:Mail:invite.html.twig', ['user' => $user, 'password' => $plainPassword]), 'text/html');
     $this->mailer->send($message);
 }
Ejemplo n.º 5
0
 /**
  * @param $randomTemplate
  * @param User $owner
  * @param Contact $contact
  * @param EmailOrigin $origin
  *
  * @return EmailUser
  */
 protected function addEmailUser($randomTemplate, $owner, $contact, $origin)
 {
     $emailUser = $this->emailEntityBuilder->emailUser($this->templates[$randomTemplate]['Subject'], $owner->getEmail(), $contact->getPrimaryEmail()->getEmail(), new \DateTime('now'), new \DateTime('now'), new \DateTime('now'));
     $this->setSecurityContext($owner);
     $emailUser->setFolder($origin->getFolder(FolderType::SENT));
     $emailUser->setOwner($owner);
     $emailUser->setOrganization($owner->getOrganization());
     $emailBody = $this->emailEntityBuilder->body("Hi,\n" . $this->templates[$randomTemplate]['Text'], false, true);
     $emailUser->getEmail()->setEmailBody($emailBody);
     $emailUser->getEmail()->setMessageId(sprintf('<id.%s@%s', uniqid(), '@bap.migration.generated>'));
     return $emailUser;
 }
Ejemplo n.º 6
0
 public function testSendResetPasswordAsAdminEmail()
 {
     $this->assertSendCalled(Processor::TEMPLATE_USER_RESET_PASSWORD_AS_ADMIN, ['entity' => $this->user], $this->buildMessage($this->user->getEmail()));
     $this->mailProcessor->sendResetPasswordAsAdminEmail($this->user);
 }
Ejemplo n.º 7
0
 /**
  * Get the truncated email displayed when requesting the resetting.
  * The default implementation only keeps the part following @ in the address.
  *
  * @param User $user
  *
  * @return string
  */
 protected function getObfuscatedEmail(User $user)
 {
     $email = $user->getEmail();
     if (false !== ($pos = strpos($email, '@'))) {
         $email = '...' . substr($email, $pos);
     }
     return $email;
 }
 /**
  * @param OroUser|ApiUser|int $user
  * @return \Diamante\UserBundle\Entity\DiamanteUser|\Oro\Bundle\UserBundle\Entity\User
  */
 private function getUserDependingOnType($user)
 {
     if ($user instanceof OroUser) {
         return $user;
     }
     if ($user instanceof ApiUser) {
         $userId = $this->userService->verifyDiamanteUserExists($user->getEmail());
         $user = empty($userId) ? $user : new User($userId, User::TYPE_DIAMANTE);
     }
     $result = $this->userService->getByUser($user);
     return $result;
 }
Ejemplo n.º 9
0
 public function testSendRFPNotification()
 {
     $this->assertSendCalled(Processor::CREATE_REQUEST_TEMPLATE_NAME, ['entity' => $this->request], $this->buildMessage($this->user->getEmail()));
     $this->mailProcessor->sendRFPNotification($this->request, $this->user);
 }