public function testNewUserHasInitialValues() { $user = new User('*****@*****.**'); $this->assertGreaterThan(0, $user->getTimeCreated()); $this->assertNotEmpty($user->getSalt()); $this->assertTrue($user->hasRole('ROLE_USER')); }
/** * 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)); }
/** * 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); }