Ejemplo n.º 1
0
 /**
  * create dependent objects before running each test
  **/
 public final function setUp()
 {
     // run the default setUp() method first
     parent::setUp();
     // Create and insert a sport to own the test team
     $this->sport = new Sport(null, "sportLeagues", "sportLeagues2", "SportNames", "SportNames2");
     $this->sport->insert($this->getPDO());
     // create and insert a Profile to own the test Team
     $this->team = new Team(null, $this->sport->getSportId(), $this->VALID_TEAMAPIID, "TeamCities2", "TeamName");
     $this->team->insert($this->getPDO());
     $this->team2 = new Team(null, $this->sport->getSportId(), $this->VALID_TEAMAPIID2, "TeamCity2", "TeamName2");
     $this->team2->insert($this->getPDO());
 }
Ejemplo n.º 2
0
 /**
  * test grabbing all Teams
  **/
 public function testGetAllValidTeams()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("team");
     // create a new Team and insert to into mySQL
     $team = new Team(null, $this->sport->getSportId(), $this->VALID_TEAMAPIID, $this->VALID_TEAMCITY, $this->VALID_TEAMNAME);
     $team->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $results = Team::getAllTeams($this->getPDO());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("team"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Sprots\\Team", $results);
     // grab the result from the array and validate it
     $pdoTeam = $results[0];
     $this->assertEquals($pdoTeam->getTeamSportId(), $this->sport->getSportId());
     $this->assertEquals($pdoTeam->getTeamApiId(), $this->VALID_TEAMAPIID);
     $this->assertEquals($pdoTeam->getTeamCity(), $this->VALID_TEAMCITY);
     $this->assertEquals($pdoTeam->getTeamName(), $this->VALID_TEAMNAME);
     //$this->assertEquals($pdoTeam->getTeamSportId(), $this->VALID_TEAMSPORTID);
 }