/** * Test reporting wins, by fetching open_match objects from a bracket draw */ public function test_report_from_brackets() { $this->get_tournament_with_open_matches(); $this->assertTrue(is_object($brackets = $this->object->brackets())); //By default, we won't have any freewins - so just grab the first match in the WB $this->assertInstanceOf('BBMatch', $match = $brackets->winners[0][0]->match); //Grab winner / loser objects, verify they're matching up with value sin the bracket draw $this->assertInstanceOf('BBTeam', $winner = $match->team()); $this->assertInstanceOf('BBTeam', $loser = $match->team2()); $this->assertEquals($brackets->winners[0][0]->team, $winner); $this->assertEquals($brackets->winners[0][0]->opponent, $loser); //Report the match $this->assertTrue($match->set_winner($winner)); //GOGOGO! $this->assertSave($match->report()); //The original match object should have updated itself $this->assertEquals($match->id, $brackets->winners[0][0]->match->id); }