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

Restore: Static cache breaks unit tests




      In the restore code that deals with course section format options, there is a static cache of course id => format which is within a function and is never cleared.

      This causes unit tests to fail in the situation where a unit test does a backup and restore that includes course section format options, and where another unit test has previously run on that same course id but with a different format selected. It leads to a situation where the test runs successfully, if run individually, but fails if run with other tests.

      While resolving this issue I also noticed an incorrect unit test in some existing code (which depends on this bug in order not to fail). Specifically, in backup/moodle2/tests/moodle2_course_format_test.php there is a function test_course_format_options_restore_new_format. This supposedly tests what happens when you restore from a course A with one format, to a course B with different format. However, in fact it restores using the 'new course' option, which therefore overwrites the format in B so that it becomes the same as in A. In order to test this facility it is necessary to use a different option such as TARGET_EXISTING_ADDING. In addition, I'm not really sure the expected values it's checking for are right either. (The actual designed behaviour is that when restoring a section from one course to another with different format, all the course format options should be discarded - documented in comments in restore_stepslib.php.)

      I'm also updating this test to work sensibly.




            quen Sam Marshall
            quen Sam Marshall
            Rajesh Taneja Rajesh Taneja
            David Monllaó David Monllaó
            CiBoT CiBoT
            0 Vote for this issue
            3 Start watching this issue




                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.