Ejemplo n.º 1
0
 /**
  * test inserting a Volunteer and regrabbing it from mySQL
  */
 public function testGetValidVolunteerByVolId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("volunteer");
     // create a new Volunteer and insert to into mySQL
     $volunteer = new Volunteer(null, $this->organization->getOrgId(), $this->VALID_EMAIL, $this->VALID_EMAIL_ACTIVATION, $this->VALID_FIRST_NAME, $this->VALID_HASH, $this->VALID_VOL_IS_ADMIN, $this->VALID_LAST_NAME, $this->VALID_PHONE, $this->VALID_SALT);
     $volunteer->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoVolunteer = Volunteer::getVolunteerByVolId($this->getPDO(), $volunteer->getVolId());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("volunteer"));
     $this->assertSame($pdoVolunteer->getOrgId(), $this->organization->getOrgId());
     $this->assertSame($pdoVolunteer->getVolEmail(), $this->VALID_EMAIL);
     $this->assertSame($pdoVolunteer->getVolEmailActivation(), $this->VALID_EMAIL_ACTIVATION);
     $this->assertSame($pdoVolunteer->getVolFirstName(), $this->VALID_FIRST_NAME);
     $this->assertSame($pdoVolunteer->getVolHash(), $this->VALID_HASH);
     $this->assertSame($pdoVolunteer->getVolIsAdmin(), $this->VALID_VOL_IS_ADMIN);
     $this->assertSame($pdoVolunteer->getVolLastName(), $this->VALID_LAST_NAME);
     $this->assertSame($pdoVolunteer->getVolPhone(), $this->VALID_PHONE);
     $this->assertSame($pdoVolunteer->getVolSalt(), $this->VALID_SALT);
 }
Ejemplo n.º 2
0
 public function testValidPut()
 {
     //create a new volunteer, and insert into the database
     $volunteer = new Volunteer(null, $this->valid_org_id, $this->VALID_EMAIL, $this->VALID_EMAIL_ACTIVATION, $this->VALID_FIRST_NAME, $this->VALID_HASH, $this->VALID_ADMIN, $this->VALID_LAST_NAME, $this->VALID_PHONE, $this->VALID_SALT);
     $volunteer->insert($this->getPDO());
     //update the volunteer
     $volunteer->setVolPhone($this->VALID_ALT_PHONE);
     //$volunteer->setVolEmail($this->VALID_ALT_EMAIL);
     //		var_dump($volunteer->getVolId());
     //send the info to update the API
     $response = $this->guzzle->put('https://bootcamp-coders.cnm.edu/~kkeller13/bread-basket/public_html/php/api/volunteer/' . $volunteer->getVolId(), ['allow-redirects' => ['strict' => true], 'json' => $volunteer, 'headers' => ['X-XSRF-TOKEN' => $this->token]]);
     //		var_dump($response);
     $newVolunteer = Volunteer::getVolunteerByVolId($this->getPDO(), $volunteer->getVolId());
     var_dump($newVolunteer);
     //ensure the response was sent, and the api returned a positive status
     $this->assertSame($response->getStatusCode(), 200);
     $body = $response->getBody();
     var_dump((string) $response->getBody());
     $retrievedVol = json_decode($body);
     //		var_dump($retrievedVol);
     $this->assertSame(200, $retrievedVol->status);
     //pull the value from the DB, and make sure it was properly updated
     $newvol = Volunteer::getVolunteerByVolId($this->getPDO(), $volunteer->getVolId());
     $this->assertSame($newvol->getVolPhone(), $this->VALID_ALT_PHONE);
 }