Esempio n. 1
0
 /**
  * test grabbing a TeamStatistic that does not exist
  **/
 public function testGetInvalidTeamStatistic()
 {
     // count the number of rows and save it for later
     $numRows = $this->getConnection()->getRowCount("teamStatistic");
     // create a new TeamStatistics and insert to into mySQL
     $teamStatistic = new TeamStatistic($this->game->getGameId(), $this->team->getTeamId(), $this->statistic->getStatisticId(), $this->VALID_TEAMSTATISTICVALUE);
     $teamStatistic->insert($this->getPDO());
     // grab the data from mySQL and enforce the fields match our expectations
     $results = TeamStatistic::getAllTeamStatistics($this->getPDO());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("teamStatistic"));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Sprots\\TeamStatistic", $results);
     // grab the result from the array and validate it
     $pdoTeamStatistic = $results[0];
     $this->assertEquals($pdoTeamStatistic->getTeamStatisticGameId(), $this->game->getGameId());
     $this->assertEquals($pdoTeamStatistic->getTeamStatisticTeamId(), $this->team->getTeamId());
     $this->assertEquals($pdoTeamStatistic->getTeamStatisticStatisticId(), $this->statistic->getStatisticId());
     $this->assertEquals($pdoTeamStatistic->getTeamStatisticValue(), $this->VALID_TEAMSTATISTICVALUE);
 }
Esempio n. 2
0
 /**
  * test grabbing Game by time
  */
 public function testGetGameByGameTime()
 {
     // count the number of row and save
     $numRows = $this->getConnection()->getRowCount("game");
     //create a new Game and insert into mySql
     $game = new Game(null, $this->team->getTeamId(), $this->team2->getTeamId(), $this->VALID_GAMETIME);
     $game->insert($this->getPDO());
     //grab data from mySQL and enforce the fields to match
     $pdoGame = Game::getGameByGameTime($this->getPDO(), $game->getGameId());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("game"));
     $this->assertEquals($pdoGame->getGameFirstTeamId(), $this->team->getTeamId());
     $this->assertEquals($pdoGame->getGameTime(), $this->VALID_GAMETIME);
 }