/** * Test reporting wins, by fetching open_match objects from a group-rounds draw */ public function test_report_from_groups() { $this->get_tournament_with_open_matches(true); $this->assertTrue(is_object($groups = $this->object->groups())); //Grab the first match in group A $this->assertInstanceOf('BBMatch', $match = $groups->a[0][0]->match); //Grab winner / loser objects, verify they're matching up with values in the draw $this->assertInstanceOf('BBTeam', $winner = $match->team()); $this->assertInstanceOf('BBTeam', $loser = $match->team2()); $this->assertEquals($groups->a[0][0]->team, $winner); $this->assertEquals($groups->a[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, $groups->a[0][0]->match->id); }