/** * Tests if the getPlayers method * has the expected interactions. */ public function testServiceGetPlayersWithExpectedFlow() { $tournamentID = 1; $fakeTournament = m::mock('App\\Models\\Tournament'); $fakePlayers = [m::mock('App\\Models\\Player')]; $this->fakeTournamentsRepo->shouldReceive('getTournament')->withArgs([$tournamentID])->once()->andReturn($fakeTournament); $this->fakePlayersRepo->shouldReceive('getAllPlayers')->withArgs([m::type('App\\Models\\Tournament')])->once()->andReturn($fakePlayers); $players = $this->service->getPlayers($tournamentID); $this->assertEquals($players, $fakePlayers); }
/** * Calculates the number of rounds * given a number of players. * * @param int $tournamentID * * @return int */ public function roundsCount($tournamentID) { $playersCount = $this->playersService->getPlayersCount($tournamentID); return floor(log($playersCount, 2)); }