예제 #1
0
 /**
  * test grabbing all users
  */
 public function testGetAllValidUsers()
 {
     //create a new user and insert into mySQL
     $user = new User(null, $this->company->getCompanyId(), $this->crew->getCrewId(), $this->access->getAccessId(), $this->VALID_USERPHONE, $this->VALID_USERFIRSTNAME, $this->VALID_USERLASTNAME, $this->VALID_USEREMAIL, $this->VALID_USERACTIVATION, $this->VALID_USERHASH, $this->VALID_USERSALT);
     $user->insert($this->getPDO());
     //count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("user");
     //grab the data for mySQL and enforce the field match our expectations
     $results = User::getAllUsers($this->getPDO());
     $this->assertEquals($numRows, $results->count());
 }
예제 #2
0
             $reply->data = $user;
         }
     } else {
         if (empty($userEmail) === false) {
             $user = User::getUserByUserEmail($pdo, $userEmail);
             if ($user !== null) {
                 $reply->data = $user;
             }
         } else {
             if (empty($userActivation) === false) {
                 $user = User::getUserByUserActivation($pdo, $userActivation);
                 if ($user !== null) {
                     $reply->data = $user;
                 }
             } else {
                 $users = User::getAllUsers($pdo);
                 $reply->data = $users;
             }
         }
     }
 }
 //if the session belongs to an admin, allow post, put, and delete methods
 if (empty($_SESSION["user"]) === false) {
     if (Access::isAdminLoggedIn() === true) {
         if ($method === "PUT" || $method === "POST") {
             verifyXsrf();
             $requestContent = file_get_contents("php://input");
             $requestObject = json_decode($requestContent);
             //make sure all fields are present, in order to prevent database issues
             if (empty($requestObject->userCompanyId) === true) {
                 throw new InvalidArgumentException("userCompanyId cannot be empty", 405);