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

Availability: Date restriction unit test has static data, may break other tests

    XMLWordPrintable

Details

    • MOODLE_28_STABLE
    • MOODLE_28_STABLE, MOODLE_29_STABLE
    • MDL-51077-master
    • Hide

      1. Download attached file later_test.php and place in /availability/condition/date/tests.
      2. Run vendor/bin/phpunit --testsuite=availability_date_testsuite

      This test should pass. Prior to this fix, the test failed.

      Once finished testing, remember to delete later_test.php.

      Show
      1. Download attached file later_test.php and place in /availability/condition/date/tests. 2. Run vendor/bin/phpunit --testsuite=availability_date_testsuite This test should pass. Prior to this fix, the test failed. Once finished testing, remember to delete later_test.php.

    Description

      In \availability_date\condition there is a function 'set_current_time_for_test' which is only for use in PHPunit.

      However this sets a static value which is not cleared after the test finishes. As a result, if any future PHPunit test tries to set up something with a date restriction, it may have unexpected behaviour (i.e. the test fails when run as a group, even though it passes individually).

      There are no core tests that break as a result of this, but third-party plugins might do (and we have one that does).

      Attachments

        Activity

          People

            quen Sam Marshall
            quen Sam Marshall
            Tim Hunt Tim Hunt
            David Monllaó David Monllaó
            Adrian Greeve Adrian Greeve
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              14/Sep/15