Skip to content
Snippets Groups Projects
Commit e2aff12c authored by Stefan Bürk's avatar Stefan Bürk Committed by Christian Kuhn
Browse files

[TASK] Mitigate PHPUnit `NameAlreadyInUseException`

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

Resolves: #104005
Releases: main, 12.4
Change-Id: Icc558844275c9ae9f67a0e7c20daa318f5ad6b41
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84530


Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarAndreas Wolf <andreas.wolf@typo3.org>
Reviewed-by: default avatarAndreas Wolf <andreas.wolf@typo3.org>
parent 1cbcf824
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment