public function testTeamLinkFilter() { $team = new Team(); $team->setId(1); $team->setName('Team A'); $this->assertEquals('<a href="generated_link">Team A</a>', $this->linkExtension->teamLinkFilter($team)); }
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()); }
/** * @param string $name * @param int $money */ private function createTeam($name, $money) { $team = new Team(); $team->setName($name); $team->setMoney($money); /** @var League $league */ $league = $this->getReference('league1'); $team->setLeague($league); $this->manager->persist($team); $this->addReference('team' . $this->teamCounter++, $team); }
public function testGetGoalEvents() { $team1 = new Team(); $team1->setId(1); $team2 = new Team(); $team2->setId(2); $fixture = new Fixture(); $fixture->setTeamHome($team1); $fixture->setTeamAway($team2); $fixture->addEvent(Event::createGoal($fixture, $team1, new Player(), 1)); $fixture->addEvent(Event::createChance($fixture, $team2, new Player(), 2)); $this->assertCount(1, $fixture->getGoalEvents()); }
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)); }
/** * @param Team $team */ public function setTeam(Team $team) { $this->team = $team; if (null === $this->team->getManager()) { $this->team->setManager($this); } }
/** * @param Team $team */ public function setTeam(Team $team) { if (null === $this->team || !$this->team->equals($team)) { $this->team = $team; $this->team->addPlayer($this); } }
public function testSendMoney() { $this->team->setMoney(1000); $targetTeam = new Team(); $this->team->sendMoney($targetTeam, 500); $this->assertEquals(500, $this->team->getMoney()); $this->assertEquals(500, $targetTeam->getMoney()); }
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)); }
/** * @param Team $team * @param int $amount */ public function sendMoney(Team $team, $amount) { $this->subtractAmount($amount); $team->addMoney($amount); }
/** * @return bool */ public function isSellDenied() { return $this->originTeam->getManager()->isSellDenied($this->player); }
/** * @param int $id * * @return Team */ private function createTeam($id) { $team = new Team(); $team->setId($id); $team->addPlayer(new Player()); return $team; }
/** * @param Team $team * * @return string */ public function teamLinkFilter(Team $team) { return '<a href="' . $this->router->generate('profile_team', array('id' => $team->getId())) . '">' . $team->getName() . '</a>'; }
/** * @param int $money * * @return Team */ private function createTeam($money) { $team = new Team(); $team->setMoney($money); for ($i = 1; $i <= 20; $i++) { $team->addPlayer(new Player()); } return $team; }