コード例 #1
0
 /**
  * Tests the GetCount method on the Players
  * service for a given Tournament.
  */
 public function testServiceGetCountWithExpectedMethodFlow()
 {
     $count = 10;
     $tournamentID = 1;
     $fakeTournament = m::mock('App\\Models\\Tournament');
     $this->fakeTournamentsRepo->shouldReceive('getTournament')->withArgs(array($tournamentID))->once()->andReturn($fakeTournament);
     $this->fakePlayersRepo->shouldReceive('getCount')->withArgs(array(m::type('App\\Models\\Tournament')))->once()->andReturn($count);
     $returnedCount = $this->service->getPlayersCount($tournamentID);
     $this->assertEquals($count, $returnedCount);
 }
コード例 #2
0
 /**
  * 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));
 }