[TASK] Unit tests: Do not rely on CacheManager instance 55/55855/4
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 21 Feb 2018 17:39:46 +0000 (18:39 +0100)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Wed, 21 Feb 2018 20:23:53 +0000 (21:23 +0100)
The typo3/testing-framework bootstrap up until now
initialized the CacheManager singleton and put it
into GeneralUtility instance stack.
To better isolate the tests and as a next step in
side effect free uni testing, the test bootstrap
now cleans this instance after use:

composer update typo/testing-framework

About 300 tests fail with this and are fixed with
the patch by improving their mocking.

Change-Id: Ia3e9dd1f94af10b20e0463a0062ccde74be23660
Resolves: #84004
Releases: master
Reviewed-on: https://review.typo3.org/55855
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
35 files changed:
composer.lock
typo3/sysext/backend/Tests/Unit/Controller/File/FileControllerTest.php
typo3/sysext/backend/Tests/Unit/Form/Element/InputDateTimeElementTest.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/NodeExpansion/FieldControlTest.php
typo3/sysext/core/Classes/Localization/LanguageStore.php
typo3/sysext/core/Classes/Log/Writer/FileWriter.php
typo3/sysext/core/Tests/Integrity/IntegrityTest.php
typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php
typo3/sysext/core/Tests/Unit/Imaging/IconRegistryTest.php
typo3/sysext/core/Tests/Unit/Imaging/IconTest.php
typo3/sysext/core/Tests/Unit/Localization/LocalesTest.php
typo3/sysext/core/Tests/Unit/Localization/LocalizationFactoryTest.php
typo3/sysext/core/Tests/Unit/Localization/Parser/LocallangXmlParserTest.php
typo3/sysext/core/Tests/Unit/Localization/Parser/XliffParserTest.php
typo3/sysext/core/Tests/Unit/Resource/Filter/FileNameFilterTest.php
typo3/sysext/core/Tests/Unit/Resource/Utility/FileExtensionFilterTest.php
typo3/sysext/core/Tests/Unit/TypoScript/Parser/TypoScriptParserTest.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
typo3/sysext/core/Tests/Unit/Utility/RootlineUtilityTest.php
typo3/sysext/extbase/Tests/Unit/Core/BootstrapTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/Generic/BackendTest.php
typo3/sysext/extbase/Tests/Unit/Persistence/RepositoryTest.php
typo3/sysext/extbase/Tests/Unit/Utility/LocalizationUtilityTest.php
typo3/sysext/extensionmanager/Tests/Unit/Controller/UpdateFromTerControllerTest.php [deleted file]
typo3/sysext/form/Tests/Unit/Controller/FormManagerControllerTest.php
typo3/sysext/form/Tests/Unit/Service/TranslationServiceTest.php
typo3/sysext/frontend/Tests/Unit/Authentication/FrontendUserAuthenticationTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/AbstractMenuContentObjectTest.php
typo3/sysext/frontend/Tests/Unit/View/AdminPanelViewTest.php
typo3/sysext/install/Tests/Unit/Service/CoreUpdateServiceTest.php
typo3/sysext/recordlist/Tests/UnitDeprecated/RecordList/AbstractDatabaseRecordListTest.php
typo3/sysext/saltedpasswords/Tests/Unit/Salt/Pbkdf2SaltTest.php

index 964e291..57e5b65 100644 (file)
         },
         {
             "name": "typo3/testing-framework",
-            "version": "3.1.1",
+            "version": "3.1.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/TYPO3/testing-framework.git",
-                "reference": "91e9fd5ef81ec608a68db87fb55919ad067183f8"
+                "reference": "e6e8e5fd53abbb61d3196f906c882ef0fccea140"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/91e9fd5ef81ec608a68db87fb55919ad067183f8",
-                "reference": "91e9fd5ef81ec608a68db87fb55919ad067183f8",
+                "url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/e6e8e5fd53abbb61d3196f906c882ef0fccea140",
+                "reference": "e6e8e5fd53abbb61d3196f906c882ef0fccea140",
                 "shasum": ""
             },
             "require": {
                 "tests",
                 "typo3"
             ],
-            "time": "2018-02-17T19:06:51+00:00"
+            "time": "2018-02-21T17:38:06+00:00"
         },
         {
             "name": "webmozart/assert",
index 3f4a682..df6f65b 100644 (file)
@@ -14,20 +14,21 @@ namespace TYPO3\CMS\Backend\Tests\Unit\Controller\File;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
+use TYPO3\CMS\Backend\Controller\File\FileController;
 use TYPO3\CMS\Core\Http\Response;
 use TYPO3\CMS\Core\Http\ServerRequest;
+use TYPO3\CMS\Core\Imaging\Icon;
+use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Tests for \TYPO3\CMS\Backend\Tests\Unit\Controller\File\FileController
  */
-class FileControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class FileControllerTest extends UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Backend\Controller\File\FileController|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
-     */
-    protected $fileController;
-
-    /**
      * @var \TYPO3\CMS\Core\Resource\File|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $fileResourceMock;
@@ -81,32 +82,36 @@ class FileControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
-    public function flattenResultDataValueFlattensFileAndFolderResourcesButReturnsAnythingElseAsIs()
+    public function flattenResultDataValueReturnsAnythingElseAsIs()
     {
-        $this->fileController = $this->getAccessibleMock(\TYPO3\CMS\Backend\Controller\File\FileController::class, ['dummy']);
+        $subject = $this->getAccessibleMock(FileController::class, ['dummy']);
+        $this->assertTrue($subject->_call('flattenResultDataValue', true));
+        $this->assertSame([], $subject->_call('flattenResultDataValue', []));
+    }
 
-        $this->folderResourceMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('bar'));
+    /**
+     * @test
+     */
+    public function flattenResultDataValueFlattensFile()
+    {
+        $subject = $this->getAccessibleMock(FileController::class, ['dummy']);
 
-        $this->mockFileProcessor->expects($this->any())->method('getErrorMessages')->will($this->returnValue([]));
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+        $iconProphecy = $this->prophesize(Icon::class);
+        $iconProphecy->render()->shouldBeCalled()->willReturn('');
+        $iconFactoryProphecy->getIconForFileExtension(Argument::cetera())->willReturn($iconProphecy->reveal());
 
-        $this->assertTrue($this->fileController->_call('flattenResultDataValue', true));
-        $this->assertSame([], $this->fileController->_call('flattenResultDataValue', []));
-        $result = $this->fileController->_call('flattenResultDataValue', $this->fileResourceMock);
-        $this->assertContains('<span class="t3js-icon icon icon-size-small icon-state-default icon-mimetypes-text-html" data-identifier="mimetypes-text-html">', $result['icon']);
-        unset($result['icon']);
+        $result = $subject->_call('flattenResultDataValue', $this->fileResourceMock);
         $this->assertSame(
             [
                 'id' => 'foo',
                 'date' => '29-11-73',
+                'icon' => '',
                 'thumbUrl' => '',
             ],
             $result
         );
-
-        $this->assertSame(
-            'bar',
-            $this->fileController->_call('flattenResultDataValue', $this->folderResourceMock)
-        );
     }
 
     /**
@@ -114,16 +119,16 @@ class FileControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function processAjaxRequestDeleteProcessActuallyDoesNotChangeFileData()
     {
-        $this->fileController = $this->getAccessibleMock(\TYPO3\CMS\Backend\Controller\File\FileController::class, ['init', 'main']);
+        $subject = $this->getAccessibleMock(FileController::class, ['init', 'main']);
 
         $fileData = ['delete' => [true]];
-        $this->fileController->_set('fileProcessor', $this->mockFileProcessor);
-        $this->fileController->_set('fileData', $fileData);
-        $this->fileController->_set('redirect', false);
+        $subject->_set('fileProcessor', $this->mockFileProcessor);
+        $subject->_set('fileData', $fileData);
+        $subject->_set('redirect', false);
 
-        $this->fileController->expects($this->once())->method('main');
+        $subject->expects($this->once())->method('main');
 
-        $this->fileController->processAjaxRequest($this->request, $this->response);
+        $subject->processAjaxRequest($this->request, $this->response);
     }
 
     /**
@@ -131,16 +136,16 @@ class FileControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function processAjaxRequestEditFileProcessActuallyDoesNotChangeFileData()
     {
-        $this->fileController = $this->getAccessibleMock(\TYPO3\CMS\Backend\Controller\File\FileController::class, ['init', 'main']);
+        $subject = $this->getAccessibleMock(FileController::class, ['init', 'main']);
 
         $fileData = ['editfile' => [true]];
-        $this->fileController->_set('fileProcessor', $this->mockFileProcessor);
-        $this->fileController->_set('fileData', $fileData);
-        $this->fileController->_set('redirect', false);
+        $subject->_set('fileProcessor', $this->mockFileProcessor);
+        $subject->_set('fileData', $fileData);
+        $subject->_set('redirect', false);
 
-        $this->fileController->expects($this->once())->method('main');
+        $subject->expects($this->once())->method('main');
 
-        $this->fileController->processAjaxRequest($this->request, $this->response);
+        $subject->processAjaxRequest($this->request, $this->response);
     }
 
     /**
@@ -148,14 +153,14 @@ class FileControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function processAjaxRequestReturnsStatus200IfNoErrorOccures()
     {
-        $this->fileController = $this->getAccessibleMock(\TYPO3\CMS\Backend\Controller\File\FileController::class, ['init', 'main']);
+        $subject = $this->getAccessibleMock(FileController::class, ['init', 'main']);
 
         $fileData = ['editfile' => [true]];
-        $this->fileController->_set('fileProcessor', $this->mockFileProcessor);
-        $this->fileController->_set('fileData', $fileData);
-        $this->fileController->_set('redirect', false);
+        $subject->_set('fileProcessor', $this->mockFileProcessor);
+        $subject->_set('fileData', $fileData);
+        $subject->_set('redirect', false);
 
-        $result = $this->fileController->processAjaxRequest($this->request, $this->response);
+        $result = $subject->processAjaxRequest($this->request, $this->response);
         $this->assertEquals(200, $result->getStatusCode());
     }
 
@@ -164,10 +169,10 @@ class FileControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function processAjaxRequestReturnsStatus500IfErrorOccurs()
     {
-        $this->fileController = $this->getAccessibleMock(\TYPO3\CMS\Backend\Controller\File\FileController::class, ['init', 'main']);
+        $subject = $this->getAccessibleMock(FileController::class, ['init', 'main']);
         $this->mockFileProcessor->expects($this->any())->method('getErrorMessages')->will($this->returnValue(['error occured']));
-        $this->fileController->_set('fileProcessor', $this->mockFileProcessor);
-        $result = $this->fileController->processAjaxRequest($this->request, $this->response);
+        $subject->_set('fileProcessor', $this->mockFileProcessor);
+        $result = $subject->processAjaxRequest($this->request, $this->response);
         $this->assertEquals(500, $result->getStatusCode());
     }
 }
index d654009..6be866f 100644 (file)
@@ -19,7 +19,10 @@ use TYPO3\CMS\Backend\Form\AbstractNode;
 use TYPO3\CMS\Backend\Form\Element\InputDateTimeElement;
 use TYPO3\CMS\Backend\Form\NodeExpansion\FieldInformation;
 use TYPO3\CMS\Backend\Form\NodeFactory;
+use TYPO3\CMS\Core\Imaging\Icon;
+use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Localization\LanguageService;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -116,6 +119,11 @@ class InputDateTimeElementTest extends UnitTestCase
             'additionalHiddenFields' => [],
             'stylesheetFiles' => [],
         ]);
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+        $iconProphecy = $this->prophesize(Icon::class);
+        $iconProphecy->render()->willReturn('');
+        $iconFactoryProphecy->getIcon(Argument::cetera())->willReturn($iconProphecy->reveal());
         $nodeFactoryProphecy = $this->prophesize(NodeFactory::class);
         $nodeFactoryProphecy->create(Argument::cetera())->willReturn($abstractNode->reveal());
         $fieldInformationProphecy = $this->prophesize(FieldInformation::class);
index beb3181..ef85c84 100644 (file)
@@ -27,6 +27,9 @@ use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer;
 use TYPO3\CMS\Core\Database\RelationHandler;
+use TYPO3\CMS\Core\Imaging\Icon;
+use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Imaging\IconRegistry;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
@@ -315,6 +318,9 @@ class TcaSelectItemsTest extends UnitTestCase
             ],
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         $this->expectException(\UnexpectedValueException::class);
         $this->expectExceptionCode(1439298496);
 
@@ -358,6 +364,9 @@ class TcaSelectItemsTest extends UnitTestCase
         ];
         $GLOBALS['TCA_DESCR']['aTable']['columns']['']['description'] = 'aDescription';
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         /** @var LanguageService|ObjectProphecy $languageService */
         $languageService = $this->prophesize(LanguageService::class);
         $GLOBALS['LANG'] = $languageService->reveal();
@@ -373,7 +382,7 @@ class TcaSelectItemsTest extends UnitTestCase
             0 => [
                 0 => 'aTitle',
                 1 => 'aTable',
-                2 => 'default-not-found',
+                2 => null,
                 3 => [
                     'description' => 'aDescription',
                 ],
@@ -424,6 +433,9 @@ class TcaSelectItemsTest extends UnitTestCase
             ],
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         /** @var LanguageService|ObjectProphecy $languageService */
         $languageService = $this->prophesize(LanguageService::class);
         $GLOBALS['LANG'] = $languageService->reveal();
@@ -437,7 +449,7 @@ class TcaSelectItemsTest extends UnitTestCase
             0 => [
                 0 => 'aLabel',
                 1 => 'aValue',
-                2 => 'default-not-found',
+                2 => null,
                 3 => null,
             ]
         ];
@@ -474,7 +486,7 @@ class TcaSelectItemsTest extends UnitTestCase
                     0 => [
                         0 => 'fooTableTitle',
                         1 => '--div--',
-                        2 => 'default-not-found',
+                        2 => null,
                         3 => null,
                     ],
                     1 => [
@@ -509,7 +521,7 @@ class TcaSelectItemsTest extends UnitTestCase
                     0 => [
                         0 => 'fooTableTitle',
                         1 => '--div--',
-                        2 => 'default-not-found',
+                        2 => null,
                         3 => null,
                     ],
                     1 => [
@@ -586,6 +598,9 @@ class TcaSelectItemsTest extends UnitTestCase
         ];
         $GLOBALS['TCA'] = $tca;
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         $result = (new TcaSelectItems)->addData($input);
 
         $this->assertSame($expectedItems, $result['processedTca']['columns']['aField']['config']['items']);
@@ -650,11 +665,14 @@ class TcaSelectItemsTest extends UnitTestCase
             ],
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         $expectedItems = [
             0 => [
                 0 => 'fooTableTitle aFlexFieldTitle dummy',
                 1 => '--div--',
-                2 => 'default-not-found',
+                2 => null,
                 3 => null,
             ],
             1 => [
@@ -715,6 +733,9 @@ class TcaSelectItemsTest extends UnitTestCase
             ],
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         /** @var LanguageService|ObjectProphecy $languageService */
         $languageService = $this->prophesize(LanguageService::class);
         $GLOBALS['LANG'] = $languageService->reveal();
@@ -786,6 +807,9 @@ class TcaSelectItemsTest extends UnitTestCase
             ],
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         /** @var LanguageService|ObjectProphecy $languageService */
         $languageService = $this->prophesize(LanguageService::class);
         $GLOBALS['LANG'] = $languageService->reveal();
@@ -872,6 +896,9 @@ class TcaSelectItemsTest extends UnitTestCase
             ],
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         /** @var LanguageService|ObjectProphecy $languageService */
         $languageService = $this->prophesize(LanguageService::class);
         $GLOBALS['LANG'] = $languageService->reveal();
@@ -964,6 +991,9 @@ class TcaSelectItemsTest extends UnitTestCase
             ],
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         /** @var LanguageService|ObjectProphecy $languageService */
         $languageService = $this->prophesize(LanguageService::class);
         $GLOBALS['LANG'] = $languageService->reveal();
@@ -1024,6 +1054,9 @@ class TcaSelectItemsTest extends UnitTestCase
             ],
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         $expectedItems = [
             0 => [
                 0 => 'aLangTitle [42]',
@@ -1075,6 +1108,9 @@ class TcaSelectItemsTest extends UnitTestCase
             ]
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         $expectedItems = [
             0 => [
                 0 => 'aHeader',
@@ -1091,7 +1127,7 @@ class TcaSelectItemsTest extends UnitTestCase
             2 => [
                 0 => 'anotherTitle',
                 1 => 'aKey:anotherKey',
-                2 => 'status-status-permission-denied',
+                2 => 'empty-empty',
                 3 => [ 'description' => 'aDescription' ],
             ],
         ];
@@ -1124,6 +1160,9 @@ class TcaSelectItemsTest extends UnitTestCase
 
         $GLOBALS['TBE_MODULES'] = [];
 
+        $iconFactoryProphecy = $this->prophesize(IconRegistry::class);
+        GeneralUtility::setSingletonInstance(IconRegistry::class, $iconFactoryProphecy->reveal());
+
         /** @var ModuleLoader|ObjectProphecy $moduleLoaderProphecy */
         $moduleLoaderProphecy = $this->prophesize(ModuleLoader::class);
         GeneralUtility::addInstance(ModuleLoader::class, $moduleLoaderProphecy->reveal());
@@ -1636,6 +1675,9 @@ class TcaSelectItemsTest extends UnitTestCase
 
         $GLOBALS['TCA']['fTable'] = [];
 
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         list($queryBuilderProphet, $connectionPoolProphet) = $this->mockDatabaseConnection();
 
         /** @var Statement|ObjectProphecy $statementProphet */
@@ -1723,6 +1765,9 @@ class TcaSelectItemsTest extends UnitTestCase
 
         $GLOBALS['TCA']['fTable'] = [];
 
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         /** @var BackendUserAuthentication|ObjectProphecy $backendUserProphecy */
         $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
         $GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
@@ -1869,6 +1914,9 @@ class TcaSelectItemsTest extends UnitTestCase
             'columns' => [],
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         /** @var BackendUserAuthentication|ObjectProphecy $backendUserProphecy */
         $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
         $GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
@@ -1910,13 +1958,13 @@ class TcaSelectItemsTest extends UnitTestCase
             0 => [
                 0 => 'aPrefix[LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.no_title]',
                 1 => 1,
-                2 => 'default-not-found',
+                2 => null,
                 3 => null,
             ],
             1 => [
                 0 => 'aPrefix[LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.no_title]',
                 1 => 2,
-                2 => 'default-not-found',
+                2 => null,
                 3 => null,
             ],
         ];
@@ -1965,6 +2013,9 @@ class TcaSelectItemsTest extends UnitTestCase
             ],
         ];
 
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         /** @var BackendUserAuthentication|ObjectProphecy $backendUserProphecy */
         $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
         $GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
@@ -2805,6 +2856,9 @@ class TcaSelectItemsTest extends UnitTestCase
     {
         $GLOBALS['TCA']['foreignTable'] = [];
 
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         /** @var BackendUserAuthentication|ObjectProphecy $backendUserProphecy */
         $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
         $GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
@@ -2862,6 +2916,9 @@ class TcaSelectItemsTest extends UnitTestCase
     {
         $GLOBALS['TCA']['foreignTable'] = [];
 
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         /** @var BackendUserAuthentication|ObjectProphecy $backendUserProphecy */
         $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
         $GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
@@ -2917,6 +2974,9 @@ class TcaSelectItemsTest extends UnitTestCase
     {
         $GLOBALS['TCA']['foreignTable'] = [];
 
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         /** @var BackendUserAuthentication|ObjectProphecy $backendUserProphecy */
         $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
         $GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
@@ -3375,6 +3435,9 @@ class TcaSelectItemsTest extends UnitTestCase
 
         $GLOBALS['TCA'][$foreignTable] = [];
 
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         /** @var BackendUserAuthentication|ObjectProphecy $backendUserProphecy */
         $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
         $GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
index 4f89c15..1274b46 100644 (file)
@@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
 use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Database\Query\Restriction\DefaultRestrictionContainer;
+use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider;
 use TYPO3\CMS\Core\Tree\TableConfiguration\TableConfigurationTree;
@@ -131,6 +132,10 @@ class TcaSelectTreeItemsTest extends UnitTestCase
     {
         $GLOBALS['TCA']['foreignTable'] = [];
 
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         /** @var BackendUserAuthentication|ObjectProphecy $backendUserProphecy */
         $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
         $GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
@@ -194,6 +199,10 @@ class TcaSelectTreeItemsTest extends UnitTestCase
     {
         $GLOBALS['TCA']['foreignTable'] = [];
 
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         /** @var BackendUserAuthentication|ObjectProphecy $backendUserProphecy */
         $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
         $GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
index 27607f4..f58b0cc 100644 (file)
@@ -18,7 +18,10 @@ use Prophecy\Argument;
 use TYPO3\CMS\Backend\Form\AbstractNode;
 use TYPO3\CMS\Backend\Form\NodeExpansion\FieldControl;
 use TYPO3\CMS\Backend\Form\NodeFactory;
+use TYPO3\CMS\Core\Imaging\Icon;
+use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Localization\LanguageService;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
@@ -31,6 +34,12 @@ class FieldControlTest extends UnitTestCase
      */
     public function renderMergesResultOfSingleControls()
     {
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+        $iconProphecy = $this->prophesize(Icon::class);
+        $iconProphecy->render()->shouldBeCalled()->willReturn('');
+        $iconFactoryProphecy->getIcon(Argument::cetera())->shouldBeCalled()->willReturn($iconProphecy->reveal());
+
         $languageServiceProphecy = $this->prophesize(LanguageService::class);
         $languageServiceProphecy->sL(Argument::cetera())->willReturnArgument(0);
         $GLOBALS['LANG'] = $languageServiceProphecy->reveal();
index f3f0a84..e5c6bbb 100644 (file)
@@ -16,12 +16,13 @@ namespace TYPO3\CMS\Core\Localization;
 
 use TYPO3\CMS\Core\Localization\Exception\FileNotFoundException;
 use TYPO3\CMS\Core\Localization\Exception\InvalidParserException;
+use TYPO3\CMS\Core\SingletonInterface;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Language store.
  */
-class LanguageStore implements \TYPO3\CMS\Core\SingletonInterface
+class LanguageStore implements SingletonInterface
 {
     /**
      * File extension supported by the localization parser
index 271129c..25a4f27 100644 (file)
@@ -168,7 +168,7 @@ class FileWriter extends AbstractWriter
      */
     protected function closeLogFile()
     {
-        if (is_resource(self::$logFileHandles[$this->logFile])) {
+        if (!empty(self::$logFileHandles[$this->logFile]) && is_resource(self::$logFileHandles[$this->logFile])) {
             fclose(self::$logFileHandles[$this->logFile]);
             unset(self::$logFileHandles[$this->logFile]);
         }
index 172cd4e..277d199 100644 (file)
@@ -13,7 +13,9 @@ namespace TYPO3\CMS\Core\Tests\Integrity;
  *
  * 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
@@ -23,27 +25,9 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
  * should fail if some other test before destroys the environment with
  * invalid mocking or backups.
  */
-class IntegrityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class IntegrityTest extends UnitTestCase
 {
     /**
-     * This test fails if some test before called
-     * \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances() without a proper
-     * backup via \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances()
-     * and a reconstitution via \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances().
-     *
-     * The test for CacheManager should never fail since this object is
-     * already instantiated during bootstrap and must always be there.
-     *
-     * @test
-     */
-    public function standardSingletonIsRegistered()
-    {
-        $registeredSingletons = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-        $this->assertArrayHasKey(\TYPO3\CMS\Core\Cache\CacheManager::class, $registeredSingletons);
-        $this->assertTrue($registeredSingletons[\TYPO3\CMS\Core\Cache\CacheManager::class] instanceof \TYPO3\CMS\Core\Cache\CacheManager);
-    }
-
-    /**
      * This test fails if any test case manipulates the configurationManager
      * property in LocalizationUtility due to mocking and fails to restore it
      * properly.
index 0ef9c6d..110fddc 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\DataHandler;
 use Prophecy\Argument;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Tests\Unit\DataHandling\Fixtures\AllowAccessHookFixture;
@@ -56,6 +57,10 @@ class DataHandlerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $GLOBALS['TCA'] = [];
         $this->singletonInstances = GeneralUtility::getSingletonInstances();
+        $cacheManagerProphecy = $this->prophesize(CacheManager::class);
+        GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
+        $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
+        $cacheManagerProphecy->getCache('cache_runtime')->willReturn($cacheFrontendProphecy->reveal());
         $this->backEndUser = $this->createMock(BackendUserAuthentication::class);
         $this->subject = $this->getAccessibleMock(DataHandler::class, ['dummy']);
         $this->subject->start([], '', $this->backEndUser);
index 169ce32..efcb195 100644 (file)
@@ -14,31 +14,40 @@ namespace TYPO3\CMS\Core\Tests\Unit\Imaging;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider;
 use TYPO3\CMS\Core\Imaging\IconProviderInterface;
+use TYPO3\CMS\Core\Imaging\IconRegistry;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * TestCase for \TYPO3\CMS\Core\Imaging\IconRegistry
+ * Test case
  */
-class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class IconRegistryTest extends UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Core\Imaging\IconRegistry
-     */
-    protected $subject = null;
-
-    /**
      * @var string
      */
     protected $notRegisteredIconIdentifier = 'my-super-unregistered-identifier';
 
-    /**
-     * Set up
-     */
-    protected function setUp()
+    public function setUp()
+    {
+        $cacheManagerProphecy = $this->prophesize(CacheManager::class);
+        GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
+        $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
+        $cacheManagerProphecy->getCache('assets')->willReturn($cacheFrontendProphecy->reveal());
+        $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
+        $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
+    }
+
+    public function tearDown()
     {
-        $this->subject = new \TYPO3\CMS\Core\Imaging\IconRegistry();
+        // Drop cache manager singleton again
+        GeneralUtility::purgeInstances();
+        parent::tearDown();
     }
 
     /**
@@ -46,7 +55,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getDefaultIconIdentifierReturnsTheCorrectDefaultIconIdentifierString()
     {
-        $result = $this->subject->getDefaultIconIdentifier();
+        $result = (new IconRegistry)->getDefaultIconIdentifier();
         $this->assertEquals($result, 'default-not-found');
     }
 
@@ -55,7 +64,8 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function isRegisteredReturnsTrueForRegisteredIcon()
     {
-        $result = $this->subject->isRegistered($this->subject->getDefaultIconIdentifier());
+        $subject = new IconRegistry();
+        $result = $subject->isRegistered($subject->getDefaultIconIdentifier());
         $this->assertEquals($result, true);
     }
 
@@ -64,7 +74,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function isRegisteredReturnsFalseForNotRegisteredIcon()
     {
-        $result = $this->subject->isRegistered($this->notRegisteredIconIdentifier);
+        $result = (new IconRegistry)->isRegistered($this->notRegisteredIconIdentifier);
         $this->assertEquals($result, false);
     }
 
@@ -74,12 +84,13 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function registerIconAddNewIconToRegistry()
     {
         $unregisterdIcon = 'foo-bar-unregistered';
-        $this->assertFalse($this->subject->isRegistered($unregisterdIcon));
-        $this->subject->registerIcon($unregisterdIcon, FontawesomeIconProvider::class, [
+        $subject = new IconRegistry();
+        $this->assertFalse($subject->isRegistered($unregisterdIcon));
+        $subject->registerIcon($unregisterdIcon, FontawesomeIconProvider::class, [
             'name' => 'pencil',
             'additionalClasses' => 'fa-fw'
         ]);
-        $this->assertTrue($this->subject->isRegistered($unregisterdIcon));
+        $this->assertTrue($subject->isRegistered($unregisterdIcon));
     }
 
     /**
@@ -90,7 +101,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->expectException(\InvalidArgumentException::class);
         $this->expectExceptionCode(1437425803);
 
-        $this->subject->registerIcon($this->notRegisteredIconIdentifier, GeneralUtility::class);
+        (new IconRegistry)->registerIcon($this->notRegisteredIconIdentifier, GeneralUtility::class);
     }
 
     /**
@@ -101,7 +112,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->expectException(\TYPO3\CMS\Core\Exception::class);
         $this->expectExceptionCode(1437425804);
 
-        $this->subject->getIconConfigurationByIdentifier($this->notRegisteredIconIdentifier);
+        (new IconRegistry)->getIconConfigurationByIdentifier($this->notRegisteredIconIdentifier);
     }
 
     /**
@@ -109,7 +120,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getIconConfigurationByIdentifierReturnsCorrectConfiguration()
     {
-        $result = $this->subject->getIconConfigurationByIdentifier('default-not-found');
+        $result = (new IconRegistry)->getIconConfigurationByIdentifier('default-not-found');
         // result must contain at least provider and options array
         $this->assertArrayHasKey('provider', $result);
         $this->assertArrayHasKey('options', $result);
@@ -122,7 +133,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getAllRegisteredIconIdentifiersReturnsAnArrayWithIconIdentiefiers()
     {
-        $this->assertInternalType('array', $this->subject->getAllRegisteredIconIdentifiers());
+        $this->assertInternalType('array', (new IconRegistry)->getAllRegisteredIconIdentifiers());
     }
 
     /**
@@ -130,7 +141,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getAllRegisteredIconIdentifiersReturnsArrayWithAllRegisteredIconIdentifiers()
     {
-        $result = $this->subject->getAllRegisteredIconIdentifiers();
+        $result = (new IconRegistry)->getAllRegisteredIconIdentifiers();
         $this->assertInternalType('array', $result);
         $this->assertContains('default-not-found', $result);
     }
@@ -140,7 +151,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getIconIdentifierForFileExtensionReturnsDefaultIconIdentifierForEmptyFileExtension()
     {
-        $result = $this->subject->getIconIdentifierForFileExtension('');
+        $result = (new IconRegistry)->getIconIdentifierForFileExtension('');
         $this->assertEquals('mimetypes-other-other', $result);
     }
 
@@ -149,7 +160,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getIconIdentifierForFileExtensionReturnsDefaultIconIdentifierForUnknownFileExtension()
     {
-        $result = $this->subject->getIconIdentifierForFileExtension('xyz');
+        $result = (new IconRegistry)->getIconIdentifierForFileExtension('xyz');
         $this->assertEquals('mimetypes-other-other', $result);
     }
 
@@ -158,7 +169,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getIconIdentifierForFileExtensionReturnsImageIconIdentifierForImageFileExtension()
     {
-        $result = $this->subject->getIconIdentifierForFileExtension('jpg');
+        $result = (new IconRegistry)->getIconIdentifierForFileExtension('jpg');
         $this->assertEquals('mimetypes-media-image', $result);
     }
 
@@ -167,8 +178,9 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function registerFileExtensionRegisterAnIcon()
     {
-        $this->subject->registerFileExtension('abc', 'xyz');
-        $result = $this->subject->getIconIdentifierForFileExtension('abc');
+        $subject = new IconRegistry();
+        $subject->registerFileExtension('abc', 'xyz');
+        $result = $subject->getIconIdentifierForFileExtension('abc');
         $this->assertEquals('xyz', $result);
     }
 
@@ -177,8 +189,9 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function registerFileExtensionOverwriteAnExistingIcon()
     {
-        $this->subject->registerFileExtension('jpg', 'xyz');
-        $result = $this->subject->getIconIdentifierForFileExtension('jpg');
+        $subject = new IconRegistry();
+        $subject->registerFileExtension('jpg', 'xyz');
+        $result = $subject->getIconIdentifierForFileExtension('jpg');
         $this->assertEquals('xyz', $result);
     }
 
@@ -187,8 +200,9 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function registerMimeTypeIconRegisterAnIcon()
     {
-        $this->subject->registerMimeTypeIcon('foo/bar', 'mimetype-foo-bar');
-        $result = $this->subject->getIconIdentifierForMimeType('foo/bar');
+        $subject = new IconRegistry();
+        $subject->registerMimeTypeIcon('foo/bar', 'mimetype-foo-bar');
+        $result = $subject->getIconIdentifierForMimeType('foo/bar');
         $this->assertEquals('mimetype-foo-bar', $result);
     }
 
@@ -197,8 +211,9 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function registerMimeTypeIconOverwriteAnExistingIcon()
     {
-        $this->subject->registerMimeTypeIcon('video/*', 'mimetype-foo-bar');
-        $result = $this->subject->getIconIdentifierForMimeType('video/*');
+        $subject = new IconRegistry();
+        $subject->registerMimeTypeIcon('video/*', 'mimetype-foo-bar');
+        $result = $subject->getIconIdentifierForMimeType('video/*');
         $this->assertEquals('mimetype-foo-bar', $result);
     }
 
@@ -207,7 +222,7 @@ class IconRegistryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function getIconIdentifierForMimeTypeWithUnknowMimeTypeReturnNull()
     {
-        $result = $this->subject->getIconIdentifierForMimeType('bar/foo');
+        $result = (new IconRegistry)->getIconIdentifierForMimeType('bar/foo');
         $this->assertEquals(null, $result);
     }
 }
index e7fee44..1744e0a 100644 (file)
@@ -14,17 +14,22 @@ namespace TYPO3\CMS\Core\Tests\Unit\Imaging;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Type\Icon\IconState;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for \TYPO3\CMS\Core\Imaging\Icon
+ * Test case
  */
-class IconTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class IconTest extends UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Core\Imaging\Icon
+     * @var Icon
      */
     protected $subject = null;
 
@@ -43,10 +48,23 @@ class IconTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     protected function setUp()
     {
+        $cacheManagerProphecy = $this->prophesize(CacheManager::class);
+        GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
+        $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
+        $cacheManagerProphecy->getCache('assets')->willReturn($cacheFrontendProphecy->reveal());
+        $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
+        $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
         $iconFactory = new IconFactory();
         $this->subject = $iconFactory->getIcon($this->iconIdentifier, Icon::SIZE_SMALL, $this->overlayIdentifier, IconState::cast(IconState::STATE_DISABLED));
     }
 
+    public function tearDown()
+    {
+        // Drop cache manager singleton again
+        GeneralUtility::purgeInstances();
+        parent::tearDown();
+    }
+
     /**
      * @test
      */
index 13e6551..9733eab 100644 (file)
@@ -15,25 +15,14 @@ namespace TYPO3\CMS\Core\Tests\Unit\Localization;
  */
 
 use TYPO3\CMS\Core\Localization\Locales;
-use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class LocalesTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class LocalesTest extends UnitTestCase
 {
     /**
-     * @var Locales
-     */
-    protected $subject;
-
-    protected function setUp()
-    {
-        $this->subject = GeneralUtility::makeInstance(Locales::class);
-        Locales::initialize();
-    }
-
-    /**
      * @return array
      */
     public function browserLanguageDetectionWorksDataProvider(): array
@@ -67,7 +56,7 @@ class LocalesTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function browserLanguageDetectionWorks(string $acceptLanguageHeader, string $expected)
     {
-        $detectedLanguage = $this->subject->getPreferredClientLanguage(
+        $detectedLanguage = (new Locales)->getPreferredClientLanguage(
             $acceptLanguageHeader
         );
         $this->assertSame($expected, $detectedLanguage);
index 5af2758..e0a714f 100644 (file)
@@ -14,25 +14,44 @@ namespace TYPO3\CMS\Core\Tests\Unit\Localization;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+use TYPO3\CMS\Core\Localization\Exception\FileNotFoundException;
+use TYPO3\CMS\Core\Localization\LanguageStore;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class LocalizationFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class LocalizationFactoryTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
      */
     protected static $suppressNotices = true;
 
+    public function tearDown()
+    {
+        // Drop created singletons again
+        GeneralUtility::purgeInstances();
+        parent::tearDown();
+    }
+
     /**
      * @test
      */
     public function getParsedDataHandlesLocallangXMLOverride()
     {
-        /** @var $subject LocalizationFactory */
+        $cacheManagerProphecy = $this->prophesize(CacheManager::class);
+        GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
+        $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
+        $cacheManagerProphecy->getCache('l10n')->willReturn($cacheFrontendProphecy->reveal());
+        $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
+        $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
+
         $subject = new LocalizationFactory;
 
         $unique = 'locallangXMLOverrideTest' . substr($this->getUniqueId(), 0, 10);
@@ -46,21 +65,21 @@ class LocalizationFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
                        </T3locallang>';
         $file = PATH_site . 'typo3temp/var/tests/' . $unique . '.xml';
         GeneralUtility::writeFileToTypo3tempDir($file, $xml);
-        // Make sure there is no cached version of the label
-        GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('l10n')->flush();
+        $this->testFilesToDelete[] = $file;
+
         // Get default value
         $defaultLL = $subject->getParsedData('EXT:lang/Resources/Private/Language/locallang_core.xlf', 'default');
-        // Clear language cache again
-        GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('l10n')->flush();
+
         // Set override file
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:lang/Resources/Private/Language/locallang_core.xlf'][$unique] = $file;
-        /** @var $store \TYPO3\CMS\Core\Localization\LanguageStore */
-        $store = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageStore::class);
+
+        /** @var $store LanguageStore */
+        $store = GeneralUtility::makeInstance(LanguageStore::class);
         $store->flushData('EXT:lang/Resources/Private/Language/locallang_core.xlf');
+
         // Get override value
         $overrideLL = $subject->getParsedData('EXT:lang/Resources/Private/Language/locallang_core.xlf', 'default');
-        // Clean up again
-        unlink($file);
+
         $this->assertNotEquals($overrideLL['default']['buttons.logout'][0]['target'], '');
         $this->assertNotEquals($defaultLL['default']['buttons.logout'][0]['target'], $overrideLL['default']['buttons.logout'][0]['target']);
         $this->assertEquals($overrideLL['default']['buttons.logout'][0]['target'], 'EXIT');
@@ -71,9 +90,12 @@ class LocalizationFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
      */
     public function getParsedDataCallsLocalizationOverrideIfFileNotFoundExceptionIsThrown()
     {
+        $cacheManagerProphecy = $this->prophesize(CacheManager::class);
+        GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
+
         /** @var $subject LocalizationFactory */
         $localizationFactory = $this->getAccessibleMock(LocalizationFactory::class, ['localizationOverride']);
-        $languageStore = $this->getMockBuilder(\TYPO3\CMS\Core\Localization\LanguageStore::class)
+        $languageStore = $this->getMockBuilder(LanguageStore::class)
             ->setMethods(['hasData', 'setConfiguration', 'getData', 'setData'])
             ->getMock();
         $cacheInstance = $this->getMockBuilder(\TYPO3\CMS\Core\Cache\Frontend\VariableFrontend::class)
@@ -84,7 +106,7 @@ class LocalizationFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
         $localizationFactory->_set('cacheInstance', $cacheInstance);
         $languageStore->method('hasData')->willReturn(false);
         $languageStore->method('getData')->willReturn([]);
-        $languageStore->method('setConfiguration')->willThrowException(new \TYPO3\CMS\Core\Localization\Exception\FileNotFoundException('testing', 1476049512));
+        $languageStore->method('setConfiguration')->willThrowException(new FileNotFoundException('testing', 1476049512));
         $cacheInstance->method('get')->willReturn(false);
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'] = ['foo' => 'bar'];
 
index e16e53d..75b79a9 100644 (file)
@@ -13,12 +13,20 @@ namespace TYPO3\CMS\Core\Tests\Unit\Localization\Parser;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
+use Prophecy\Argument;
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+use TYPO3\CMS\Core\Localization\LanguageStore;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
+use TYPO3\CMS\Core\Localization\Parser\LocallangXmlParser;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for class \TYPO3\CMS\Core\Localization\Parser\LocallangXmlParser.
+ * Test case
  */
-class LocallangXmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class LocallangXmlParserTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -26,60 +34,42 @@ class LocallangXmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
     protected static $suppressNotices = true;
 
     /**
-     * @var \TYPO3\CMS\Core\Localization\Parser\LocallangXmlParser
-     */
-    protected $parser;
-
-    /**
-     * @var array
-     */
-    protected $locallangXMLOverride;
-
-    /**
-     * @var string
-     */
-    protected $l10nPriority;
-
-    protected static function getFixtureFilePath($filename)
-    {
-        // We have to take the whole relative path as otherwise this test fails on Windows systems
-        return PATH_site . 'typo3/sysext/core/Tests/Unit/Localization/Parser/Fixtures/' . $filename;
-    }
-
-    /**
      * Prepares the environment before running a test.
      */
     protected function setUp()
     {
-        // Backup locallangXMLOverride and localization format priority
-        $this->locallangXMLOverride = $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'];
-        $this->l10nPriority = $GLOBALS['TYPO3_CONF_VARS']['SYS']['lang']['format']['priority'];
-        $this->parser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\Parser\LocallangXmlParser::class);
-
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['lang']['format']['priority'] = 'xml';
-        \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageStore::class)->initialize();
-        // Clear localization cache
-        \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('l10n')->flush();
-    }
 
+        $cacheManagerProphecy = $this->prophesize(CacheManager::class);
+        GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
+        $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
+        $cacheManagerProphecy->getCache('l10n')->willReturn($cacheFrontendProphecy->reveal());
+        $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
+        $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
+
+        GeneralUtility::makeInstance(LanguageStore::class)->initialize();
+    }
     /**
      * Cleans up the environment after running a test.
      */
     protected function tearDown()
     {
-        // Restore locallangXMLOverride and localization format priority
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'] = $this->locallangXMLOverride;
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['lang']['format']['priority'] = $this->l10nPriority;
-        \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageStore::class)->initialize();
+        GeneralUtility::purgeInstances();
         parent::tearDown();
     }
 
+    protected static function getFixtureFilePath($filename)
+    {
+        // We have to take the whole relative path as otherwise this test fails on Windows systems
+        return PATH_site . 'typo3/sysext/core/Tests/Unit/Localization/Parser/Fixtures/' . $filename;
+    }
+
     /**
      * @test
      */
     public function canParseLlxmlInEnglish()
     {
-        $LOCAL_LANG = $this->parser->getParsedData(self::getFixtureFilePath('locallang.xml'), 'default');
+        $LOCAL_LANG = (new LocallangXmlParser)->getParsedData(self::getFixtureFilePath('locallang.xml'), 'default');
         $this->assertArrayHasKey('default', $LOCAL_LANG, 'default key not found in $LOCAL_LANG');
         $expectedLabels = [
             'label1' => 'This is label #1',
@@ -96,7 +86,7 @@ class LocallangXmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
      */
     public function canParseLlxmlInMd5Code()
     {
-        $LOCAL_LANG = $this->parser->getParsedData(self::getFixtureFilePath('locallang.xml'), 'md5');
+        $LOCAL_LANG = (new LocallangXmlParser)->getParsedData(self::getFixtureFilePath('locallang.xml'), 'md5');
         $this->assertArrayHasKey('md5', $LOCAL_LANG, 'md5 key not found in $LOCAL_LANG');
         $expectedLabels = [
             'label1' => '409a6edbc70dbeeccbfe5f1e569d6717',
@@ -113,7 +103,7 @@ class LocallangXmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
      */
     public function canParseLlxmlInFrenchAndReturnsNullLabelsIfNoTranslationIsFound()
     {
-        $LOCAL_LANG = $this->parser->getParsedData(self::getFixtureFilePath('locallangOnlyDefaultLanguage.xml'), 'fr');
+        $LOCAL_LANG = (new LocallangXmlParser)->getParsedData(self::getFixtureFilePath('locallangOnlyDefaultLanguage.xml'), 'fr');
         $expectedLabels = [
             'label1' => null,
             'label2' => null,
@@ -160,17 +150,28 @@ class LocallangXmlParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
 
     public function numericKeysDataProvider()
     {
-        /** @var $factory LocalizationFactory */
-        $factory = new LocalizationFactory;
-
-        $LOCAL_LANG = $factory->getParsedData(self::getFixtureFilePath('locallangNumericKeys.xml'), 'default');
-        $translations = [];
-
-        foreach ($LOCAL_LANG['default'] as $key => $labelData) {
-            $translations['Numerical key ' . $key] = [$key, $labelData[0]['source'] . ' [FR]'];
-        }
-
-        return $translations;
+        return [
+            'Numeric key 1' => [
+                1,
+                'This is label #1 [FR]'
+            ],
+            'Numeric key 2' => [
+                2,
+                'This is label #2 [FR]'
+            ],
+            'Numeric key 3' => [
+                3,
+                'This is label #3 [FR]'
+            ],
+            'Numeric key 5' => [
+                5,
+                'This is label #5 [FR]'
+            ],
+            'Numeric key 10' => [
+                10,
+                'This is label #10 [FR]'
+            ],
+        ];
     }
 
     /**
index d577b1b..2f6f6b4 100644 (file)
@@ -13,29 +13,21 @@ namespace TYPO3\CMS\Core\Tests\Unit\Localization\Parser;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
+use Prophecy\Argument;
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
+use TYPO3\CMS\Core\Localization\Parser\XliffParser;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for class \TYPO3\CMS\Core\Localization\Parser\XliffParser.
+ * Test case
  */
-class XliffParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class XliffParserTest extends UnitTestCase
 {
     /**
-     * @var \TYPO3\CMS\Core\Localization\Parser\XliffParser
-     */
-    protected $parser;
-
-    /**
-     * @var array
-     */
-    protected $locallangXMLOverride;
-
-    /**
-     * @var string
-     */
-    protected $l10nPriority;
-
-    /**
      * @var array
      */
     protected $xliffFileNames;
@@ -45,11 +37,6 @@ class XliffParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     protected function setUp()
     {
-        // Backup locallangXMLOverride and localization format priority
-        $this->locallangXMLOverride = $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'];
-        $this->l10nPriority = $GLOBALS['TYPO3_CONF_VARS']['SYS']['lang']['format']['priority'];
-        $this->parser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\Parser\XliffParser::class);
-
         // We have to take the whole relative path as otherwise this test fails on Windows systems
         $fixturePath = PATH_site . 'typo3/sysext/core/Tests/Unit/Localization/Parser/Fixtures/';
         $this->xliffFileNames = [
@@ -58,9 +45,14 @@ class XliffParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
             'locallang_override_fr' => $fixturePath . 'fr.locallang_override.xlf'
         ];
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['lang']['format']['priority'] = 'xlf';
-        \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageStore::class)->initialize();
-        // Clear localization cache
-        \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)->getCache('l10n')->flush();
+
+        $cacheManagerProphecy = $this->prophesize(CacheManager::class);
+        GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
+        $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
+        $cacheManagerProphecy->getCache('l10n')->willReturn($cacheFrontendProphecy->reveal());
+        $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
+        $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
+        $cacheFrontendProphecy->flush()->willReturn(null);
     }
 
     /**
@@ -68,10 +60,7 @@ class XliffParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     protected function tearDown()
     {
-        // Restore locallangXMLOverride and localization format priority
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride'] = $this->locallangXMLOverride;
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['lang']['format']['priority'] = $this->l10nPriority;
-        \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Localization\LanguageStore::class)->initialize();
+        GeneralUtility::purgeInstances();
         parent::tearDown();
     }
 
@@ -80,7 +69,7 @@ class XliffParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function canParseXliffInEnglish()
     {
-        $LOCAL_LANG = $this->parser->getParsedData($this->xliffFileNames['locallang'], 'default');
+        $LOCAL_LANG = (new XliffParser)->getParsedData($this->xliffFileNames['locallang'], 'default');
         $this->assertArrayHasKey('default', $LOCAL_LANG, 'default key not found in $LOCAL_LANG');
         $expectedLabels = [
             'label1' => 'This is label #1',
@@ -97,7 +86,7 @@ class XliffParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function canParseXliffInFrench()
     {
-        $LOCAL_LANG = $this->parser->getParsedData($this->xliffFileNames['locallang'], 'fr');
+        $LOCAL_LANG = (new XliffParser)->getParsedData($this->xliffFileNames['locallang'], 'fr');
         $this->assertArrayHasKey('fr', $LOCAL_LANG, 'fr key not found in $LOCAL_LANG');
         $expectedLabels = [
             'label1' => 'Ceci est le libellĂ© no. 1',
index 5f5d3a9..dd435d8 100644 (file)
@@ -61,6 +61,7 @@ class FileNameFilterTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function filterHiddenFilesAndFoldersFiltersHiddenFilesAndFolders($itemName, $itemIdentifier, $expected)
     {
         /** @var DriverInterface|\PHPUnit_Framework_MockObject_MockObject $driverMock */
+        FileNameFilter::setShowHiddenFilesAndFolders(false);
         $driverMock = $this->createMock(DriverInterface::class);
         $this->assertSame(
             $expected,
index 9b6177f..d0288b6 100644 (file)
@@ -14,58 +14,23 @@ namespace TYPO3\CMS\Core\Tests\Unit\Resource\Utility;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\DataHandling\DataHandler;
+use TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter;
+use TYPO3\CMS\Core\Resource\ResourceFactory;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
 /**
  * Test suite for filtering files by their extensions.
  */
-class FileExtensionFilterTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class FileExtensionFilterTest extends UnitTestCase
 {
     /**
-     * @var array A backup of registered singleton instances
-     */
-    protected $singletonInstances = [];
-
-    /**
-     * @var \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter
-     */
-    protected $filter;
-
-    /**
-     * @var array
-     */
-    protected $parameters;
-
-    /**
-     * @var \TYPO3\CMS\Core\DataHandling\DataHandler|PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $dataHandlerMock;
-
-    /**
-     * @var \TYPO3\CMS\Core\Resource\ResourceFactory|PHPUnit_Framework_MockObject_MockObject
-     */
-    protected $fileFactoryMock;
-
-    /**
-     * Sets up this test suite.
-     */
-    protected function setUp()
-    {
-        $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-        $this->filter = new \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter();
-        $this->dataHandlerMock = $this->getMockBuilder(\TYPO3\CMS\Core\DataHandling\DataHandler::class)
-            ->setMethods(['deleteAction'])
-            ->getMock();
-        $this->fileFactoryMock = $this->getMockBuilder(\TYPO3\CMS\Core\Resource\ResourceFactory::class)
-            ->setMethods(['getFileReferenceObject'])
-            ->getMock();
-        \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Resource\ResourceFactory::class, $this->fileFactoryMock);
-    }
-
-    /**
      * Cleans up this test suite.
      */
     protected function tearDown()
     {
-        \TYPO3\CMS\Core\Utility\GeneralUtility::resetSingletonInstances($this->singletonInstances);
+        GeneralUtility::purgeInstances();
         parent::tearDown();
     }
 
@@ -90,14 +55,17 @@ class FileExtensionFilterTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
      */
     public function areInlineChildrenFilteredWithInvalidParameters($allowed, $disallowed, $values)
     {
-        $this->parameters = [
+        $parameters = [
             'allowedFileExtensions' => $allowed,
             'disallowedFileExtensions' => $disallowed,
             'values' => $values
         ];
-        $this->dataHandlerMock->expects($this->never())->method('deleteAction');
-        $this->fileFactoryMock->expects($this->never())->method('getFileReferenceObject');
-        $this->filter->filterInlineChildren($this->parameters, $this->dataHandlerMock);
+        $dataHandlerProphecy = $this->prophesize(DataHandler::class);
+        $dataHandlerProphecy->deleteAction()->shouldNotBeCalled();
+        $resourceFactoryProphecy = $this->prophesize(ResourceFactory::class);
+        $resourceFactoryProphecy->getFileReferenceObject()->shouldNotBeCalled();
+        GeneralUtility::setSingletonInstance(ResourceFactory::class, $resourceFactoryProphecy->reveal());
+        (new FileExtensionFilter())->filterInlineChildren($parameters, $dataHandlerProphecy->reveal());
     }
 
     /**
@@ -134,8 +102,8 @@ class FileExtensionFilterTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
      */
     public function extensionFilterIgnoresCaseInAllowedExtensionCheck($fileExtension, $allowedExtensions, $disallowedExtensions, $isAllowed)
     {
-        /** @var \TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter $filter */
-        $filter = $this->getAccessibleMock(\TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter::class, ['dummy']);
+        /** @var FileExtensionFilter $filter */
+        $filter = $this->getAccessibleMock(FileExtensionFilter::class, ['dummy']);
         $filter->setAllowedFileExtensions($allowedExtensions);
         $filter->setDisallowedFileExtensions($disallowedExtensions);
         $result = $filter->_call('isAllowed', 'file.' . $fileExtension);
index 1f5a3b8..7df1e6d 100644 (file)
@@ -14,12 +14,15 @@ namespace TYPO3\CMS\Core\Tests\Unit\TypoScript\Parser;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Test case for \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
+ * Test case
  */
-class TypoScriptParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class TypoScriptParserTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -27,7 +30,7 @@ class TypoScriptParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
     protected static $suppressNotices = true;
 
     /**
-     * @var \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
+     * @var TypoScriptParser|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
      */
     protected $typoScriptParser = null;
 
@@ -36,10 +39,16 @@ class TypoScriptParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     protected function setUp()
     {
-        $accessibleClassName = $this->buildAccessibleProxy(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
+        $accessibleClassName = $this->buildAccessibleProxy(TypoScriptParser::class);
         $this->typoScriptParser = new $accessibleClassName();
     }
 
+    protected function tearDown()
+    {
+        GeneralUtility::purgeInstances();
+        parent::tearDown();
+    }
+
     /**
      * Data provider for executeValueModifierReturnsModifiedResult
      *
@@ -272,6 +281,9 @@ class TypoScriptParserTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
      */
     public function invalidCharactersInObjectNamesAreReported()
     {
+        $timeTrackerProphecy = $this->prophesize(TimeTracker::class);
+        GeneralUtility::setSingletonInstance(TimeTracker::class, $timeTrackerProphecy->reveal());
+
         $typoScript = '$.10 = invalid';
         $this->typoScriptParser->parse($typoScript);
         $expected = 'Line 0: Object Name String, "$.10" contains invalid character "$". Must be alphanumeric or one of: "_:-\."';
index ea5e23c..5d9a5e8 100644 (file)
@@ -3994,7 +3994,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function addInstanceMakesMakeInstanceReturnThatInstance()
     {
-        $instance = $this->createMock('foo');
+        $instance = $this->createMock('stdClass');
         $className = get_class($instance);
         GeneralUtility::addInstance($className, $instance);
         $this->assertSame($instance, GeneralUtility::makeInstance($className));
@@ -4005,7 +4005,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function makeInstanceCalledTwoTimesAfterAddInstanceReturnTwoDifferentInstances()
     {
-        $instance = $this->createMock('foo');
+        $instance = $this->createMock('stdClass');
         $className = get_class($instance);
         GeneralUtility::addInstance($className, $instance);
         $this->assertNotSame(GeneralUtility::makeInstance($className), GeneralUtility::makeInstance($className));
@@ -4016,7 +4016,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function addInstanceCalledTwoTimesMakesMakeInstanceReturnBothInstancesInAddingOrder()
     {
-        $instance1 = $this->createMock('foo');
+        $instance1 = $this->createMock('stdClass');
         $className = get_class($instance1);
         GeneralUtility::addInstance($className, $instance1);
         $instance2 = new $className();
@@ -4030,7 +4030,7 @@ class GeneralUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function purgeInstancesDropsAddedInstance()
     {
-        $instance = $this->createMock('foo');
+        $instance = $this->createMock('stdClass');
         $className = get_class($instance);
         GeneralUtility::addInstance($className, $instance);
         GeneralUtility::purgeInstances();
index 362245b..34f1f0f 100644 (file)
@@ -14,12 +14,17 @@ namespace TYPO3\CMS\Core\Tests\Unit\Utility;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\RootlineUtility;
+use TYPO3\CMS\Frontend\Page\PageRepository;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for class \TYPO3\CMS\Core\Utility\RootlineUtility
+ * Test case
  */
-class RootlineUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class RootlineUtilityTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -32,27 +37,28 @@ class RootlineUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     protected $subject;
 
     /**
-     * @var \TYPO3\CMS\Frontend\Page\PageRepository|\PHPUnit_Framework_MockObject_MockObject
+     * @var PageRepository|\PHPUnit_Framework_MockObject_MockObject
      */
     protected $pageContextMock;
 
     protected function setUp()
     {
-        $this->pageContextMock = $this->createMock(\TYPO3\CMS\Frontend\Page\PageRepository::class);
-        $this->subject = $this->getAccessibleMock(\TYPO3\CMS\Core\Utility\RootlineUtility::class, ['enrichWithRelationFields'], [1, '', $this->pageContextMock]);
+        $cacheManagerProphecy = $this->prophesize(CacheManager::class);
+        GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
+        $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
+        $cacheManagerProphecy->getCache('cache_rootline')->willReturn($cacheFrontendProphecy->reveal());
+
+        $this->pageContextMock = $this->createMock(PageRepository::class);
+        $this->subject = $this->getAccessibleMock(RootlineUtility::class, ['enrichWithRelationFields'], [1, '', $this->pageContextMock]);
     }
 
     protected function tearDown()
     {
-        parent::tearDown();
         RootlineUtility::purgeCaches();
+        GeneralUtility::purgeInstances();
+        parent::tearDown();
     }
 
-    /***
-     *
-     *                 UTILITY FUNCTIONS
-     *
-     */
     /**
      * Tests that $subsetCandidate is completely part of $superset
      * and keys match.
@@ -66,11 +72,6 @@ class RootlineUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->assertSame($subsetCandidate, array_intersect_assoc($subsetCandidate, $superset));
     }
 
-    /***
-     *
-     *                 >TEST CASES
-     *
-     */
     /**
      * @test
      */
@@ -107,7 +108,7 @@ class RootlineUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->expectExceptionCode(1343464100);
 
         $this->subject->__construct(1, '1-99');
-        $this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT]);
+        $this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => PageRepository::DOKTYPE_DEFAULT]);
     }
 
     /**
@@ -116,7 +117,7 @@ class RootlineUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function processMountedPageWithMountedPageNotThrowsException()
     {
         $this->subject->__construct(1, '1-99');
-        $this->assertNotEmpty($this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1]));
+        $this->assertNotEmpty($this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1]));
     }
 
     /**
@@ -125,7 +126,7 @@ class RootlineUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function processMountedPageWithMountedPageAddsMountedFromParameter()
     {
         $this->subject->__construct(1, '1-99');
-        $result = $this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1]);
+        $result = $this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1]);
         $this->assertTrue(isset($result['_MOUNTED_FROM']));
         $this->assertSame(1, $result['_MOUNTED_FROM']);
     }
@@ -136,7 +137,7 @@ class RootlineUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function processMountedPageWithMountedPageAddsMountPointParameterToReturnValue()
     {
         $this->subject->__construct(1, '1-99');
-        $result = $this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1]);
+        $result = $this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1]);
         $this->assertTrue(isset($result['_MP_PARAM']));
         $this->assertSame('1-99', $result['_MP_PARAM']);
     }
@@ -147,7 +148,7 @@ class RootlineUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function processMountedPageForMountPageIsOverlayAddsMountOLParameter()
     {
         $this->subject->__construct(1, '1-99');
-        $result = $this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1, 'mount_pid_ol' => 1]);
+        $result = $this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1, 'mount_pid_ol' => 1]);
         $this->assertTrue(isset($result['_MOUNT_OL']));
         $this->assertSame(true, $result['_MOUNT_OL']);
     }
@@ -158,7 +159,7 @@ class RootlineUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function processMountedPageForMountPageIsOverlayAddsDataInformationAboutMountPage()
     {
         $this->subject->__construct(1, '1-99');
-        $result = $this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1, 'mount_pid_ol' => 1, 'pid' => 5, 'title' => 'TestCase']);
+        $result = $this->subject->_call('processMountedPage', ['uid' => 1], ['uid' => 99, 'doktype' => PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1, 'mount_pid_ol' => 1, 'pid' => 5, 'title' => 'TestCase']);
         $this->assertTrue(isset($result['_MOUNT_PAGE']));
         $this->assertSame(['uid' => 99, 'pid' => 5, 'title' => 'TestCase'], $result['_MOUNT_PAGE']);
     }
@@ -168,7 +169,7 @@ class RootlineUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function processMountedPageForMountPageWithoutOverlayReplacesMountedPageWithMountPage()
     {
-        $mountPointPageData = ['uid' => 99, 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1, 'mount_pid_ol' => 0];
+        $mountPointPageData = ['uid' => 99, 'doktype' => PageRepository::DOKTYPE_MOUNTPOINT, 'mount_pid' => 1, 'mount_pid_ol' => 0];
         $this->subject->__construct(1, '1-99');
         $result = $this->subject->_call('processMountedPage', ['uid' => 1], $mountPointPageData);
         $this->assertIsSubset($mountPointPageData, $result);
index d844b01..37d7766 100644 (file)
@@ -14,10 +14,12 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Core;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
 /**
  * Test case
  */
-class BootstrapTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class BootstrapTest extends UnitTestCase
 {
     /**
      * @var array A backup of registered singleton instances
index 5586d44..1c730e3 100644 (file)
@@ -13,11 +13,16 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Database\ReferenceIndex;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
+use TYPO3\CMS\Extbase\Persistence\Generic\Backend;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class BackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class BackendTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -30,7 +35,7 @@ class BackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function insertRelationInRelationtableSetsMmMatchFieldsInRow()
     {
         /* \TYPO3\CMS\Extbase\Persistence\Generic\Backend|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
-        $fixture = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Backend::class, ['dummy'], [], '', false);
+        $fixture = $this->getAccessibleMock(Backend::class, ['dummy'], [], '', false);
         /* \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper|\PHPUnit_Framework_MockObject_MockObject */
         $dataMapper = $this->createMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::class);
         /* \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMap|\PHPUnit_Framework_MockObject_MockObject */
@@ -80,20 +85,23 @@ class BackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
-    public function getIdentifierByObjectReturnsIdentifierForNonlazyObject()
+    public function getIdentifierByObjectReturnsIdentifierForNonLazyObject()
     {
         $fakeUuid = 'fakeUuid';
-        $configurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
+        $configurationManager = $this->createMock(ConfigurationManagerInterface::class);
         $session = $this->getMockBuilder('stdClass')
             ->setMethods(['getIdentifierByObject'])
             ->disableOriginalConstructor()
             ->getMock();
         $object = new \stdClass();
 
+        $referenceIndexProphecy = $this->prophesize(ReferenceIndex::class);
+        GeneralUtility::addInstance(ReferenceIndex::class, $referenceIndexProphecy->reveal());
+
         $session->expects($this->once())->method('getIdentifierByObject')->with($object)->will($this->returnValue($fakeUuid));
 
-        /** @var \TYPO3\CMS\Extbase\Persistence\Generic\Backend $backend */
-        $backend = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Backend::class, ['dummy'], [$configurationManager]);
+        /** @var Backend $backend */
+        $backend = $this->getAccessibleMock(Backend::class, ['dummy'], [$configurationManager]);
         $backend->_set('session', $session);
 
         $this->assertEquals($backend->getIdentifierByObject($object), $fakeUuid);
@@ -105,7 +113,7 @@ class BackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function getIdentifierByObjectReturnsIdentifierForLazyObject()
     {
         $fakeUuid = 'fakeUuid';
-        $configurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
+        $configurationManager = $this->createMock(ConfigurationManagerInterface::class);
         $parentObject = new \stdClass();
         $proxy = $this->getMockBuilder(\TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy::class)
             ->setMethods(['_loadRealInstance'])
@@ -118,11 +126,14 @@ class BackendTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
             ->getMock();
         $object = new \stdClass();
 
+        $referenceIndexProphecy = $this->prophesize(ReferenceIndex::class);
+        GeneralUtility::addInstance(ReferenceIndex::class, $referenceIndexProphecy->reveal());
+
         $proxy->expects($this->once())->method('_loadRealInstance')->will($this->returnValue($object));
         $session->expects($this->once())->method('getIdentifierByObject')->with($object)->will($this->returnValue($fakeUuid));
 
-        /** @var \TYPO3\CMS\Extbase\Persistence\Generic\Backend $backend */
-        $backend = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Backend::class, ['dummy'], [$configurationManager]);
+        /** @var Backend $backend */
+        $backend = $this->getAccessibleMock(Backend::class, ['dummy'], [$configurationManager]);
         $backend->_set('session', $session);
 
         $this->assertEquals($backend->getIdentifierByObject($proxy), $fakeUuid);
index 9347738..d70d569 100644 (file)
@@ -13,13 +13,16 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
 use TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException;
+use TYPO3\CMS\Extbase\Persistence\Generic\Backend;
 use TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedMethodException;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class RepositoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class RepositoryTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -80,7 +83,7 @@ class RepositoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $this->mockQueryFactory->expects($this->any())->method('create')->will($this->returnValue($this->mockQuery));
         $this->mockSession = $this->createMock(\TYPO3\CMS\Extbase\Persistence\Generic\Session::class);
         $this->mockConfigurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class);
-        $this->mockBackend = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Backend::class, ['dummy'], [$this->mockConfigurationManager]);
+        $this->mockBackend = $this->getAccessibleMock(Backend::class, ['dummy'], [$this->mockConfigurationManager], '', false);
         $this->inject($this->mockBackend, 'session', $this->mockSession);
         $this->mockPersistenceManager = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class, ['createQueryForType']);
         $this->inject($this->mockBackend, 'persistenceManager', $this->mockPersistenceManager);
index dd739df..99b17c2 100644 (file)
@@ -14,12 +14,16 @@ namespace TYPO3\CMS\Extbase\Tests\Unit\Utility;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
+use TYPO3\CMS\Core\Localization\LocalizationFactory;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class LocalizationUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class LocalizationUtilityTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -165,12 +169,16 @@ class LocalizationUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
             ],
         ];
 
-        $reflectionClass = new \ReflectionClass(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::class);
+        $reflectionClass = new \ReflectionClass(LocalizationUtility::class);
 
         $this->configurationManager = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManager::class, ['getConfiguration']);
         $property = $reflectionClass->getProperty('configurationManager');
         $property->setAccessible(true);
         $property->setValue($this->configurationManager);
+
+        $localizationFactoryProphecy = $this->prophesize(LocalizationFactory::class);
+        GeneralUtility::setSingletonInstance(LocalizationFactory::class, $localizationFactoryProphecy->reveal());
+        $localizationFactoryProphecy->getParsedData(Argument::cetera())->willReturn([]);
     }
 
     /**
@@ -178,7 +186,7 @@ class LocalizationUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
      */
     protected function tearDown()
     {
-        $reflectionClass = new \ReflectionClass(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::class);
+        $reflectionClass = new \ReflectionClass(LocalizationUtility::class);
 
         $property = $reflectionClass->getProperty('configurationManager');
         $property->setAccessible(true);
@@ -188,6 +196,8 @@ class LocalizationUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
         $property->setAccessible(true);
         $property->setValue([]);
 
+        GeneralUtility::purgeInstances();
+
         parent::tearDown();
     }
 
@@ -205,7 +215,7 @@ class LocalizationUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
      */
     public function implodeTypoScriptLabelArrayWorks()
     {
-        $reflectionClass = new \ReflectionClass(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::class);
+        $reflectionClass = new \ReflectionClass(LocalizationUtility::class);
         $method = $reflectionClass->getMethod('flattenTypoScriptLabelArray');
         $method->setAccessible(true);
 
@@ -293,7 +303,7 @@ class LocalizationUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
      */
     public function translateTestWithBackendUserLanguage($key, $languageKey, $expected, array $altLanguageKeys = [], array $arguments = null)
     {
-        $reflectionClass = new \ReflectionClass(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::class);
+        $reflectionClass = new \ReflectionClass(LocalizationUtility::class);
 
         $property = $reflectionClass->getProperty('LOCAL_LANG');
         $property->setAccessible(true);
@@ -316,7 +326,7 @@ class LocalizationUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
      */
     public function translateTestWithExplicitLanguageParameters($key, $languageKey, $expected, array $altLanguageKeys = [], array $arguments = null)
     {
-        $reflectionClass = new \ReflectionClass(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::class);
+        $reflectionClass = new \ReflectionClass(LocalizationUtility::class);
 
         $property = $reflectionClass->getProperty('LOCAL_LANG');
         $property->setAccessible(true);
@@ -429,7 +439,7 @@ class LocalizationUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
      */
     public function loadTypoScriptLabels(array $LOCAL_LANG, array $typoScriptLocalLang, $languageKey, array $expected)
     {
-        $reflectionClass = new \ReflectionClass(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::class);
+        $reflectionClass = new \ReflectionClass(LocalizationUtility::class);
 
         $property = $reflectionClass->getProperty('LOCAL_LANG');
         $property->setAccessible(true);
@@ -454,7 +464,7 @@ class LocalizationUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
      */
     public function clearLabelWithTypoScript()
     {
-        $reflectionClass = new \ReflectionClass(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::class);
+        $reflectionClass = new \ReflectionClass(LocalizationUtility::class);
 
         $property = $reflectionClass->getProperty('LOCAL_LANG');
         $property->setAccessible(true);
@@ -481,17 +491,6 @@ class LocalizationUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTest
     }
 
     /**
-     * Tests whether method can be invoked without second parameter. Actual translation is not tested here.
-     *
-     * @test
-     */
-    public function translateWithFullyQualifiedKey()
-    {
-        $result = LocalizationUtility::translate('LLL:EXT:extbase/Resources/Private/Language/locallang_db.xlf:fe_users.tx_extbase_type');
-        $this->assertNotEmpty($result);
-    }
-
-    /**
      * @test
      */
     public function translateThrowsExceptionWithEmptyExtensionNameIfKeyIsNotPrefixedWithLLL()
diff --git a/typo3/sysext/extensionmanager/Tests/Unit/Controller/UpdateFromTerControllerTest.php b/typo3/sysext/extensionmanager/Tests/Unit/Controller/UpdateFromTerControllerTest.php
deleted file mode 100644 (file)
index ac1fcfd..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-<?php
-namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Controller;
-
-/*
- * 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\Extensionmanager\Controller\UpdateFromTerController;
-use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
-
-/**
- * Update from TER controller test
- */
-class UpdateFromTerControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
-{
-    /**
-     * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
-     */
-    protected $mockObjectManager;
-
-    /**
-     * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository
-     */
-    protected $repositoryRepositoryMock;
-
-    /**
-     * @var \TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository
-     */
-    protected $extensionRepositoryMock;
-
-    /**
-     * @var \TYPO3\CMS\Extensionmanager\Utility\Repository\Helper
-     */
-    protected $repositoryHelperMock;
-
-    /**
-     * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Localization\LanguageService
-     */
-    protected $languageServiceMock;
-
-    protected function setUp()
-    {
-        $this->mockObjectManager = $this->getMockBuilder(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class)->getMock();
-        $this->repositoryRepositoryMock = $this->getMockBuilder(\TYPO3\CMS\Extensionmanager\Domain\Repository\RepositoryRepository::class)
-            ->setMethods(['findByUid'])
-            ->setConstructorArgs([$this->mockObjectManager])
-            ->getMock();
-        $this->extensionRepositoryMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository::class, [], [$this->mockObjectManager]);
-        $this->repositoryHelperMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper::class, ['updateExtList'], [], '', false);
-        $this->languageServiceMock = $this->getMockBuilder(\TYPO3\CMS\Core\Localization\LanguageService::class)
-            ->setMethods(['__none'])
-            ->getMock();
-    }
-
-    /**
-     * @test
-     */
-    public function updateExtensionListFromTerCallsUpdateExtListIfExtensionListIsEmpty()
-    {
-        /** @var \PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface|UpdateFromTerController $controllerMock */
-        $controllerMock = $this->getAccessibleMock(UpdateFromTerController::class, ['getLanguageService']);
-        $controllerMock->expects($this->any())->method('getLanguageService')->will($this->returnValue($this->languageServiceMock));
-
-        $repositoryModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class, ['getLastUpdate']);
-        $viewMock = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, ['assign'], [], '', false);
-        $requestMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, ['hasArgument', 'getArgument']);
-        $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
-        $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
-        $this->repositoryHelperMock->expects($this->once())->method('updateExtList');
-        $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(0));
-        $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
-        $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
-        $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
-        $controllerMock->_set('settings', ['repositoryUid' => 1]);
-        $controllerMock->_set('view', $viewMock);
-        $controllerMock->_set('request', $requestMock);
-        $controllerMock->updateExtensionListFromTerAction();
-    }
-
-    /**
-     * @test
-     */
-    public function updateExtensionListFromTerDoesNotCallsUpdateExtListIfExtensionListIsNotEmpty()
-    {
-        /** @var \PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface|UpdateFromTerController $controllerMock */
-        $controllerMock = $this->getAccessibleMock(UpdateFromTerController::class, ['getLanguageService']);
-        $controllerMock->expects($this->any())->method('getLanguageService')->will($this->returnValue($this->languageServiceMock));
-
-        $repositoryModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class, ['getLastUpdate']);
-        $viewMock = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, ['assign'], [], '', false);
-        $requestMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, ['hasArgument', 'getArgument']);
-        $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
-        $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
-        $this->repositoryHelperMock->expects($this->never())->method('updateExtList');
-        $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
-        $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
-        $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
-        $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
-        $controllerMock->_set('settings', ['repositoryUid' => 1]);
-        $controllerMock->_set('view', $viewMock);
-        $controllerMock->_set('request', $requestMock);
-        $controllerMock->updateExtensionListFromTerAction();
-    }
-
-    /**
-     * @test
-     */
-    public function updateExtensionListFromTerCallsUpdateExtListIfForceUpdateCheckIsSet()
-    {
-        /** @var \PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface|UpdateFromTerController $controllerMock */
-        $controllerMock = $this->getAccessibleMock(UpdateFromTerController::class, ['getLanguageService']);
-        $controllerMock->expects($this->any())->method('getLanguageService')->will($this->returnValue($this->languageServiceMock));
-
-        $repositoryModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class, ['getLastUpdate']);
-        $viewMock = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, ['assign'], [], '', false);
-        $requestMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, ['hasArgument', 'getArgument']);
-        $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
-        $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
-        $this->repositoryHelperMock->expects($this->once())->method('updateExtList');
-        $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
-        $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
-        $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
-        $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
-        $controllerMock->_set('settings', ['repositoryUid' => 1]);
-        $controllerMock->_set('view', $viewMock);
-        $controllerMock->_set('request', $requestMock);
-        $controllerMock->updateExtensionListFromTerAction(true);
-    }
-}
index 05e76a6..e77bea7 100644 (file)
@@ -15,6 +15,8 @@ namespace TYPO3\CMS\Form\Tests\Unit\Controller;
  */
 
 use Prophecy\Argument;
+use TYPO3\CMS\Core\Imaging\Icon;
+use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Resource\Folder;
 use TYPO3\CMS\Core\Resource\ResourceStorage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -24,11 +26,12 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Form\Controller\FormManagerController;
 use TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager;
 use TYPO3\CMS\Form\Service\TranslationService;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
  * Test case
  */
-class FormManagerControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class FormManagerControllerTest extends UnitTestCase
 {
     /**
      * Subject is not notice free, disable E_NOTICES
@@ -255,6 +258,12 @@ class FormManagerControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTe
      */
     public function getProcessedReferencesRowsReturnsProcessedArray()
     {
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+        $iconProphecy = $this->prophesize(Icon::class);
+        $iconFactoryProphecy->getIconForRecord(Argument::cetera())->willReturn($iconProphecy->reveal());
+        $iconProphecy->render()->shouldBeCalled()->willReturn('');
+
         $mockController = $this->getAccessibleMock(FormManagerController::class, [
             'getModuleUrl',
             'getRecord',
@@ -291,13 +300,7 @@ class FormManagerControllerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTe
             0 => [
                 'recordPageTitle' => 'record title',
                 'recordTitle' => 'record title',
-                'recordIcon' =>
-'<span class="t3js-icon icon icon-size-small icon-state-default icon-default-not-found" data-identifier="default-not-found">
-       <span class="icon-markup">
-<img src="typo3/sysext/core/Resources/Public/Icons/T3Icons/default/default-not-found.svg" width="16" height="16" />
-       </span>
-       
-</span>',
+                'recordIcon' => '',
                 'recordUid' => -1,
                 'recordEditUrl' => '/typo3/index.php?some=param',
             ],
index 07f7bde..392d135 100644 (file)
@@ -14,7 +14,9 @@ namespace TYPO3\CMS\Form\Tests\Unit\Mvc\Service;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Prophecy\Argument;
 use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Localization\LanguageStore;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -60,6 +62,15 @@ class TranslationServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
      */
     public function setUp()
     {
+        $this->singletonInstances = GeneralUtility::getSingletonInstances();
+
+        $cacheManagerProphecy = $this->prophesize(CacheManager::class);
+        GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
+        $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
+        $cacheManagerProphecy->getCache('l10n')->willReturn($cacheFrontendProphecy->reveal());
+        $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
+        $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
+
         $this->mockConfigurationManager = $this->getAccessibleMock(ConfigurationManager::class, [
             'getConfiguration'
         ], [], '', false);
@@ -79,11 +90,8 @@ class TranslationServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestC
             ->method('getConfigurationManager')
             ->willReturn($this->mockConfigurationManager);
 
-        GeneralUtility::makeInstance(CacheManager::class)->getCache('l10n')->flush();
         $this->store = GeneralUtility::makeInstance(LanguageStore::class);
         $this->store->initialize();
-
-        $this->singletonInstances = GeneralUtility::getSingletonInstances();
     }
 
     /**
index 87e81f2..a96b089 100644 (file)
@@ -241,7 +241,7 @@ class FrontendUserAuthenticationTest extends UnitTestCase
             'newSessionId',
             [
                 'ses_id' => 'newSessionId',
-                'ses_iplock' => '',
+                'ses_iplock' => '[DISABLED]',
                 'ses_userid' => 0,
                 'ses_tstamp' => $currentTime,
                 'ses_data' => serialize(['foo' => 'bar']),
@@ -254,6 +254,7 @@ class FrontendUserAuthenticationTest extends UnitTestCase
         $subject->setLogger(new NullLogger());
         $subject->gc_probability = -1;
         $subject->start();
+        $subject->lockIP = 0;
         $this->assertEmpty($subject->getSessionData($uniqueSessionId));
         $this->assertEmpty($subject->user);
         $subject->setSessionData('foo', 'bar');
index f040b76..f5e5385 100644 (file)
@@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Resource\Exception\InvalidPathException;
 use TYPO3\CMS\Core\Resource\File;
 use TYPO3\CMS\Core\Resource\ResourceFactory;
 use TYPO3\CMS\Core\Resource\ResourceStorage;
+use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\TemplateService;
 use TYPO3\CMS\Core\Utility\DebugUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -3548,6 +3549,9 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Unit\UnitTe
      */
     public function notAllStdWrapProcessorsAreCallableWithEmptyConfiguration()
     {
+        $timeTrackerProphecy = $this->prophesize(TimeTracker::class);
+        GeneralUtility::setSingletonInstance(TimeTracker::class, $timeTrackerProphecy->reveal());
+
         $expectExceptions = ['numRows', 'split', 'bytes'];
         $count = 0;
         $processors = [];
index c2d633c..b04d758 100644 (file)
@@ -52,6 +52,7 @@ class AbstractMenuContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\Un
         $this->subject = $this->getMockForAbstractClass($proxyClassName);
         $GLOBALS['TSFE'] = $this->getMockBuilder(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class)
             ->setConstructorArgs([$GLOBALS['TYPO3_CONF_VARS'], 1, 1])
+            ->setMethods(['initCaches'])
             ->getMock();
         $GLOBALS['TSFE']->cObj = new ContentObjectRenderer();
         $GLOBALS['TSFE']->page = [];
index af79688..4d910db 100644 (file)
@@ -13,6 +13,11 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\View;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use Prophecy\Argument;
+use TYPO3\CMS\Core\Cache\CacheManager;
+use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface;
+use TYPO3\CMS\Core\Imaging\Icon;
+use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Localization\LanguageService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
@@ -33,9 +38,19 @@ class AdminPanelViewTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     protected function setUp()
     {
         $GLOBALS['LANG'] = $this->createMock(LanguageService::class);
+        $cacheManagerProphecy = $this->prophesize(CacheManager::class);
+        GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
+        $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
+        $cacheManagerProphecy->getCache('cache_pages')->willReturn($cacheFrontendProphecy->reveal());
         $GLOBALS['TSFE'] = new TypoScriptFrontendController([], 1, 1);
     }
 
+    protected function tearDown()
+    {
+        GeneralUtility::purgeInstances();
+        parent::tearDown();
+    }
+
     /**
      * @test
      */
@@ -97,6 +112,11 @@ class AdminPanelViewTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
             ->setMethods(['extGetLL'])
             ->disableOriginalConstructor()
             ->getMock();
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+        $iconProphecy = $this->prophesize(Icon::class);
+        $iconFactoryProphecy->getIcon(Argument::cetera())->willReturn($iconProphecy->reveal());
+        $iconProphecy->render(Argument::cetera())->willReturn('');
         $adminPanelMock->initialize();
         $hookMock->expects($this->once())->method('extendAdminPanel')->with($this->isType('string'), $this->isInstanceOf(\TYPO3\CMS\Frontend\View\AdminPanelView::class));
         $adminPanelMock->display();
index 90b60ca..0df2af4 100644 (file)
@@ -72,17 +72,4 @@ class CoreUpdateServiceTest extends UnitTestCase
         putenv('REDIRECT_TYPO3_DISABLE_CORE_UPDATER=1');
         $this->assertFalse($instance->isCoreUpdateEnabled());
     }
-
-    /**
-     * @test
-     */
-    public function isCoreUpdateEnabledReturnsFalseFor_TYPO3_COMPOSER_MODE_EnvironmentVariableSet()
-    {
-        if (!defined('TYPO3_COMPOSER_MODE')) {
-            putenv('TYPO3_COMPOSER_MODE=1');
-        }
-        /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\TestingFramework\Core\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
-        $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\CoreUpdateService::class, ['dummy'], [], '', false);
-        $this->assertFalse($instance->isCoreUpdateEnabled());
-    }
 }
index 61eb000..17a9f89 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Recordlist\Tests\UnitDeprecated\RecordList;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Imaging\IconFactory;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRecordList;
 
 /**
@@ -35,7 +37,7 @@ class AbstractDatabaseRecordListTest extends \TYPO3\TestingFramework\Core\Unit\U
     public function setTableDisplayOrderConvertsStringInput(array $input, array $expected)
     {
         /** @var AbstractDatabaseRecordList|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface $subject */
-        $subject = $this->getAccessibleMock(AbstractDatabaseRecordList::class, ['dummy']);
+        $subject = $this->getAccessibleMock(AbstractDatabaseRecordList::class, ['dummy'], [], '', false);
         $subject->setTableDisplayOrder($input);
         $this->assertSame($expected, $subject->_get('tableDisplayOrder'));
     }
@@ -96,6 +98,9 @@ class AbstractDatabaseRecordListTest extends \TYPO3\TestingFramework\Core\Unit\U
      */
     public function setTableDisplayOrderThrowsExceptionOnInvalidAfter()
     {
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         $this->expectException(\UnexpectedValueException::class);
         $this->expectExceptionCode(1436195934);
         $test = [
@@ -110,6 +115,9 @@ class AbstractDatabaseRecordListTest extends \TYPO3\TestingFramework\Core\Unit\U
      */
     public function setTableDisplayOrderThrowsExceptionOnInvalidBefore()
     {
+        $iconFactoryProphecy = $this->prophesize(IconFactory::class);
+        GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
+
         $this->expectException(\UnexpectedValueException::class);
         $this->expectExceptionCode(1436195933);
         $test = [
index 33403b0..20a7865 100644 (file)
@@ -16,42 +16,30 @@ namespace TYPO3\CMS\Saltedpasswords\Tests\Unit\Salt;
 
 use TYPO3\CMS\Core\Crypto\Random;
 use TYPO3\CMS\Saltedpasswords\Salt\Pbkdf2Salt;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 /**
- * Testcase for Pbkdf2Salt
+ * Test case
  */
-class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
+class Pbkdf2SaltTest extends UnitTestCase
 {
     /**
      * Keeps instance of object to test.
      *
      * @var Pbkdf2Salt
      */
-    protected $objectInstance = null;
+    protected $subject = null;
 
     /**
      * Sets up the fixtures for this testcase.
      */
     protected function setUp()
     {
-        $this->objectInstance = $this->getMockBuilder(Pbkdf2Salt::class)
-            ->setMethods(['dummy'])
-            ->getMock();
+        $this->subject = new Pbkdf2Salt();
         // Speed up the tests by reducing the iteration count
-        $this->objectInstance->setHashCount(1000);
-    }
-
-    /**
-     * @test
-     */
-    public function hasCorrectBaseClass()
-    {
-        $hasCorrectBaseClass = get_class($this->objectInstance) === Pbkdf2Salt::class;
-        // XCLASS ?
-        if (!$hasCorrectBaseClass && false != get_parent_class($this->objectInstance)) {
-            $hasCorrectBaseClass = is_subclass_of($this->objectInstance, Pbkdf2Salt::class);
-        }
-        $this->assertTrue($hasCorrectBaseClass);
+        $this->subject->setHashCount(1000);
+        $this->subject->setMinHashCount(1000);
+        $this->subject->setMaxHashCount(10000000);
     }
 
     /**
@@ -59,7 +47,7 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function nonZeroSaltLength()
     {
-        $this->assertTrue($this->objectInstance->getSaltLength() > 0);
+        $this->assertTrue($this->subject->getSaltLength() > 0);
     }
 
     /**
@@ -68,7 +56,7 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function emptyPasswordResultsInNullSaltedPassword()
     {
         $password = '';
-        $this->assertNull($this->objectInstance->getHashedPassword($password));
+        $this->assertNull($this->subject->getHashedPassword($password));
     }
 
     /**
@@ -77,7 +65,7 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function nonEmptyPasswordResultsInNonNullSaltedPassword()
     {
         $password = 'a';
-        $this->assertNotNull($this->objectInstance->getHashedPassword($password));
+        $this->assertNotNull($this->subject->getHashedPassword($password));
     }
 
     /**
@@ -86,8 +74,8 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function createdSaltedHashOfProperStructure()
     {
         $password = 'password';
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $this->assertTrue($this->objectInstance->isValidSaltedPW($saltedHashPassword));
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $this->assertTrue($this->subject->isValidSaltedPW($saltedHashPassword));
     }
 
     /**
@@ -97,11 +85,11 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $password = 'password';
         // custom salt without setting
-        $randomBytes = (new Random())->generateRandomBytes($this->objectInstance->getSaltLength());
-        $salt = $this->objectInstance->base64Encode($randomBytes, $this->objectInstance->getSaltLength());
-        $this->assertTrue($this->objectInstance->isValidSalt($salt));
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password, $salt);
-        $this->assertTrue($this->objectInstance->isValidSaltedPW($saltedHashPassword));
+        $randomBytes = (new Random())->generateRandomBytes($this->subject->getSaltLength());
+        $salt = $this->subject->base64Encode($randomBytes, $this->subject->getSaltLength());
+        $this->assertTrue($this->subject->isValidSalt($salt));
+        $saltedHashPassword = $this->subject->getHashedPassword($password, $salt);
+        $this->assertTrue($this->subject->isValidSaltedPW($saltedHashPassword));
     }
 
     /**
@@ -110,12 +98,12 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function createdSaltedHashOfProperStructureForMinimumHashCount()
     {
         $password = 'password';
-        $minHashCount = $this->objectInstance->getMinHashCount();
-        $this->objectInstance->setHashCount($minHashCount);
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $this->assertTrue($this->objectInstance->isValidSaltedPW($saltedHashPassword));
+        $minHashCount = $this->subject->getMinHashCount();
+        $this->subject->setHashCount($minHashCount);
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $this->assertTrue($this->subject->isValidSaltedPW($saltedHashPassword));
         // reset hashcount
-        $this->objectInstance->setHashCount(null);
+        $this->subject->setHashCount(null);
     }
 
     /**
@@ -130,7 +118,7 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $password = 'password';
         $saltedHashPassword = '$pbkdf2-sha256$1000$woPhT0yoWm3AXJXSjuxJ3w$iZ6EvTulMqXlzr0NO8z5EyrklFcJk5Uw2Fqje68FfaQ';
-        $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
+        $this->assertTrue($this->subject->checkPassword($password, $saltedHashPassword));
     }
 
     /**
@@ -142,7 +130,7 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $password = 'password';
         $saltedHashPassword = '$pbkdf2-sha256$1000$woPhT0yoWm3AXJXSjuxJ3w$iZ6EvTulMqXlzr0NO8z5EyrklFcJk5Uw2Fqje68Ffa';
-        $this->assertFalse($this->objectInstance->checkPassword($password, $saltedHashPassword));
+        $this->assertFalse($this->subject->checkPassword($password, $saltedHashPassword));
     }
 
     /**
@@ -156,8 +144,8 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function authenticationWithValidAlphaCharClassPassword()
     {
         $password = 'aEjOtY';
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $this->assertTrue($this->subject->checkPassword($password, $saltedHashPassword));
     }
 
     /**
@@ -171,8 +159,8 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function authenticationWithValidNumericCharClassPassword()
     {
         $password = '01369';
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $this->assertTrue($this->subject->checkPassword($password, $saltedHashPassword));
     }
 
     /**
@@ -186,8 +174,8 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function authenticationWithValidAsciiSpecialCharClassPassword()
     {
         $password = ' !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~';
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $this->assertTrue($this->subject->checkPassword($password, $saltedHashPassword));
     }
 
     /**
@@ -205,8 +193,8 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
             $password .= chr($i);
         }
         $password .= chr(215) . chr(247);
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $this->assertTrue($this->subject->checkPassword($password, $saltedHashPassword));
     }
 
     /**
@@ -229,8 +217,8 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         for ($i = 248; $i <= 255; $i++) {
             $password .= chr($i);
         }
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $this->assertTrue($this->objectInstance->checkPassword($password, $saltedHashPassword));
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $this->assertTrue($this->subject->checkPassword($password, $saltedHashPassword));
     }
 
     /**
@@ -240,8 +228,8 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     {
         $password = 'password';
         $password1 = $password . 'INVALID';
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $this->assertFalse($this->objectInstance->checkPassword($password1, $saltedHashPassword));
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $this->assertFalse($this->subject->checkPassword($password1, $saltedHashPassword));
     }
 
     /**
@@ -252,11 +240,11 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $pad = 'a';
         $criticalPwLength = 0;
         // We're using a constant salt.
-        $saltedHashPasswordCurrent = $salt = $this->objectInstance->getHashedPassword($pad);
+        $saltedHashPasswordCurrent = $salt = $this->subject->getHashedPassword($pad);
         for ($i = 0; $i <= 128; $i += 8) {
             $password = str_repeat($pad, max($i, 1));
             $saltedHashPasswordPrevious = $saltedHashPasswordCurrent;
-            $saltedHashPasswordCurrent = $this->objectInstance->getHashedPassword($password, $salt);
+            $saltedHashPasswordCurrent = $this->subject->getHashedPassword($password, $salt);
             if ($i > 0 && $saltedHashPasswordPrevious === $saltedHashPasswordCurrent) {
                 $criticalPwLength = $i;
                 break;
@@ -270,11 +258,11 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function modifiedMinHashCount()
     {
-        $minHashCount = $this->objectInstance->getMinHashCount();
-        $this->objectInstance->setMinHashCount($minHashCount - 1);
-        $this->assertTrue($this->objectInstance->getMinHashCount() < $minHashCount);
-        $this->objectInstance->setMinHashCount($minHashCount + 1);
-        $this->assertTrue($this->objectInstance->getMinHashCount() > $minHashCount);
+        $minHashCount = $this->subject->getMinHashCount();
+        $this->subject->setMinHashCount($minHashCount - 1);
+        $this->assertTrue($this->subject->getMinHashCount() < $minHashCount);
+        $this->subject->setMinHashCount($minHashCount + 1);
+        $this->assertTrue($this->subject->getMinHashCount() > $minHashCount);
     }
 
     /**
@@ -282,11 +270,11 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function modifiedMaxHashCount()
     {
-        $maxHashCount = $this->objectInstance->getMaxHashCount();
-        $this->objectInstance->setMaxHashCount($maxHashCount + 1);
-        $this->assertTrue($this->objectInstance->getMaxHashCount() > $maxHashCount);
-        $this->objectInstance->setMaxHashCount($maxHashCount - 1);
-        $this->assertTrue($this->objectInstance->getMaxHashCount() < $maxHashCount);
+        $maxHashCount = $this->subject->getMaxHashCount();
+        $this->subject->setMaxHashCount($maxHashCount + 1);
+        $this->assertTrue($this->subject->getMaxHashCount() > $maxHashCount);
+        $this->subject->setMaxHashCount($maxHashCount - 1);
+        $this->assertTrue($this->subject->getMaxHashCount() < $maxHashCount);
     }
 
     /**
@@ -294,15 +282,15 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function modifiedHashCount()
     {
-        $hashCount = $this->objectInstance->getHashCount();
-        $this->objectInstance->setMaxHashCount($hashCount + 1);
-        $this->objectInstance->setHashCount($hashCount + 1);
-        $this->assertTrue($this->objectInstance->getHashCount() > $hashCount);
-        $this->objectInstance->setMinHashCount($hashCount - 1);
-        $this->objectInstance->setHashCount($hashCount - 1);
-        $this->assertTrue($this->objectInstance->getHashCount() < $hashCount);
+        $hashCount = $this->subject->getHashCount();
+        $this->subject->setMaxHashCount($hashCount + 1);
+        $this->subject->setHashCount($hashCount + 1);
+        $this->assertTrue($this->subject->getHashCount() > $hashCount);
+        $this->subject->setMinHashCount($hashCount - 1);
+        $this->subject->setHashCount($hashCount - 1);
+        $this->assertTrue($this->subject->getHashCount() < $hashCount);
         // reset hashcount
-        $this->objectInstance->setHashCount(null);
+        $this->subject->setHashCount(null);
     }
 
     /**
@@ -311,8 +299,8 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function updateNecessityForValidSaltedPassword()
     {
         $password = 'password';
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $this->assertFalse($this->objectInstance->isHashUpdateNeeded($saltedHashPassword));
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $this->assertFalse($this->subject->isHashUpdateNeeded($saltedHashPassword));
     }
 
     /**
@@ -321,13 +309,13 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function updateNecessityForIncreasedHashcount()
     {
         $password = 'password';
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $increasedHashCount = $this->objectInstance->getHashCount() + 1;
-        $this->objectInstance->setMaxHashCount($increasedHashCount);
-        $this->objectInstance->setHashCount($increasedHashCount);
-        $this->assertTrue($this->objectInstance->isHashUpdateNeeded($saltedHashPassword));
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $increasedHashCount = $this->subject->getHashCount() + 1;
+        $this->subject->setMaxHashCount($increasedHashCount);
+        $this->subject->setHashCount($increasedHashCount);
+        $this->assertTrue($this->subject->isHashUpdateNeeded($saltedHashPassword));
         // reset hashcount
-        $this->objectInstance->setHashCount(null);
+        $this->subject->setHashCount(null);
     }
 
     /**
@@ -336,13 +324,13 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     public function updateNecessityForDecreasedHashcount()
     {
         $password = 'password';
-        $saltedHashPassword = $this->objectInstance->getHashedPassword($password);
-        $decreasedHashCount = $this->objectInstance->getHashCount() - 1;
-        $this->objectInstance->setMinHashCount($decreasedHashCount);
-        $this->objectInstance->setHashCount($decreasedHashCount);
-        $this->assertFalse($this->objectInstance->isHashUpdateNeeded($saltedHashPassword));
+        $saltedHashPassword = $this->subject->getHashedPassword($password);
+        $decreasedHashCount = $this->subject->getHashCount() - 1;
+        $this->subject->setMinHashCount($decreasedHashCount);
+        $this->subject->setHashCount($decreasedHashCount);
+        $this->assertFalse($this->subject->isHashUpdateNeeded($saltedHashPassword));
         // reset hashcount
-        $this->objectInstance->setHashCount(null);
+        $this->subject->setHashCount(null);
     }
 
     /**
@@ -350,9 +338,8 @@ class Pbkdf2SaltTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
      */
     public function isCompatibleWithPythonPasslibHashes()
     {
-        $this->objectInstance->setMinHashCount(1000);
         $passlibSaltedHash= '$pbkdf2-sha256$6400$.6UI/S.nXIk8jcbdHx3Fhg$98jZicV16ODfEsEZeYPGHU3kbrUrvUEXOPimVSQDD44';
-        $saltedHashPassword = $this->objectInstance->getHashedPassword('password', $passlibSaltedHash);
+        $saltedHashPassword = $this->subject->getHashedPassword('password', $passlibSaltedHash);
 
         $this->assertSame($passlibSaltedHash, $saltedHashPassword);
     }