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

PHPUnit 9.6: replace withConsecutive() which will be removed in PHPUnit 10

XMLWordPrintable

      withConsecutive() was deprecated in PHPUnit 9.6 (without visible warning) and completely removed in PHPUnit 10. There is no direct replacement, but here are some ideas on how to solve this: https://github.com/sebastianbergmann/phpunit/issues/4026

      We have a few instances of those...

      $ ag '>withConsecutive' --php
      admin/tool/dataprivacy/tests/expired_contexts_test.php
      1375:            ->withConsecutive(
      1593:            ->withConsecutive(
      1646:            ->withConsecutive(
      1865:            ->withConsecutive(
       
      admin/tool/usertours/tests/tour_test.php
      567:            ->withConsecutive(
       
      course/tests/category_hooks_test.php
      191:            ->withConsecutive(
       
      lib/tests/content/export/exportable_items/exportable_filearea_test.php
      245:            ->withConsecutive(...$storedfileargs);
       
      lib/tests/content/export/exportable_items/exportable_textarea_test.php
      331:            ->withConsecutive(...$storedfileargs);
       
      lib/tests/completionlib_test.php
      268:            ->withConsecutive(
      690:            ->withConsecutive(
      1178:            ->withConsecutive(
       
      repository/dropbox/tests/api_test.php
      423:            ->withConsecutive(['testEndpoint'], ['testEndpoint/continue'], ['testEndpoint/continue'])
      478:            ->withConsecutive(
      557:            ->withConsecutive(
      596:            ->withConsecutive(
       
      repository/googledocs/tests/googledocs_search_content_test.php
      69:            ->withConsecutive(
       
      repository/googledocs/tests/local/browser/googledocs_drive_content_test.php
      68:            ->withConsecutive(
       
      completion/tests/activity_custom_completion_test.php
      106:                ->withConsecutive(
      

      In this issue we should:

      1. Decide the target for the fix: Moodle 4.4 with PHPUnit 9.6 vs future Moodle version with PHPUnit 10.
      2. Look how many of the uses detected are really useful, there is a lot of debate about when this sort of mocking is correct or no. Maybe we can reduce the uses.
      3. No matter the previous point, for sure some of the cases will need to be converted to some alternative, that can be:
        1. Create some trait providing an in-place (or near in-place) replacement.
        2. Add support from advanced_testcase or similar.
        3. Other, custom, working replacements, case by case.
        4. ...

            dobedobedoh Andrew Lyons
            Daniel Ziegenberg Daniel Ziegenberg
            Paul Holden Paul Holden
            Jun Pataleta Jun Pataleta
            Jun Pataleta Jun Pataleta
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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

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