예제 #1
0
 /**
  * test grabbing all Crews
  **/
 public function testGetAllValidCrews()
 {
     //count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowcount("crew");
     //create a new Crew and insert it into mySQL
     $crew = new Crew(null, $this->company->getCompanyId(), $this->VALID_CREWLOCATION);
     $crew->insert($this->getPDO());
     //grab the data from mySQL and enforce the fields match our expectations
     $pdoCrews = Crew::getAllCrews($this->getPDO());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("crew"));
     foreach ($pdoCrews as $pdoCrew) {
         if ($pdoCrew->getCrewId() === $crew->getCrewId()) {
             $this->assertEquals($pdoCrew->getCrewId(), $crew->getCrewId());
             $this->assertEquals($pdoCrew->getCrewLocation(), $crew->getCrewLocation());
             $this->assertEquals($pdoCrew->getCrewCompanyId(), $crew->getCrewCompanyId());
         }
     }
 }
예제 #2
0
 /**
  * test inserting a Company and re-grabbing it from mySQL
  **/
 public function testGetValidCompanyByCompanyId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("company");
     // create a new Company and insert to into mySQL
     $company = new Company(null, $this->VALID_COMPANYNAME, $this->VALID_COMPANYADDRESS1, $this->VALID_COMPANYADDRESS2, $this->VALID_COMPANYATTN, $this->VALID_COMPANYSTATE, $this->VALID_COMPANYCITY, $this->VALID_COMPANYZIP, $this->VALID_COMPANYPHONE, $this->VALID_COMPANYEMAIL, $this->VALID_COMPANYURL);
     $company->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoCompany = Company::getCompanyByCompanyId($this->getPDO(), $company->getCompanyId());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("company"));
     $this->assertEquals($pdoCompany->getCompanyName(), $this->VALID_COMPANYNAME);
     $this->assertEquals($pdoCompany->getCompanyAddress1(), $this->VALID_COMPANYADDRESS1);
     $this->assertEquals($pdoCompany->getCompanyAddress2(), $this->VALID_COMPANYADDRESS2);
     $this->assertEquals($pdoCompany->getCompanyAttn(), $this->VALID_COMPANYATTN);
     $this->assertEquals($pdoCompany->getCompanyState(), $this->VALID_COMPANYSTATE);
     $this->assertEquals($pdoCompany->getCompanyCity(), $this->VALID_COMPANYCITY);
     $this->assertEquals($pdoCompany->getCompanyZip(), $this->VALID_COMPANYZIP);
     $this->assertEquals($pdoCompany->getCompanyPhone(), $this->VALID_COMPANYPHONE);
     $this->assertEquals($pdoCompany->getCompanyEmail(), $this->VALID_COMPANYEMAIL);
     $this->assertEquals($pdoCompany->getCompanyUrl(), $this->VALID_COMPANYURL);
 }
예제 #3
0
         $companyAttn = null;
     }
     if (empty($requestObject->companyUrl) !== true) {
         $companyUrl = filter_var($requestObject->companyUrl, FILTER_SANITIZE_URL);
     } else {
         $companyUrl = null;
     }
 }
 //		if($password !== $verifyPassword) {
 //			throw(new InvalidArgumentException ("Password and verify password must match."));
 //		}
 //create a new company for the user
 $company = new Company(null, $companyAttn, $companyName, $companyAddress1, $companyAddress2, $companyCity, $companyState, $companyZip, "111-111-1111", $companyEmail, $companyUrl);
 $company->insert($pdo);
 //create a new crew for the user
 $crew = new Crew(null, $company->getCompanyId(), "");
 $crew->insert($pdo);
 //create new user
 //create password salt, hash and activation code
 $activation = bin2hex(random_bytes(16));
 $salt = bin2hex(random_bytes(32));
 $hash = hash_pbkdf2("sha512", "password", $salt, 262144);
 $user = new User(null, $company->getCompanyId(), $crew->getCrewId(), Access::ADMIN, "5055551212", $userFirstName, $userLastName, $userEmail, $activation, $hash, $salt);
 $user->insert($pdo);
 $messageSubject = "Time Crunch Account Activation";
 //building the activation link that can travel to another server and still work. This is the link that will be clicked to confirm the account.
 // FIXME: make sure URL is /public_html/activation/$activation
 $basePath = dirname($_SERVER["SCRIPT_NAME"], 4);
 $urlglue = $basePath . "/activation/" . $activation;
 $confirmLink = "https://" . $_SERVER["SERVER_NAME"] . $urlglue;
 $message = <<<EOF