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

Unit test failure from test_usergetdate

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.8
    • Fix Version/s: 1.9.9
    • Component/s: Libraries
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE

      Description

      I get a unit test failure in 1.9.x stable.

      Fail: lib/simpletest/testmoodlelib.php / ? moodlelib_test / ? test_usergetdate / ?
      Equal expectation fails because [Integer: 3] differs from [Integer: 11] by 8 at [/Users/tim/Documents/workspace/moodle_19/lib/simpletest/testmoodlelib.php line 289]

      The issue is that when you call usergetdate($ts) without the second argument, the result depends on $USER. What you should do is

      1. At the start of this test, store $USER->timezone in a temporary variable.

      2. Also at the start of the test, set $USER->timezone to a particular value.

      3. At the end of the test, set $USER->timezone back to the real value that you stored in a temporary.

        Gliffy Diagrams

          Activity

          Hide
          andyjdavis Andrew Davis added a comment -

          Thanks Tim. I've committed the fix you suggested.

          Show
          andyjdavis Andrew Davis added a comment - Thanks Tim. I've committed the fix you suggested.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                8/Jun/10