Ejemplo n.º 1
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.º 2
0
 /**
  * @param League $league
  * @param int $season
  *
  * @return Fixture[]
  */
 public function findByLeagueAndSeasonWithEvents(League $league, $season)
 {
     $qb = $this->_em->createQueryBuilder();
     $qb->select(array('f', 'e'));
     $qb->from('CoreBundle:Fixture', 'f');
     $qb->where('f.league = :league');
     $qb->setParameter('league', $league->getId());
     $qb->andWhere('f.season = :season');
     $qb->setParameter('season', $season);
     $qb->join('f.events', 'e');
     return $qb->getQuery()->getResult();
 }
Ejemplo n.º 3
0
 public function testGetPositionByTeam()
 {
     $league = new League();
     $team1 = new Team();
     $team1->setId(1);
     $team1->setPoints(1);
     $league->addTeam($team1);
     $team2 = new Team();
     $team2->setId(2);
     $team2->setPoints(3);
     $league->addTeam($team2);
     $this->assertEquals(1, $league->getPositionByTeam($team2));
     $this->assertEquals(2, $league->getPositionByTeam($team1));
 }
Ejemplo n.º 4
0
 /**
  * @param int $season
  *
  * @throws \Exception
  */
 public function createFinalPosition($season)
 {
     $finalPosition = new FinalPosition();
     $finalPosition->setTeam($this);
     $finalPosition->setSeason($season);
     $finalPosition->setLeague($this->league);
     $finalPosition->setPosition($this->league->getPositionByTeam($this));
     $this->finalPositions->add($finalPosition);
 }