/** * test inserting a Volunteer, editing it, and then updating it **/ public function testUpdateValidVolunteer() { // 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()); // edit the Volunteer and update it in mySQL $volunteer->setVolEmail($this->VALID_EMAIL_ALT); $volunteer->update($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_ALT); $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); }