/**
  * Tests if the pairings array returns
  * the correct pairings count.
  */
 public function testPairingsCorrectArrayReturned()
 {
     $tournamentID = 1;
     $fakePlayers = [0 => getFakePlayers(11)];
     $expectedPairingsCount = 6;
     \Swiss::shouldReceive('roundsCount')->with($tournamentID)->once()->andReturn(1);
     $result = $this->pairingsHandler->ranked($fakePlayers, $tournamentID);
     $this->assertCount(6, $result);
 }
 /**
  * Generates ranked pairings form the given
  * array of players.
  *
  * @param array $players
  * @param int $tournamentID
  *
  * @return array
  */
 public function ranked($players, $tournamentID)
 {
     $rankedPairings = [];
     $numberOfRounds = \Swiss::roundsCount($tournamentID);
     for ($index = 0; $index < $numberOfRounds; $index++) {
         if (!array_key_exists($index, $players)) {
             continue;
         }
         $pairingsForRound = $this->getRandomPairings($players[$index]);
         $rankedPairings = array_merge($rankedPairings, $pairingsForRound);
     }
     return $rankedPairings;
 }