Ejemplo n.º 1
0
 public function testEquals()
 {
     $player2 = new Player();
     $this->assertTrue($this->player->equals($player2));
     $this->player->setId(1);
     $player2->setId(1);
     $this->assertTrue($this->player->equals($player2));
     $this->player->setId(1);
     $player2->setId(2);
     $this->assertFalse($this->player->equals($player2));
 }
Ejemplo n.º 2
0
 public function testPlayerLinkFilter()
 {
     $player = new Player();
     $player->setId(1);
     $player->setName('Daniel Mecke');
     $this->assertEquals('<a href="generated_link">Daniel Mecke</a>', $this->linkExtension->playerLinkFilter($player));
 }
Ejemplo n.º 3
0
 public function testScorer()
 {
     $league = new League();
     $team1 = new Team();
     $team1->setId(1);
     $league->addTeam($team1);
     $player1 = new Player();
     $player1->setId(1);
     $player1->setTeam($team1);
     $team2 = new Team();
     $team2->setId(2);
     $league->addTeam($team2);
     $player2 = new Player();
     $player2->setId(2);
     $player2->setTeam($team2);
     $fixture = new Fixture();
     $fixture->setTeamHome($team1);
     $fixture->setTeamAway($team2);
     $league->addFixture($fixture);
     $fixture->addEvent(Event::createGoal($fixture, $team1, $player1, 1));
     $fixture->addEvent(Event::createGoal($fixture, $team1, $player1, 2));
     $fixture->addEvent(Event::createGoal($fixture, $team2, $player2, 3));
     $scorer = $this->leagueService->getScorer(array($fixture));
     $this->assertEquals($player1, $scorer[0]->getPlayer());
     $this->assertEquals($player2, $scorer[1]->getPlayer());
     $this->assertEquals(2, $scorer[0]->getGoals());
     $this->assertEquals(1, $scorer[1]->getGoals());
 }
Ejemplo n.º 4
0
 public function testAddAndGetByPlayer()
 {
     $scorerManager = new ScorerManager();
     $player1 = new Player();
     $player1->setId(1);
     $scorer = $scorerManager->addAndGetByPlayer($player1);
     $this->assertEquals($player1, $scorer->getPlayer());
     $player2 = new Player();
     $player2->setId(2);
     $scorer = $scorerManager->addAndGetByPlayer($player2);
     $this->assertEquals($player2, $scorer->getPlayer());
     $scorer = $scorerManager->addAndGetByPlayer($player1);
     $this->assertEquals($player1, $scorer->getPlayer());
 }
Ejemplo n.º 5
0
 public function testSelectBestFittingPlayer()
 {
     $team = new Team();
     $team->setId(1);
     $team->setMoney(10);
     $this->manager->setTeam($team);
     $player1 = new Player();
     $player1->setId(1);
     $player1->setTeam($team);
     $player1->setSkillDefense(10);
     $players = array($player1);
     $this->assertNull($this->manager->selectBestFittingPlayer($players));
     $player2 = new Player();
     $player2->setId(2);
     $player2->setSkillDefense(10);
     $players[] = $player2;
     $this->assertEquals($player2, $this->manager->selectBestFittingPlayer($players));
 }
Ejemplo n.º 6
0
 public function testLineup()
 {
     $player1 = new Player();
     $player1->setId(1);
     $player1->setSkillDefense(40);
     $player1->setSkillOffense(40);
     $this->team->addPlayer($player1);
     for ($i = 2; $i <= 12; $i++) {
         $player = new Player();
         $player->setId($i);
         $player->setSkillDefense(50);
         $player->setSkillOffense(50);
         $this->team->addPlayer($player);
     }
     $player2 = new Player();
     $player2->setId(13);
     $player2->setSkillDefense(40);
     $player2->setSkillOffense(40);
     $this->team->addPlayer($player2);
     $this->assertCount(11, $this->team->getLineup());
     $this->assertNotContains($player1, $this->team->getLineup());
     $this->assertNotContains($player2, $this->team->getLineup());
 }