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

Problems with tearDownAfterClass() and some customfield phpunit tests

XMLWordPrintable

      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

            stronk7 Eloy Lafuente (stronk7)
            stronk7 Eloy Lafuente (stronk7)
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Jun Pataleta Jun Pataleta
            CiBoT CiBoT
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                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

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