Beispiel #1
0
 /**
  * test inserting a segmentId, editing it and then updating it
  **/
 public function testUpdateValidSegment()
 {
     //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());
     //edit the stopElevation in segment and update it in mySQL
     $segment->setSegmentStartElevation($this->VALID_SEGMENTSTARTELEVATION2);
     $segment->update($this->getPDO());
     //grab the data from mySQL and verify the fields
     $pdoSegments = Segment::getSegmentBySegmentId($this->getPDO(), $segment->getSegmentId());
     $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);
     }
 }