Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 14: Fix failing phpunit due to unpredictable sorting #53

Open
wants to merge 1 commit into
base: MOODLE_39_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function block_grade_me_query_prefix() {
*/
function block_grade_me_query_suffix($mod) {
$query = " AND bgm.courseid = ?
AND bgm.itemmodule = '$mod'";
AND bgm.itemmodule = '$mod' ORDER BY submissionid ASC";
return $query;
}

Expand Down
8 changes: 3 additions & 5 deletions tests/grade_me_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ public function test_query_prefix() {
*/
public function test_query_suffix() {
$expected = " AND bgm.courseid = ?
AND bgm.itemmodule = 'assign'";
AND bgm.itemmodule = 'assign' ORDER BY submissionid ASC";
$this->assertEquals($expected, block_grade_me_query_suffix('assign'));
}

Expand Down Expand Up @@ -357,8 +357,7 @@ public function test_query_quiz($datafile, $expected) {
$this->update_quiz_ngrade();

list($sql, $params) = block_grade_me_query_quiz(array($users[0]->id));
$sql = block_grade_me_query_prefix().$sql.block_grade_me_query_suffix('quiz') .
' ORDER BY submissionid ASC';
$sql = block_grade_me_query_prefix().$sql.block_grade_me_query_suffix('quiz');

$actual = array();
$result = $DB->get_recordset_sql($sql, array($params[0], $courses[0]->id));
Expand Down Expand Up @@ -508,8 +507,7 @@ public function standard_query_tests($datafile, $expected, $suffix) {

$dbfunction = 'block_grade_me_query_'.$suffix;
list($sql, $params) = $dbfunction(array($users[0]->id));
$sql = block_grade_me_query_prefix().$sql.block_grade_me_query_suffix($suffix) .
' ORDER BY submissionid ASC';
$sql = block_grade_me_query_prefix().$sql.block_grade_me_query_suffix($suffix);

$actual = array();
$result = $DB->get_recordset_sql($sql, array($params[0], $courses[0]->id));
Expand Down