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

Static variable in grade_get_letters causes unit test failures

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Run Unit Tests

      1. Initialise phpunit tests.
      2. Run vendor/bin/phpunit --testsuite=core_grades_testsuite
      3. Run vendor/bin/phpunit lib/tests/gradelib_test.php

       

      Expected:

      All unit tests pass

       

      Run Behat Tests

      1. Initialise behat tests
      2. Run php admin/tool/behat/cli/run.php --tags=@core_grades

      Expected:

      All Behat Tests pass

      Show
      Run Unit Tests Initialise phpunit tests. Run vendor/bin/phpunit --testsuite=core_grades_testsuite Run  vendor/bin/phpunit lib/tests/gradelib_test.php   Expected: All unit tests pass   Run Behat Tests Initialise behat tests Run  php admin/tool/behat/cli/run.php --tags=@core_grades Expected: All Behat Tests pass
    • Affected Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      If unit tests for whatever reason need to validate against a different set of grade letters, then it will fail especially if it is run after the core_grades_testsuite because the static $cache variable does not reset and the contextid collides with previous unit tests.

       

      Steps to reproduce:

      1. Have unit tests that implement a different set of grade letters
      2. Run vendor/bin/phpunit --testsuite=core_grades_testsuite,your_custom_testsuite

       

      Expected:

      Unit tests pass

       

      Actual:

      Unit tests fail with unexpected grade letters getting returned (because it is using the default grade letters)

        Attachments

          Activity

            People

            Assignee:
            marcusboon Marcus Boon
            Reporter:
            marcusboon Marcus Boon
            Peer reviewer:
            Dmitrii Metelkin Dmitrii Metelkin
            Integrator:
            Andrew Lyons Andrew Lyons
            Tester:
            CiBoT CiBoT
            Participants:
            Component watchers:
            Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Sujith Haridasan, Andrew Lyons, Dongsheng Cai, Huong Nguyen, 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:
              13/Jul/20

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 6 minutes
                2h 6m