Review main Merged

78138[TASK] Replace withConsecutive() calls in ext:backend tests

Torben Hansen CR +2 V +2 Normal +117 −35 updated 03/20/23, 16:56

Commit message

This change replaces all `withConsecutive()` calls in tests
by using a callback function to check for consecutive arguments
and return values.

(`withConsecutive()` is deprecated in PHPUnit 9.6 and removed
from PHPUnit 10.)

Review

  • Code review CR +2 Done
    • Christian Kuhn +2
    • Oliver Klee +1
  • Verified V +2 Done
    • Christian Kuhn +2
    • Oliver Klee +1
    • core-ci +1 CI

Issues 1

Files 8

Review log 1619

  1. Torben Hansen uploaded patch set 1 03/16/23, 08:49

  2. Oliver Klee updated the commit message in patch set 2 03/16/23, 08:56

  3. Oliver Klee commented on patch set 2 03/16/23, 08:57

    PaletteAndSingleContainerTest.php:77

    Please let's have parameter and return type declarations for the new anonymous functions. (Ditto in the other changed tests.)
  4. core-ci voted on patch set 1 V +1 03/16/23, 08:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39039

  5. Oliver Klee commented on patch set 2 03/16/23, 09:04

    On it.
  6. Torben Hansen commented on patch set 2 03/16/23, 09:10

    PaletteAndSingleContainerTest.php:77 Reply

    `$args` as argument will always be an array, but the return type might differ from case to case (e.g. `$args[0]` might even have different types for the same test scenario). What is the benefit, if we would have types here? IMO, this makes the code even more difficult to read than it actually is.
  7. core-ci voted on patch set 2 V +1 03/16/23, 09:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39041

  8. Oliver Klee commented on patch set 2 03/16/23, 09:16

    Reply

    Done

    PaletteAndSingleContainerTest.php:77 Reply

    Done
  9. Oliver Klee uploaded patch set 3 V +1 03/16/23, 09:16

  10. Oliver Klee commented on patch set 3 03/16/23, 09:17

    PaletteAndSingleContainerTest.php:77 Reply

    It helps static analysis and helps us catch incorrect test.
  11. Oliver Klee commented on patch set 3 03/16/23, 09:21

    PaletteAndSingleContainerTest.php:77 Reply

    Please note that the type of `...$args` will not be array, but of the types of the individual arguments (which is something I learned only last week: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78080)
  12. core-ci voted on patch set 3 V +1 03/16/23, 09:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39044

  13. Oliver Klee voted on patch set 3 V +1 CR +1 03/16/23, 09:30

  14. Christian Kuhn commented on patch set 3 CR -1 03/16/23, 09:56

    reviewing.
  15. Christian Kuhn commented on patch set 3 03/16/23, 10:01

    I think at least a couple of these cases can be simplified: withConsecutive() can be directly switched to willReturnOnCensecutiveCalls() quite often, avoiding the more complex callback. I did that in Fluid standalone recently. See https://github.com/TYPO3/Fluid/commit/a2bf1ba5f3c7078e70136bc60efad23b68bc4ebf#diff-c29e663c9847d0a180423c0a2f8270b39b51f2fd8a56d2816479dc0abdec35cdR114 for an example, and search for more willReturnOnCensecutiveCalls() in this patch. Could you give this patch a second look to see if we could simplify some of these constructs in this regard, maybe?
  16. Christian Kuhn commented on patch set 3 V +1 CR +1 03/20/23, 16:56

    talked with torben about this one: it's fine ... i mixed up some details in fluid standalone and fixed them again.
  17. Christian Kuhn commented on patch set 3 03/20/23, 16:56

    Reply

    Done
  18. Christian Kuhn voted on patch set 3 V +2 CR +2 03/20/23, 16:56

  19. Christian Kuhn merged patch set 4 03/20/23, 16:56