Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-70245

Static variable $cache in grade_get_setting causes unit test failures

    XMLWordPrintable

    Details

      Description

      When the unit test tries to validate "finalgrade" with different set of grade max, then it will fail after "test_upgrade_calculated_grade_items_freeze" function in core_testsuite because the static $cache variable does not reset and the "minmaxtouse" collides with previous unit tests.

       

      Steps to reproduce:

      1. Write unit test (attached in MDL-70245-patch.txt) that implement to validate "finalgrade" with different set of grademax (for course category and grade item) after the function "test_upgrade_calculated_grade_items_freeze" .
      2. Run vendor/bin/phpunit --testsuite=core_testsuite

       

      Expected:

      Unit tests pass

       

      Actual:

      Unit tests fail with unexpected "finalgrade" getting returned (because it is using the previous "minmaxtouse" which is set in the function "test_upgrade_calculated_grade_items_freeze")

       

       

        Attachments

          Activity

            People

            Assignee:
            tomotsuyuki Tomo Tsuyuki
            Reporter:
            anupamadharmajan Anupama Dharmajan
            Peer reviewer:
            John Yao
            Integrator:
            Eloy Lafuente (stronk7)
            Tester:
            Eloy Lafuente (stronk7)
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              18/Jan/21

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 45 minutes
                45m