Ejemplo n.º 1
0
 public function testSendConfirmationMessage()
 {
     $this->mailer->setFromAddress('*****@*****.**');
     $this->mailer->setFromName('From Name');
     $user = new User('*****@*****.**');
     $this->swiftmailer->expects($this->once())->method('send')->with($this->callback(function ($message) use($user) {
         if (!$message instanceof \Swift_Message) {
             return false;
         }
         $msg = $message->toString();
         $patterns = array('/From: From Name <*****@*****.**>/', '/To: to@example.com/', '/Hello, ' . $user->getName() . '/');
         foreach ($patterns as $pattern) {
             if (!preg_match($pattern, $msg)) {
                 echo 'Message failed to match pattern "' . $pattern . '".';
                 return false;
             }
         }
         return true;
     }));
     $this->mailer->sendConfirmationMessage($user);
 }
Ejemplo n.º 2
0
 /**
  * Update data in the database for an existing user.
  *
  * @param User $user
  */
 public function update(User $user)
 {
     $this->dispatcher->dispatch(UserEvents::BEFORE_UPDATE, new UserEvent($user));
     $sql = 'UPDATE ' . $this->conn->quoteIdentifier($this->userTableName) . '
         SET ' . $this->getUserColumns('email') . ' = :email
         , ' . $this->getUserColumns('password') . ' = :password
         , ' . $this->getUserColumns('salt') . ' = :salt
         , ' . $this->getUserColumns('name') . ' = :name
         , ' . $this->getUserColumns('roles') . ' = :roles
         , ' . $this->getUserColumns('time_created') . ' = :timeCreated
         , ' . $this->getUserColumns('username') . ' = :username
         , ' . $this->getUserColumns('isEnabled') . ' = :isEnabled
         , ' . $this->getUserColumns('confirmationToken') . ' = :confirmationToken
         , ' . $this->getUserColumns('timePasswordResetRequested') . ' = :timePasswordResetRequested
         WHERE ' . $this->getUserColumns('id') . ' = :id';
     $params = array('email' => $user->getEmail(), 'password' => $user->getPassword(), 'salt' => $user->getSalt(), 'name' => $user->getName(), 'roles' => implode(',', $user->getRoles()), 'timeCreated' => $user->getTimeCreated(), 'username' => $user->getRealUsername(), 'isEnabled' => $user->isEnabled(), 'confirmationToken' => $user->getConfirmationToken(), 'timePasswordResetRequested' => $user->getTimePasswordResetRequested(), 'id' => $user->getId());
     $this->conn->executeUpdate($sql, $params);
     $this->saveUserCustomFields($user);
     $this->dispatcher->dispatch(UserEvents::AFTER_UPDATE, new UserEvent($user));
 }
Ejemplo n.º 3
0
 /**
  * Update data in the database for an existing user.
  *
  * @param User $user
  */
 public function update(User $user)
 {
     $sql = 'UPDATE users
         SET email = :email
         , password = :password
         , salt = :salt
         , name = :name
         , roles = :roles
         , time_created = :timeCreated
         WHERE id = :id';
     $params = array('email' => $user->getEmail(), 'password' => $user->getPassword(), 'salt' => $user->getSalt(), 'name' => $user->getName(), 'roles' => implode(',', $user->getRoles()), 'timeCreated' => $user->getTimeCreated(), 'id' => $user->getId());
     $this->conn->executeUpdate($sql, $params);
 }