Review 12.4 Merged

84531[TASK] Mitigate PHPUnit `NameAlreadyInUseException`

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

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
  • Verified V +2 Done
    • Christian Kuhn +2
    • core-ci +1 CI

Issues 1

Files 3

Review log 58

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

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

  3. Christian Kuhn uploaded patch set 2 V +1 06/10/24, 15:06

  4. Christian Kuhn uploaded patch set 3 06/10/24, 15:16

  5. core-ci voted on patch set 2 V +1 06/10/24, 15:17 Copied votes on follow-up patch sets have been updated: * Verified+1 has been copied to patch set 3 (copy condition: "changekind:NO_CHANGE"). Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/59025

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

  7. Christian Kuhn voted on patch set 3 CR +2 V +2 06/10/24, 15:42

  8. Christian Kuhn merged patch set 4 06/10/24, 15:42