/** * set up for dependent objects */ public final function setUp() { //run default set-up method parent::setUp(); //create new organization for the test volunteers $this->organization = new Organization(null, "123 Easy Street", '', "Albuquerque", "Feeding people since 1987", "9 - 5", "Food for Hungry People", "505-765-4321", "NM", "R", "87801"); $this->organization->insert($this->getPDO()); //create a new listing type $this->listingType = new ListingType(null, "Perishable"); $this->listingType->insert($this->getPDO()); //create a new volunteer to use as an admin for the tests $salt = bin2hex(openssl_random_pseudo_bytes(32)); $hash = hash_pbkdf2("sha512", "password4321", $salt, 262144, 128); $this->admin = new Volunteer(null, $this->organization->getOrgId(), "*****@*****.**", null, "John", $hash, true, "Doe", "505-123-4567", $salt); $this->admin->insert($this->getPDO()); //create a non-admin volunteer for the tests $salt = bin2hex(openssl_random_pseudo_bytes(32)); $hash = hash_pbkdf2("sha512", "password1234", $salt, 262144, 128); $this->volunteer = new Volunteer(null, $this->organization->getOrgId(), "*****@*****.**", null, "Jane", $hash, false, "Doe", "505-555-5555", $salt); $this->volunteer->insert($this->getPDO()); //create the guzzle client $this->guzzle = new \GuzzleHttp\Client(["cookies" => true]); //visit ourselves to get the xsrf-token $this->guzzle->get('https://bootcamp-coders.cnm.edu/~bbrown52/bread-basket/public_html/php/api/listing'); $cookies = $this->guzzle->getConfig()["cookies"]; $this->token = $cookies->getCookieByName("XSRF-TOKEN")->getValue(); //send a request to the sign-in method $adminLogin = new stdClass(); $adminLogin->email = "*****@*****.**"; $adminLogin->password = "******"; $login = $this->guzzle->post('https://bootcamp-coders.cnm.edu/~bbrown52/bread-basket/public_html/php/controllers/sign-in-controller.php', ['json' => $adminLogin, 'headers' => ['X-XSRF-TOKEN' => $this->token]]); }
/** * set up for dependent objects before running each test */ public final function setUp() { //run default setUp() method first parent::setUp(); //create a salt and hash for test $this->VALID_SALT = bin2hex(openssl_random_pseudo_bytes(32)); $this->VALID_HASH = $this->VALID_HASH = hash_pbkdf2("sha512", "password4321", $this->VALID_SALT, 262144, 128); //create a valid organization to reference in test $this->organization = new Organization(null, "23 Star Trek Rd", "Suit 2", "Bloomington", "Coffee, black", "24/7", "Test", "5051234567", "NM", "G", "87106"); $this->organization->insert($this->getPDO()); }
/** * set up for valid organization */ public final function setUp() { //run default setUp() method first parent::setUp(); //create a valid organization to reference in test $this->organization = new Organization(null, "88 Spring", "Suit 2", "ABQ", "Home2", "24/7", "2", "5051234567", "NM", "G", "87106"); $this->organization->insert($this->getPDO()); //create a valid Listing Type Id to reference in test $this->listingType = new ListingType(null, "Refrigerated"); $this->listingType->insert($this->getPDO()); $this->valid_datetime = DateTime::createFromFormat("Y-m-d H:i:s", "2012-07-08 11:14:15"); }
/** * set up for valid organization */ public final function setUp() { //run default setUp() method first parent::setUp(); //create a valid organization to reference in test $this->organization = new Organization(null, "89 Spring", "Suit 2", "ABQ", "Home2", "24/7", "2", "5051234567", "NM", "G", "87106"); $this->organization->insert($this->getPDO()); //create a valid ListingTypeId to reference in test $this->listingType = new ListingType(null, "Refrigerated"); $this->listingType->insert($this->getPDO()); //create a valid Listing Id to reference in test $this->listing = new Listing(null, $this->organization->getOrgId(), 33, true, 23.0, "We have apples", 102, "2012-07-08 11:14:15", $this->listingType->getListingTypeId()); $this->listing->insert($this->getPDO()); }
/** *Setting up dependant objects before running each test */ public function setUp() { //run default set-up method parent::setUp(); //create a new organization for the test message to belong $organization = new Message(null, ""); $organization->insert($this->getPDO()); //create a new volunteer for the test message to belong $volunteer = new Message(null, ""); $volunteer->insert($this->getPDO()); //create a new Listing type for the test message to belong $listingType = new Message(null, ""); $listingType->insert($this->getPDO()); //create a new listing type for the test message to belong $listing = new message(null . ""); $listing->insert($this->getPDO()); //create a new volunteer to use as an admin for the tests //dont need to insert them into database: just need their info to create sessions //for testing purposes, allow them to create organizations they not associated with $salt = bin2hex(openssl_random_pseudo_bytes(32)); $hash = hash_pbkdf2("userone", "passwordone", $salt, 262144, 128); $this->admin = new Volunteer(null, $organization->getOrgId(), "*****@*****.**", null, "Mike", $hash, true, "Smith", "505-321-1234", $salt); $this->admin->insert($this->getPDO()); //create a non-admin voulunteer for the test $salt = bin2hex(openssl_random_pseudo_bytes(32)); $hash = hash_pbkdf2("usertwo", "passwordtwo", $salt, 262144, 128); $this->volunteer = new Volunteer(null, $organization->getOrgId(), "*****@*****.**", null, "Smithers", $hash, true, "Mikeson", "505-432-1234", $salt); $this->volunteer->insert($this->getPDO()); // created guzzle client $this->guzzle = new \GuzzleHttp\Client(['cookies' => true]); //Visit ourselves to get the xsrf-token $this->guzzle = get('https://bootcamp-coders.cnm.edu/~cberaun2/bread-basket/public_html/php/api/organization'); $cookies = $this->guzzle->getConfig()["cookies"]; $this->token = $cookies->getCookiesByname("XSRF-TOKEN")->getValue(); //send a request to the sign-in-method $adminLogin = new stdClass(); $adminLogin->email = "*****@*****.**"; $adminLogin->password = "******"; $login = $this->guzzle->post('https://bootcamp-coders.cnm.edu/~cberaun2/bread-basket/public_html/php/controlls/sign-in-controller.php', ['json' => $adminLogin, 'headers' => ['X-XSRF-TOKEN' => $this->token]]); }
/** * set up for dependent objects before running each test */ public final function setUp() { //run default set-up method parent::setUp(); //create salt and hash $this->VALID_HASH = hash_pbkdf2("sha512", "idonatefood", $this->VALID_SALT, 262144, 128); $this->VALID_SALT = bin2hex(openssl_random_pseudo_bytes(32)); //create an organization for the volunteers to be a part of $organization = new Organization(null, "123 Easy Street", '', "Albuquerque", "Feeding people since 1987", "9 - 5", "Food for Hangry People", "505-765-4321", "NM", "R", "87801"); $organization->insert($this->getPDO()); $this->valid_org_id = $organization->getOrgId(); //create a new volunteer to use as an admin for the tests //don't need to insert them into the database: just need their info to create sessions //for testing purposes, allow them to create organizations they're not associated with $salt = bin2hex(openssl_random_pseudo_bytes(32)); $hash = hash_pbkdf2("sha512", "coffeeblack", $salt, 262144, 128); $this->admin = new Volunteer(null, $organization->getOrgId(), "*****@*****.**", null, "Kathryn", $hash, true, "Janeway", "505-123-4567", $salt); $this->admin->insert($this->getPDO()); //create a non-admin volunteer for the tests $salt = bin2hex(openssl_random_pseudo_bytes(32)); $hash = hash_pbkdf2("sha512", "password1234", $salt, 262144, 128); $this->volunteer = new Volunteer(null, $organization->getOrgId(), "*****@*****.**", null, "Jane", $hash, false, "Doe", "505-555-5555", $salt); $this->volunteer->insert($this->getPDO()); //create the guzzle client $this->guzzle = new \GuzzleHttp\Client(["cookies" => true]); //visit ourselves to get the xsrf-token $this->guzzle->get('https://bootcamp-coders.cnm.edu/~kkeller13/bread-basket/public_html/php/api/volunteer'); $cookies = $this->guzzle->getConfig()["cookies"]; $this->token = $cookies->getCookieByName("XSRF-TOKEN")->getValue(); //send a request to the sign-in method $adminLogin = new stdClass(); $adminLogin->email = "*****@*****.**"; $adminLogin->password = "******"; $login = $this->guzzle->post('https://bootcamp-coders.cnm.edu/~kkeller13/bread-basket/public_html/php/controllers/sign-in-controller.php', ['json' => $adminLogin, 'headers' => ['X-XSRF-TOKEN' => $this->token]]); }