Project

General

Profile

Actions

Bug #40780

closed

Fix for unit tests to change singletons and reset again

Added by Christian Kuhn over 11 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
Start date:
2012-09-10
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.0
PHP Version:
5.3
Tags:
Complexity:
hard
Is Regression:
Sprint Focus:

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.

Actions #1

Updated by Gerrit Code Review over 11 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

Actions #2

Updated by Christian Kuhn over 11 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #3

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF