Esempio n. 1
0
 /**
  * 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());
 }