Ejemplo n.º 1
0
 /**
  * test grabbing a Sport by the Name
  **/
 public function testGetValidSportBySportName()
 {
     // count the number of rows, and save it for later
     $numRows = $this->getConnection()->getRowCount("sport");
     // create a new Sport and insert it into the db
     $sport = new Sport(null, $this->VALID_SPORTLEAGUE, $this->VALID_SPORTNAME);
     $sport->insert($this->getPDO());
     // grab the data from the db and enforce the fields match our expectations
     $results = Sport::getSportBySportName($this->getPDO(), $sport->getSportName());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("sport"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Sprots\\Sport", $results);
     // grab the results from the array and validate it
     $pdoSport = $results[0];
     $this->assertEquals($pdoSport->getSportLeague(), $this->VALID_SPORTLEAGUE);
     $this->assertEquals($pdoSport->getSportName(), $this->VALID_SPORTNAME);
 }