Ejemplo n.º 1
0
 /**
  * Test unreport() on a match that is not allowed
  *  to be unreported - because either team has 
  *  reported other wins since
  */
 public function test_unreport_bracket_invalid()
 {
     $this->assertTrue($this->object->set_winner($this->object->team()));
     $this->assertSave($this->object->report());
     //Game team() another win, but we may have to report other matches until he has an opponent
     while (is_null($this->object->winner->match())) {
         $this->assertInstanceOf('BBMatch', $match = $this->object->tournament->open_matches[0]);
         $this->assertTrue($match->set_winner($match->team2()));
         $this->assertSave($match->report());
     }
     //should have an open match now - report it
     $this->assertInstanceOf('BBMatch', $match = $this->object->winner->match());
     $this->assertTrue($match->set_winner($this->object->winner()));
     $this->assertSave($match->report());
     //now that winner() has had reported beyond $this->object, we should no longer be allowed to unreport it
     $this->assertFalse($this->object->unreport());
 }
Ejemplo n.º 2
0
 /**
  * If a match is reported, this method can be called to clear any
  *		cached opponent results this team may have saved
  * 
  * @return void
  */
 public function reset_opponents()
 {
     //If the current match was reported, save it as the last_match
     $this->last_match =& $this->bb->ref(null);
     if (!is_null($this->match)) {
         if ($this->match->team_in_match($this)) {
             if (!$this->match->is_new()) {
                 $this->last_match = $this->match;
             }
         }
     }
     //Assign to a new reference, so that we're not changing the original team value in Tournament::$teams
     $this->opponent =& $this->bb->ref(null);
     $this->match =& $this->bb->ref(null);
     $this->eliminated_by =& $this->bb->ref(null);
     //Clear all cache for this team's ID
     $this->clear_id_cache();
 }
Ejemplo n.º 3
0
 /**
  * These objects aren't cached directly, so we pass
  *  attempts to clear object cache directly to the parent match
  * {@inheritdoc}
  */
 public function clear_id_cache($svc = null)
 {
     if (!is_null($this->match)) {
         $this->match->clear_id_cache($svc);
     }
 }
Ejemplo n.º 4
0
 /**
  * Create a new match, or validate an existing one<br /><br />
  *
  * <br /><br />
  * Can be used 2 ways:<br /><br />
  *  <b>1)</b> Returns the open BBMatch object where the $team1 and $team2 meet,<br />
  *      it will try to return an unreported BBMatch from the open_matches array
  *
  * <br />
  *  <b>2)</b> Verifies that the provided BBMatch object is valid / part of this tournament
  *      In which case, we return the valid most up-to-date object instance possible, even if the only thing that matches
  *      from your BBMatch, is the id
  * 
  * 
  * @param int|BBTeam|BBMatch        $team1
  * <b>Possible values:</b>
  * - The <b>integer</b> ID the either team in the match
  * - The {@link BBTeam} object of either team in the match
  * - A {@link BBMatch} object - to verify that it exists and to fetch the latest and created instance, stored in our open matches array
  *  
  * @param int|BBTeam                $team2
  * <b>Possible values:</b>
  * - The <b>integer</b> ID the either team in the match (can't be the same as <var>$team1</var>)
  * - The {@link BBTeam} object of either team in the match (can't be the same as <var>$team1</var>)
  * 
  * @return BBMatch|null
  */
 public function &match($team1 = null, $team2 = null)
 {
     //If given BBMatch, verify or return null
     if ($team1 instanceof BBMatch) {
         //if unreported - check it against our open_matches list
         if ($team1->is_new()) {
             return $this->get_child($team1, $this->open_matches());
         } else {
             //Cast as a BBMatch
             $match = $this->bb->match($team1->id);
             $match->init($this);
             if ($match->tourney_id != $this->id) {
                 return $this->bb->ref(null);
             }
             //success!
             return $match;
         }
     }
     //If team1 is a number, and team 2 is null, treat team1 as a tourney_match_id
     if (is_numeric($team1) && is_null($team2)) {
         $match = $this->bb->match($team1);
         $match->init($this);
         return $match->load();
     }
     //Let open_match() take over
     return $this->open_match($team1, $team2);
 }