コード例 #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 playerStatistic
     $this->sport = new Sport(null, "sportName", "sportLeague");
     $this->sport->insert($this->getPDO());
     //create and insert a team to own the test playerStatistic
     $this->team = new Team(null, $this->sport->getSportId(), $this->VALID_TEAMAPIID, "TeamCity", "TeamName");
     $this->team->insert($this->getPDO());
     $this->team2 = new Team(null, $this->sport->getSportId(), $this->VALID_TEAMAPIID2, "TeamCity2", "TeamName2");
     $this->team2->insert($this->getPDO());
     //create and insert a Game to own the test playerStatistic
     $this->game = new Game(null, $this->team->getTeamId(), $this->team2->getTeamId(), "2015-03-23 15:23:04");
     $this->game->insert($this->getPDO());
     // calculate the date (same as unit test)
     $this->VALID_GAMETIME = \DateTime::createFromFormat("Y-m-d H:i:s", "2015-03-23 15:23:04");
     $this->VALID_GAMETIME2 = \DateTime::createFromFormat("Y-m-d H:i:s", "2015-03-23 16:23:04");
     //create and insert a Player to own the test playerStatistic
     // int $newPlayerId = null, int $newPlayerApiId, int $newPlayerTeamId, int $newPlayerSportId, string $newPlayerName
     $this->player = new Player(null, $this->VALID_PLAYERAPIID, $this->team->getTeamId(), $this->sport->getSportId(), "PlayerName");
     $this->player->insert($this->getPDO());
     $this->player2 = new Player(null, $this->VALID_PLAYERAPIID2, $this->team2->getTeamId(), $this->sport->getSportId(), "PlayerNames");
     $this->player2->insert($this->getPDO());
     //create and insert a Statistic to own the test playerStatistic
     $this->statistic = new Statistic(null, "statisticName");
     $this->statistic->insert($this->getPDO());
 }
コード例 #2
0
 public function testGetAllValidStatistic()
 {
     //count the numbers of rows and save
     $numRows = $this->getConnection()->getRowCount("statistic");
     //create a new Game and insert into mySQL
     $statistic = new Statistic(null, $this->VALID_STATISTICNAME);
     $statistic->insert($this->getPDO());
     //grab the data from mySQL and enforce the fields match
     $results = Statistic::getAllStatistic($this->getPDO());
     $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount('statistic'));
     $this->assertCount(1, $results);
     $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Sprots\\Statistic", $results);
     // grab the result from the array and validate it
     $pdoStatistic = $results[0];
     $this->assertEquals($pdoStatistic->getStatisticName(), $this->VALID_STATISTICNAME);
 }