public function testConstructor()
 {
     // Clear validations
     \model\ValidationService::Clear();
     $user = new User(10, "someusername", "firstname", "surname", "password", true, true, "", true);
     // Check if password is hashed
     $this->assertTrue(password_verify("password", $user->GetPassword()));
     // Check other values
     $this->assertEquals("someusername", $user->GetUserName());
     $this->assertEquals("firstname", $user->GetFirstName());
     $this->assertEquals("surname", $user->GetSurName());
     $this->assertTrue($user->IsTokenHashed());
     $this->assertNotEmpty($user->GetToken());
     $this->assertTrue($user->IsPasswordHashed());
     // Should be valid
     $this->assertTrue(\model\ValidationService::IsValid());
 }
 /**
  * @return int or false
  * @param User $user
  * @desc Save the supplied object to the database, and return the id
  */
 public function SaveUser($user)
 {
     # check parameters
     if (!$user instanceof User) {
         throw new Exception('Unable to save person');
     }
     # build query
     $table = $this->GetSettings()->GetTable('User');
     $this->Lock($table);
     $s_sql = "UPDATE {$table} SET " . "known_as = " . Sql::ProtectString($this->GetDataConnection(), $user->GetName()) . ", " . "name_first = " . Sql::ProtectString($this->GetDataConnection(), $user->GetFirstName()) . ", " . "name_last = " . Sql::ProtectString($this->GetDataConnection(), $user->GetLastName()) . ", " . "name_sort = " . Sql::ProtectString($this->GetDataConnection(), $user->GetSortName()) . ", " . "email = " . Sql::ProtectString($this->GetDataConnection(), $user->GetEmail()) . ", " . 'date_changed = ' . gmdate('U') . ' ' . 'WHERE user_id = ' . Sql::ProtectNumeric($user->GetId());
     $result = $this->GetDataConnection()->query($s_sql);
     $this->Unlock();
     $success = !$this->GetDataConnection()->isError();
     return $success ? $user->GetId() : false;
 }