From bb2ed945faf197dfa16fd2ea1622c2542c6cb6db Mon Sep 17 00:00:00 2001 From: Sagar Ghimire Date: Wed, 8 May 2019 17:00:57 +1000 Subject: [PATCH] Fix failing test_get_grades (#282) --- tests/element_helper_test.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/element_helper_test.php b/tests/element_helper_test.php index 4402a75..3279321 100644 --- a/tests/element_helper_test.php +++ b/tests/element_helper_test.php @@ -37,6 +37,11 @@ global $CFG; */ class mod_customcert_element_helper_testcase extends advanced_testcase { + /** + * Static variable used for clearing cache + */ + static $courseId; + /** * Test set up. */ @@ -197,6 +202,9 @@ class mod_customcert_element_helper_testcase extends advanced_testcase { // Create a course. $course = $this->getDataGenerator()->create_course(); + // Assign course->id for cache + self::$courseId = $course->id; + // Set that we want 3 decimals to display. grade_set_setting($course->id, 'decimalpoints', 3); @@ -264,6 +272,9 @@ class mod_customcert_element_helper_testcase extends advanced_testcase { // Create a course. $course = $this->getDataGenerator()->create_course(); + // Assign course->id for cache + self::$courseId = $course->id; + // Set that we want 3 decimals to display. grade_set_setting($course->id, 'decimalpoints', 3); @@ -322,6 +333,9 @@ class mod_customcert_element_helper_testcase extends advanced_testcase { // Create a course. $course = $this->getDataGenerator()->create_course(); + // Assign course->id for cache + self::$courseId = $course->id; + // Set that we want 3 decimals to display. grade_set_setting($course->id, 'decimalpoints', 3); @@ -374,4 +388,16 @@ class mod_customcert_element_helper_testcase extends advanced_testcase { $this->assertEquals('-', $grade->get_displaygrade()); $this->assertEquals(null, $grade->get_dategraded()); } + + /** + * Cleanup after all tests are executed. + * + * + * @static + * @return void + */ + public static function tearDownAfterClass() { + // Clear the cache + grade_get_setting(self::$courseId, null, null, true); + } }