Ejemplo n.º 1
0
 /**
  * test grabbing all access
  **/
 public function testGetAllValidAccess()
 {
     //count all the rows and save it for later
     $numRows = $this->getConnection()->getRowCount("access");
     //create a new access and insert into mySQL
     $access = new Access(null, $this->VALID_ACCESSNAME);
     $access->insert($this->getPDO());
     //grab the data from mySQL and enforce the fields match our expectations
     $results = Access::getAllAccess($this->getPDO());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("access"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Timecrunchers\\Access", $results);
     //grab the result from the array and validate it
     $pdoAccess = $results[0];
     $this->assertEquals($pdoAccess->getAccessName(), $this->VALID_ACCESSNAME);
 }
Ejemplo n.º 2
0
 //get the Access based on the given field
 if (empty($id) === false) {
     $access = Access::getAccessByAccessId($pdo, $id);
     // this is for restricting by company - remember is access is wide open
     // however keep this stuff for other APIs :D
     if ($access !== null) {
         $reply->data = $access;
     }
 } else {
     if (empty($id) === false) {
         $access = Access::getAccessByAccessName($pdo, $accessName);
         if ($access !== null) {
             $reply->data = $reply;
         }
     } else {
         $accessors = Access::getAllAccess($pdo);
         if ($accessors !== null) {
             $reply->data = $accessors;
         }
     }
 }
 //if the session belongs to an admin, allow post, put and delete methods
 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 fix database issues
         if (empty($requestObject->accessName) === true) {
             throw new InvalidArgumentException("accessName cannot be null", 405);
         }