<commit_before><?php

namespace Edu\Cnm\Sprots\Test;

use Edu\Cnm\Sprots\TeamStatistic;
use Edu\Cnm\Sprots\Sport;
use Edu\Cnm\Sprots\Game;
use Edu\Cnm\Sprots\Team;
use Edu\Cnm\Sprots\Statistic;






// grab the project test parameters
require_once("SprotsTest.php");

// grab the class under scrutiny
require_once(dirname(__DIR__) . "/public_html/php/classes/autoload.php");

/**
 * Full PHPUnit test for the TeamStatistic class
 *
 * This is a complete PHPUnit test of the TeamStatistic class. It is complete because *ALL* mySQL/PDO enabled methods
 * are tested for both invalid and valid inputs.
 *
 * @see
 * @author <NAME> <<EMAIL>>
 **/

class TeamStatisticTest extends SprotsTest {

	/**
	 * timestamp of the Game; this starts as null and is assigned later
	 * @var \DateTime $VALID_GAMETIME
	 */
	protected $VALID_GAMETIME = "2015-03-23 14:20:04";
	/**
	 * timestamp of the Game; this starts as null and is assigned later
	 * @var \DateTime $VALID_GAMETIME
	 */
	protected $VALID_GAMETIME2 = "2015-02-23 14:23:02";

	/**
	 * content of Team
	 * @var int $VALID_TEAMAPIID
	 */
	protected $VALID_TEAMAPIID = 42;

	/**
	 * content of Team
	 * @var int $VALID_TEAMAPIID2
	 */
	protected $VALID_TEAMAPIID2 = 64;

	/**
	 * content of Team
	 * @var int $VALID_TEAMAPIID
	 */
	protected $VALID_TEAMCITY = "Nashville";

	/**
	 * content for teamName
	 * @var string $VALID_TEAMNAME
	 */

	protected $VALID_TEAMNAME = "Titans";

	/**
	 * content for teamName
	 * @var string $VALID_TEAMNAME2
	 */
	protected $VALID_TEAMNAME2 = "Cowboys";

	/**
	 * is unique to Team and Game Played
	 * @var string $VALID_TEAMSTATISTICGAMEID
	 */
	protected $VALID_TEAMSTATISTICGAMEID = null;

	/**
	 * content of updated TeamStatisticGameId
	 * @var string $VALID_TEAMSTATISTICGAMEID2
	 */
	protected $VALID_TEAMSTATISTICGAMEID2 = null;

	/**
	 * is unique to Statistic and Team
	 * @var string $VALID_TEAMSTATISTICSTATISTICID
	 */
	protected $VALID_TEAMSTATISTICSTATISTICID = null;

	/**
	 * content of the updated statistic and team
	 * @var string $VALID_TEAMSTATISTICSTATISTICID2
	 **/
	protected $VALID_TEAMSTATISTICSTATISTICID2 = "Touchdowns";

	/**
	 * Id of the TeamStatistic
	 * @var string $VALID_TEAMSTATISTICTEAMID
	 **/
	protected $VALID_TEAMSTATISTICTEAMID = null;

	/**
	 * content of the updated teamStatisticId
	 * @var string $VALID_TEAMSTATISTICTEAMID2
	 **/
	protected $VALID_TEAMSTATISTICTEAMID2 = null;

	/**
	 * is unique value of the teamStatistic
	 * @var string $VALID_TEAMSTATISTICVALUE
	 **/
	protected $VALID_TEAMSTATISTICVALUE = null;

	///**
	// * content of the updated teamStatisticValue
	// * @var string $VALID_TEAMSTATISTICVALUE2
	// **/
	//protected $VALID_TEAMSTATISTICVALUE2 = null;

	/**
	 * Game that PlayerStatistic derived from
	 * @var Game $game
	 */
	protected $game = null;

	/**
	 * Sport that the Player is playing
	 * @var Sport $sport
	 */
	protected $sport = null;

	/**
	 * Statistic that is associated with the player
	 * @var Statistic $statistic
	 */
	protected $statistic = null;

	/**
	 * Player that the Stat is associated with
	 * @var Player $player
	 */
	protected $team = null;
	/**
	 * Player that the Stat is associated with
	 * @var Player $player2
	 */
	protected $team2 = null;

	/**
	 * 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 sport to own the test teamstatistic
		$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 Statistic to own the test playerStatistic
		$this->statistic = new Statistic(null, $this->team->getTeamId(), "statisticName");
		$this->statistic->insert($this->getPDO());

		//create and insert a Game to own the test playerStatistic
		$this->game = new Game(null,$this->team->getTeamId(), $this->team2->getTeamId(), $this->VALID_GAMETIME);
		$this->game->insert($this->getPDO());

	}

	/**
	 * test inserting a valid TeamStatistic and verify that the actual mySQL data matches
	 **/
	public function testInsertValidTeamStatistic() {
		// count the number of rows and save it for later
		$numRows = $this->getConnection()->getRowCount("teamStatistic");

		// create a new TeamStatistic and insert to into mySQL
		$teamStatistic = new TeamStatistic($this->statistic->getStatisticId(), $this->team->getTeamId(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$teamStatistic->insert($this->getPDO());

		// grab the data from mySQL and enforce the fields match our expectations
		$pdoTeamStatistic = TeamStatistic::getTeamStatisticByTeamStatisticId($this->getPDO(), $teamStatistic->getTeamStatisticId());
		$this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("teamStatistic"));
		$this->assertEquals($this->team->getTeamId(), $pdoTeamStatistic->getTeamId());
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticTeamId(), $this->VALID_TEAMSTATISTICTEAMID);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticValue(), $this->VALID_TEAMSTATISTICVALUE);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticStatisticId(), $this->VALID_TEAMSTATISTICSTATISTICID);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticGameId(), $this->VALID_TEAMSTATISTICGAMEID);
	}


	/**
	 * test inserting a Statistic that already exists
	 *
	 * @expectedException \PDOException
	 **/
	public function testInsertInvalidTeamStatistic() {
		// create a teamStatistic with a non null TeamStatisticId and watch it fail
		$teamStatistic = new TeamStatistic(SprotsTest::INVALID_KEY, $this->team->getTeamId(), $this->VALID_TEAMSTATISTICTEAMID, SprotsTest::INVALID_KEY, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$teamStatistic->insert($this->getPDO());
	}

	/**
	 * test inserting a teamStatistic, editing it, and then updating it
	 **/
	public function testUpdateValidTeamStatistic() {
		// count the number of rows and save it for later
		$numRows = $this->getConnection()->getRowCount("teamStatistic");

		// create a new TeamStatistic and insert to into mySQL
		$teamStatistic = new TeamStatistic(null, $this->team->getTeamId(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$teamStatistic->insert($this->getPDO());

		// edit the TeamStatisitc and update it in mySQL
		$teamStatistic->setTeamStatisitcContent($this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$teamStatistic->update($this->getPDO());

		// grab the data from mySQL and enforce the fields match our expectations
		$pdoTeamStatistic = TeamStatistic::getTeamStatisticByTeamStatisticId($this->getPDO(), $teamStatistic->getTeamId());
		$this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("teamStatistic"));
		$this->assertEquals($pdoTeamStatistic->getTeamId(), $this->team->getTeamId());
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticContent(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticTeamId(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticValue(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticStatisticId(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$this->assertEqulas($pdoTeamStatistic->getTeamStatisticGameId(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);<commit_msg>edited variables for FavoritePlayerTest class https://app.asana.com/0/84113659891109/90739360432007<commit_after><?php

namespace Edu\Cnm\Sprots\Test;

use Edu\Cnm\Sprots\TeamStatistic;
use Edu\Cnm\Sprots\Sport;
use Edu\Cnm\Sprots\Game;
use Edu\Cnm\Sprots\Team;
use Edu\Cnm\Sprots\Statistic;






// grab the project test parameters
require_once("SprotsTest.php");

// grab the class under scrutiny
require_once(dirname(__DIR__) . "/public_html/php/classes/autoload.php");

/**
 * Full PHPUnit test for the TeamStatistic class
 *
 * This is a complete PHPUnit test of the TeamStatistic class. It is complete because *ALL* mySQL/PDO enabled methods
 * are tested for both invalid and valid inputs.
 *
 * @see
 * @author <NAME> <<EMAIL>>
 **/

class TeamStatisticTest extends SprotsTest {

	/**
	 * timestamp of the Game; this starts as null and is assigned later
	 * @var \DateTime $VALID_GAMETIME
	 */
	protected $VALID_GAMETIME = "2015-03-23 14:20:04";
	/**
	 * timestamp of the Game; this starts as null and is assigned later
	 * @var \DateTime $VALID_GAMETIME
	 */
	protected $VALID_GAMETIME2 = "2015-02-23 14:23:02";

	/**
	 * content of Team
	 * @var int $VALID_TEAMAPIID
	 */
	protected $VALID_TEAMAPIID = 42;

	/**
	 * content of Team
	 * @var int $VALID_TEAMAPIID2
	 */
	protected $VALID_TEAMAPIID2 = 64;

	/**
	 * content of Team
	 * @var int $VALID_TEAMAPIID
	 */
	protected $VALID_TEAMCITY = "Nashville";

	/**
	 * content for teamName
	 * @var string $VALID_TEAMNAME
	 */

	protected $VALID_TEAMNAME = "Titans";

	/**
	 * content for teamName
	 * @var string $VALID_TEAMNAME2
	 */
	protected $VALID_TEAMNAME2 = "Cowboys";

	/**
	 * is unique to Team and Game Played
	 * @var string $VALID_TEAMSTATISTICGAMEID
	 */
	protected $VALID_TEAMSTATISTICGAMEID = null;

	/**
	 * content of updated TeamStatisticGameId
	 * @var string $VALID_TEAMSTATISTICGAMEID2
	 */
	protected $VALID_TEAMSTATISTICGAMEID2 = null;

	/**
	 * is unique to Statistic and Team
	 * @var string $VALID_TEAMSTATISTICSTATISTICID
	 */
	protected $VALID_TEAMSTATISTICSTATISTICID = null;

	/**
	 * content of the updated statistic and team
	 * @var string $VALID_TEAMSTATISTICSTATISTICID2
	 **/
	protected $VALID_TEAMSTATISTICSTATISTICID2 = "Touchdowns";

	/**
	 * Id of the TeamStatistic
	 * @var string $VALID_TEAMSTATISTICTEAMID
	 **/
	protected $VALID_TEAMSTATISTICTEAMID = null;

	/**
	 * content of the updated teamStatisticId
	 * @var string $VALID_TEAMSTATISTICTEAMID2
	 **/
	protected $VALID_TEAMSTATISTICTEAMID2 = null;

	/**
	 * is unique value of the teamStatistic
	 * @var string $VALID_TEAMSTATISTICVALUE
	 **/
	protected $VALID_TEAMSTATISTICVALUE = null;

	///**
	// * content of the updated teamStatisticValue
	// * @var string $VALID_TEAMSTATISTICVALUE2
	// **/
	//protected $VALID_TEAMSTATISTICVALUE2 = null;

	/**
	 * Game that PlayerStatistic derived from
	 * @var Game $game
	 */
	protected $game = null;

	/**
	 * Sport that the Player is playing
	 * @var Sport $sport
	 */
	protected $sport = null;

	/**
	 * Statistic that is associated with the player
	 * @var Statistic $statistic
	 */
	protected $statistic = null;

	/**
	 * Player that the Stat is associated with
	 * @var Player $player
	 */
	protected $team = null;
	/**
	 * Player that the Stat is associated with
	 * @var Player $player2
	 */
	protected $team2 = null;

	/**
	 * 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 sport to own the test teamstatistic
		$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 Statistic to own the test playerStatistic
		$this->statistic = new Statistic(null, $this->team->getTeamId(), "statisticName");
		$this->statistic->insert($this->getPDO());

		//create and insert a Game to own the test playerStatistic
		$this->game = new Game(null,$this->team->getTeamId(), $this->team2->getTeamId(), $this->VALID_GAMETIME);
		$this->game->insert($this->getPDO());

	}

	/**
	 * test inserting a valid TeamStatistic and verify that the actual mySQL data matches
	 **/
	public function testInsertValidTeamStatistic() {
		// count the number of rows and save it for later
		$numRows = $this->getConnection()->getRowCount("teamStatistic");

		// create a new TeamStatistic and insert to into mySQL
		$teamStatistic = new TeamStatistic($this->statistic->getStatisticId(), $this->team->getTeamId(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$teamStatistic->insert($this->getPDO());

		// grab the data from mySQL and enforce the fields match our expectations
		$pdoTeamStatistic = TeamStatistic::getTeamStatisticByTeamStatisticId($this->getPDO(), $teamStatistic->getTeamStatisticId());
		$this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("teamStatistic"));
		$this->assertEquals($this->team->getTeamId(), $pdoTeamStatistic->getTeamId());
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticTeamId(), $this->VALID_TEAMSTATISTICTEAMID);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticValue(), $this->VALID_TEAMSTATISTICVALUE);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticStatisticId(), $this->VALID_TEAMSTATISTICSTATISTICID);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticGameId(), $this->VALID_TEAMSTATISTICGAMEID);
	}


	/**
	 * test inserting a Statistic that already exists
	 *
	 * @expectedException \PDOException
	 **/
	public function testInsertInvalidTeamStatistic() {
		// create a teamStatistic with a non null TeamStatisticId and watch it fail
		$teamStatistic = new TeamStatistic(SprotsTest::INVALID_KEY, $this->team->getTeamId(), SprotsTest::INVALID_KEY, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$teamStatistic->insert($this->getPDO());
	}

	/**
	 * test inserting a teamStatistic, editing it, and then updating it
	 **/
	public function testUpdateValidTeamStatistic() {
		// count the number of rows and save it for later
		$numRows = $this->getConnection()->getRowCount("teamStatistic");

		// create a new TeamStatistic and insert to into mySQL
		$teamStatistic = new TeamStatistic(null, $this->team->getTeamId(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$teamStatistic->insert($this->getPDO());

		// edit the TeamStatisitc and update it in mySQL
		$teamStatistic->setTeamStatisitcContent($this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$teamStatistic->update($this->getPDO());

		// grab the data from mySQL and enforce the fields match our expectations
		$pdoTeamStatistic = TeamStatistic::getTeamStatisticByTeamStatisticId($this->getPDO(), $teamStatistic->getTeamId());
		$this->assertEquals($numRows + 1, $this->getConnection()->getRowCount("teamStatistic"));
		$this->assertEquals($pdoTeamStatistic->getTeamId(), $this->team->getTeamId());
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticContent(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticTeamId(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticValue(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$this->assertEquals($pdoTeamStatistic->getTeamStatisticStatisticId(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
		$this->assertEqulas($pdoTeamStatistic->getTeamStatisticGameId(), $this->VALID_TEAMSTATISTICTEAMID, $this->VALID_TEAMSTATISTICVALUE, $this->VALID_TEAMSTATISTICSTATISTICID, $this->VALID_TEAMSTATISTICGAMEID);
{'fraction_non_alphanumeric': 0.13043732802529126, 'fraction_numerical': 0.008137696856155962, 'mean_word_length': 5.2548517026730135, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 267, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4862458', 'n_tokens_mistral': 6017, 'n_tokens_neox': 5619, 'n_words': 1212}