예제 #1
0
 /**
  * Removes maps from the map pool, using map_ids
  *
  * @covers BBTournament::remove_map
  */
 public function test_remove_id()
 {
     $this->test_add_id();
     $this->AssertTrue($this->object->remove_map(125));
     $this->assertArraySize($this->object->map_pool, 0);
     $this->assertSave($this->object->save());
     $this->assertArraySize($this->object->map_pool, 0);
     $fresh = $this->bb->tournament($this->object->id);
     $this->assertArraySize($fresh->map_pool, 0);
 }
 /**
  * Test deleting teams to make sure they are removed from the tournament correctly afterwards
  */
 public function test_remove_teams()
 {
     $this->get_tournament_inactive();
     //Add teams that will be saved before removal
     for ($x = 0; $x < 8; $x++) {
         $this->object->team->confirm();
     }
     //Should now have 8 teams with ids
     $this->assertSave($this->object->save());
     $this->assertArraySize($this->object->teams(), 8);
     foreach ($this->object->teams as $team) {
         $this->assertID($team->id);
     }
     //Add teams that won't have ids when removed
     for ($x = 0; $x < 8; $x++) {
         $this->object->team->ban();
     }
     $this->assertArraySize($this->object->teams(), 16);
     $this->assertArraySize($this->object->confirmed_teams(), 8);
     $this->assertArraySize($this->object->banned_teams(), 8);
     //Deleted!!!
     foreach ($this->object->teams as $team) {
         $team->delete();
     }
     $this->assertArraySize($this->object->teams(), 0);
     $this->assertArraySize($this->object->confirmed_teams(), 0);
     $this->assertArraySize($this->object->banned_teams(), 0);
     //Check externally
     $this->AssertTournamentValueExternally($this->object, 'teams', array());
 }
예제 #3
0
 /**
  * Adds 8 confirmed teams to the tournament reference
  * @param BBTournament  $tournament
  * @param boolean       $save
  */
 protected function add_tournament_teams(BBTournament &$tournament, $save = true)
 {
     //Must start with an ID
     $this->assertSave($tournament->save());
     //Add 8 players
     $countries = array('USA', 'GBR', 'USA', 'NOR', 'JPN', 'SWE', 'NOR', 'GBR');
     for ($x = 0; $x < 8; $x++) {
         $team = $tournament->team();
         $team->confirm();
         $team->display_name = 'Player ' . ($x + 1);
         $team->country_code = $countries[$x];
     }
     if ($save) {
         $this->assertTrue($tournament->save_teams());
     }
 }