/** * test inserting a User, editing it, and then updating it **/ public function testUpdateValidUser() { //count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("user"); //create a new user and insert it into mySQL $user = new User(null, $this->company->getCompanyId(), $this->crew->getCrewId(), $this->access->getAccessId(), $this->VALID_USERPHONE, $this->VALID_USERFIRSTNAME, $this->VALID_USERLASTNAME, $this->VALID_USEREMAIL, $this->VALID_USERACTIVATION, $this->VALID_USERHASH, $this->VALID_USERSALT); $user->insert($this->getPDO()); //edit the user and update it in mySQL $user->setUserPhone($this->VALID_USERPHONE); $user->setUserFirstName($this->VALID_USERFIRSTNAME2); $user->setUserLastName($this->VALID_USERLASTNAME); $user->setUserEmail($this->VALID_USEREMAIL); $user->setUserActivation($this->VALID_USERACTIVATION); $user->setUserHash($this->VALID_USERHASH); $user->setUserSalt($this->VALID_USERSALT); $user->update($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $pdoUser = User::getUserbyUserId($this->getPDO(), $user->getUserId()); $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("user")); $this->assertEquals($pdoUser->getUserCompanyId(), $this->company->getCompanyId()); $this->assertEquals($pdoUser->getUserCrewId(), $this->crew->getCrewId()); $this->assertEquals($pdoUser->getUserAccessId(), $this->access->getAccessId()); $this->assertSame($pdoUser->getUserPhone(), $this->VALID_USERPHONE); $this->assertSame($pdoUser->getUserFirstName(), $this->VALID_USERFIRSTNAME2); $this->assertSame($pdoUser->getUserLastName(), $this->VALID_USERLASTNAME); $this->assertSame($pdoUser->getUserEmail(), $this->VALID_USEREMAIL); $this->assertEquals($pdoUser->getUserActivation(), $this->VALID_USERACTIVATION); $this->assertEquals($pdoUser->getUserHash(), $this->VALID_USERHASH); $this->assertEquals($pdoUser->getUserSalt(), $this->VALID_USERSALT); }