/** * test grabbing a PlayerStatistic that does not exist **/ public function testGetInvalidPlayerStatistic() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("playerStatistic"); // create a new PlayerStatistics and insert to into mySQL $playerStatistic = new PlayerStatistic($this->game->getGameId(), $this->player->getPlayerID(), $this->team->getTeamId(), $this->statistic->getStatisticId(), $this->VALID_PLAYERSTATISTICVALUE); $playerStatistic->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $results = PlayerStatistic::getAllPlayerStatistics($this->getPDO()); $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("playerStatistic")); $this->assertCount(1, $results); $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Sprots\\PlayerStatistic", $results); // grab the result from the array and validate it $pdoPlayerStatistic = $results[0]; $this->assertEquals($pdoPlayerStatistic->getPlayerStatisticGameId(), $this->game->getGameId()); $this->assertEquals($pdoPlayerStatistic->getPlayerStatisticPlayerId(), $this->player->getPlayerId()); $this->assertEquals($pdoPlayerStatistic->getPlayerStatisticTeamId(), $this->team->getTeamId()); $this->assertEquals($pdoPlayerStatistic->getPlayerStatisticStatisticId(), $this->statistic->getStatisticId()); $this->assertEquals($pdoPlayerStatistic->getPlayerStatisticValue(), $this->VALID_PLAYERSTATISTICVALUE); }
/** * test grabbing all players **/ public function testGetAllValidPlayers() { // count the number of rows and save it for later $numRows = $this->getConnection()->getRowCount("player"); // create a new player and insert to into mySQL $player = new Player(null, $this->VALID_PLAYERAPIID, $this->team->getTeamId(), $this->sport->getSportId(), $this->VALID_PLAYERNAME); $player->insert($this->getPDO()); // grab the data from mySQL and enforce the fields match our expectations $results = Player::getAllPlayers($this->getPDO()); $this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("player")); $this->assertCount(1, $results); $this->assertContainsOnlyInstancesOf("Edu\\Cnm\\Sprots\\Player", $results); // grab the result from the array and validate it $pdoPlayer = $results[0]; $this->assertEquals($pdoPlayer->getPlayerId(), $player->getPlayerId()); $this->assertEquals($pdoPlayer->getPlayerApiId(), $this->VALID_PLAYERAPIID); $this->assertEquals($pdoPlayer->getPlayerTeamId(), $this->team->getTeamId()); $this->assertEquals($pdoPlayer->getPlayerSportId(), $this->sport->getSportId()); $this->assertEquals($pdoPlayer->getPlayerName(), $this->VALID_PLAYERNAME); }