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

Reset Course handler singleton after core_customfield unit tests run

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Run unit test for core_customfield_testsuite and format_topics_testsuite test suite in one go:

      vendor/bin/phpunit --testsuite core_customfield_testsuite,format_topics_testsuite
      

      Confirm that there is no error:

      OK (39 tests, 253 assertions)
      

      Show
      Run unit test for core_customfield_testsuite and format_topics_testsuite test suite in one go: vendor/bin/phpunit --testsuite core_customfield_testsuite,format_topics_testsuite Confirm that there is no error: OK ( 39 tests, 253 assertions)
    • Affected Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_37_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      master-MDL-66794

      Description

       

      Since Customfields unit tests create categories and fields stored in Course handler singleton class it should be reset/erased after test. Otherwise this changes behaviour of other unit tests and can cause errors like this:

      Moodle 3.8dev unit testing: 

      root@ab637055742f:/siteroot# vendor/bin/phpunit --testsuite core_customfield_testsuite,format_topics_testsuite
      Moodle 3.8dev (Build: 20190927), 9528b1ff5b8c8ff439d5502cfb509c5aacd306b0
      Php: 7.2.19.0.0.18.04.1, pgsql: 11.4 (Debian 11.4-1.pgdg90+1), OS: Linux 4.15.0-62-generic x86_64
      PHPUnit 7.5.15 by Sebastian Bergmann and contributors..................................E.....                           39 / 39 (100%)Time: 6.8 seconds, Memory: 90.25 MBThere was 1 error:1) format_topics_testcase::test_default_course_enddate
      dml_missing_record_exception: Invalid user (SELECT id FROM {user} WHERE id = ? AND deleted = ?
      [array (
        0 => 0,
        1 => 0,
      )])/siteroot/lib/dml/moodle_database.php:1562
      /siteroot/lib/dml/moodle_database.php:1538
      /siteroot/lib/accesslib.php:6420
      /siteroot/lib/filelib.php:403
      /siteroot/lib/filelib.php:199
      /siteroot/customfield/field/textarea/classes/data_controller.php:133
      /siteroot/customfield/classes/handler.php:568
      /siteroot/course/edit_form.php:363
      /siteroot/lib/formslib.php:206
      /siteroot/course/format/topics/tests/format_topics_test.php:218
      /siteroot/lib/phpunit/classes/advanced_testcase.php:80To re-run:
       vendor/bin/phpunit "format_topics_testcase" course/format/topics/tests/format_topics_test.phpERRORS!
      Tests: 39, Assertions: 252, Errors: 1.
      

       

      Moodle 3.7.2+ unit testing:

      root@ab637055742f:/siteroot# vendor/bin/phpunit --testsuite core_customfield_testsuite,format_topics_testsuite
      Moodle 3.7.2+ (Build: 20190927), 31f8f7567240d8fafc2fa3b2dd6f0e9f622d515c
      Php: 7.2.19.0.0.18.04.1, pgsql: 11.4 (Debian 11.4-1.pgdg90+1), OS: Linux 4.15.0-62-generic x86_64
      PHPUnit 7.5.15 by Sebastian Bergmann and contributors..................................E.....                           39 / 39 (100%)Time: 4.71 seconds, Memory: 88.25 MBThere was 1 error:1) format_topics_testcase::test_default_course_enddate
      dml_missing_record_exception: Invalid user (SELECT id FROM {user} WHERE id = ? AND deleted = ?
      [array (
        0 => 0,
        1 => 0,
      )])/siteroot/lib/dml/moodle_database.php:1562
      /siteroot/lib/dml/moodle_database.php:1538
      /siteroot/lib/accesslib.php:6395
      /siteroot/lib/filelib.php:403
      /siteroot/lib/filelib.php:199
      /siteroot/customfield/field/textarea/classes/data_controller.php:133
      /siteroot/customfield/classes/handler.php:568
      /siteroot/course/edit_form.php:343
      /siteroot/lib/formslib.php:206
      /siteroot/course/format/topics/tests/format_topics_test.php:218
      /siteroot/lib/phpunit/classes/advanced_testcase.php:80To re-run:
       vendor/bin/phpunit "format_topics_testcase" course/format/topics/tests/format_topics_test.phpERRORS!
      Tests: 39, Assertions: 252, Errors: 1.
      

       

       

        Attachments

          Activity

            People

            Assignee:
            mikhailgolenkov Mikhail Golenkov
            Reporter:
            mikhailgolenkov Mikhail Golenkov
            Peer reviewer:
            Dmitrii Metelkin
            Integrator:
            Adrian Greeve
            Tester:
            Jennifer Bauzon
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/Nov/19

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 15 minutes
                1h 15m