Task #89890

Reset PSR-11 container in GeneralUtility in unit tests

Added by Benjamin Franzke 6 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Tests
Start date:
2019-12-06
Due date:
% Done:

100%

TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

If a container instance is provided for a unit test via GeneralUtility::setContainer(), it needs to set to null again, in order to not affect other unit tests.

Associated revisions

Revision 5263197e (diff)
Added by Benjamin Franzke 6 months ago

[TASK] Do not set GeneralUtility::$container in unit tests

The GeneralUtility $container instance should only be set/used
in functional tests as we a) can not reset the instance (which
means other unit tests are affected) and b) should mock/inject
dependencies in unit tests.

TreeDataProviderFactoryTest is therefore changed to to use
GeneralUtility::addInstance() (which is intended for unit tests)
instead of GeneralUtility::setContainer().

Change-Id: I9fc0e76077cc1cc2a6935d025b97309efc315f4f
Releases: master
Resolves: #89890
Related: #89733
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62573
Tested-by: TYPO3com <>
Tested-by: Susanne Moog <>
Tested-by: Andreas Fernandez <>
Reviewed-by: Susanne Moog <>
Reviewed-by: Andreas Fernandez <>

History

#1 Updated by Benjamin Franzke 6 months ago

https://review.typo3.org/c/Packages/TYPO3.CMS/+/62331 introduced setContainer in TreeDataProviderFactoryTest, which needs to be reset.

#2 Updated by Gerrit Code Review 6 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62573

#3 Updated by Gerrit Code Review 6 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62573

#4 Updated by Gerrit Code Review 6 months ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62573

#5 Updated by Benjamin Franzke 6 months ago

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

#6 Updated by Benni Mack 5 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF