/** * test grabbing a Trail Relationship by segmentType **/ public function testGetValidTrailRelationshipBySegmentType() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("trailRelationship"); //create a new Trail Relationship and insert it into mySQL $trailRelationship = new TrailRelationship($this->segment->getSegmentId(), $this->trail->getTrailId(), $this->VALID_SEGMENTTYPE); $trailRelationship->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $pdoTrailRelationship = TrailRelationship::getTrailRelationshipBySegmentType($this->getPDO(), $this->VALID_SEGMENTTYPE); $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("trailRelationship")); $this->assertSame($pdoTrailRelationship->getSegmentId(), $this->segment->getSegmentId()); $this->assertSame($pdoTrailRelationship->getTrailId(), $this->trail->getTrailId()); $this->assertSame($pdoTrailRelationship->getSegmentType(), $this->VALID_SEGMENTTYPE); }
/** * test inserting a Rating and grabbing it from my sql */ public function testGetValidRatingByTrail() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("rating"); // create a new rating and insert it into my sql $rating = new Rating($this->trail->getTrailId(), $this->user->getUserId(), $this->VALID_RATINGVALUE); $rating->insert($this->getPDO()); //grab the data from mySQL and enforce the fields match expectations $pdoRatings = Rating::getRatingValueByTrailId($this->getPDO(), $this->trail->getTrailId()); foreach ($pdoRatings as $pdoRating) { $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("rating")); $this->assertSame($pdoRating->getRatingValue(), $this->VALID_RATINGVALUE); } }
/** * test grabbing a comment by its commentText */ public function testGetValidCommentByCommentText() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("comment"); //create a new comment and insert it into mysql $comment = new Comment(null, $this->trail->getTrailId(), $this->user->getUserId(), $this->VALID_BROWSER, $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, $this->VALID_COMMENTPHOTO, $this->VALID_COMMENTPHOTOTYPE, $this->VALID_COMMENTTEXT); $comment->insert($this->getPDO()); // grab the data from mySQL and enforce it meets expectations $pdoComments = Comment::getCommentByCommentText($this->getPDO(), $comment->getCommentText()); $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("comment")); foreach ($pdoComments as $pdoComment) { $this->assertSame($pdoComment->getBrowser(), $this->VALID_BROWSER); $this->assertEquals($pdoComment->getCreateDate(), $this->VALID_CREATEDATE); $this->assertSame($pdoComment->getIpAddress(), $this->VALID_IPADDRESS); $this->assertSame($pdoComment->getCommentPhoto(), $this->VALID_COMMENTPHOTO); $this->assertSame($pdoComment->getCommentPhotoType(), $this->VALID_COMMENTPHOTOTYPE); $this->assertSame($pdoComment->getCommentText(), $this->VALID_COMMENTTEXT); } }
/** * test grabbing a trail by submitTrailId **/ public function testGetValidTrailBySubmitTrailId() { //count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("trail"); //create a new trail and insert it into mySQL $trail = new Trail(null, $this->user->getUserId(), $this->VALID_BROWSER, $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, null, $this->VALID_TRAILAMENITIES, $this->VALID_TRAILCONDITIION, $this->VALID_TRAILDESCRIPTION, $this->VALID_TRAILDIFFICULTY, $this->VALID_TRAILDISTANCE, $this->VALID_TRAILNAME, $this->VALID_TRAILSUBMISSIONTYPE, $this->VALID_TRAILTERRAIN, $this->VALID_TRAILTRAFFIC, $this->VALID_TRAILUSE, null); $trail->insert($this->getPDO()); $submitTrail = new Trail(null, $this->user->getUserId(), $this->VALID_BROWSER, $this->VALID_CREATEDATE, $this->VALID_IPADDRESS, $trail->getTrailId(), $this->VALID_TRAILAMENITIES, $this->VALID_TRAILCONDITIION, $this->VALID_TRAILDESCRIPTION, $this->VALID_TRAILDIFFICULTY, $this->VALID_TRAILDISTANCE, $this->VALID_TRAILNAME, $this->VALID_TRAILSUBMISSIONTYPE, $this->VALID_TRAILTERRAIN, $this->VALID_TRAILTRAFFIC, $this->VALID_TRAILUSE, $this->VALID_TRAILUUID); $submitTrail->insert($this->getPDO()); //grab the data from mySQL and enforce the fields match our expectations $pdoTrails = Trail::getTrailBySubmitTrailId($this->getPDO(), $submitTrail->getSubmitTrailId()); foreach ($pdoTrails as $pdoTrail) { $this->assertSame($numRows + 2, $this->getConnection()->getRowCount("trail")); $this->assertLessThan($pdoTrail->getTrailId(), 0); $this->assertSame($pdoTrail->getUserId(), $this->user->getUserId()); $this->assertSame($pdoTrail->getBrowser(), $this->VALID_BROWSER); $this->assertEquals($pdoTrail->getCreateDate(), $this->VALID_CREATEDATE); $this->assertSame($pdoTrail->getIpAddress(), $this->VALID_IPADDRESS); $this->assertSame($pdoTrail->getSubmitTrailId(), $submitTrail->getSubmitTrailId()); $this->assertSame($pdoTrail->getTrailAmenities(), $this->VALID_TRAILAMENITIES); $this->assertSame($pdoTrail->getTrailCondition(), $this->VALID_TRAILCONDITIION); $this->assertSame($pdoTrail->getTrailDescription(), $this->VALID_TRAILDESCRIPTION); $this->assertSame($pdoTrail->getTrailDifficulty(), $this->VALID_TRAILDIFFICULTY); $this->assertSame($pdoTrail->getTrailDistance(), $this->VALID_TRAILDISTANCE); $this->assertSame($pdoTrail->getTrailName(), $this->VALID_TRAILNAME); $this->assertSame($pdoTrail->getTrailDescription(), $this->VALID_TRAILDESCRIPTION); $this->assertSame($pdoTrail->getTrailSubmissionType(), $this->VALID_TRAILSUBMISSIONTYPE); $this->assertSame($pdoTrail->getTrailTerrain(), $this->VALID_TRAILTERRAIN); $this->assertSame($pdoTrail->getTrailTraffic(), $this->VALID_TRAILTRAFFIC); $this->assertSame($pdoTrail->getTrailUse(), $this->VALID_TRAILUSE); $this->assertSame($this->longUuidToShortUuid($pdoTrail->getTrailUuId()), $this->VALID_TRAILUUID); } // clean up to prevent PHPUnit from f*****g up $submitTrail->delete($this->getPDO()); $trail->delete($this->getPDO()); }