[TYPO3-core] RFC #16267 Feature: Add functions to provide mocks for makeInstance

Oliver Klee typo3-german-01 at oliverklee.de
Fri Nov 5 16:47:11 CET 2010


This is an SVN patch request.

Type: New feature

Bugtracker references: http://bugs.typo3.org/view.php?id=16267

Branches: trunk

Problem:
There is no dependency injection in the core, and there are only a few
factories. Instead, new classes are created all over the place using
t3lib_div::makeInstance. This hard-codes the dependencies, making
unit-testing a PITA.

In addition, once makeInstance has created an instance of a particular
singleton class, it holds on to it for dear life.

Solution:

Add functions for providing singleton and non-singleton instances which
makeInstance then will return.

Also add a function to purge all existing instances, including non-mock
singleton instances.

The patch also adds an exception if makeInstance is called with an empty
class name.

In addition, this patch adds some unit tests for the already existing
functionality of makeInstance.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 16267.diff
Type: text/x-diff
Size: 24098 bytes
Desc: not available
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20101105/9d572da9/attachment.diff>


More information about the TYPO3-team-core mailing list