Exemplo n.º 1
0
 /**
  * test grabbing a segment by SegmentStopElevation
  **/
 public function testGetValidSegmentByStopElevation()
 {
     //count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("segment");
     //create a new segment and insert it into the database
     $segment = new Segment(null, $this->VALID_SEGMENTSTART, $this->VALID_SEGMENTSTOP, $this->VALID_SEGMENTSTARTELEVATION, $this->VALID_SEGMENTSTOPELEVATION);
     $segment->insert($this->getPDO());
     //grab the data from mySQL and verify the fields
     $pdoSegments = Segment::getSegmentBySegmentStopElevation($this->getPDO(), $segment->getSegmentStopElevation());
     $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("segment"));
     foreach ($pdoSegments as $pdoSegment) {
         $this->assertSame($pdoSegment->getSegmentStart()->getX(), $this->VALID_SEGMENTSTART->getX());
         $this->assertSame($pdoSegment->getSegmentStart()->getY(), $this->VALID_SEGMENTSTART->getY());
         $this->assertSame($pdoSegment->getSegmentStop()->getX(), $this->VALID_SEGMENTSTOP->getX());
         $this->assertSame($pdoSegment->getSegmentStop()->getY(), $this->VALID_SEGMENTSTOP->getY());
         $this->assertSame($pdoSegment->getSegmentStartElevation(), $this->VALID_SEGMENTSTARTELEVATION);
         $this->assertSame($pdoSegment->getSegmentStopElevation(), $this->VALID_SEGMENTSTOPELEVATION);
     }
 }