コード例 #1
0
 /**
  * test grabbing all Requests
  **/
 public function testGetAllValidRequests()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("request");
     // create a new Request and insert to into mySQL
     $request = new Request(null, $this->requestor->getUserId(), $this->admin->getUserId(), $this->VALID_REQUESTTIMESTAMP, $this->VALID_REQUESTACTIONTIMESTAMP, $this->requestApprove, $this->VALID_REQUESTREQUESTORTEXT, $this->VALID_REQUESTADMINTEXT);
     $request->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $results = Request::getAllRequests($this->getPDO());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("request"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\TimeCrunchers\\Request", $results);
     // grab the result from the array and validate it
     $pdoRequest = $results[0];
     $this->assertEquals($pdoRequest->getRequestRequestorId(), $this->requestor->getUserId());
     $this->assertEquals($pdoRequest->getRequestAdminId(), $this->admin->getUserId());
     $this->assertEquals($pdoRequest->getRequestTimeStamp(), $this->VALID_REQUESTTIMESTAMP);
     $this->assertEquals($pdoRequest->getRequestActionTimeStamp(), $this->VALID_REQUESTACTIONTIMESTAMP);
     $this->assertEquals($pdoRequest->getRequestApprove(), $this->requestApprove);
     $this->assertEquals($pdoRequest->getRequestRequestorText(), $this->VALID_REQUESTREQUESTORTEXT2);
     $this->assertEquals($pdoRequest->getRequestAdminText(), $this->VALID_REQUESTADMINTEXT);
 }
コード例 #2
0
 /**
  * test inserting a Access and regrabbing it from mySQL
  **/
 public function testGetValidUserByUserId()
 {
     //count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("user");
     //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());
     //grab from the mySQL and enforce the fields match our expectations
     $pdoUser = User::getUserByUserId($this->getPDO(), $user->getUserId());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("user"));
     $this->assertEquals($pdoUser->getUserCompanyId(), $this->company->getCompanyId());
     $this->assertEquals($pdoUser->getUserCrewId(), $this->crew->getCrewId());
     $this->assertEquals($pdoUser->getUserAccessId(), $this->access->getAccessId());
     $this->assertSame($pdoUser->getUserPhone(), $this->VALID_USERPHONE);
     $this->assertSame($pdoUser->getUserFirstName(), $this->VALID_USERFIRSTNAME);
     $this->assertSame($pdoUser->getUserLastName(), $this->VALID_USERLASTNAME);
     $this->assertSame($pdoUser->getUserEmail(), $this->VALID_USEREMAIL);
     $this->assertEquals($pdoUser->getUserActivation(), $this->VALID_USERACTIVATION);
     $this->assertEquals($pdoUser->getUserHash(), $this->VALID_USERHASH);
     $this->assertEquals($pdoUser->getUserSalt(), $this->VALID_USERSALT);
 }