예제 #1
0
 /**
  *create dependent objects before running each test
  **/
 public final function setUp()
 {
     //run the default setUp() method first
     parent::setUp();
     //create and insert a Company to own the test Crew
     $this->company = new Company(null, "Kitty Scratchers", "1600 Pennsylvania Ave NW", "Senator's Palace", "Senator Arlo", "WA", "Felis Felix", "20500", "+12125551212", "*****@*****.**", "www.kitty.com");
     $this->company->insert($this->getPDO());
     //calculate the date(just use the time the unit test was setup...)
     //$this->VALID_CREWDATE = new \DateTime();
 }
예제 #2
0
 /**
  * test grabbing all Companies
  **/
 public function testGetAllCompanies()
 {
     // 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
     $results = Company::getAllCompanies($this->getPDO());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("company"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Timecrunchers\\Company", $results);
     // grab the result from the array and validate it
     $pdoCompany = $results[0];
     $this->assertSame($pdoCompany->getCompanyName(), $this->VALID_COMPANYNAME);
     $this->assertSame($pdoCompany->getCompanyAddress1(), $this->VALID_COMPANYADDRESS1);
     $this->assertSame($pdoCompany->getCompanyAddress2(), $this->VALID_COMPANYADDRESS2);
     $this->assertSame($pdoCompany->getCompanyAttn(), $this->VALID_COMPANYATTN);
     $this->assertSame($pdoCompany->getCompanyState(), $this->VALID_COMPANYSTATE);
     $this->assertSame($pdoCompany->getCompanyCity(), $this->VALID_COMPANYCITY);
     $this->assertSame($pdoCompany->getCompanyZip(), $this->VALID_COMPANYZIP);
     $this->assertSame($pdoCompany->getCompanyPhone(), $this->VALID_COMPANYPHONE);
     $this->assertSame($pdoCompany->getCompanyEmail(), $this->VALID_COMPANYEMAIL);
     $this->assertSame($pdoCompany->getCompanyUrl(), $this->VALID_COMPANYURL);
 }
예제 #3
0
         $companyAttn = filter_var($requestObject->companyAttn, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
     } else {
         $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;