Skip to content

Commit

Permalink
phpunit: create test to cover get_quiz_users()
Browse files Browse the repository at this point in the history
  • Loading branch information
semteacher committed Nov 10, 2023
1 parent 98b2f71 commit e65376f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/mooduell_external_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,29 @@ public function test_get_game_data() {
$this->assertEquals(0, $games["quizzes"][0]["games"][0]["winnerid"]);
$this->assertEmpty($games["warnings"]);
}

/**
* Test get game data.
* @runInSeparateProcess
* @covers ::get_quiz_users
* @throws \coding_exception
* @throws \dml_exception
*/
public function test_get_quiz_users() {

list($duel1, $user1, $user2, $cmd1, $course) = $this->returntestdata();

$users = mod_mooduell_external::get_quiz_users($course->id, $cmd1->id);

// Check users.
$this->assertIsArray($users);
$this->assertEquals(2, count($users));
// TODO: no built-in methods to compare stdClass instances.
$this->assertEquals($user1->id, $users[1]->id);
$this->assertEquals($user1->username, $users[1]->username);
$this->assertEquals($user1->email, $users[1]->email);
$this->assertEquals($user2->id, $users[0]->id);
$this->assertEquals($user2->email, $users[0]->email);
$this->assertEquals($user2->username, $users[0]->username);
}
}

0 comments on commit e65376f

Please sign in to comment.