[TASK] Properly reset unit test singletons 69/57169/11
authorChristian Kuhn <lolli@schwarzbu.ch>
Sun, 10 Jun 2018 17:30:14 +0000 (19:30 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 11 Jun 2018 05:27:00 +0000 (07:27 +0200)
typo3/testing-framework since version 3.8.0 can reset
singletons created by makeInstance automatically
if $this->$resetSingletonInstances is set to true.

This version additionally checks for left over singletons
in case that property has not been set and lets tests
fail in this case.

composer require --dev typo3/testing-framework:^3.8

As advantage, a manual backup of singleton instances
within tests is not needed anymore.

The patch comes with a set of test case adaptions to
cope with this new situation.

Change-Id: Ib5f278145e385e32d543541872cf5e1f208fad47
Resolves: #85209
Releases: master
Reviewed-on: https://review.typo3.org/57169
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
92 files changed:
composer.json
composer.lock
typo3/sysext/adminpanel/Tests/Unit/Middleware/AdminPanelInitiatorTest.php
typo3/sysext/backend/Tests/Unit/Controller/LoginControllerTest.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/DatabaseSystemLanguageRowsTest.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaCheckboxItemsTest.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaFlexPrepareTest.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaGroupTest.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaRadioItemsTest.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectTreeItemsTest.php
typo3/sysext/backend/Tests/Unit/Form/InlineStackProcessorTest.php
typo3/sysext/backend/Tests/UnitDeprecated/Form/FormDataProvider/TcaFlexPrepareTest.php
typo3/sysext/core/Classes/Log/LogManager.php
typo3/sysext/core/Tests/Integrity/IntegrityTest.php [deleted file]
typo3/sysext/core/Tests/Unit/Authentication/AuthenticationServiceTest.php
typo3/sysext/core/Tests/Unit/Cache/Backend/PdoBackendTest.php
typo3/sysext/core/Tests/Unit/Configuration/FlexForm/FlexFormToolsTest.php
typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php
typo3/sysext/core/Tests/Unit/Database/Schema/Parser/TableBuilderTest.php
typo3/sysext/core/Tests/Unit/Database/Schema/SqlReaderTest.php
typo3/sysext/core/Tests/Unit/Html/RteHtmlParserTest.php
typo3/sysext/core/Tests/Unit/Imaging/IconFactoryTest.php
typo3/sysext/core/Tests/Unit/Log/LogManagerTest.php
typo3/sysext/core/Tests/Unit/Mail/MailerTest.php
typo3/sysext/core/Tests/Unit/Mail/TransportFactoryTest.php
typo3/sysext/core/Tests/Unit/MetaTag/MetaTagManagerRegistryTest.php
typo3/sysext/core/Tests/Unit/Page/PageRendererTest.php
typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php
typo3/sysext/core/Tests/Unit/Resource/FileReferenceTest.php
typo3/sysext/core/Tests/Unit/Resource/FileTest.php
typo3/sysext/core/Tests/Unit/Resource/FolderTest.php
typo3/sysext/core/Tests/Unit/Resource/ProcessedFileTest.php
typo3/sysext/core/Tests/Unit/Resource/Rendering/RendererRegistryTest.php
typo3/sysext/core/Tests/Unit/Resource/ResourceFactoryTest.php
typo3/sysext/core/Tests/Unit/Resource/ResourceStorageTest.php
typo3/sysext/core/Tests/Unit/Service/MarkerBasedTemplateServiceTest.php
typo3/sysext/core/Tests/Unit/Utility/ExtensionManagementUtilityTest.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
typo3/sysext/core/Tests/Unit/Utility/MailUtilityTest.php
typo3/sysext/core/Tests/UnitDeprecated/Encoder/JavaScriptEncoderTest.php
typo3/sysext/core/Tests/UnitDeprecated/Html/RteHtmlParserTest.php
typo3/sysext/core/Tests/UnitDeprecated/Utility/ExtensionManagementUtilityTest.php
typo3/sysext/core/composer.json
typo3/sysext/extbase/Tests/Unit/Core/BootstrapTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/Cli/CommandTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/Controller/ActionControllerTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/Web/Routing/UriBuilderTest.php
typo3/sysext/extbase/Tests/Unit/Object/Container/ContainerTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/Storage/Typo3DbQueryParserTest.php
typo3/sysext/extbase/Tests/Unit/Reflection/ClassSchemaTest.php
typo3/sysext/extbase/Tests/Unit/Service/FlexFormServiceTest.php
typo3/sysext/extbase/Tests/Unit/Service/ImageScriptServiceTest.php
typo3/sysext/extbase/Tests/Unit/SignalSlot/DispatcherTest.php
typo3/sysext/extbase/Tests/UnitDeprecated/Reflection/ClassSchemaTest.php
typo3/sysext/extensionmanager/Tests/Unit/Task/UpdateExtensionListTaskTest.php
typo3/sysext/extensionmanager/Tests/Unit/Utility/ExtensionModelUtilityTest.php
typo3/sysext/felogin/Tests/Unit/Controller/FrontendLoginControllerTest.php
typo3/sysext/fluid/Tests/Unit/Core/Cache/FluidTemplateCacheTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/CObjectViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/ImageViewHelperTest.php
typo3/sysext/form/Tests/Unit/Controller/FormEditorControllerTest.php
typo3/sysext/form/Tests/Unit/Controller/FormManagerControllerTest.php
typo3/sysext/form/Tests/Unit/Domain/Finishers/AbstractFinisherTest.php
typo3/sysext/form/Tests/Unit/Domain/FormElements/AbstractSectionTest.php
typo3/sysext/form/Tests/Unit/Domain/Runtime/FormRuntimeTest.php
typo3/sysext/form/Tests/Unit/Hooks/DataStructureIdentifierHookTest.php
typo3/sysext/form/Tests/Unit/Mvc/ProcessingRuleTest.php
typo3/sysext/form/Tests/Unit/Mvc/Property/PropertyMappingConfigurationTest.php
typo3/sysext/form/Tests/Unit/Service/TranslationServiceTest.php
typo3/sysext/frontend/Tests/Functional/Controller/TypoScriptFrontendControllerTest.php
typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/CaseContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/FilesContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/FluidTemplateContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/Controller/ErrorControllerTest.php
typo3/sysext/frontend/Tests/Unit/Controller/TypoScriptFrontendControllerTest.php
typo3/sysext/frontend/Tests/Unit/Page/PageGeneratorTest.php
typo3/sysext/frontend/Tests/Unit/Plugin/AbstractPluginTest.php
typo3/sysext/frontend/Tests/Unit/Typolink/AbstractTypolinkBuilderTest.php
typo3/sysext/indexed_search/Tests/Unit/Example/PluginHookTest.php
typo3/sysext/indexed_search/Tests/Unit/IndexerTest.php
typo3/sysext/install/Tests/Unit/Service/CoreVersionServiceTest.php
typo3/sysext/install/Tests/Unit/Updates/Compatibility7ExtractionUpdateTest.php
typo3/sysext/install/Tests/UnitDeprecated/Service/CoreVersionServiceTest.php
typo3/sysext/redirects/Tests/Unit/Service/RedirectServiceTest.php
typo3/sysext/rsaauth/Tests/Unit/Backend/CommandLineBackendTest.php
typo3/sysext/rsaauth/Tests/Unit/Backend/PhpBackendTest.php
typo3/sysext/scheduler/Tests/Unit/Task/CachingFrameworkGarbageCollectionTest.php
typo3/sysext/workspaces/Tests/Unit/Controller/Remote/RemoteServerTest.php

index 5dc8874..a266740 100644 (file)
@@ -64,7 +64,7 @@
                "fiunchinho/phpunit-randomizer": "^4.0",
                "friendsofphp/php-cs-fixer": "^2.0",
                "typo3/cms-styleguide": "^9.1",
-               "typo3/testing-framework": "^3.2"
+               "typo3/testing-framework": "^3.8"
        },
        "suggest": {
                "ext-gd": "GDlib/Freetype is required for building images with text (GIFBUILDER) and can also be used to scale images",
index 66bdbfd..2dab12d 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "80a09c87266d7b40d69d7963c0d78d2f",
+    "content-hash": "8527aa1a371d8a4062ec28fa1c74c75b",
     "packages": [
         {
             "name": "cogpowered/finediff",
         },
         {
             "name": "typo3/testing-framework",
-            "version": "3.7.0",
+            "version": "3.8.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/TYPO3/testing-framework.git",
-                "reference": "a00307acc88ad2ad365932aa67ea73dc90a078f5"
+                "reference": "987bba68fdd93a9c1fcb397c7f0711e4f2cd9d1a"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/a00307acc88ad2ad365932aa67ea73dc90a078f5",
-                "reference": "a00307acc88ad2ad365932aa67ea73dc90a078f5",
+                "url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/987bba68fdd93a9c1fcb397c7f0711e4f2cd9d1a",
+                "reference": "987bba68fdd93a9c1fcb397c7f0711e4f2cd9d1a",
                 "shasum": ""
             },
             "require": {
                 "tests",
                 "typo3"
             ],
-            "time": "2018-06-08T10:33:39+00:00"
+            "time": "2018-06-10T17:26:48+00:00"
         },
         {
             "name": "webmozart/assert",
index 6bc08c3..6c2eaa7 100644 (file)
@@ -1,9 +1,22 @@
 <?php
 declare(strict_types = 1);
-
 namespace TYPO3\CMS\Adminpanel\Tests\Unit\Middleware;
 
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
 use Prophecy\Argument;
+use Prophecy\Prophecy\ObjectProphecy;
 use Psr\Http\Message\ResponseInterface;
 use Psr\Http\Server\RequestHandlerInterface;
 use TYPO3\CMS\Adminpanel\Controller\MainController;
@@ -15,8 +28,15 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
+/**
+ * Test case
+ */
 class AdminPanelInitiatorTest extends UnitTestCase
 {
+    /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
@@ -124,7 +144,7 @@ class AdminPanelInitiatorTest extends UnitTestCase
     }
 
     /**
-     * @return \Prophecy\Prophecy\ObjectProphecy|\Psr\Http\Server\RequestHandlerInterface
+     * @return ObjectProphecy|RequestHandlerInterface
      */
     protected function prophesizeHandler()
     {
index 0dc16ad..b5b8c73 100644 (file)
@@ -26,11 +26,16 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Class LoginControllerTest
+ * Test case
  */
 class LoginControllerTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var LoginController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
      */
     protected $loginControllerMock;
index 06acd71..204ef47 100644 (file)
@@ -39,14 +39,8 @@ class DatabaseSystemLanguageRowsTest extends UnitTestCase
      */
     protected $subject;
 
-    /**
-     * @var array A backup of registered singleton instances
-     */
-    protected $singletonInstances = [];
-
     protected function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $languageService = $this->prophesize(LanguageService::class);
         $GLOBALS['LANG'] = $languageService->reveal();
         $languageService->sL(Argument::cetera())->willReturnArgument(0);
@@ -56,7 +50,6 @@ class DatabaseSystemLanguageRowsTest extends UnitTestCase
     protected function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index ec0a425..3ea9d26 100644 (file)
@@ -30,23 +30,18 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class TcaCheckboxItemsTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * Tear down
      */
-    protected $singletonInstances = [];
-
-    protected function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
     protected function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
-    public function checkboxConfigurationDataProvider()
+    /**
+     * @return array
+     */
+    public function checkboxConfigurationDataProvider(): array
     {
         return [
             'simpleCheckboxConfig' => [
index 2984a19..bacd136 100644 (file)
@@ -27,15 +27,8 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class TcaFlexPrepareTest extends UnitTestCase
 {
-    /**
-     * @var array A backup of registered singleton instances
-     */
-    protected $singletonInstances = [];
-
     protected function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-
         // Suppress cache foo in xml helpers of GeneralUtility
         /** @var CacheManager|ObjectProphecy $cacheManagerProphecy */
         $cacheManagerProphecy = $this->prophesize(CacheManager::class);
@@ -47,7 +40,6 @@ class TcaFlexPrepareTest extends UnitTestCase
     protected function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index 8293032..4ebeeae 100644 (file)
@@ -30,20 +30,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class TcaGroupTest extends UnitTestCase
 {
     /**
-     * @var array
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances;
-
-    protected function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
index 58d715f..5f24979 100644 (file)
@@ -30,19 +30,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class TcaRadioItemsTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * Tear down
      */
-    protected $singletonInstances = [];
-
-    protected function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
     protected function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index 4f25ebc..e5e916f 100644 (file)
@@ -45,14 +45,10 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class TcaSelectItemsTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * Set up
      */
-    protected $singletonInstances = [];
-
     protected function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-
         // Default LANG prophecy just returns incoming value as label if calling ->sL()
         $languageServiceProphecy = $this->prophesize(LanguageService::class);
         $languageServiceProphecy->loadSingleTableDescription(Argument::cetera())->willReturn(null);
@@ -70,10 +66,12 @@ class TcaSelectItemsTest extends UnitTestCase
         GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
     }
 
+    /**
+     * Tear down
+     */
     protected function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index c3c906d..abb08a5 100644 (file)
@@ -41,24 +41,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class TcaSelectTreeItemsTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
-
-    /**
-     * Initializes the mock object.
-     */
-    public function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
-    protected function tearDown()
-    {
-        GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * Setup a mock database connection with expectations for
index d6d88f8..43bebfa 100644 (file)
@@ -28,9 +28,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class InlineStackProcessorTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * Set up
@@ -38,7 +38,6 @@ class InlineStackProcessorTest extends UnitTestCase
     public function setUp()
     {
         parent::setUp();
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $cacheManagerProphecy = $this->prophesize(CacheManager::class);
         $cacheProphecy = $this->prophesize(FrontendInterface::class);
         $cacheManagerProphecy->getCache('cache_runtime')->willReturn($cacheProphecy->reveal());
@@ -48,15 +47,6 @@ class InlineStackProcessorTest extends UnitTestCase
     }
 
     /**
-     * Tear down
-     */
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
-    /**
      * @return array
      */
     public function structureStringIsParsedDataProvider()
index 48d54ff..e1f83ce 100644 (file)
@@ -22,11 +22,12 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Test case for TcaFlexPrepare to render the functionality when a TCA migration happened
+ * Test case
  */
-class TcaFlexPrepareTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class TcaFlexPrepareTest extends UnitTestCase
 {
     /**
      * @var TcaFlexPrepare
@@ -39,14 +40,10 @@ class TcaFlexPrepareTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     protected $backendUserProphecy;
 
     /**
-     * @var array A backup of registered singleton instances
+     * Set up
      */
-    protected $singletonInstances = [];
-
     protected function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-
         // Suppress cache foo in xml helpers of GeneralUtility
         /** @var CacheManager|ObjectProphecy $cacheManagerProphecy */
         $cacheManagerProphecy = $this->prophesize(CacheManager::class);
@@ -57,10 +54,12 @@ class TcaFlexPrepareTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->subject = new TcaFlexPrepare();
     }
 
+    /**
+     * Tear down
+     */
     protected function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index 131a801..ca0a15a 100644 (file)
@@ -14,12 +14,14 @@ namespace TYPO3\CMS\Core\Log;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\SingletonInterface;
+
 /**
  * Global LogManager that keeps track of global logging information.
  *
  * Inspired by java.util.logging
  */
-class LogManager implements \TYPO3\CMS\Core\SingletonInterface, LogManagerInterface
+class LogManager implements SingletonInterface, LogManagerInterface
 {
     /**
      * @var string
diff --git a/typo3/sysext/core/Tests/Integrity/IntegrityTest.php b/typo3/sysext/core/Tests/Integrity/IntegrityTest.php
deleted file mode 100644 (file)
index 277d199..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Integrity;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
-
-/**
- * This test case is used in test suites to check for healthy
- * environments after other tests were run.
- *
- * This test is usually executed as the very last file in a suite and
- * should fail if some other test before destroys the environment with
- * invalid mocking or backups.
- */
-class IntegrityTest extends UnitTestCase
-{
-    /**
-     * This test fails if any test case manipulates the configurationManager
-     * property in LocalizationUtility due to mocking and fails to restore it
-     * properly.
-     *
-     * @test
-     */
-    public function ensureLocalisationUtilityConfigurationManagerIsNull()
-    {
-        $reflectionClass = new \ReflectionClass(LocalizationUtility::class);
-        $property = $reflectionClass->getProperty('configurationManager');
-        $property->setAccessible(true);
-        $this->assertNull($property->getValue());
-    }
-}
index a634ec7..00ce727 100644 (file)
@@ -14,16 +14,22 @@ namespace TYPO3\CMS\Core\Tests\Unit\Authentication;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 use TYPO3\CMS\Core\Authentication\AuthenticationService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for class \TYPO3\CMS\Core\Authentication\AuthenticationService
+ * Test case
  */
 class AuthenticationServiceTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * Date provider for processLoginReturnsCorrectData
      *
      * @return array
index c9b6505..43464c0 100644 (file)
@@ -27,6 +27,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class PdoBackendTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * Sets up this testcase
      */
     protected function setUp()
@@ -34,6 +39,7 @@ class PdoBackendTest extends UnitTestCase
         if (!extension_loaded('pdo_sqlite')) {
             $this->markTestSkipped('pdo_sqlite extension was not available');
         }
+        parent::setUp();
     }
 
     /**
index 75f2f1b..a528db8 100644 (file)
@@ -57,9 +57,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class FlexFormToolsTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * Set up
@@ -67,7 +67,6 @@ class FlexFormToolsTest extends UnitTestCase
     public function setUp()
     {
         parent::setUp();
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         // Underlying static GeneralUtility::xml2array() uses caches that have to be mocked here
         $cacheManagerProphecy = $this->prophesize(CacheManager::class);
         $cacheProphecy = $this->prophesize(FrontendInterface::class);
@@ -78,15 +77,6 @@ class FlexFormToolsTest extends UnitTestCase
     }
 
     /**
-     * Tear down
-     */
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
-    /**
      * @test
      */
     public function getDataStructureIdentifierCallsRegisteredPreProcessHook(): void
index e0a76dd..156da3a 100644 (file)
@@ -37,6 +37,11 @@ class DataHandlerTest extends UnitTestCase
     protected static $suppressNotices = true;
 
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var array A backup of registered singleton instances
      */
     protected $singletonInstances = [];
@@ -57,7 +62,6 @@ class DataHandlerTest extends UnitTestCase
     protected function setUp()
     {
         $GLOBALS['TCA'] = [];
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $cacheManagerProphecy = $this->prophesize(CacheManager::class);
         GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
         $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
@@ -68,18 +72,6 @@ class DataHandlerTest extends UnitTestCase
     }
 
     /**
-     * Tear down the tests
-     */
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
-    //////////////////////////////////////
-    // Tests for the basic functionality
-    //////////////////////////////////////
-    /**
      * @test
      */
     public function fixtureCanBeCreated()
index f55b56c..a26bb24 100644 (file)
@@ -24,7 +24,6 @@ use Doctrine\DBAL\Types\SmallIntType;
 use Doctrine\DBAL\Types\TextType;
 use TYPO3\CMS\Core\Database\Schema\Parser\Parser;
 use TYPO3\CMS\Core\Database\Schema\SqlReader;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -33,6 +32,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class TableBuilderTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var Table
      */
     protected $table;
@@ -44,10 +48,10 @@ class TableBuilderTest extends UnitTestCase
     {
         parent::setUp();
         $sqlFile = file_get_contents(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'Fixtures', 'tablebuilder.sql']));
-        $sqlReader = GeneralUtility::makeInstance(SqlReader::class);
+        $sqlReader = new SqlReader();
         $statements = $sqlReader->getCreateTableStatementArray($sqlFile);
 
-        $parser = GeneralUtility::makeInstance(Parser::class, $statements[0]);
+        $parser = new Parser($statements[0]);
         $this->table = $parser->parse()[0];
     }
 
index 55862e0..9d3b945 100644 (file)
@@ -17,34 +17,25 @@ namespace TYPO3\CMS\Core\Tests\Unit\Database\Schema;
  */
 
 use TYPO3\CMS\Core\Database\Schema\SqlReader;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Tests for SqlReader
+ * Test case
  */
 class SqlReaderTest extends UnitTestCase
 {
     /**
-     * @var SqlReader
+     * @var bool Reset singletons created by subject
      */
-    protected $subject;
-
-    /**
-     * Set up the test subject
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-        $this->subject = GeneralUtility::makeInstance(SqlReader::class);
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
      */
     public function getStatementArraySplitsStatements()
     {
-        $result = $this->subject->getStatementArray(
+        $subject = new SqlReader();
+        $result = $subject->getStatementArray(
             'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
             LF .
             'INSERT INTO aTestTable(`aTestField`) VALUES(1);'
@@ -59,7 +50,8 @@ class SqlReaderTest extends UnitTestCase
      */
     public function getStatementArrayFiltersStatements()
     {
-        $result = $this->subject->getStatementArray(
+        $subject = new SqlReader();
+        $result = $subject->getStatementArray(
             'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
             LF .
             'INSERT INTO aTestTable(`aTestField`) VALUES(1);',
@@ -74,7 +66,8 @@ class SqlReaderTest extends UnitTestCase
      */
     public function getInsertStatementArrayResult()
     {
-        $result = $this->subject->getInsertStatementArray(
+        $subject = new SqlReader();
+        $result = $subject->getInsertStatementArray(
             'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
             LF .
             'INSERT INTO aTestTable(`aTestField`) VALUES(1);'
@@ -89,7 +82,8 @@ class SqlReaderTest extends UnitTestCase
      */
     public function getInsertStatementArrayResultWithNewline()
     {
-        $result = $this->subject->getInsertStatementArray(
+        $subject = new SqlReader();
+        $result = $subject->getInsertStatementArray(
             'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
             LF .
             'INSERT INTO aTestTable(`aTestField`) ' .
@@ -106,7 +100,8 @@ class SqlReaderTest extends UnitTestCase
      */
     public function getCreateTableStatementArrayResult()
     {
-        $result = $this->subject->getCreateTableStatementArray(
+        $subject = new SqlReader();
+        $result = $subject->getCreateTableStatementArray(
             'CREATE TABLE aTestTable(' . LF . '  aTestField INT(11)' . LF . ');' .
             LF .
             'INSERT INTO aTestTable(`aTestField`) VALUES(1);'
index 6cee081..9aac4d8 100644 (file)
@@ -19,20 +19,27 @@ use TYPO3\CMS\Core\Html\RteHtmlParser;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for \TYPO3\CMS\Core\Html\RteHtmlParser
+ * Test case
  */
 class RteHtmlParserTest extends UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Core\Html\RteHtmlParser
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
+     * @var RteHtmlParser
      */
     protected $subject = null;
 
+    /**
+     * Set up
+     */
     protected function setUp()
     {
         $this->subject = new RteHtmlParser();
         $this->subject->procOptions = [
-            'allowTagsOutside' => 'hr, address',
             'overruleMode' => 'default',
         ];
     }
index 26c1ac3..ede87ab 100644 (file)
@@ -26,12 +26,17 @@ use TYPO3\CMS\Core\Resource\ResourceStorage;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * TestCase for \TYPO3\CMS\Core\Imaging\IconFactory
+ * Test case
  */
 class IconFactoryTest extends UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Core\Imaging\IconFactory
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
+     * @var IconFactory
      */
     protected $subject = null;
 
@@ -88,7 +93,7 @@ class IconFactoryTest extends UnitTestCase
         $this->iconRegistryMock->isRegistered('tcarecords--default')->willReturn(false);
         $this->iconRegistryMock->isRegistered(Argument::any())->willReturn(true);
         $this->iconRegistryMock->isDeprecated(Argument::any())->willReturn(false);
-        $this->iconRegistryMock->getDefaultIconIdentifier(Argument::any())->willReturn('default-not-found');
+        $this->iconRegistryMock->getDefaultIconIdentifier()->willReturn('default-not-found');
         $this->iconRegistryMock->getIconIdentifierForMimeType('application/pdf')->willReturn('mimetypes-pdf');
         $this->iconRegistryMock->getIconIdentifierForMimeType('image/*')->willReturn('mimetypes-media-image');
         $this->iconRegistryMock->getIconIdentifierForMimeType(Argument::any())->willReturn(null);
index 62e940a..2a0aa28 100644 (file)
@@ -20,7 +20,6 @@ use TYPO3\CMS\Core\Log\LogLevel;
 use TYPO3\CMS\Core\Log\LogManager;
 use TYPO3\CMS\Core\Log\Processor\NullProcessor;
 use TYPO3\CMS\Core\Log\Writer\NullWriter;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -29,27 +28,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class LogManagerTest extends UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Core\Log\LogManager
-     */
-    protected $logManagerInstance = null;
-
-    protected function setUp()
-    {
-        $this->logManagerInstance = GeneralUtility::makeInstance(LogManager::class);
-    }
-
-    protected function tearDown()
-    {
-        GeneralUtility::makeInstance(LogManager::class)->reset();
-        parent::tearDown();
-    }
-
-    /**
      * @test
      */
     public function logManagerReturnsLoggerWhenRequestedWithGetLogger()
     {
-        $this->assertInstanceOf(Logger::class, $this->logManagerInstance->getLogger('test'));
+        $this->assertInstanceOf(Logger::class, (new LogManager())->getLogger('test'));
     }
 
     /**
@@ -57,7 +40,7 @@ class LogManagerTest extends UnitTestCase
      */
     public function logManagerTurnsUnderScoreStyleLoggerNamesIntoDotStyleLoggerNames()
     {
-        $this->assertSame('test.a.b', $this->logManagerInstance->getLogger('test_a_b')->getName());
+        $this->assertSame('test.a.b', (new LogManager())->getLogger('test_a_b')->getName());
     }
 
     /**
@@ -65,7 +48,7 @@ class LogManagerTest extends UnitTestCase
      */
     public function logManagerTurnsNamespaceStyleLoggerNamesIntoDotStyleLoggerNames()
     {
-        $this->assertSame('test.a.b', $this->logManagerInstance->getLogger('test\\a\\b')->getName());
+        $this->assertSame('test.a.b', (new LogManager())->getLogger('test\\a\\b')->getName());
     }
 
     /**
@@ -74,9 +57,10 @@ class LogManagerTest extends UnitTestCase
     public function managerReturnsSameLoggerOnRepeatedRequest()
     {
         $loggerName = $this->getUniqueId('test.core.log');
-        $this->logManagerInstance->registerLogger($loggerName);
-        $logger1 = $this->logManagerInstance->getLogger($loggerName);
-        $logger2 = $this->logManagerInstance->getLogger($loggerName);
+        $logger = new LogManager();
+        $logger->registerLogger($loggerName);
+        $logger1 = $logger->getLogger($loggerName);
+        $logger2 = $logger->getLogger($loggerName);
         $this->assertSame($logger1, $logger2);
     }
 
@@ -93,8 +77,7 @@ class LogManagerTest extends UnitTestCase
                 $writer => []
             ]
         ];
-        /** @var $logger \TYPO3\CMS\Core\Log\Logger */
-        $logger = $this->logManagerInstance->getLogger($component);
+        $logger = (new LogManager())->getLogger($component);
         $writers = $logger->getWriters();
         $this->assertInstanceOf($writer, $writers[$level][0]);
     }
@@ -112,8 +95,7 @@ class LogManagerTest extends UnitTestCase
                 $processor => []
             ]
         ];
-        /** @var $logger \TYPO3\CMS\Core\Log\Logger */
-        $logger = $this->logManagerInstance->getLogger($component);
+        $logger = (new LogManager())->getLogger($component);
         $processors = $logger->getProcessors();
         $this->assertInstanceOf($processor, $processors[$level][0]);
     }
index 678e2ea..8257b20 100644 (file)
@@ -22,15 +22,23 @@ use TYPO3\CMS\Core\Tests\Unit\Mail\Fixtures\FakeTransportFixture;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for the TYPO3\CMS\Core\Mail\Mailer class.
+ * Test case
  */
 class MailerTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var Mailer
      */
     protected $subject;
 
+    /**
+     * Set up
+     */
     protected function setUp()
     {
         $this->subject = $this->getMockBuilder(Mailer::class)
@@ -39,9 +47,6 @@ class MailerTest extends UnitTestCase
             ->getMock();
     }
 
-    //////////////////////////
-    // Tests concerning TYPO3\CMS\Core\Mail\Mailer
-    //////////////////////////
     /**
      * @test
      */
index f069297..22e05d8 100644 (file)
@@ -20,23 +20,17 @@ use TYPO3\CMS\Core\Mail\MemorySpool;
 use TYPO3\CMS\Core\Mail\TransportFactory;
 use TYPO3\CMS\Core\Tests\Unit\Mail\Fixtures\FakeInvalidSpoolFixture;
 use TYPO3\CMS\Core\Tests\Unit\Mail\Fixtures\FakeValidSpoolFixture;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for the TYPO3\CMS\Core\Mail\TransportFactory class.
+ * Test case
  */
 class TransportFactoryTest extends UnitTestCase
 {
     /**
-     * * @var TransportFactory
+     * @var bool Reset singletons created by subject
      */
-    protected $subject;
-
-    protected function setUp()
-    {
-        $this->subject = GeneralUtility::makeInstance(TransportFactory::class);
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
@@ -60,8 +54,7 @@ class TransportFactoryTest extends UnitTestCase
         // Register fixture class
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\Swift_FileSpool::class]['className'] = Fixtures\FakeFileSpoolFixture::class;
 
-        /** @var \Swift_SpoolTransport $transport */
-        $transport = $this->subject->get($mailSettings);
+        $transport = (new TransportFactory())->get($mailSettings);
         $this->assertInstanceOf(\Swift_SpoolTransport::class, $transport);
 
         /** @var Fixtures\FakeFileSpoolFixture $spool */
@@ -94,8 +87,7 @@ class TransportFactoryTest extends UnitTestCase
         // Register fixture class
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][MemorySpool::class]['className'] = Fixtures\FakeMemorySpoolFixture::class;
 
-        /** @var \Swift_SpoolTransport $transport */
-        $transport = $this->subject->get($mailSettings);
+        $transport = (new TransportFactory())->get($mailSettings);
         $this->assertInstanceOf(\Swift_SpoolTransport::class, $transport);
 
         /** @var \Swift_MemorySpool $spool */
@@ -122,8 +114,7 @@ class TransportFactoryTest extends UnitTestCase
             'transport_spool_filepath' => Environment::getVarPath() . '/messages/',
         ];
 
-        /** @var \Swift_SpoolTransport $transport */
-        $transport = $this->subject->get($mailSettings);
+        $transport = (new TransportFactory())->get($mailSettings);
         $this->assertInstanceOf(\Swift_SpoolTransport::class, $transport);
 
         /** @var Fixtures\FakeValidSpoolFixture $spool */
@@ -155,7 +146,7 @@ class TransportFactoryTest extends UnitTestCase
             'transport_spool_filepath' => Environment::getVarPath() . '/messages/',
         ];
 
-        $this->subject->get($mailSettings);
+        (new TransportFactory())->get($mailSettings);
     }
 
     /**
@@ -177,7 +168,7 @@ class TransportFactoryTest extends UnitTestCase
             'transport_spool_filepath' => Environment::getVarPath() . '/messages/',
         ];
 
-        $transport = $this->subject->get($mailSettings);
+        $transport = (new TransportFactory())->get($mailSettings);
         $this->assertInstanceOf(\Swift_MailTransport::class, $transport);
     }
 }
index 4bdea07..bd34937 100644 (file)
@@ -21,13 +21,19 @@ use TYPO3\CMS\Core\MetaTag\Html5MetaTagManager;
 use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry;
 use TYPO3\CMS\Seo\MetaTag\OpenGraphMetaTagManager;
 use TYPO3\CMS\Seo\MetaTag\TwitterCardMetaTagManager;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class MetaTagManagerRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class MetaTagManagerRegistryTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @test
      */
     public function checkRegisterNonExistingManagerDoesntThrowErrorWhenFetchingManagers()
index d598121..337f7f3 100644 (file)
@@ -15,20 +15,20 @@ namespace TYPO3\CMS\Core\Tests\Unit\Page;
  */
 
 use TYPO3\CMS\Core\Page\PageRenderer;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Unit test case
- *
- * @see According functional test case
+ * Test case
  */
-class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class PageRendererTest extends UnitTestCase
 {
     /**
      * @test
      */
     public function renderMethodCallsResetInAnyCase()
     {
-        $pageRenderer = $this->getMockBuilder(\TYPO3\CMS\Core\Page\PageRenderer::class)
+        $this->resetSingletonInstances = true;
+        $pageRenderer = $this->getMockBuilder(PageRenderer::class)
             ->setMethods(['reset', 'prepareRendering', 'renderJavaScriptAndCss', 'getPreparedMarkerArray', 'getTemplateForPart'])
             ->getMock();
         $pageRenderer->expects($this->exactly(3))->method('reset');
@@ -46,8 +46,8 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->expectException(\UnexpectedValueException::class);
         $this->expectExceptionCode(1341505305);
 
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['dummy'], [], '', false);
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['dummy'], [], '', false);
         $subject->_set('availableLocalJqueryVersions', ['1.1.1']);
         $subject->loadJquery('2.2.2');
     }
@@ -60,8 +60,8 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->expectException(\UnexpectedValueException::class);
         $this->expectExceptionCode(1341571604);
 
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['dummy'], [], '', false);
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['dummy'], [], '', false);
         $subject->loadJquery(null, null, '12sd.12fsd');
         $subject->render();
     }
@@ -71,8 +71,8 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function addBodyContentAddsContent()
     {
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['dummy'], [], '', false);
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['dummy'], [], '', false);
         $expectedReturnValue = 'ABCDE';
         $subject->addBodyContent('A');
         $subject->addBodyContent('B');
@@ -88,8 +88,8 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function addInlineLanguageLabelFileSetsInlineLanguageLabelFiles()
     {
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['dummy'], [], '', false);
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['dummy'], [], '', false);
         $fileReference = $this->getUniqueId('file_');
         $selectionPrefix = $this->getUniqueId('prefix_');
         $stripFromSelectionName = $this->getUniqueId('strip_');
@@ -111,8 +111,8 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function addInlineLanguageLabelFileSetsTwoDifferentInlineLanguageLabelFiles()
     {
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['dummy'], [], '', false);
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['dummy'], [], '', false);
         $fileReference1 = $this->getUniqueId('file1_');
         $selectionPrefix1 = $this->getUniqueId('prefix1_');
         $stripFromSelectionName1 = $this->getUniqueId('strip1_');
@@ -143,8 +143,8 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function addInlineLanguageLabelFileDoesNotSetSameLanguageFileTwice()
     {
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['dummy'], [], '', false);
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['dummy'], [], '', false);
         $fileReference = $this->getUniqueId('file2_');
         $selectionPrefix = $this->getUniqueId('prefix2_');
         $stripFromSelectionName = $this->getUniqueId('strip2_');
@@ -162,8 +162,8 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionCode(1284906026);
 
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['dummy'], [], '', false);
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['dummy'], [], '', false);
         $subject->_set('charSet', 'utf-8');
         $subject->_call('includeLanguageFileForInline', 'someLLFile.xml');
     }
@@ -176,8 +176,8 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->expectException(\RuntimeException::class);
         $this->expectExceptionCode(1284906026);
 
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['dummy'], [], '', false);
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['dummy'], [], '', false);
         $subject->_set('lang', 'default');
         $subject->_call('includeLanguageFileForInline', 'someLLFile.xml');
     }
@@ -187,8 +187,8 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function includeLanguageFileForInlineDoesNotAddToInlineLanguageLabelsIfFileCouldNotBeRead()
     {
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['readLLfile'], [], '', false);
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['readLLfile'], [], '', false);
         $subject->_set('lang', 'default');
         $subject->_set('charSet', 'utf-8');
         $subject->_set('inlineLanguageLabels', []);
@@ -253,8 +253,8 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function includeLanguageFileForInlineAddsProcessesLabelsToInlineLanguageLabels($llFileContent, $selectionPrefix, $stripFromSelectionName, $expectation)
     {
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['readLLfile'], [], '', false);
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['readLLfile'], [], '', false);
         $subject->_set('lang', 'default');
         $subject->_set('charSet', 'utf-8');
         $subject->_set('inlineLanguageLabels', []);
@@ -268,8 +268,9 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getAddedMetaTag()
     {
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['whatDoesThisDo']);
+        $this->resetSingletonInstances = true;
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['whatDoesThisDo']);
         $subject->setMetaTag('nAme', 'Author', 'foobar');
         $actualResult = $subject->getMetaTag('naMe', 'AUTHOR');
         $expectedResult = [
@@ -285,8 +286,9 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function overrideMetaTag()
     {
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['whatDoesThisDo']);
+        $this->resetSingletonInstances = true;
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['whatDoesThisDo']);
         $subject->setMetaTag('nAme', 'Author', 'Axel Foley');
         $subject->setMetaTag('nAme', 'Author', 'foobar');
         $actualResult = $subject->getMetaTag('naMe', 'AUTHOR');
@@ -303,8 +305,9 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function unsetAddedMetaTag()
     {
-        /** @var \TYPO3\CMS\Core\Page\PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['whatDoesThisDo']);
+        $this->resetSingletonInstances = true;
+        /** @var PageRenderer|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['whatDoesThisDo']);
         $subject->setMetaTag('nAme', 'Author', 'foobar');
         $subject->removeMetaTag('naMe', 'AUTHOR');
         $actualResult = $subject->getMetaTag('naMe', 'AUTHOR');
@@ -317,7 +320,7 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function parseLanguageLabelsForJavaScriptReturnsEmptyStringIfEmpty()
     {
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['dummy'], [], '', false);
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['dummy'], [], '', false);
         $inlineLanguageLabels = [];
         $subject->_set('inlineLanguageLabels', $inlineLanguageLabels);
         $actual = $subject->_call('parseLanguageLabelsForJavaScript');
@@ -329,7 +332,7 @@ class PageRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function parseLanguageLabelsForJavaScriptReturnsFlatArray()
     {
-        $subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Page\PageRenderer::class, ['dummy'], [], '', false);
+        $subject = $this->getAccessibleMock(PageRenderer::class, ['dummy'], [], '', false);
         $inlineLanguageLabels = [
             'key' => 'label',
             'foo' => 'bar',
index ae758da..ee6b68e 100644 (file)
@@ -30,19 +30,19 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\FileStreamWrapper;
 
 /**
- * Testcase for the local storage driver class of the TYPO3 VFS
+ * Test case
  */
 class LocalDriverTest extends BaseTestCase
 {
     /**
-     * @var LocalDriver
+     * @var bool Reset singletons created by subject
      */
-    protected $localDriver;
+    protected $resetSingletonInstances = true;
 
     /**
-     * @var array A backup of registered singleton instances
+     * @var LocalDriver
      */
-    protected $singletonInstances = [];
+    protected $localDriver;
 
     /**
      * @var array
index ca1b1f8..280d314 100644 (file)
@@ -15,28 +15,11 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource;
  */
 
 /**
- * Testcase for the file class of the TYPO3 FAL
+ * Test case
  */
 class FileReferenceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
-     */
-    protected $singletonInstances = [];
-
-    protected function setUp()
-    {
-        $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-        \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
-    }
-
-    protected function tearDown()
-    {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
-    /**
      * @param array $fileReferenceProperties
      * @param array $originalFileProperties
      * @return \TYPO3\CMS\Core\Resource\FileReference|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
index 159ac0c..32232de 100644 (file)
@@ -27,9 +27,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class FileTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * @var ResourceStorage
@@ -38,7 +38,6 @@ class FileTest extends UnitTestCase
 
     protected function setUp(): void
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $this->storageMock = $this->createMock(ResourceStorage::class);
         $this->storageMock->expects($this->any())->method('getUid')->will($this->returnValue(5));
 
@@ -47,12 +46,6 @@ class FileTest extends UnitTestCase
         GeneralUtility::setSingletonInstance(MetaDataRepository::class, $mockedMetaDataRepository);
     }
 
-    protected function tearDown(): void
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
     /**
      * @return File
      */
index 659ad85..1e353a9 100644 (file)
@@ -15,31 +15,25 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource;
  */
 
 use org\bovigo\vfs\vfsStream;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for the storage collection class of the TYPO3 FAL
+ * Test case
  */
-class FolderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class FolderTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     protected $basedir = 'basedir';
 
     protected function setUp()
     {
-        $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
         vfsStream::setup($this->basedir);
     }
 
-    protected function tearDown()
-    {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
     protected function createFolderFixture($path, $name, $mockedStorage = null)
     {
         if ($mockedStorage === null) {
index b479d17..586e4ea 100644 (file)
@@ -27,6 +27,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class ProcessedFileTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var \PHPUnit_Framework_MockObject_MockObject|Folder
      */
     protected $folderMock;
index 097d538..7de7fdb 100644 (file)
@@ -14,8 +14,12 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource\Rendering;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer;
+use TYPO3\CMS\Core\Resource\Rendering\RendererRegistry;
+use TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer;
+
 /**
- * Test cases for RendererRegistry
+ * Test case
  */
 class RendererRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
 {
@@ -23,11 +27,11 @@ class RendererRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      * Initialize a RendererRegistry and mock createRendererInstance()
      *
      * @param array $createsRendererInstances
-     * @return \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Resource\Rendering\RendererRegistry
+     * @return \PHPUnit_Framework_MockObject_MockObject|RendererRegistry
      */
     protected function getTestRendererRegistry(array $createsRendererInstances = [])
     {
-        $rendererRegistry = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\Rendering\RendererRegistry::class)
+        $rendererRegistry = $this->getMockBuilder(RendererRegistry::class)
             ->setMethods(['createRendererInstance'])
             ->getMock();
 
@@ -198,9 +202,10 @@ class RendererRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function getRendererReturnsCorrectInstance2()
     {
-        $rendererRegistry = \TYPO3\CMS\Core\Resource\Rendering\RendererRegistry::getInstance();
-        $rendererRegistry->registerRendererClass(\TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer::class);
-        $rendererRegistry->registerRendererClass(\TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer::class);
+        $this->resetSingletonInstances = true;
+        $rendererRegistry = RendererRegistry::getInstance();
+        $rendererRegistry->registerRendererClass(AudioTagRenderer::class);
+        $rendererRegistry->registerRendererClass(VideoTagRenderer::class);
 
         $fileResourceMock = $this->createMock(\TYPO3\CMS\Core\Resource\File::class);
         $fileResourceMock->expects($this->any())->method('getMimeType')->will($this->returnValue('video/mp4'));
@@ -209,6 +214,6 @@ class RendererRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
 
         $renderer = $rendererRegistry->getRenderer($fileResourceMock);
 
-        $this->assertInstanceOf(\TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer::class, $renderer);
+        $this->assertInstanceOf(VideoTagRenderer::class, $renderer);
     }
 }
index 1055e90..bdcb7f4 100644 (file)
@@ -14,18 +14,21 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Resource\ResourceFactory;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
 /**
- * Testcase for the factory of FAL
+ * Test case
  */
-class ResourceFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ResourceFactoryTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
-     * @var \TYPO3\CMS\Core\Resource\ResourceFactory
+     * @var ResourceFactory
      */
     protected $subject;
 
@@ -34,15 +37,19 @@ class ResourceFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     protected $filesCreated = [];
 
+    /**
+     * Set up
+     */
     protected function setUp()
     {
-        $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-        $this->subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Resource\ResourceFactory::class, ['dummy'], [], '', false);
+        $this->subject = $this->getAccessibleMock(ResourceFactory::class, ['dummy'], [], '', false);
     }
 
+    /**
+     * Tear down
+     */
     protected function tearDown()
     {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
         foreach ($this->filesCreated as $file) {
             unlink($file);
         }
@@ -93,9 +100,9 @@ class ResourceFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function retrieveFileOrFolderObjectCallsGetFolderObjectFromCombinedIdentifierWithRelativePath()
     {
-        /** @var $subject \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\TYPO3\CMS\Core\Resource\ResourceFactory */
+        /** @var $subject \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|ResourceFactory */
         $subject = $this->getAccessibleMock(
-            \TYPO3\CMS\Core\Resource\ResourceFactory::class,
+            ResourceFactory::class,
             ['getFolderObjectFromCombinedIdentifier'],
             [],
             '',
@@ -113,9 +120,9 @@ class ResourceFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function retrieveFileOrFolderObjectCallsGetFolderObjectFromCombinedIdentifierWithAbsolutePath()
     {
-        /** @var $subject \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\TYPO3\CMS\Core\Resource\ResourceFactory */
+        /** @var $subject \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|ResourceFactory */
         $subject = $this->getAccessibleMock(
-            \TYPO3\CMS\Core\Resource\ResourceFactory::class,
+            ResourceFactory::class,
             ['getFolderObjectFromCombinedIdentifier'],
             [],
             '',
@@ -133,7 +140,7 @@ class ResourceFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function retrieveFileOrFolderObjectReturnsFileIfPathIsGiven()
     {
-        $this->subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Resource\ResourceFactory::class, ['getFileObjectFromCombinedIdentifier'], [], '', false);
+        $this->subject = $this->getAccessibleMock(ResourceFactory::class, ['getFileObjectFromCombinedIdentifier'], [], '', false);
         $filename = 'typo3temp/var/tests/4711.txt';
         $this->subject->expects($this->once())
             ->method('getFileObjectFromCombinedIdentifier')
index 06fec88..949a913 100644 (file)
@@ -42,19 +42,21 @@ class ResourceStorageTest extends BaseTestCase
     protected static $suppressNotices = true;
 
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * @var ResourceStorage|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $subject;
 
+    /**
+     * Set up
+     */
     protected function setUp()
     {
         parent::setUp();
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         /** @var FileRepository|\PHPUnit_Framework_MockObject_MockObject $fileRepositoryMock */
         $fileRepositoryMock = $this->createMock(FileRepository::class);
         GeneralUtility::setSingletonInstance(
@@ -69,12 +71,6 @@ class ResourceStorageTest extends BaseTestCase
         GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
     }
 
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
     /**
      * Prepare ResourceStorage
      *
index c9d2520..7a85570 100644 (file)
@@ -35,30 +35,23 @@ class MarkerBasedTemplateServiceTest extends UnitTestCase
     protected $templateService;
 
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
+    /**
+     * Set up
+     */
     protected function setUp(): void
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-
         /** @var CacheManager|ObjectProphecy $cacheManagerProphecy */
         $cacheManagerProphecy = $this->prophesize(CacheManager::class);
         GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
         $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
         $cacheManagerProphecy->getCache(Argument::cetera())->willReturn($cacheFrontendProphecy->reveal());
-
         $this->templateService = new MarkerBasedTemplateService();
     }
 
-    protected function tearDown(): void
-    {
-        GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
     /**
      * Data provider for getSubpart
      *
index 27ff22c..4dd677e 100644 (file)
@@ -24,11 +24,12 @@ use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class ExtensionManagementUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ExtensionManagementUtilityTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -36,29 +37,32 @@ class ExtensionManagementUtilityTest extends \TYPO3\TestingFramework\Core\Unit\U
     protected static $suppressNotices = true;
 
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * @var \TYPO3\CMS\Core\Package\PackageManager
      */
     protected $backUpPackageManager;
 
+    /**
+     * Set up
+     */
     protected function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $this->backUpPackageManager = ExtensionManagementUtilityAccessibleProxy::getPackageManager();
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
     }
 
+    /**
+     * Tear down
+     */
     protected function tearDown()
     {
         ExtensionManagementUtility::clearExtensionKeyMap();
         ExtensionManagementUtilityAccessibleProxy::setPackageManager($this->backUpPackageManager);
         ExtensionManagementUtilityAccessibleProxy::setCacheManager(null);
         $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->backUpPackageManager);
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index 4074085..d2123fa 100644 (file)
@@ -53,9 +53,9 @@ class GeneralUtilityTest extends UnitTestCase
     protected static $suppressNotices = true;
 
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * @var \TYPO3\CMS\Core\Package\PackageManager
@@ -71,7 +71,6 @@ class GeneralUtilityTest extends UnitTestCase
         GeneralUtilityFixture::$isAllowedHostHeaderValueCallCount = 0;
         GeneralUtilityFixture::setAllowHostHeaderValue(false);
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['trustedHostsPattern'] = GeneralUtility::ENV_TRUSTED_HOSTS_PATTERN_ALLOW_ALL;
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $this->backupPackageManager = ExtensionManagementUtilityAccessibleProxy::getPackageManager();
     }
 
@@ -80,7 +79,6 @@ class GeneralUtilityTest extends UnitTestCase
      */
     protected function tearDown()
     {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         ExtensionManagementUtilityAccessibleProxy::setPackageManager($this->backupPackageManager);
         parent::tearDown();
     }
index c273e74..afcbfbb 100644 (file)
@@ -22,20 +22,9 @@ use TYPO3\CMS\Core\Utility\MailUtility;
 class MailUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
-
-    protected function setUp()
-    {
-        $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-    }
-
-    protected function tearDown()
-    {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
index d9d2a36..1b11db2 100644 (file)
@@ -14,20 +14,18 @@ namespace TYPO3\CMS\Core\Tests\UnitDeprecated\Encoder;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Encoder\JavaScriptEncoder;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
 /**
- * Test cases for TYPO3\CMS\Core\Encoder\JavaScriptEncoder.
+ * Test case
  */
-class JavaScriptEncoderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class JavaScriptEncoderTest extends UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Core\Encoder\JavaScriptEncoder
+     * @var bool Reset singletons created by subject
      */
-    protected $subject = null;
-
-    protected function setUp()
-    {
-        $this->subject = new \TYPO3\CMS\Core\Encoder\JavaScriptEncoder();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * Data provider for encodeEncodesCorrectly.
@@ -84,6 +82,7 @@ class JavaScriptEncoderTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa
      */
     public function encodeEncodesCorrectly($input, $expected)
     {
-        $this->assertSame($expected, $this->subject->encode($input));
+        $subject = new JavaScriptEncoder();
+        $this->assertSame($expected, $subject->encode($input));
     }
 }
index e6c0e5d..e6ada36 100644 (file)
@@ -14,12 +14,19 @@ namespace TYPO3\CMS\Core\Tests\Unit_Deprecated\Html;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
 /**
- * Testcase for \TYPO3\CMS\Core\Html\RteHtmlParser
+ * Test case
  */
-class RteHtmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class RteHtmlParserTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * Subject is not notice free, disable E_NOTICES
      */
     protected static $suppressNotices = true;
index 73b2838..41f0386 100644 (file)
@@ -21,36 +21,35 @@ use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class ExtensionManagementUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ExtensionManagementUtilityTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
-     */
-    protected $singletonInstances = [];
-
-    /**
      * @var \TYPO3\CMS\Core\Package\PackageManager
      */
     protected $backUpPackageManager;
 
+    /**
+     * Set up
+     */
     protected function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $this->backUpPackageManager = ExtensionManagementUtilityAccessibleProxy::getPackageManager();
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
     }
 
+    /**
+     * Tear down
+     */
     protected function tearDown()
     {
         ExtensionManagementUtility::clearExtensionKeyMap();
         ExtensionManagementUtilityAccessibleProxy::setPackageManager($this->backUpPackageManager);
         ExtensionManagementUtilityAccessibleProxy::setCacheManager(null);
         $GLOBALS['TYPO3_LOADED_EXT'] = new LoadedExtensionsArray($this->backUpPackageManager);
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index 777aca1..866a104 100644 (file)
@@ -46,7 +46,7 @@
                "fiunchinho/phpunit-randomizer": "^4.0",
                "friendsofphp/php-cs-fixer": "^2.0",
                "typo3/cms-styleguide": "^9.1",
-               "typo3/testing-framework": "^3.2"
+               "typo3/testing-framework": "^3.8"
        },
        "suggest": {
                "ext-fileinfo": "Used for proper file type detection in the file abstraction layer",
index 37d7766..1cec66b 100644 (file)
@@ -22,24 +22,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class BootstrapTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
-
-    /**
-     * Sets up this testcase
-     */
-    protected function setUp()
-    {
-        $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-    }
-
-    protected function tearDown()
-    {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
-        \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
index 22438e2..928fcf0 100644 (file)
@@ -26,28 +26,17 @@ use TYPO3\CMS\Extbase\Mvc\Cli\Command;
 use TYPO3\CMS\Extbase\Mvc\Cli\CommandArgumentDefinition;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Extbase\Tests\Unit\Mvc\Cli\Fixture\Command\MockCCommandController;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class CommandTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class CommandTest extends UnitTestCase
 {
     /**
-     * @var array
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances;
-
-    protected function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-        GeneralUtility::purgeInstances();
-    }
-
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @return array
index a983469..5d93f4e 100644 (file)
@@ -39,6 +39,11 @@ use TYPO3Fluid\Fluid\View\TemplateView as FluidTemplateView;
 class ActionControllerTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var \TYPO3\CMS\Extbase\Mvc\Controller\ActionController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
      */
     protected $actionController;
index f84b160..a79ded9 100644 (file)
@@ -39,6 +39,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class UriBuilderTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var ConfigurationManagerInterface
      */
     protected $mockConfigurationManager;
index 735093f..5293c53 100644 (file)
@@ -22,46 +22,39 @@ use TYPO3\CMS\Extbase\Reflection\Exception\UnknownClassException;
 use TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\ArgumentTestClassForPublicPropertyInjection;
 use TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\ProtectedPropertyInjectClass;
 use TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\PublicPropertyInjectClass;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ContainerTest extends UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Extbase\Object\Container\Container
+     * @var bool Reset singletons created by subject
      */
-    protected $container;
+    protected $resetSingletonInstances = true;
 
     /**
-     * @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
+     * @var Container
      */
-    protected $logger;
+    protected $subject;
 
     /**
-     * @var \TYPO3\CMS\Extbase\Object\Container\ClassInfo
+     * @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject
      */
-    protected $cachedClassInfo;
+    protected $logger;
 
     protected function setUp()
     {
-        // The mocked cache will always indicate that he has nothing in the cache to force that we get the real class info
-        $mockedCache = $this->getMockBuilder(\TYPO3\CMS\Extbase\Object\Container\ClassInfoCache::class)
-            ->setMethods(['get', 'set', 'has'])
-            ->getMock();
-        $mockedCache->expects($this->any())->method('get')->will($this->returnValue(false));
-        $mockedCache->expects($this->never())->method('has');
-
         $this->logger = $this->getMockBuilder(Logger::class)
             ->setMethods(['notice'])
             ->disableOriginalConstructor()
             ->getMock();
 
-        $this->container = $this->getMockBuilder(\TYPO3\CMS\Extbase\Object\Container\Container::class)
-            ->setMethods(['getLogger', 'getClassInfoCache'])
+        $this->subject = $this->getMockBuilder(Container::class)
+            ->setMethods(['getLogger'])
             ->getMock();
-        $this->container->expects($this->any())->method('getClassInfoCache')->will($this->returnValue($mockedCache));
-        $this->container->expects($this->any())->method('getLogger')->will($this->returnValue($this->logger));
+        $this->subject->expects($this->any())->method('getLogger')->will($this->returnValue($this->logger));
     }
 
     /**
@@ -69,7 +62,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceReturnsInstanceOfSimpleClass()
     {
-        $object = $this->container->getInstance('t3lib_object_tests_c');
+        $object = $this->subject->getInstance('t3lib_object_tests_c');
         $this->assertInstanceOf('t3lib_object_tests_c', $object);
     }
 
@@ -78,7 +71,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceReturnsInstanceOfSimpleNamespacedClass()
     {
-        $object = $this->container->getInstance(\TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\NamespacedClass::class);
+        $object = $this->subject->getInstance(\TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\NamespacedClass::class);
         $this->assertInstanceOf(\TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\NamespacedClass::class, $object);
     }
 
@@ -87,7 +80,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceReturnsInstanceOfAClassWithConstructorInjection()
     {
-        $object = $this->container->getInstance('t3lib_object_tests_b');
+        $object = $this->subject->getInstance('t3lib_object_tests_b');
         $this->assertInstanceOf('t3lib_object_tests_b', $object);
         $this->assertInstanceOf('t3lib_object_tests_c', $object->c);
     }
@@ -97,7 +90,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceReturnsInstanceOfAClassWithTwoLevelDependency()
     {
-        $object = $this->container->getInstance('t3lib_object_tests_a');
+        $object = $this->subject->getInstance('t3lib_object_tests_a');
         $this->assertInstanceOf('t3lib_object_tests_a', $object);
         $this->assertInstanceOf('t3lib_object_tests_c', $object->b->c);
     }
@@ -107,7 +100,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceReturnsInstanceOfAClassWithMixedSimpleTypeAndConstructorInjection()
     {
-        $object = $this->container->getInstance('t3lib_object_tests_amixed_array');
+        $object = $this->subject->getInstance('t3lib_object_tests_amixed_array');
         $this->assertInstanceOf('t3lib_object_tests_amixed_array', $object);
         $this->assertEquals(['some' => 'default'], $object->myvalue);
     }
@@ -117,7 +110,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceReturnsInstanceOfAClassWithMixedSimpleTypeAndConstructorInjectionWithNullDefaultValue()
     {
-        $object = $this->container->getInstance('t3lib_object_tests_amixed_null');
+        $object = $this->subject->getInstance('t3lib_object_tests_amixed_null');
         $this->assertInstanceOf('t3lib_object_tests_amixed_null', $object);
         $this->assertNull($object->myvalue);
     }
@@ -129,7 +122,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $this->expectException(Exception::class);
         $this->expectExceptionCode(1292858051);
-        $this->container->getInstance('t3lib_object_tests_amixed_array_singleton', ['somevalue']);
+        $this->subject->getInstance('t3lib_object_tests_amixed_array_singleton', ['somevalue']);
     }
 
     /**
@@ -137,7 +130,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceReturnsInstanceOfAClassWithConstructorInjectionAndDefaultConstructorParameters()
     {
-        $object = $this->container->getInstance('t3lib_object_tests_amixed_array');
+        $object = $this->subject->getInstance('t3lib_object_tests_amixed_array');
         $this->assertInstanceOf('t3lib_object_tests_b', $object->b);
         $this->assertInstanceOf('t3lib_object_tests_c', $object->c);
         $this->assertEquals(['some' => 'default'], $object->myvalue);
@@ -149,7 +142,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstancePassesGivenParameterToTheNewObject()
     {
         $mockObject = $this->createMock('t3lib_object_tests_c');
-        $object = $this->container->getInstance('t3lib_object_tests_a', [$mockObject]);
+        $object = $this->subject->getInstance('t3lib_object_tests_a', [$mockObject]);
         $this->assertInstanceOf('t3lib_object_tests_a', $object);
         $this->assertSame($mockObject, $object->c);
     }
@@ -159,8 +152,8 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceReturnsAFreshInstanceIfObjectIsNoSingleton()
     {
-        $object1 = $this->container->getInstance('t3lib_object_tests_a');
-        $object2 = $this->container->getInstance('t3lib_object_tests_a');
+        $object1 = $this->subject->getInstance('t3lib_object_tests_a');
+        $object2 = $this->subject->getInstance('t3lib_object_tests_a');
         $this->assertNotSame($object1, $object2);
     }
 
@@ -169,8 +162,8 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceReturnsSameInstanceInstanceIfObjectIsSingleton()
     {
-        $object1 = $this->container->getInstance('t3lib_object_tests_singleton');
-        $object2 = $this->container->getInstance('t3lib_object_tests_singleton');
+        $object1 = $this->subject->getInstance('t3lib_object_tests_singleton');
+        $object2 = $this->subject->getInstance('t3lib_object_tests_singleton');
         $this->assertSame($object1, $object2);
     }
 
@@ -181,7 +174,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $this->expectException(CannotBuildObjectException::class);
         $this->expectExceptionCode(1295611406);
-        $this->container->getInstance('t3lib_object_tests_cyclic1WithSetterDependency');
+        $this->subject->getInstance('t3lib_object_tests_cyclic1WithSetterDependency');
     }
 
     /**
@@ -191,7 +184,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $this->expectException(CannotBuildObjectException::class);
         $this->expectExceptionCode(1295611406);
-        $this->container->getInstance('t3lib_object_tests_cyclic1');
+        $this->subject->getInstance('t3lib_object_tests_cyclic1');
     }
 
     /**
@@ -201,7 +194,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $this->expectException(UnknownClassException::class);
         $this->expectExceptionCode(1278450972);
-        $this->container->getInstance('nonextistingclass_bla');
+        $this->subject->getInstance('nonextistingclass_bla');
     }
 
     /**
@@ -209,7 +202,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceInitializesObjects()
     {
-        $instance = $this->container->getInstance('t3lib_object_tests_initializable');
+        $instance = $this->subject->getInstance('t3lib_object_tests_initializable');
         $this->assertTrue($instance->isInitialized());
     }
 
@@ -218,7 +211,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getEmptyObjectReturnsInstanceOfSimpleClass()
     {
-        $object = $this->container->getEmptyObject('t3lib_object_tests_c');
+        $object = $this->subject->getEmptyObject('t3lib_object_tests_c');
         $this->assertInstanceOf('t3lib_object_tests_c', $object);
     }
 
@@ -227,7 +220,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getEmptyObjectReturnsInstanceOfClassImplementingSerializable()
     {
-        $object = $this->container->getEmptyObject('t3lib_object_tests_serializable');
+        $object = $this->subject->getEmptyObject('t3lib_object_tests_serializable');
         $this->assertInstanceOf('t3lib_object_tests_serializable', $object);
     }
 
@@ -236,7 +229,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getEmptyObjectInitializesObjects()
     {
-        $object = $this->container->getEmptyObject('t3lib_object_tests_initializable');
+        $object = $this->subject->getEmptyObject('t3lib_object_tests_initializable');
         $this->assertTrue($object->isInitialized());
     }
 
@@ -245,7 +238,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function test_canGetChildClass()
     {
-        $object = $this->container->getInstance('t3lib_object_tests_b_child');
+        $object = $this->subject->getInstance('t3lib_object_tests_b_child');
         $this->assertInstanceOf('t3lib_object_tests_b_child', $object);
     }
 
@@ -254,8 +247,8 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function test_canInjectInterfaceInClass()
     {
-        $this->container->registerImplementation('t3lib_object_tests_someinterface', 't3lib_object_tests_someimplementation');
-        $object = $this->container->getInstance('t3lib_object_tests_needsinterface');
+        $this->subject->registerImplementation('t3lib_object_tests_someinterface', 't3lib_object_tests_someimplementation');
+        $object = $this->subject->getInstance('t3lib_object_tests_needsinterface');
         $this->assertInstanceOf('t3lib_object_tests_needsinterface', $object);
         $this->assertInstanceOf('t3lib_object_tests_someinterface', $object->dependency);
         $this->assertInstanceOf('t3lib_object_tests_someimplementation', $object->dependency);
@@ -266,7 +259,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function test_canBuildCyclicDependenciesOfSingletonsWithSetter()
     {
-        $object = $this->container->getInstance('t3lib_object_tests_resolveablecyclic1');
+        $object = $this->subject->getInstance('t3lib_object_tests_resolveablecyclic1');
         $this->assertInstanceOf('t3lib_object_tests_resolveablecyclic1', $object);
         $this->assertInstanceOf('t3lib_object_tests_resolveablecyclic1', $object->o2->o3->o1);
     }
@@ -277,7 +270,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function singletonWhichRequiresPrototypeViaSetterInjectionWorksAndAddsDebugMessage()
     {
         $this->logger->expects($this->once())->method('notice')->with('The singleton "t3lib_object_singletonNeedsPrototype" needs a prototype in "injectDependency". This is often a bad code smell; often you rather want to inject a singleton.');
-        $object = $this->container->getInstance('t3lib_object_singletonNeedsPrototype');
+        $object = $this->subject->getInstance('t3lib_object_singletonNeedsPrototype');
         $this->assertInstanceOf('t3lib_object_prototype', $object->dependency);
     }
 
@@ -287,7 +280,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function singletonWhichRequiresSingletonViaSetterInjectionWorks()
     {
         $this->logger->expects($this->never())->method('notice');
-        $object = $this->container->getInstance('t3lib_object_singletonNeedsSingleton');
+        $object = $this->subject->getInstance('t3lib_object_singletonNeedsSingleton');
         $this->assertInstanceOf('t3lib_object_singleton', $object->dependency);
     }
 
@@ -297,7 +290,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function prototypeWhichRequiresPrototypeViaSetterInjectionWorks()
     {
         $this->logger->expects($this->never())->method('notice');
-        $object = $this->container->getInstance('t3lib_object_prototypeNeedsPrototype');
+        $object = $this->subject->getInstance('t3lib_object_prototypeNeedsPrototype');
         $this->assertInstanceOf('t3lib_object_prototype', $object->dependency);
     }
 
@@ -307,7 +300,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function prototypeWhichRequiresSingletonViaSetterInjectionWorks()
     {
         $this->logger->expects($this->never())->method('notice');
-        $object = $this->container->getInstance('t3lib_object_prototypeNeedsSingleton');
+        $object = $this->subject->getInstance('t3lib_object_prototypeNeedsSingleton');
         $this->assertInstanceOf('t3lib_object_singleton', $object->dependency);
     }
 
@@ -317,7 +310,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function singletonWhichRequiresPrototypeViaConstructorInjectionWorksAndAddsDebugMessage()
     {
         $this->logger->expects($this->once())->method('notice')->with('The singleton "t3lib_object_singletonNeedsPrototypeInConstructor" needs a prototype in the constructor. This is often a bad code smell; often you rather want to inject a singleton.');
-        $object = $this->container->getInstance('t3lib_object_singletonNeedsPrototypeInConstructor');
+        $object = $this->subject->getInstance('t3lib_object_singletonNeedsPrototypeInConstructor');
         $this->assertInstanceOf('t3lib_object_prototype', $object->dependency);
     }
 
@@ -327,7 +320,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function singletonWhichRequiresSingletonViaConstructorInjectionWorks()
     {
         $this->logger->expects($this->never())->method('notice');
-        $object = $this->container->getInstance('t3lib_object_singletonNeedsSingletonInConstructor');
+        $object = $this->subject->getInstance('t3lib_object_singletonNeedsSingletonInConstructor');
         $this->assertInstanceOf('t3lib_object_singleton', $object->dependency);
     }
 
@@ -337,7 +330,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function prototypeWhichRequiresPrototypeViaConstructorInjectionWorks()
     {
         $this->logger->expects($this->never())->method('notice');
-        $object = $this->container->getInstance('t3lib_object_prototypeNeedsPrototypeInConstructor');
+        $object = $this->subject->getInstance('t3lib_object_prototypeNeedsPrototypeInConstructor');
         $this->assertInstanceOf('t3lib_object_prototype', $object->dependency);
     }
 
@@ -347,7 +340,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function prototypeWhichRequiresSingletonViaConstructorInjectionWorks()
     {
         $this->logger->expects($this->never())->method('notice');
-        $object = $this->container->getInstance('t3lib_object_prototypeNeedsSingletonInConstructor');
+        $object = $this->subject->getInstance('t3lib_object_prototypeNeedsSingletonInConstructor');
         $this->assertInstanceOf('t3lib_object_singleton', $object->dependency);
     }
 
@@ -356,8 +349,8 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function isSingletonReturnsTrueForSingletonInstancesAndFalseForPrototypes()
     {
-        $this->assertTrue($this->container->isSingleton(\TYPO3\CMS\Extbase\Object\Container\Container::class));
-        $this->assertFalse($this->container->isSingleton(\TYPO3\CMS\Extbase\Core\Bootstrap::class));
+        $this->assertTrue($this->subject->isSingleton(Container::class));
+        $this->assertFalse($this->subject->isSingleton(\TYPO3\CMS\Extbase\Core\Bootstrap::class));
     }
 
     /**
@@ -365,8 +358,8 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function isPrototypeReturnsFalseForSingletonInstancesAndTrueForPrototypes()
     {
-        $this->assertFalse($this->container->isPrototype(\TYPO3\CMS\Extbase\Object\Container\Container::class));
-        $this->assertTrue($this->container->isPrototype(\TYPO3\CMS\Extbase\Core\Bootstrap::class));
+        $this->assertFalse($this->subject->isPrototype(Container::class));
+        $this->assertTrue($this->subject->isPrototype(\TYPO3\CMS\Extbase\Core\Bootstrap::class));
     }
 
     /************************************************
@@ -379,7 +372,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceGivesSimpleConstructorArgumentToClassInstance()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\SimpleTypeConstructorArgument::class,
             [true]
         );
@@ -392,7 +385,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceDoesNotInfluenceSimpleTypeConstructorArgumentIfNotGiven()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\SimpleTypeConstructorArgument::class
         );
         $this->assertFalse($object->foo);
@@ -405,7 +398,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceGivesExistingConstructorArgumentToClassInstance()
     {
         $argumentTestClass = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\MandatoryConstructorArgument::class,
             [$argumentTestClass]
         );
@@ -422,7 +415,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceInjectsNewInstanceOfClassToClassIfArgumentIsMandatory()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\MandatoryConstructorArgument::class
         );
         $this->assertInstanceOf(
@@ -441,7 +434,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceDoesNotInjectAnOptionalArgumentIfNotGiven()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\OptionalConstructorArgument::class
         );
         $this->assertInstanceOf(
@@ -457,7 +450,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceDoesNotInjectAnOptionalArgumentIfGivenArgumentIsNull()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\OptionalConstructorArgument::class,
             [null]
         );
@@ -475,7 +468,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceGivesExistingConstructorArgumentToClassInstanceIfArgumentIsGiven()
     {
         $argumentTestClass = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\OptionalConstructorArgument::class,
             [$argumentTestClass]
         );
@@ -494,7 +487,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $firstArgument = new Fixtures\ArgumentTestClass();
         $secondArgument = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\MandatoryConstructorArgumentTwo::class,
             [$firstArgument, $secondArgument]
         );
@@ -518,7 +511,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceInjectsTwoMandatoryArguments()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\MandatoryConstructorArgumentTwo::class
         );
         $this->assertInstanceOf(
@@ -546,7 +539,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceInjectsSecondMandatoryArgumentIfFirstIsGiven()
     {
         $firstArgument = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\MandatoryConstructorArgumentTwo::class,
             [$firstArgument]
         );
@@ -575,7 +568,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceInjectsFirstMandatoryArgumentIfSecondIsGiven()
     {
         $secondArgument = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\MandatoryConstructorArgumentTwo::class,
             [null, $secondArgument]
         );
@@ -609,7 +602,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $firstArgument = new Fixtures\ArgumentTestClass();
         $secondArgument = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsSecondOptional::class,
             [$firstArgument, $secondArgument]
         );
@@ -633,7 +626,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceInjectsFirstMandatoryArgumentIfSecondIsOptionalAndNoneAreGiven()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsSecondOptional::class
         );
         $this->assertInstanceOf(
@@ -653,7 +646,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceInjectsFirstMandatoryArgumentIfSecondIsOptionalAndBothAreGivenAsNull()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsSecondOptional::class,
             [null, null]
         );
@@ -675,7 +668,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceGivesFirstArgumentToConstructorIfSecondIsOptionalAndFirstIsGiven()
     {
         $firstArgument = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsSecondOptional::class,
             [$firstArgument]
         );
@@ -697,7 +690,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceGivesFirstArgumentToConstructorIfSecondIsOptionalFirstIsGivenAndSecondIsGivenNull()
     {
         $firstArgument = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsSecondOptional::class,
             [$firstArgument, null]
         );
@@ -719,7 +712,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceOnFirstOptionalAndSecondMandatoryInjectsSecondArgumentIfFirstIsGivenAsNull()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsFirstOptional::class,
             [null]
         );
@@ -741,7 +734,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $first = new Fixtures\ArgumentTestClass();
         $second = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsFirstOptional::class,
             [$first, $second]
         );
@@ -766,7 +759,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceOnFirstOptionalAndSecondMandatoryInjectsSecondArgumentIfFirstIsGiven()
     {
         $first = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsFirstOptional::class,
             [$first]
         );
@@ -796,7 +789,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceOnFirstOptionalAndSecondMandatoryGivesSecondArgumentAsIsIfFirstIsGivenAsNullAndSecondIsGiven()
     {
         $second = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsFirstOptional::class,
             [null, $second]
         );
@@ -817,7 +810,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceOnFirstOptionalAndSecondMandatoryInjectsSecondArgumentIfFirstIsGivenAsNullAndSecondIsNull()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsFirstOptional::class,
             [null, null]
         );
@@ -839,7 +832,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $first = new Fixtures\ArgumentTestClass();
         $second = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsBothOptional::class,
             [$first, $second]
         );
@@ -863,7 +856,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceOnTwoOptionalGivesNoArgumentsToConstructorIfArgumentsAreNull()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsBothOptional::class,
             [null, null]
         );
@@ -881,7 +874,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getInstanceOnTwoOptionalGivesNoArgumentsToConstructorIfNoneAreGiven()
     {
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsBothOptional::class
         );
         $this->assertInstanceOf(
@@ -899,7 +892,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceOnTwoOptionalGivesOneArgumentToConstructorIfFirstIsObjectAndSecondIsNotGiven()
     {
         $first = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsBothOptional::class,
             [$first]
         );
@@ -921,7 +914,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceOnTwoOptionalGivesOneArgumentToConstructorIfFirstIsObjectAndSecondIsNull()
     {
         $first = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsBothOptional::class,
             [$first, null]
         );
@@ -943,7 +936,7 @@ class ContainerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getInstanceOnTwoOptionalGivesOneArgumentToConstructorIfFirstIsNullAndSecondIsObject()
     {
         $second = new Fixtures\ArgumentTestClass();
-        $object = $this->container->getInstance(
+        $object = $this->subject->getInstance(
             \TYPO3\CMS\Extbase\Tests\Unit\Object\Container\Fixtures\TwoConstructorArgumentsBothOptional::class,
             [null, $second]
         );
index 7de15c2..42287a8 100644 (file)
@@ -40,26 +40,11 @@ class Typo3DbQueryParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
     protected static $suppressNotices = true;
 
     /**
-     * @var array
-     */
-    protected $singletonInstances;
-
-    /**
-     * Set up tests
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
-    /**
      * Clean up after tests
      */
     protected function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index 7adfa1f..8cd9a47 100644 (file)
@@ -21,30 +21,37 @@ use TYPO3\CMS\Extbase\Validation\Exception\InvalidTypeHintException;
 use TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationConfigurationException;
 use TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator;
 use TYPO3\CMS\Extbase\Validation\Validator\StringLengthValidator;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ClassSchemaTest extends UnitTestCase
 {
     /**
      * @test
      */
     public function classSchemaForModelIsSetAggregateRootIfRepositoryClassIsFoundForNamespacedClasses()
     {
-        /** @var \TYPO3\CMS\Extbase\Reflection\ReflectionService $service */
+        $this->resetSingletonInstances = true;
         $service = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class);
         $classSchema = $service->getClassSchema(Fixture\DummyModel::class);
         $this->assertTrue($classSchema->isAggregateRoot());
     }
 
-    public function testClassSchemaHasConstructor()
+    /**
+     * @test
+     */
+    public function classSchemaHasConstructor()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithConstructorAndConstructorArguments::class);
         static::assertTrue($classSchema->hasConstructor());
     }
 
-    public function testClassSchemaDetectsConstructorArguments()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsConstructorArguments()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithConstructorAndConstructorArguments::class);
         static::assertTrue($classSchema->hasConstructor());
@@ -62,7 +69,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertSame([], $classSchema->getConstructorArguments());
     }
 
-    public function testClassSchemaDetectsConstructorArgumentsWithDependencies()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsConstructorArgumentsWithDependencies()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithConstructorAndConstructorArgumentsWithDependencies::class);
         static::assertTrue($classSchema->hasConstructor());
@@ -72,7 +82,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertSame(Fixture\DummyClassWithGettersAndSetters::class, $methodDefinition['params']['foo']['dependency']);
     }
 
-    public function testClassSchemaGetProperties()
+    /**
+     * @test
+     */
+    public function classSchemaGetProperties()
     {
         static::assertSame(
             [
@@ -93,14 +106,20 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         );
     }
 
-    public function testClassSchemaHasMethod()
+    /**
+     * @test
+     */
+    public function classSchemaHasMethod()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfMethods::class);
         static::assertTrue($classSchema->hasMethod('publicMethod'));
         static::assertFalse($classSchema->hasMethod('nonExistentMethod'));
     }
 
-    public function testClassSchemaGetMethods()
+    /**
+     * @test
+     */
+    public function classSchemaGetMethods()
     {
         static::assertSame(
             [
@@ -122,7 +141,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         );
     }
 
-    public function testClassSchemaDetectsMethodVisibility()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsMethodVisibility()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfMethods::class);
 
@@ -142,7 +164,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertTrue($methodDefinition['private']);
     }
 
-    public function testClassSchemaDetectsInjectProperties()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsInjectProperties()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithInjectDoctrineAnnotation::class);
         static::assertTrue($classSchema->hasInjectProperties());
@@ -161,7 +186,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertSame('AliasedClassSchemaTest', $injectProperties['propertyWithImportedAndAliasedClassName']);
     }
 
-    public function testClassSchemaDetectsInjectMethods()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsInjectMethods()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfMethods::class);
         static::assertTrue($classSchema->hasInjectMethods());
@@ -182,13 +210,19 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertArrayHasKey('injectFoo', $injectMethods);
     }
 
-    public function testClassSchemaDetectsPropertiesWithLazyAnnotation()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsPropertiesWithLazyAnnotation()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithLazyDoctrineAnnotation::class);
         static::assertTrue($classSchema->getProperty('propertyWithLazyAnnotation')['annotations']['lazy']);
     }
 
-    public function testClassSchemaDetectsStaticMethods()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsStaticMethods()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfMethods::class);
 
@@ -196,7 +230,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertTrue($methodDefinition['static']);
     }
 
-    public function testClassSchemaDetectsMandatoryParams()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsMandatoryParams()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfMethods::class);
 
@@ -204,7 +241,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertFalse($methodDefinition['params']['param']['optional']);
     }
 
-    public function testClassSchemaDetectsNullableParams()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsNullableParams()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfMethods::class);
 
@@ -212,7 +252,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertTrue($methodDefinition['params']['param']['nullable']);
     }
 
-    public function testClassSchemaDetectsDefaultValueParams()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsDefaultValueParams()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfMethods::class);
 
@@ -220,7 +263,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertSame('foo', $methodDefinition['params']['param']['default']);
     }
 
-    public function testClassSchemaDetectsParamTypeFromTypeHint()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsParamTypeFromTypeHint()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfMethods::class);
 
@@ -228,7 +274,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertSame('string', $methodDefinition['params']['param']['type']);
     }
 
-    public function testClassSchemaDetectsPropertyVisibility()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsPropertyVisibility()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class);
 
@@ -248,7 +297,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertTrue($propertyDefinition['private']);
     }
 
-    public function testClassSchemaDetectsInjectProperty()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsInjectProperty()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class);
 
@@ -256,7 +308,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertTrue($propertyDefinition['annotations']['inject']);
     }
 
-    public function testClassSchemaDetectsTransientProperty()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsTransientProperty()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class);
 
@@ -264,7 +319,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertTrue($propertyDefinition['annotations']['transient']);
     }
 
-    public function testClassSchemaDetectsCascadeProperty()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsCascadeProperty()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class);
 
@@ -272,7 +330,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertSame('remove', $propertyDefinition['annotations']['cascade']);
     }
 
-    public function testClassSchemaDetectsCascadePropertyOnlyWithVarAnnotation()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsCascadePropertyOnlyWithVarAnnotation()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class);
 
@@ -280,7 +341,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertNull($propertyDefinition['annotations']['cascade']);
     }
 
-    public function testClassSchemaDetectsIgnoreValidationAnnotation()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsIgnoreValidationAnnotation()
     {
         $classSchema = new ClassSchema(Fixture\DummyControllerWithIgnoreValidationDoctrineAnnotation::class);
         static::assertTrue(isset($classSchema->getMethod('someAction')['tags']['ignorevalidation']));
@@ -289,7 +353,10 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertFalse(in_array('baz', $classSchema->getMethod('someAction')['tags']['ignorevalidation'], true));
     }
 
-    public function testClassSchemaDetectsTypeAndElementType()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsTypeAndElementType()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class);
 
@@ -298,46 +365,71 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         static::assertSame(Fixture\DummyClassWithAllTypesOfProperties::class, $propertyDefinition['elementType']);
     }
 
-    public function testClassSchemaDetectsSingletons()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsSingletons()
     {
         static::assertTrue((new ClassSchema(Fixture\DummySingleton::class))->isSingleton());
     }
 
-    public function testClassSchemaDetectsModels()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsModels()
     {
         static::assertTrue((new ClassSchema(Fixture\DummyEntity::class))->isModel());
         static::assertTrue((new ClassSchema(Fixture\DummyValueObject::class))->isModel());
     }
 
-    public function testClassSchemaDetectsEntities()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsEntities()
     {
         static::assertTrue((new ClassSchema(Fixture\DummyEntity::class))->isEntity());
     }
 
-    public function testClassSchemaDetectsValueObjects()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsValueObjects()
     {
         static::assertTrue((new ClassSchema(Fixture\DummyValueObject::class))->isValueObject());
     }
 
-    public function testClassSchemaDetectsClassName()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsClassName()
     {
+        $this->resetSingletonInstances = true;
         static::assertSame(Fixture\DummyModel::class, (new ClassSchema(Fixture\DummyModel::class))->getClassName());
     }
 
-    public function testClassSchemaDetectsNonStaticProperties()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsNonStaticProperties()
     {
         static::assertTrue((new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class))->hasProperty('publicProperty'));
         static::assertTrue((new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class))->hasProperty('protectedProperty'));
         static::assertTrue((new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class))->hasProperty('privateProperty'));
     }
 
-    public function testClassSchemaDetectsStaticProperties()
+    /**
+     * @test
+     */
+    public function classSchemaDetectsStaticProperties()
     {
         static::assertTrue((new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class))->hasProperty('publicStaticProperty'));
         static::assertTrue((new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class))->hasProperty('protectedStaticProperty'));
         static::assertTrue((new ClassSchema(Fixture\DummyClassWithAllTypesOfProperties::class))->hasProperty('privateStaticProperty'));
     }
 
+    /**
+     * @test
+     */
     public function testClassSchemaGetTags()
     {
         $tags = (new ClassSchema(Fixture\DummyClassWithTags::class))->getTags();
@@ -357,8 +449,8 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function classSchemaDetectsValidateAnnotationsModelProperties(): void
     {
+        $this->resetSingletonInstances = true;
         $classSchema = new ClassSchema(Fixture\DummyModel::class);
-
         static::assertSame(
             [
                 [
@@ -404,8 +496,8 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function classSchemaDetectsValidateAnnotationsOfControllerActions(): void
     {
+        $this->resetSingletonInstances = true;
         $classSchema = new ClassSchema(Fixture\DummyController::class);
-
         static::assertSame(
             [
                 [
@@ -451,6 +543,7 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function classSchemaGenerationThrowsExceptionWithValidateDoctrineAnnotationsForParamWithoutTypeHint()
     {
+        $this->resetSingletonInstances = true;
         $this->expectException(InvalidTypeHintException::class);
         $this->expectExceptionMessage('Missing type information for parameter "$fooParam" in TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyControllerWithValidateAnnotationWithoutParamTypeHint->methodWithValidateAnnotationsAction(): Either use an @param annotation or use a type hint.');
         $this->expectExceptionCode(1515075192);
@@ -463,6 +556,7 @@ class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function classSchemaGenerationThrowsExceptionWithValidateDoctrineAnnotationsForMissingParam()
     {
+        $this->resetSingletonInstances = true;
         $this->expectException(InvalidValidationConfigurationException::class);
         $this->expectExceptionMessage('Invalid validate annotation in TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyControllerWithValidateAnnotationWithoutParam->methodWithValidateAnnotationsAction(): The following validators have been defined for missing param "$fooParam": NotEmpty, StringLength');
         $this->expectExceptionCode(1515073585);
index c3d3aba..47221f3 100644 (file)
@@ -15,33 +15,17 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Service;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class FlexFormServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class FlexFormServiceTest extends UnitTestCase
 {
     /**
-     * @var array Backup of singletons
+     * @var bool Reset singletons created by subject
      */
-    protected $backupSingletons = [];
-
-    /**
-     * Set up
-     */
-    protected function setUp()
-    {
-        $this->backupSingletons = GeneralUtility::getSingletonInstances();
-    }
-
-    /**
-     * Tear down
-     */
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->backupSingletons);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
index 14eb1dc..3918734 100644 (file)
@@ -29,6 +29,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class ImageScriptServiceTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var ImageService
      */
     protected $subject;
index a26b637..0c4ee0c 100644 (file)
@@ -31,6 +31,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class DispatcherTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
      */
     protected $signalSlotDispatcher;
index f363774..31bb0ab 100644 (file)
@@ -19,12 +19,18 @@ use TYPO3\CMS\Extbase\Validation\Exception\InvalidTypeHintException;
 use TYPO3\CMS\Extbase\Validation\Exception\InvalidValidationConfigurationException;
 use TYPO3\CMS\Extbase\Validation\Validator\NotEmptyValidator;
 use TYPO3\CMS\Extbase\Validation\Validator\StringLengthValidator;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class ClassSchemaTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ClassSchemaTest extends UnitTestCase
 {
+    /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
     public function testClassSchemaDetectsInjectProperties()
     {
         $classSchema = new ClassSchema(Fixture\DummyClassWithInjectProperty::class);
index 4ce4e56..1a12131 100644 (file)
@@ -14,49 +14,28 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Task;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask;
+use TYPO3\CMS\Extensionmanager\Utility\Repository\Helper;
+use TYPO3\CMS\Scheduler\Task\AbstractTask;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
 /**
  * Test case
  */
-class UpdateExtensionListTaskTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class UpdateExtensionListTaskTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
-     */
-    protected $singletonInstances = [];
-
-    /**
-     * @var \TYPO3\CMS\Extensionmanager\Utility\Repository\Helper
-     */
-    protected $repositoryHelper;
-
-    /**
-     * Set up
+     * @var bool Reset singletons created by subject
      */
-    protected function setUp()
-    {
-        if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('scheduler')) {
-            $this->markTestSkipped('Tests need EXT:scheduler loaded.');
-        }
-        $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-        $this->repositoryHelper = $this->createMock(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper::class);
-    }
-
-    /**
-     * Tear down
-     */
-    protected function tearDown()
-    {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
      */
     public function updateExtensionListTaskIsInstanceOfAbstractTask()
     {
-        $taskMock = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask::class)->getMock();
-        $this->assertInstanceOf(\TYPO3\CMS\Scheduler\Task\AbstractTask::class, $taskMock);
+        $taskMock = $this->getMockBuilder(UpdateExtensionListTask::class)->getMock();
+        $this->assertInstanceOf(AbstractTask::class, $taskMock);
     }
 
     /**
@@ -64,7 +43,8 @@ class UpdateExtensionListTaskTest extends \TYPO3\TestingFramework\Core\Unit\Unit
      */
     public function executeCallsUpdateExtListOfRepositoryHelper()
     {
-        $this->repositoryHelper
+        $repositoryHelper = $this->createMock(Helper::class);
+        $repositoryHelper
                 ->expects($this->once())
                 ->method('updateExtList');
 
@@ -72,8 +52,8 @@ class UpdateExtensionListTaskTest extends \TYPO3\TestingFramework\Core\Unit\Unit
         $objectManagerMock
                 ->expects($this->at(0))
                 ->method('get')
-                ->with(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper::class)
-                ->will($this->returnValue($this->repositoryHelper));
+                ->with(Helper::class)
+                ->will($this->returnValue($repositoryHelper));
 
         $persistenceManagerMock = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class)->getMock();
         $objectManagerMock
@@ -83,7 +63,7 @@ class UpdateExtensionListTaskTest extends \TYPO3\TestingFramework\Core\Unit\Unit
 
         \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class, $objectManagerMock);
 
-        $task = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask::class)
+        $task = $this->getMockBuilder(UpdateExtensionListTask::class)
             ->setMethods(['dummy'])
             ->disableOriginalConstructor()
             ->getMock();
@@ -95,12 +75,13 @@ class UpdateExtensionListTaskTest extends \TYPO3\TestingFramework\Core\Unit\Unit
      */
     public function executeCallsPersistAllOnPersistenceManager()
     {
+        $repositoryHelper = $this->createMock(Helper::class);
         $objectManagerMock = $this->getMockBuilder(\TYPO3\CMS\Extbase\Object\ObjectManager::class)->getMock();
         $objectManagerMock
             ->expects($this->at(0))
             ->method('get')
-            ->with(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper::class)
-            ->will($this->returnValue($this->repositoryHelper));
+            ->with(Helper::class)
+            ->will($this->returnValue($repositoryHelper));
 
         $persistenceManagerMock = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class)->getMock();
         $persistenceManagerMock
@@ -114,8 +95,8 @@ class UpdateExtensionListTaskTest extends \TYPO3\TestingFramework\Core\Unit\Unit
 
         \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class, $objectManagerMock);
 
-        /** @var \TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask|PHPUnit_Framework_MockObject_MockObject $task */
-        $task = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask::class)
+        /** @var UpdateExtensionListTask|PHPUnit_Framework_MockObject_MockObject $task */
+        $task = $this->getMockBuilder(UpdateExtensionListTask::class)
             ->setMethods(['dummy'])
             ->disableOriginalConstructor()
             ->getMock();
index 0a801b3..96bf0dc 100644 (file)
@@ -14,12 +14,19 @@ namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
 /**
  * Test for ExtensionModelUtilityTest
  */
-class ExtensionModelUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ExtensionModelUtilityTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @test
      */
     public function convertDependenciesToObjectsCreatesObjectStorage()
index ed0fc9f..cae5ad3 100644 (file)
@@ -56,16 +56,10 @@ class FrontendLoginControllerTest extends \TYPO3\TestingFramework\Core\Unit\Unit
     protected $testTableName;
 
     /**
-     * @var array
-     */
-    protected $singletonInstances;
-
-    /**
      * Set up
      */
     protected function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $GLOBALS['TSFE'] = new \stdClass();
         $GLOBALS['TSFE']->gr_list = '0,-1';
         $this->testTableName = 'sys_domain';
@@ -84,10 +78,8 @@ class FrontendLoginControllerTest extends \TYPO3\TestingFramework\Core\Unit\Unit
     protected function tearDown()
     {
         // setUpDatabaseMock() prepares some instances via addInstance(), but not all
-        // tests use that instance. purgeInstances() removes left overs and resets known
-        // singletons afterwards
+        // tests use that instance. purgeInstances() removes left overs
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index ccc3188..3e8c2a7 100644 (file)
@@ -15,11 +15,12 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\Core\Cache;
  */
 use TYPO3\CMS\Core\Cache\Backend\PhpCapableBackendInterface;
 use TYPO3\CMS\Fluid\Core\Cache\FluidTemplateCache;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class FluidTemplateCacheTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class FluidTemplateCacheTest extends UnitTestCase
 {
     /**
      * @test
index f7544b5..ef9d5be 100644 (file)
@@ -24,11 +24,16 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
 
 /**
- * Class CObjectViewHelperTest
+ * Test case
  */
 class CObjectViewHelperTest extends ViewHelperBaseTestcase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var CObjectViewHelper
      */
     protected $viewHelper;
index 7d5b1e8..acf6637 100644 (file)
@@ -21,9 +21,17 @@ use TYPO3\CMS\Fluid\ViewHelpers\ImageViewHelper;
 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
 use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
 
+/**
+ * Test case
+ */
 class ImageViewHelperTest extends ViewHelperBaseTestcase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var ImageViewHelper
      */
     protected $viewHelper;
index 1a92fe8..1b3fcfd 100644 (file)
@@ -28,26 +28,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class FormEditorControllerTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
-
-    /**
-     * Set up
-     */
-    public function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
-    /**
-     * Tear down
-     */
-    public function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
index 860faf8..d4ee020 100644 (file)
@@ -35,26 +35,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class FormManagerControllerTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
-
-    /**
-     * Set up
-     */
-    public function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
-    /**
-     * Tear down
-     */
-    public function tearDown(): void
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
index c7807c3..614ccca 100644 (file)
@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Form\Tests\Unit\Domain\Finishers;
 
 use Prophecy\Argument;
 use Prophecy\Prophecy\ObjectProphecy;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;
 use TYPO3\CMS\Form\Domain\Finishers\Exception\FinisherException;
 use TYPO3\CMS\Form\Domain\Finishers\FinisherContext;
@@ -31,28 +30,6 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class AbstractFinisherTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
-     */
-    protected $singletonInstances = [];
-
-    /**
-     * Set up
-     */
-    public function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
-    /**
-     * Tear down
-     */
-    public function tearDown(): void
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
-    /**
      * @test
      */
     public function parseOptionReturnsNullIfOptionNameIsTranslation(): void
index 084553f..51848c1 100644 (file)
@@ -198,6 +198,7 @@ class AbstractSectionTest extends UnitTestCase
      */
     public function createElementThrowsExceptionIfTypeDefinitionNotInstanceOfFormElementInterface()
     {
+        $this->resetSingletonInstances = true;
         /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|AbstractSection $mockAbstractSection */
         $mockAbstractSection = $this->getAccessibleMockForAbstractClass(
             AbstractSection::class,
index bb77e48..b6cfd9c 100644 (file)
@@ -21,34 +21,17 @@ use TYPO3\CMS\Form\Domain\Model\FormDefinition;
 use TYPO3\CMS\Form\Domain\Model\FormElements\Page;
 use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
 use TYPO3\CMS\Form\Domain\Runtime\FormState;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class FormRuntimeTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class FormRuntimeTest extends UnitTestCase
 {
-
-    /**
-     * @var array A backup of registered singleton instances
-     */
-    protected $singletonInstances = [];
-
     /**
-     * Set up
+     * @var bool Reset singletons created by subject
      */
-    public function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
-    /**
-     * Tear down
-     */
-    public function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
index 288dea6..48106a2 100644 (file)
@@ -31,16 +31,15 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class DataStructureIdentifierHookTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * Set up
      */
     public function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $cacheManagerProphecy = $this->prophesize(CacheManager::class);
         $cacheProphecy = $this->prophesize(FrontendInterface::class);
         $cacheManagerProphecy->getCache('cache_runtime')->willReturn($cacheProphecy->reveal());
@@ -50,15 +49,6 @@ class DataStructureIdentifierHookTest extends UnitTestCase
     }
 
     /**
-     * Tear down
-     */
-    public function tearDown(): void
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
-    /**
      * @test
      */
     public function getDataStructureIdentifierPostProcessReturnsIdentifierForNotMatchingScenario(): void
index c78410a..2596c4d 100644 (file)
@@ -21,34 +21,17 @@ use TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator;
 use TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator;
 use TYPO3\CMS\Form\Mvc\ProcessingRule;
 use TYPO3\CMS\Form\Tests\Unit\Mvc\Validation\Fixtures\TestValidator;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class ProcessingRuleTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ProcessingRuleTest extends UnitTestCase
 {
-
-    /**
-     * @var array A backup of registered singleton instances
-     */
-    protected $singletonInstances = [];
-
     /**
-     * Set up
+     * @var bool Reset singletons created by subject
      */
-    public function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
-    /**
-     * Tear down
-     */
-    public function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
index b766db8..d77b5e8 100644 (file)
@@ -34,6 +34,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
  */
 class PropertyMappingConfigurationTest extends UnitTestCase
 {
+    /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
     /** @var PropertyMappingConfiguration */
     protected $propertyMappingConfiguration;
 
@@ -49,12 +54,8 @@ class PropertyMappingConfigurationTest extends UnitTestCase
     /** @var \PHPUnit_Framework_MockObject_MockObject|ProcessingRule */
     protected $processingRule;
 
-    protected $singletons = [];
-
     public function setUp()
     {
-        $this->singletons = GeneralUtility::getSingletonInstances();
-
         // Property Mapping Configuration
         $this->extbasePropertyMappingConfiguration = $this->getMockBuilder(ExtbasePropertyMappingConfiguration::class)
             ->setMethods(['setTypeConverterOptions'])
@@ -103,13 +104,6 @@ class PropertyMappingConfigurationTest extends UnitTestCase
         $this->propertyMappingConfiguration = new PropertyMappingConfiguration();
     }
 
-    public function tearDown(): void
-    {
-        // Remove all singleton instances
-        GeneralUtility::resetSingletonInstances($this->singletons);
-        parent::tearDown();
-    }
-
     /**
      * A bare minimum test that checks if the function maybe potentially works.
      * @test
index 9842b59..b7ac60f 100644 (file)
@@ -35,9 +35,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class TranslationServiceTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * @var ConfigurationManager
@@ -59,8 +59,6 @@ class TranslationServiceTest extends UnitTestCase
      */
     public function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-
         $cacheManagerProphecy = $this->prophesize(CacheManager::class);
         GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
         $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
@@ -92,15 +90,6 @@ class TranslationServiceTest extends UnitTestCase
     }
 
     /**
-     * Tear down
-     */
-    public function tearDown(): void
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
-    /**
      * @test
      */
     public function translateReturnsExistingDefaultLanguageKeyIfFullExtDefaultLanguageKeyIsRequested(): void
index e8ad6b4..04323da 100644 (file)
@@ -19,11 +19,12 @@ use TYPO3\CMS\Core\Cache\CacheManager;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
+use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
 
 /**
  * Test case
  */
-class TypoScriptFrontendControllerTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
+class TypoScriptFrontendControllerTest extends FunctionalTestCase
 {
     /**
      * @var TypoScriptFrontendController
index e9453ee..a04eb4d 100644 (file)
@@ -39,27 +39,9 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class FrontendUserAuthenticationTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
-
-    /**
-     * Sets up FrontendUserAuthentication mock
-     */
-    protected function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
-    /**
-     * Reset singletons and purge created test instances
-     */
-    protected function tearDown()
-    {
-        GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * User properties should not be set for anonymous sessions
index b33cb76..3e53e88 100644 (file)
@@ -13,19 +13,26 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Frontend\ContentObject\CaseContentObject;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\ContentObject\TextContentObject;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\Frontend\Page\PageRepository;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for TYPO3\CMS\Frontend\ContentObject\CaseContentObject
+ * Test case
  */
-class CaseContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class CaseContentObjectTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * Subject is not notice free, disable E_NOTICES
      */
     protected static $suppressNotices = true;
index 0528609..46f100d 100644 (file)
@@ -55,11 +55,12 @@ use TYPO3\CMS\Frontend\ContentObject\UserContentObject;
 use TYPO3\CMS\Frontend\ContentObject\UserInternalContentObject;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\Frontend\Page\PageRepository;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
+ * Test case
  */
-class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class ContentObjectRendererTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -67,9 +68,9 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTe
     protected static $suppressNotices = true;
 
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
@@ -125,8 +126,6 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTe
      */
     protected function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-
         $this->templateServiceMock =
             $this->getMockBuilder(TemplateService::class)
             ->setMethods(['getFileName', 'linkData'])->getMock();
@@ -158,12 +157,6 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTe
         $this->subject->start([], 'tt_content');
     }
 
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
     //////////////////////
     // Utility functions
     //////////////////////
index c05ab87..41e30d5 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 use TYPO3\CMS\Core\Resource\Collection\StaticFileCollection;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\FileCollectionRepository;
@@ -26,11 +27,12 @@ use TYPO3\CMS\Frontend\ContentObject\TextContentObject;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\Frontend\Page\PageRepository;
 use TYPO3\CMS\Frontend\Resource\FileCollector;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for TYPO3\CMS\Frontend\ContentObject\FilesContentObject
+ * Test case
  */
-class FilesContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class FilesContentObjectTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -38,6 +40,11 @@ class FilesContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
     protected static $suppressNotices = true;
 
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var \TYPO3\CMS\Frontend\ContentObject\FilesContentObject|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $subject = null;
index 85d0c75..b630cfc 100644 (file)
@@ -34,9 +34,9 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
     protected static $suppressNotices = true;
 
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * @var FluidTemplateContentObject|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
@@ -63,7 +63,6 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
      */
     protected function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $this->contentObjectRenderer = $this->getMockBuilder(
             \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class
         )->getMock();
@@ -79,15 +78,6 @@ class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\U
     }
 
     /**
-     * Tear down
-     */
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
-    /**
      * Add a mock standalone view to subject
      */
     protected function addMockViewToSubject()
index b04d758..bfa429d 100644 (file)
@@ -22,11 +22,12 @@ use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class AbstractMenuContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class AbstractMenuContentObjectTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -34,11 +35,6 @@ class AbstractMenuContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\Un
     protected static $suppressNotices = true;
 
     /**
-     * @var array
-     */
-    protected $singletonInstances = [];
-
-    /**
      * @var AbstractMenuContentObject
      */
     protected $subject = null;
@@ -56,7 +52,6 @@ class AbstractMenuContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\Un
             ->getMock();
         $GLOBALS['TSFE']->cObj = new ContentObjectRenderer();
         $GLOBALS['TSFE']->page = [];
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
     }
 
     /**
@@ -65,7 +60,6 @@ class AbstractMenuContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\Un
     protected function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index b181488..02fa469 100644 (file)
@@ -33,26 +33,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class ErrorControllerTest extends UnitTestCase
 {
     /**
-     * @var array Backup of singleton instances
-     */
-    protected $backupSingletonInstances;
-
-    /**
-     * setUp() stores non singleton instances to reset in tearDown()
-     */
-    public function setUp()
-    {
-        parent::setUp();
-        $this->backupSingletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
-    /**
-     * Purge instances and reset singleton instances
+     * Purge possibly left over instances
      */
     public function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->backupSingletonInstances);
         parent::tearDown();
     }
 
index c07a5f3..7025f36 100644 (file)
@@ -18,13 +18,19 @@ use TYPO3\CMS\Core\Page\PageRenderer;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\Frontend\Page\PageRepository;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
+ * Test case
  */
-class TypoScriptFrontendControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class TypoScriptFrontendControllerTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * Subject is not notice free, disable E_NOTICES
      */
     protected static $suppressNotices = true;
index 80c850e..1748124 100644 (file)
@@ -21,11 +21,12 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 use TYPO3\CMS\Frontend\Page\PageGenerator;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class PageGeneratorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class PageGeneratorTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -33,19 +34,11 @@ class PageGeneratorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     protected static $suppressNotices = true;
 
     /**
-     * @var array A backup of registered singleton instances
+     * Tear down
      */
-    protected $singletonInstances = [];
-
-    protected function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-    }
-
     protected function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index d3202f2..76c9806 100644 (file)
@@ -18,11 +18,12 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\ContentObject\TextContentObject;
 use TYPO3\CMS\Frontend\Plugin\AbstractPlugin;
 use TYPO3\CMS\Frontend\Tests\Unit\Fixtures\ResultBrowserPluginHook;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for TYPO3\CMS\Frontend\Plugin\AbstractPlugin
+ * Test case
  */
-class AbstractPluginTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class AbstractPluginTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -138,6 +139,7 @@ class AbstractPluginTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function piSetPiVarDefaultsStdWrap($input, $expected)
     {
+        $this->resetSingletonInstances = true;
         $this->abstractPlugin->piVars = $this->defaultPiVars;
 
         $this->abstractPlugin->conf['_DEFAULT_PI_VARS.'] = $input;
index 25e8fbe..eb875e3 100644 (file)
@@ -35,9 +35,9 @@ class AbstractTypolinkBuilderTest extends UnitTestCase
     protected static $suppressNotices = true;
 
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
+    protected $resetSingletonInstances = true;
 
     /**
      * @var \PHPUnit_Framework_MockObject_MockObject|TypoScriptFrontendController|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
@@ -56,7 +56,6 @@ class AbstractTypolinkBuilderTest extends UnitTestCase
     {
         GeneralUtility::flushInternalRuntimeCaches();
 
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $this->createMockedLoggerAndLogManager();
 
         $this->templateServiceMock =
@@ -79,12 +78,6 @@ class AbstractTypolinkBuilderTest extends UnitTestCase
         $GLOBALS['TSFE'] = $this->frontendControllerMock;
     }
 
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
-
     //////////////////////
     // Utility functions
     //////////////////////
index a8f70fb..43488e2 100644 (file)
@@ -15,35 +15,18 @@ namespace TYPO3\CMS\IndexedSearch\Tests\Unit\Example;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\IndexedSearch\Example\PluginHook;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * This class contains unit tests for the indexer
+ * Test case
  */
 class PluginHookTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
-
-    /**
-     * Indexer instance
-     *
-     * @var \TYPO3\CMS\IndexedSearch\Example\PluginHook
-     */
-    protected $subject;
-
-    /**
-     * Sets up the test
-     */
-    protected function setUp()
-    {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
-        $this->subject = new PluginHook();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
@@ -55,7 +38,7 @@ class PluginHookTest extends UnitTestCase
             'rows' => []
         ];
 
-        $result = $this->subject->getDisplayResults_postProc($searchResult);
+        $result = (new PluginHook())->getDisplayResults_postProc($searchResult);
         self::assertSame($searchResult, $result);
     }
 
@@ -80,17 +63,7 @@ class PluginHookTest extends UnitTestCase
             ]
         ];
 
-        $result = $this->subject->getDisplayResults_postProc($searchResult);
+        $result = (new PluginHook())->getDisplayResults_postProc($searchResult);
         self::assertSame($expected, $result);
     }
-
-    /**
-     * Tear down the tests
-     */
-    protected function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        unset($this->subject);
-        parent::tearDown();
-    }
 }
index e2a461d..7694601 100644 (file)
@@ -14,32 +14,24 @@ namespace TYPO3\CMS\IndexedSearch\Tests\Unit;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
+use TYPO3\CMS\IndexedSearch\Indexer;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
 /**
- * This class contains unit tests for the indexer
+ * Test case
  */
-class IndexerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class IndexerTest extends UnitTestCase
 {
     /**
-     * Subject is not notice free, disable E_NOTICES
+     * @var bool Reset singletons created by subject
      */
-    protected static $suppressNotices = true;
+    protected $resetSingletonInstances = true;
 
     /**
-     * Indexer instance
-     *
-     * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\IndexedSearch\Indexer
-     */
-    protected $subject = null;
-
-    /**
-     * Sets up the test
+     * Subject is not notice free, disable E_NOTICES
      */
-    protected function setUp()
-    {
-        $this->subject = $this->getMockBuilder(\TYPO3\CMS\IndexedSearch\Indexer::class)
-            ->setMethods(['dummy'])
-            ->getMock();
-    }
+    protected static $suppressNotices = true;
 
     /**
      * @test
@@ -47,7 +39,8 @@ class IndexerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function extractHyperLinksDoesNotReturnNonExistingLocalPath()
     {
         $html = 'test <a href="' . $this->getUniqueId() . '">test</a> test';
-        $result = $this->subject->extractHyperLinks($html);
+        $subject = new Indexer();
+        $result = $subject->extractHyperLinks($html);
         $this->assertEquals(1, count($result));
         $this->assertEquals('', $result[0]['localPath']);
     }
@@ -63,7 +56,8 @@ class IndexerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $GLOBALS['T3_VAR']['ext']['indexed_search']['indexLocalFiles'] = [
             \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5('testfile') => $temporaryFileName,
         ];
-        $result = $this->subject->extractHyperLinks($html);
+        $subject = new Indexer();
+        $result = $subject->extractHyperLinks($html);
         $this->assertEquals(1, count($result));
         $this->assertEquals($temporaryFileName, $result[0]['localPath']);
     }
@@ -75,7 +69,8 @@ class IndexerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $baseURL = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
         $html = 'test <a href="' . $baseURL . 'index.php">test</a> test';
-        $result = $this->subject->extractHyperLinks($html);
+        $subject = new Indexer();
+        $result = $subject->extractHyperLinks($html);
         $this->assertEquals(1, count($result));
         $this->assertEquals(PATH_site . 'index.php', $result[0]['localPath']);
     }
@@ -86,7 +81,8 @@ class IndexerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function extractHyperLinksFindsCorrectPathWithAbsolutePath()
     {
         $html = 'test <a href="index.php">test</a> test';
-        $result = $this->subject->extractHyperLinks($html);
+        $subject = new Indexer();
+        $result = $subject->extractHyperLinks($html);
         $this->assertEquals(1, count($result));
         $this->assertEquals(PATH_site . 'index.php', $result[0]['localPath']);
     }
@@ -98,7 +94,8 @@ class IndexerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $path = substr(PATH_typo3, strlen(PATH_site) - 1);
         $html = 'test <a href="' . $path . 'index.php">test</a> test';
-        $result = $this->subject->extractHyperLinks($html);
+        $subject = new Indexer();
+        $result = $subject->extractHyperLinks($html);
         $this->assertEquals(1, count($result));
         $this->assertEquals(PATH_typo3 . 'index.php', $result[0]['localPath']);
     }
@@ -110,14 +107,15 @@ class IndexerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $absRefPrefix = '/' . $this->getUniqueId();
         $html = 'test <a href="' . $absRefPrefix . 'index.php">test</a> test';
-        $GLOBALS['TSFE'] = $this->createMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class);
+        $GLOBALS['TSFE'] = $this->createMock(TypoScriptFrontendController::class);
         $config = [
             'config' => [
                 'absRefPrefix' => $absRefPrefix,
             ],
         ];
         $GLOBALS['TSFE']->config = $config;
-        $result = $this->subject->extractHyperLinks($html);
+        $subject = new Indexer();
+        $result = $subject->extractHyperLinks($html);
         $this->assertEquals(1, count($result));
         $this->assertEquals(PATH_site . 'index.php', $result[0]['localPath']);
     }
@@ -129,7 +127,8 @@ class IndexerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $baseHref = 'http://example.com/';
         $html = '<html><head><Base Href="' . $baseHref . '" /></head></html>';
-        $result = $this->subject->extractBaseHref($html);
+        $subject = new Indexer();
+        $result = $subject->extractBaseHref($html);
         $this->assertEquals($baseHref, $result);
     }
 
@@ -171,7 +170,8 @@ EOT;
 
 EOT;
 
-        $result = $this->subject->typoSearchTags($body);
+        $subject = new Indexer();
+        $result = $subject->typoSearchTags($body);
         $this->assertTrue($result);
         $this->assertEquals($expected, $body);
     }
@@ -226,7 +226,8 @@ EOT;
 
 EOT;
 
-        $result = $this->subject->typoSearchTags($body);
+        $subject = new Indexer();
+        $result = $subject->typoSearchTags($body);
         $this->assertTrue($result);
         $this->assertEquals($expected, $body);
     }
index 18d0e1f..dfc378f 100644 (file)
@@ -21,12 +21,18 @@ use TYPO3\CMS\Core\Http\JsonResponse;
 use TYPO3\CMS\Core\Http\RequestFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Service\CoreVersionService;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class CoreVersionServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class CoreVersionServiceTest extends UnitTestCase
 {
+    /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
     public function setUpApiResponse(string $url, array $responseData)
     {
         $response = new JsonResponse($responseData);
index d50c107..67e0bb3 100644 (file)
@@ -16,7 +16,6 @@ namespace TYPO3\CMS\Install\Tests\Unit\Updates;
  */
 
 use TYPO3\CMS\Core\Registry;
-use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Extensionmanager\Utility\InstallUtility;
@@ -25,7 +24,7 @@ use TYPO3\CMS\Install\Updates\Compatibility7ExtractionUpdate;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Class Compatibility7ExtractionUpdateTest
+ * Test case
  */
 class Compatibility7ExtractionUpdateTest extends UnitTestCase
 {
@@ -35,21 +34,20 @@ class Compatibility7ExtractionUpdateTest extends UnitTestCase
     protected $registry;
 
     /**
-     * @var SingletonInterface[]
+     * Set up
      */
-    protected $singletonInstances;
-
     protected function setUp()
     {
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $this->registry = $this->prophesize(Registry::class);
         GeneralUtility::setSingletonInstance(Registry::class, $this->registry->reveal());
     }
 
+    /**
+     * Tear down
+     */
     protected function tearDown()
     {
         GeneralUtility::purgeInstances();
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
         parent::tearDown();
     }
 
index 718ce84..eaa7280 100644 (file)
@@ -20,13 +20,19 @@ use TYPO3\CMS\Core\Http\RequestFactory;
 use TYPO3\CMS\Core\Registry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Service\CoreVersionService;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class CoreVersionServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class CoreVersionServiceTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @test
      */
     public function updateVersionMatrixRemovesOldReleasesFromMatrix(): void
index 5143c25..b38ab17 100644 (file)
@@ -31,6 +31,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 class RedirectServiceTest extends UnitTestCase
 {
     /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    /**
      * @var RedirectCacheService|ObjectProphecy
      */
     protected $redirectCacheServiceProphecy;
@@ -40,12 +45,9 @@ class RedirectServiceTest extends UnitTestCase
      */
     protected $redirectService;
 
-    protected $singletonInstances = [];
-
     protected function setUp()
     {
         parent::setUp();
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
         $loggerProphecy = $this->prophesize(LoggerInterface::class);
         $this->redirectCacheServiceProphecy = $this->prophesize(RedirectCacheService::class);
         $this->redirectService = new RedirectService();
@@ -359,13 +361,4 @@ class RedirectServiceTest extends UnitTestCase
         $uri = new Uri('https://example.com/?bar=2&baz=4&foo=1');
         self::assertEquals($uri, $result);
     }
-
-    /**
-     * Tear down
-     */
-    public function tearDown()
-    {
-        GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
 }
index f46dee0..4b636a5 100644 (file)
@@ -20,22 +20,24 @@ use TYPO3\CMS\Rsaauth\Backend\CommandLineBackend;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Test case.
+ * Test case
  */
 class CommandLineBackendTest extends UnitTestCase
 {
     /**
-     * @var CommandLineBackend
+     * @var bool Reset singletons created by subject
      */
-    protected $subject = null;
+    protected $resetSingletonInstances = true;
 
+    /**
+     * Set up
+     */
     protected function setUp()
     {
         if (Environment::isWindows()) {
             $this->markTestSkipped('This test is not available on Windows as auto-detection of openssl path will fail.');
         }
         $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['rsaauth']['temporaryDirectory'] = '';
-        $this->subject = new CommandLineBackend();
     }
 
     /**
@@ -43,7 +45,8 @@ class CommandLineBackendTest extends UnitTestCase
      */
     public function createNewKeyPairCreatesReadyKeyPair()
     {
-        $keyPair = $this->subject->createNewKeyPair();
+        $subject = new CommandLineBackend();
+        $keyPair = $subject->createNewKeyPair();
         if ($keyPair === null) {
             $this->markTestSkipped('KeyPair could not be generated. Maybe openssl was not found.');
         }
@@ -56,7 +59,8 @@ class CommandLineBackendTest extends UnitTestCase
      */
     public function createNewKeyPairCreatesKeyPairWithDefaultExponent()
     {
-        $keyPair = $this->subject->createNewKeyPair();
+        $subject = new CommandLineBackend();
+        $keyPair = $subject->createNewKeyPair();
         if ($keyPair === null) {
             $this->markTestSkipped('KeyPair could not be generated. Maybe openssl was not found.');
         }
@@ -72,9 +76,10 @@ class CommandLineBackendTest extends UnitTestCase
      */
     public function createNewKeyPairCalledTwoTimesReturnsSameKeyPairInstance()
     {
+        $subject = new CommandLineBackend();
         $this->assertSame(
-            $this->subject->createNewKeyPair(),
-            $this->subject->createNewKeyPair()
+            $subject->createNewKeyPair(),
+            $subject->createNewKeyPair()
         );
     }
 }
index ff8605b..8c96ab5 100644 (file)
@@ -15,28 +15,25 @@ namespace TYPO3\CMS\Rsaauth\Tests\Unit\Backend;
  */
 
 use TYPO3\CMS\Rsaauth\Backend\PhpBackend;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case.
  */
-class PhpBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class PhpBackendTest extends UnitTestCase
 {
     /**
-     * @var PhpBackend
+     * @var bool Reset singletons created by subject
      */
-    protected $subject = null;
-
-    protected function setUp()
-    {
-        $this->subject = new PhpBackend();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
      */
     public function createNewKeyPairCreatesReadyKeyPair()
     {
-        $keyPair = $this->subject->createNewKeyPair();
+        $subject = new PhpBackend();
+        $keyPair = $subject->createNewKeyPair();
         $this->assertNotNull($keyPair, 'Test fails because of broken environment: PHP OpenSSL extension is not working properly.');
         $this->assertTrue($keyPair->isReady());
     }
@@ -46,11 +43,12 @@ class PhpBackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function createNewKeyPairCalledTwoTimesReturnsSameKeyPairInstance()
     {
-        $keyPair1 = $this->subject->createNewKeyPair();
+        $subject = new PhpBackend();
+        $keyPair1 = $subject->createNewKeyPair();
         $this->assertNotNull($keyPair1, 'Test fails because of broken environment: PHP OpenSSL extension is not working properly.');
         $this->assertSame(
             $keyPair1,
-            $this->subject->createNewKeyPair()
+            $subject->createNewKeyPair()
         );
     }
 }
index b0ad4b4..0288ffa 100644 (file)
@@ -15,33 +15,17 @@ namespace TYPO3\CMS\Scheduler\Tests\Unit\Task;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class CachingFrameworkGarbageCollectionTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class CachingFrameworkGarbageCollectionTest extends UnitTestCase
 {
     /**
-     * @var array
+     * @var bool Reset singletons created by subject
      */
-    protected $singletonInstances = [];
-
-    /**
-     * Set up
-     */
-    protected function setUp()
-    {
-        $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-    }
-
-    /**
-     * Reset singleton instances
-     */
-    protected function tearDown()
-    {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
-        parent::tearDown();
-    }
+    protected $resetSingletonInstances = true;
 
     /**
      * @test
index aa5de53..b34bac8 100644 (file)
@@ -20,16 +20,18 @@ use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\FileReference;
 use TYPO3\CMS\Core\Resource\ProcessedFile;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Workspaces\Controller\Remote\RemoteServer;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * RemoteServer test
+ * Test case
  */
-class RemoteServerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class RemoteServerTest extends UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Workspaces\Controller\Remote\RemoteServer
+     * @var bool Reset singletons created by subject
      */
-    protected $subject;
+    protected $resetSingletonInstances = true;
 
     /**
      * @var FileReference[]|ObjectProphecy[]
@@ -37,25 +39,6 @@ class RemoteServerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     protected $fileReferenceProphecies;
 
     /**
-     * Set up
-     */
-    protected function setUp()
-    {
-        parent::setUp();
-        $this->subject = $this->getAccessibleMock(\TYPO3\CMS\Workspaces\Controller\Remote\RemoteServer::class, ['__none']);
-    }
-
-    /**
-     * Tear down.
-     */
-    protected function tearDown()
-    {
-        parent::tearDown();
-        unset($this->subject);
-        unset($this->fileReferenceProphecies);
-    }
-
-    /**
      * @return array
      */
     public function prepareFileReferenceDifferencesAreCorrectDataProvider()
@@ -129,7 +112,8 @@ class RemoteServerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $liveFileReferences = $this->getFileReferenceProphecies($fileFileReferenceList);
         $versionFileReferences = $this->getFileReferenceProphecies($versionFileReferenceList);
 
-        $result = $this->subject->_call(
+        $subject = $this->getAccessibleMock(RemoteServer::class, ['__none']);
+        $result = $subject->_call(
             'prepareFileReferenceDifferences',
             $liveFileReferences,
             $versionFileReferences,