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

PHPunit: Does not preserve $FULLME

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.9.5, 3.0.3
    • 2.9.4, 3.0.2, 3.1
    • Unit tests
    • MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE
    • MOODLE_29_STABLE, MOODLE_30_STABLE
    • MDL-52981-master
    • 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.

      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.

            quen Sam Marshall
            quen Sam Marshall
            Rajesh Taneja Rajesh Taneja
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Simey Lameze Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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