/** * create dependent objects before running each test **/ public final function setUp() { // run the default setUp() method first parent::setUp(); // create and insert a Profile to own the test Tweet $this->profile = new Profile(null, "@phpunit", "*****@*****.**", "+12125551212"); $this->profile->insert($this->getPDO()); // create the test Tweet $this->tweet = new Tweet(null, $this->profile->getProfileId(), "PHPUnit favorite test passing"); $this->tweet->insert($this->getPDO()); // calculate the date (just use the time the unit test was setup...) $this->VALID_FAVORITEDATE = new \DateTime(); }
/** * test grabbing a Profile by email **/ public function testGetValidProfileByEmail() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("profile"); // create a new Profile and insert to into mySQL $profile = new Profile(null, $this->VALID_ATHANDLE, $this->VALID_EMAIL, $this->VALID_PHONE); $profile->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $pdoProfile = Profile::getProfileByEmail($this->getPDO(), $profile->getEmail()); $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("profile")); $this->assertSame($pdoProfile->getAtHandle(), $this->VALID_ATHANDLE); $this->assertSame($pdoProfile->getEmail(), $this->VALID_EMAIL); $this->assertSame($pdoProfile->getPhone(), $this->VALID_PHONE); }