Bug #40780
closedFix for unit tests to change singletons and reset again
100%
Description
TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance() is a method
for unit tests to inject singleton mocks for classes that are
instantiated with makeInstance. purgeInstances() can be used to reset all
registered singletons, so makeInstance() creates new objects after that.
purgeInstances() can change the behaviour of tests that are executed
afterwards, because all registered singletons are reset. Currently the
helper methods for singletons around makeInstance() are not able to get
the list of registered singletons, and reset them to the previous list.
The patch introduces method getSingletonInstances() that returns a list
of all registered singletons (used in setUp()), and method
resetSingletonInstances() that resets registered singletons to a given
stored list (used in tearDown()). This way it is possible to fiddle in
tests with purgeInstances() without introducing side effects to other
tests.
All unit tests that used purgeInstances() are adapted to take care
of re constitution of changed objects this way.
Updated by Gerrit Code Review about 12 years ago
- Status changed from New to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14487
Updated by Christian Kuhn about 12 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 4fd6bfa23d2670d5a4c03790a7066171fbe34ff7.
Updated by Riccardo De Contardi about 7 years ago
- Status changed from Resolved to Closed