/** * test inserting a Trail Relationship, editing it, and then updating it * * grabs the data from mySQL via getTrailRelationshipBySegmentIdAndTrailId **/ public function testUpdateValidTrailRelationshipBySegmentIdAndTrailId() { // 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()); // edit the Trail Relationship and update it in mySQL $trailRelationship->setSegmentType($this->VALID_SEGMENTTYPE2); $trailRelationship->update($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $pdoTrailRelationship = TrailRelationship::getTrailRelationshipBySegmentIdAndTrailId($this->getPDO(), $trailRelationship->getSegmentId(), $trailRelationship->getTrailId()); $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_SEGMENTTYPE2); }