Esempio n. 1
0
 /**
  * To create a new user.
  * @param string $userID        The desired ID of the user
  * @param string $password      The password of the user
  * @param string $email         The primary email of the user
  * @return boolean              Returns if the user is created. False otherwise
  * @throws UserExistsException  Will be thrown if the user already exists in the DB
  * @throws UserIDInvalid        Will be thrown if the user ID Invalid ( It could be null, empty, it's length outside limit, use forbidden chars)
  */
 public static function createUser($userID, $password, $email)
 {
     if (!UserManagement::userExists($userID)) {
         User::newUserObject($userID, $password, $email);
         return TRUE;
     }
     return FALSE;
 }
Esempio n. 2
0
 /**
  * Function to test createUser, deleteUser and userExists functions.
  */
 public function testUser_Create_Delete_Exists()
 {
     UserManagement::createUser("owasp1", "owasp", "*****@*****.**");
     //create a user
     User::activateAccount("owasp1");
     //activate the user's account
     $userObj = UserManagement::logIn("owasp1", "owasp");
     //get the user object
     $firstTest = UserManagement::userExists("owasp1");
     //test user that exists.
     $secondTest = UserManagement::userExists("owasp2");
     //test user that does NOT exists.
     UserManagement::deleteUser("owasp1");
     //delete the created user.
     $this->assertTrue($firstTest && !$secondTest);
 }