Ejemplo n.º 1
0
 public function testGetDisplayName()
 {
     $this->user->setLogin('login');
     $this->user->setFirstName('firstname');
     $this->user->setLastName('lastname');
     $this->user->setEmail('*****@*****.**');
     $this->assertEquals($this->user->getDisplayName(), 'firstname lastname');
     $this->user->setLastName('');
     $this->assertEquals($this->user->getDisplayName(), 'firstname');
     $this->user->setFirstName('');
     $this->assertEquals($this->user->getDisplayName(), '*****@*****.**');
     $this->user->setEmail(null);
     $this->assertEquals($this->user->getDisplayName(), 'login');
     $this->user->setLastName('lastname');
     $this->assertEquals($this->user->getDisplayName(), 'lastname');
     $this->user->setLastName(null);
     $this->user->setLogin(null);
     $this->assertEquals($this->user->getDisplayName(), 'Unnamed user');
 }
Ejemplo n.º 2
0
 /**
  * Sets email for a user.
  *
  * @param User   $user
  * @param string $email
  *
  * @throws InvalidArgumentException if email is not valid or already exists.
  * @throws RuntimeException         if email already exists.
  */
 private function doSetEmail(User $user, $email)
 {
     if (null !== $email && false === (bool) \Swift_Validate::email($email)) {
         throw new InvalidArgumentException(sprintf('Email %s is not legal.', $email));
     }
     if (null !== $this->getRepository()->findByEmail($email)) {
         throw new RuntimeException(sprintf('User with email %s already exists.', $email));
     }
     $user->setEmail($email);
 }
 /**
  * {@inheritDoc}
  */
 public function setEmail($email)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setEmail', array($email));
     return parent::setEmail($email);
 }