From 14e369b775f0469a15e6f752b3d9e7182188c770 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Tue, 16 Apr 2019 20:07:21 +0800 Subject: [PATCH] Specify grades' decimal places in unit test (#277) --- tests/element_helper_test.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tests/element_helper_test.php b/tests/element_helper_test.php index 7ad3651..f65f250 100644 --- a/tests/element_helper_test.php +++ b/tests/element_helper_test.php @@ -194,14 +194,12 @@ class mod_customcert_element_helper_testcase extends advanced_testcase { * Test we return the correct grade information for an activity. */ public function test_get_mod_grade_info() { - global $CFG; - - // Set that we want 3 decimals to display. - $CFG->grade_decimalpoints = 3; - // Create a course. $course = $this->getDataGenerator()->create_course(); + // Set that we want 3 decimals to display. + grade_set_setting($course->id, 'decimalpoints', 3); + // Create two users. $student1 = $this->getDataGenerator()->create_user(); $student2 = $this->getDataGenerator()->create_user(); @@ -268,12 +266,12 @@ class mod_customcert_element_helper_testcase extends advanced_testcase { // Including to use constant. require_once($CFG->dirroot . '/mod/customcert/element/grade/classes/element.php'); - // Set that we want 3 decimals to display. - $CFG->grade_decimalpoints = 3; - // Create a course. $course = $this->getDataGenerator()->create_course(); + // Set that we want 3 decimals to display. + grade_set_setting($course->id, 'decimalpoints', 3); + // Create two users. $student1 = $this->getDataGenerator()->create_user(); $student2 = $this->getDataGenerator()->create_user(); @@ -326,14 +324,12 @@ class mod_customcert_element_helper_testcase extends advanced_testcase { * Test we return the correct grade information for a grade item. */ public function test_get_grade_item_info() { - global $CFG; - - // Set that we want 3 decimals to display. - $CFG->grade_decimalpoints = 3; - // Create a course. $course = $this->getDataGenerator()->create_course(); + // Set that we want 3 decimals to display. + grade_set_setting($course->id, 'decimalpoints', 3); + // Create two users. $student1 = $this->getDataGenerator()->create_user(); $student2 = $this->getDataGenerator()->create_user();