From bfb57d2c16d9d30c9153dc5efa6bdf8f9d083fb5 Mon Sep 17 00:00:00 2001 From: Adrian Greeve Date: Tue, 1 May 2018 14:32:58 +0800 Subject: [PATCH] MDL-61308 assignsubmission_comments: Unit test ordering fix. --- .../submission/comments/tests/privacy_test.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mod/assign/submission/comments/tests/privacy_test.php b/mod/assign/submission/comments/tests/privacy_test.php index 471174ba8cf..e5917e66d35 100644 --- a/mod/assign/submission/comments/tests/privacy_test.php +++ b/mod/assign/submission/comments/tests/privacy_test.php @@ -164,9 +164,18 @@ class assignsubmission_comments_privacy_testcase extends \mod_assign\tests\mod_a $exportdata = new \mod_assign\privacy\assign_plugin_request_data($context, $assign, $submission); \assignsubmission_comments\privacy\provider::export_submission_user_data($exportdata); $exportedcomments = $writer->get_data(['Comments']); + + // Can't rely on these comments coming out in order. + if ($exportedcomments->comments[0]->userid == $user1->id) { + $exportedstudentcomment = $exportedcomments->comments[0]->content; + $exportedteachercomment = $exportedcomments->comments[1]->content; + } else { + $exportedstudentcomment = $exportedcomments->comments[1]->content; + $exportedteachercomment = $exportedcomments->comments[0]->content; + } $this->assertCount(2, $exportedcomments->comments); - $this->assertContains($studentcomment, $exportedcomments->comments[0]->content); - $this->assertContains($teachercomment, $exportedcomments->comments[1]->content); + $this->assertContains($studentcomment, $exportedstudentcomment); + $this->assertContains($teachercomment, $exportedteachercomment); } /**