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

Problems with tearDownAfterClass() and some customfield phpunit tests

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.7.1, 3.8, 3.9
    • Fix Version/s: 3.7.5, 3.8.2
    • Component/s: Other, Policy, Unit tests
    • Labels:

      Description

      While doing various attempts to get travis able to pass under windows... I needed to split tests to workaround travis execution time restrictions.

      That revealed (just because of the way I split), some problems with "customfield" unit tests. Have been able to reproduce them locally without too much problem, just performing the same split (filtering).

      $ vendor/bin/phpunit --verbose "core_customfield_field_controller_testcase" customfield/tests/field_controller_test.php --filter '/::test_[d-e]/'
      Moodle 3.9dev (Build: 20191122), c234086cb957c2810affbabbe3e2839fd3807c53
      Php: 7.3.11, pgsql: 9.6.15, OS: Darwin 18.7.0 x86_64
      PHPUnit 7.5.17 by Sebastian Bergmann and contributors.
       
      Runtime:       PHP 7.3.11 with Xdebug 2.7.2
      Configuration: /Users/stronk7/git_moodle/moodle/phpunit.xml
       
      .                                                                   1 / 1 (100%)F
       
      Time: 1.35 seconds, Memory: 62.50 MB
       
      There was 1 failure:
       
      1) core_customfield_field_controller_testcase::tearDownAfterClass
      Exception in core_customfield_field_controller_testcase::tearDownAfterClass
      Coding error detected, it must be fixed by a programmer: id is required to delete
       
      lib/classes/persistent.php:600
      customfield/classes/field_controller.php:173
      customfield/classes/api.php:237
      customfield/classes/api.php:326
      customfield/classes/handler.php:309
      customfield/tests/field_controller_test.php:46
      

      So this issue is about:

      • Fix those issues in order to guarantee that the singleton involved is always reset properly. Maybe being part of the reset_all_data(), maybe being part of tearDown(). In any case, surely a public (restricted to phpunit usage) method will be needed within customfield API.
      • Clarify the rules for using tearDownAfterClass(), forbid the use of resetAfterTest() within setup() ... because it's a recurring problem that we face here and there.

      Ciao

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              stronk7 Eloy Lafuente (stronk7)
              Reporter:
              stronk7 Eloy Lafuente (stronk7)
              Peer reviewer:
              Sara Arjona (@sarjona)
              Integrator:
              Jun Pataleta
              Tester:
              CiBoT
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Adrian Greeve, Andrew Nicols, Eloy Lafuente (stronk7), Juan Leyva, Jun Pataleta, Sander Bangma, 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:
                9/Mar/20

                  Time Tracking

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