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

PHPunit: Does not preserve $FULLME

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.9.4, 3.0.2, 3.1
    • Fix Version/s: 2.9.5, 3.0.3
    • Component/s: Unit tests
    • Labels:
    • Testing Instructions:
      Hide

      1. Copy attached mdl_52981_test.php into the lib/tests folder (This file includes the qualified_me test from weblib_test.php plus some other surrounding fake tests)
      2. Run vendor/bin/phpunit lib/tests/mdl_52981_test.php

      EXPECTED: The qualified_me test, and the two tests either side that check $FULLME is empty, should both pass. The final test that sets $FULLME without calling resetAfterTest should fail with a warning about modifying $FULLME

      BEFORE THIS FIX: The test after qualified_me failes because the value of $FULLME has changed; meanwhile the test that just sets FULLME passes without any warning that it has modified the global.

      Show
      1. Copy attached mdl_52981_test.php into the lib/tests folder (This file includes the qualified_me test from weblib_test.php plus some other surrounding fake tests) 2. Run vendor/bin/phpunit lib/tests/mdl_52981_test.php EXPECTED: The qualified_me test, and the two tests either side that check $FULLME is empty, should both pass. The final test that sets $FULLME without calling resetAfterTest should fail with a warning about modifying $FULLME BEFORE THIS FIX: The test after qualified_me failes because the value of $FULLME has changed; meanwhile the test that just sets FULLME passes without any warning that it has modified the global.
    • Affected Branches:
      MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_29_STABLE, MOODLE_30_STABLE
    • Pull Master Branch:
      MDL-52981-master

      Description

      I had to spend quite a long time tracking down a PHPunit failure in a local plugin which only occurred if it was run as part of all unit tests - it passed individually.

      Eventually I traced this to the weblib_test.php test_qualified_me function, which causes the global $FULLME to be set. For some reason (I don't actually understand why but don't think it matters), my test failed after that happened.

      The unit test system preserves the main global variables, but does not preserve $FULLME. I think the best fix is to change the test system to preseve $FULLME in the same way. This is a simple fix; I'll submit a patch.

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                14/Mar/16