Review main Merged

84530[TASK] Mitigate PHPUnit `NameAlreadyInUseException`

Stefan Bürk CR +2 V +2 Easy +16 −34 updated 06/10/24, 15:41

Commit message

PHPUnit changed the way how double creation is handled
internally and now emits an exception if a manually defined
`mock class name` should be registered. In some places
within the unit tests, manual mock class names have been
used, because the names are needed for cross referencing
at a later point. For this, different approaches have
been used, for example hardcoded MD5 hashes as strings
or creating hashes of static values like `md5('1')`,
and also reused hashes in different places or in
tests using data providers. This now leads to an
exception:

    PHPUnit\Framework\MockObject\Generator\NameAlreadyInUseException

    The name "b70551b2b2db62b6b15a9bbfcbd50614" is already in use

This change mitigates the issue by using
`StringUtility::getUniqueId('somePrefix')` as is already done
in other places.

As a sideeffect, four phpstan baseline entries can be removed.

Used command(s):

  Build/Scripts/runTests.sh -s phpstanGenerateBaseline

[1] https://github.com/sebastianbergmann/phpunit/pull/5804

Review

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

Issues 1

Files 3

Review log 1722

  1. Stefan Bürk uploaded patch set 1 06/08/24, 15:39

  2. Stefan Bürk updated the commit message in patch set 2 06/08/24, 15:42

  3. core-ci voted on patch set 1 V +1 06/08/24, 15:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58917

  4. core-ci voted on patch set 2 V +1 06/08/24, 15:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58919

  5. Thomas Hohn voted on patch set 2 CR +1 06/08/24, 16:51

  6. Simon Schaufelberger voted on patch set 2 CR +1 V +1 06/08/24, 19:25

  7. Andreas Wolf commented on patch set 2 CR +1 06/10/24, 14:54

    Just some wording changes and format improvements in the commit message.
    ``` PHPUnit changed the way how double creation is handled internally and now emits an exception if a manually defined `mock class name` should be registered. In some places within the unit tests, manual mock class names have been used, because the names are needed for cross referencing at a later point. For this, different approaches have been used, for example hardcoded MD5 hashes as strings or creating hashes of static values like `md5('1')`, and also reused hashes in different places or in tests using dataproviders. This now leads to an exception: PHPUnit\Framework\MockObject\Generator\NameAlreadyInUseException The name "b70551b2b2db62b6b15a9bbfcbd50614" is already in use This change mitigates the issue by using the `StringUtility::getUniqueId('somePrefix')` as is already done in other places. As a sideeffect, four phpstan baseline entries can be removed. ```
  8. Christian Kuhn commented on patch set 2 CR -1 06/10/24, 15:00

    too many typos in commit message ;) will push ...
  9. Christian Kuhn commented on patch set 2 06/10/24, 15:03

    andreas wolf will edit.
  10. Andreas Wolf updated the commit message in patch set 3 CR +1 V +1 06/10/24, 15:03

  11. Andreas Wolf updated the commit message in patch set 4 06/10/24, 15:03

  12. Christian Kuhn commented on patch set 3 06/10/24, 15:03

    Reply

    Done
  13. Andreas Wolf voted on patch set 4 CR +1 06/10/24, 15:04

  14. Christian Kuhn updated the commit message in patch set 5 CR +1 06/10/24, 15:06

  15. Andreas Wolf voted on patch set 4 CR +1 V +1 06/10/24, 15:07

  16. Andreas Wolf voted on patch set 5 CR +1 V +1 06/10/24, 15:07

  17. core-ci voted on patch set 3 V +1 06/10/24, 15:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59023

  18. core-ci voted on patch set 4 V +1 06/10/24, 15:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59024

  19. Christian Kuhn commented on patch set 5 CR +1 V +1 06/10/24, 15:17

    v12 backport is in sync. will merge when green.
  20. core-ci voted on patch set 5 V +1 06/10/24, 15:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59027

  21. Christian Kuhn voted on patch set 5 CR +2 V +2 06/10/24, 15:41

  22. Christian Kuhn merged patch set 6 06/10/24, 15:41