/** * 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, "sportLeague", "sportLeague2", "SportName", "SportName2"); $this->sport->insert($this->getPDO()); }
/** * 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()); }
/** * 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()); }
/** * Test grabbing all of Names **/ public function testGetAllValidSportNames() { // 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::getAllSportNames($this->getPDO()); $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->getSportName(), $this->VALID_SPORTNAME); }