示例#1
0
 /**
  * Create dependant objects before running each test
  **/
 public final function setUp()
 {
     //Run the default setUp() method first
     parent::setUp();
     //create and insert profile to tag image
     $password = "******";
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $verify = $salt;
     $hash = hash_pbkdf2("sha512", $password, $salt, 262144);
     $this->profile = new Profile(null, true, null, "Email", "myName", $hash, 1, "mynameagain", "867", $salt, $verify);
     $this->profile->insert($this->getPDO());
     //create an image to be tagged
     $this->imageTagImage = new Image(null, $this->profile->getProfileId(), "jpeg", "myfile", "theText", null);
     $this->imageTagImage->insert($this->getPDO());
     $this->imageTagTag = new Tag(null, "Photo");
     $this->imageTagTag->insert($this->getPDO());
 }
示例#2
0
 /**
  * test grabbing all Votes
  **/
 public function testGetAllValidVotes()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("vote");
     // create a new Vote and insert to into mySQL
     $vote = new Vote($this->voteProfile->getProfileId(), $this->voteImage->getImageId(), $this->VALID_VOTEVALUE);
     $vote->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $results = Vote::getAllvotes($this->getPDO());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("vote"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Jpegery\\Vote", $results);
     // grab the result from the array and validate it
     $pdoVote = $results[0];
     $this->assertEquals($pdoVote->getVoteProfileId(), $this->voteProfile->getProfileId());
     $this->assertEquals($pdoVote->getVoteImageId(), $this->voteImage->getImageId());
     $this->assertEquals($pdoVote->getVoteValue(), $this->VALID_VOTEVALUE);
 }
示例#3
0
 /**
  * test inserting a Profile and regrabbing it from mySQL
  **/
 public function testGetValidProfileByProfileId()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("profile");
     // create a new Profile and insert to into mySQL
     $password = "******";
     $salt = bin2hex(openssl_random_pseudo_bytes(32));
     $hash = hash_pbkdf2("sha512", $password, $salt, 262144);
     $profile = new Profile(null, $this->VALID_PROFILEADMIN, $this->VALID_PROFILECREATEDATE, $this->VALID_PROFILEEMAIL, $this->VALID_PROFILEHANDLE, $hash, $this->VALID_PROFILEIMAGEID, $this->VALID_PROFILENAME, $this->VALID_PROFILEPHONE, $salt, $this->VALID_PROFILEVERIFY);
     $profile->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $pdoProfile = Profile::getProfileByProfileId($this->getPDO(), $profile->getProfileId());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("profile"));
     $this->assertEquals($pdoProfile->getProfileId(), $profile->getProfileId());
     $this->assertEquals($pdoProfile->getProfileAdmin(), $this->VALID_PROFILEADMIN);
     $this->assertEquals($pdoProfile->getProfileCreateDate(), $this->VALID_PROFILECREATEDATE);
     $this->assertEquals($pdoProfile->getProfileEmail(), $this->VALID_PROFILEEMAIL);
     $this->assertEquals($pdoProfile->getProfileHandle(), $this->VALID_PROFILEHANDLE);
     $this->assertEquals($pdoProfile->getProfileHash(), $hash);
     $this->assertEquals($pdoProfile->getProfileImageId(), $this->VALID_PROFILEIMAGEID);
     $this->assertEquals($pdoProfile->getProfileName(), $this->VALID_PROFILENAME);
     $this->assertEquals($pdoProfile->getProfilePhone(), $this->VALID_PROFILEPHONE);
     $this->assertEquals($pdoProfile->getProfileSalt(), $salt);
     $this->assertEquals($pdoProfile->getProfileVerify(), $this->VALID_PROFILEVERIFY);
 }
示例#4
0
 /**
  * @expectedException \RangeException
  */
 public function testInsertInvalidCommentByTooMuchText()
 {
     //Create a new Comment and insert it into mySQL
     $comment = new Comment(null, $this->image->getImageId(), $this->profile->getProfileId(), $this->VALID_COMMENTDATE, $this->INVALID_TEXTLENGTH);
     $comment->insert($this->getPDO());
 }
示例#5
0
 /**
  * @expectedException \RangeException
  **/
 public function testSetInvalidFollowerByNegativeFollowedId()
 {
     $follow = new Follower($this->follower->getProfileId(), -1);
     $follow->insert($this->getPDO());
 }