-
Christian Kuhn authored
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. Change-Id: I19dc869423a537226bb019e227d84b6f74fe9afc Resolves: #40780 Releases: 6.0 Reviewed-on: http://review.typo3.org/14487 Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn
4fd6bfa2