Review main Merged

78201[TASK] Replace withConsecutive() call in ext:adminpanel test

Torben Hansen CR +2 V +2 Easy +7 −7 updated 03/22/23, 13:44

Commit message

This change replaces a `withConsecutive()` call in a test
by using a callback function to check for expected
arguments in no explicit order.

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

Review

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

Issues 2

Files 1

Review log 1924

  1. Torben Hansen uploaded patch set 1 03/21/23, 17:55

  2. core-ci voted on patch set 1 V +1 03/21/23, 18:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39333

  3. Oliver Klee commented on patch set 1 03/21/23, 21:18

    PreviewModuleTest.php:96

    I'd like to avoid those `...$args` as much as possible in the callbacks, and use explicit types from the original interface of the mocked method instead: ```php ->willReturnCallback(static function (string $name, AspectInterface $aspect)): void { static $series = ['date', 'visibility', 'visibility', 'frontend.user', 'frontend.preview']; self::assertSame(array_shift($series), $name); ``` This makes the anonymous function a lot easier to understand IMHO. (Also, we can make the static function static.)
  4. Torben Hansen uploaded patch set 2 V +1 03/22/23, 07:06

  5. Torben Hansen commented on patch set 1 03/22/23, 07:06

    PreviewModuleTest.php:96 Reply

    Agree, done.
  6. core-ci voted on patch set 2 V +1 03/22/23, 07:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39365

  7. Oliver Klee voted on patch set 2 V +1 CR +1 03/22/23, 09:17

  8. Nikita Hovratov uploaded patch set 3 CR +1 V +1 03/22/23, 10:47

  9. Nikita Hovratov uploaded patch set 4 03/22/23, 10:47

  10. Nikita Hovratov commented on patch set 4 03/22/23, 10:54

    PreviewModuleTest.php:96

    Hey, I found this pattern on GitHub while searching for "withConsecutive" replacements. It rarely makes sense to check for the exact order of execution, but to make sure expected arguments are provided. This also removes the duplicated "visibility" argument.
  11. core-ci voted on patch set 4 V -1 03/22/23, 10:56 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39371

  12. Nikita Hovratov uploaded patch set 5 V -1 03/22/23, 11:01

  13. core-ci voted on patch set 5 V +1 03/22/23, 11:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39373

  14. Oliver Klee voted on patch set 5 V +1 CR +1 03/22/23, 11:22

  15. Oliver Klee voted on patch set 5 CR 0 03/22/23, 11:22

  16. Oliver Klee commented on patch set 5 03/22/23, 11:23

    PreviewModuleTest.php:101

    This won't fail though if one or more of the calls is missing, of if all calls use the same. Or am I missing something here?
  17. Christian Kuhn updated the commit message in patch set 6 V +1 03/22/23, 11:26

  18. core-ci voted on patch set 6 V +1 03/22/23, 11:38 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39377

  19. Nikita Hovratov commented on patch set 6 03/22/23, 12:05

    PreviewModuleTest.php:101 Reply

    Thanks for raising this point, however: 1. This was the case even before this change, as we have `$context->expects(self::any())` 2. IMO this is not good testing anyway, as we expect to know the internal processes. 3. I'd say for the sake of replacing `withConsecutive` this is fine and we can maybe convert this test to a functional and make assertions around the `$context` object.
  20. Christian Kuhn commented on patch set 6 03/22/23, 12:45

    PreviewModuleTest.php:101 Reply

    Yes. A functional test wouldn't be bad. There are various options to do this, one possible solution: An extension that registers a "late" middleware that gets the context injected, to then check the values, and throw a "everything ok" exception if all is fine. the test then creates a FE sub request and excepts the exception. Shouldn't be too hard. Anyone wants to step in? However, for now, since this patch is about getting rid of withConsecutive(), i'd be fine with the patch as such as well.
  21. Christian Kuhn voted on patch set 6 V +1 CR +1 03/22/23, 13:21

  22. Nikita Hovratov voted on patch set 6 V +2 CR +2 03/22/23, 13:26

  23. Nikita Hovratov merged patch set 7 03/22/23, 13:27

  24. Oliver Klee commented on patch set 7 03/22/23, 13:44

    PreviewModuleTest.php:101 Reply

    Ack. Thanks everbody!