/** *create dependent objects before running each test **/ public final function setUp() { //run the default setUp() method first parent::setUp(); // *********************** $password = "******"; $activation = bin2hex(random_bytes(16)); $salt = bin2hex(random_bytes(32)); $hash = hash_pbkdf2("sha512", $password, $salt, 262144); // creates and inserts Company to sql for User foreign key relations $this->company = new Company(null, "Taco B.", "404 Taco St.", "suite:666", "Attention!!", "NM", "Burque", "87106", "5055551111", "*****@*****.**", "www.tocobell.com"); $this->company->insert($this->getPDO()); $_SESSION["company"] = $this->company; // creates and inserts Access to sql for User foreign key relations $this->access = new Access(null, "requestor or admin"); $this->access->insert($this->getPDO()); // create and insert a Crew to own the test Schedule $this->crew = new Crew(null, $this->company->getCompanyId(), "Burque"); $this->crew->insert($this->getPDO()); //***************** //create and insert a User to test Shift $this->requestor = new User(null, $this->company->getCompanyId(), $this->crew->getCrewId(), $this->access->getAccessId(), "5551212", "Johnny", "Requestorman", "*****@*****.**", $activation, $hash, $salt); $this->requestor->insert($this->getPDO()); //create and insert a User to test Shift $this->admin = new User(null, $this->company->getCompanyId(), $this->crew->getCrewId(), $this->access->getAccessId(), "5551212", "Dave", "Adminman", "*****@*****.**", $activation, $hash, $salt); $this->admin->insert($this->getPDO()); //create and insert a Request to test Shift $this->request = new Request(null, $this->requestor->getUserId(), $this->admin->getUserId(), null, null, false, "I can haz time off nao, plz?", "Yes, and bring me a sandwich."); $this->request->insert($this->getPDO()); }
/** * create dependent objects before running each test */ public final function setUp() { // run the default setUp() method first parent::setUp(); $password = "******"; $activation = bin2hex(random_bytes(16)); $salt = bin2hex(random_bytes(32)); $hash = hash_pbkdf2("sha512", $password, $salt, 262144); // creates and inserts Company to sql for User foreign key relations $this->company = new Company(null, "Taco B.", "404 Taco St.", "suite:666", "Attention!!", "NM", "Burque", "87106", "5055551111", "*****@*****.**", "www.tocobell.com"); $this->company->insert($this->getPDO()); $_SESSION["company"] = $this->company; // creates and inserts Crew to sql for User foreign key relations $this->crew = new Crew(null, $this->company->getCompanyId(), "the moon"); $this->crew->insert($this->getPDO()); // creates and inserts Access to sql for User foreign key relations $this->access = new Access(null, "requestor or admin"); $this->access->insert($this->getPDO()); // create and insert a User to own the test Request $this->requestor = new User(null, $this->company->getCompanyId(), $this->crew->getCrewId(), $this->access->getAccessId(), "5551212", "Johnny", "Requestorman", "*****@*****.**", $activation, $hash, $salt); $this->requestor->insert($this->getPDO()); $this->admin = new User(null, $this->company->getCompanyId(), $this->crew->getCrewId(), $this->access->getAccessId(), "5552121", "Suzy", "Hughes", "*****@*****.**", $activation, $hash, $salt); $this->admin->insert($this->getPDO()); // calculate the date (just use the time the unit test was setup...) $this->VALID_REQUESTTIMESTAMP = new \DateTime(); $this->VALID_REQUESTACTIONTIMESTAMP = new \DateTime(); }
/** * test inserting access and regrabbing it from mySQL **/ public function testGetValidAccessByAccessId() { //count the number of row 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 $pdoAccess = Access::getAccessByAccessId($this->getPDO(), $access->getAccessId()); $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("access")); $this->assertEquals($pdoAccess->getAccessName(), $this->VALID_ACCESSNAME); }