From 2cb30584e999b348f03a63c7c038dba22b7d18e0 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Thu, 17 Nov 2022 09:28:50 +0100 Subject: [PATCH] [TASK] Remove a heavy-mocking unit test getPagesTSconfigWorksWithoutInitializedBackendUser() does nothing insanely useful and is more a burden than a helper when the implementation of the test subject is changed. Resolves: #99112 Releases: main Change-Id: I7377c17283fcfe641bb46356fd5cd1e91b92552d Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76656 Tested-by: Benni Mack <benni@typo3.org> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Tested-by: core-ci <typo3@b13.com> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Tests/Unit/Utility/BackendUtilityTest.php | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php b/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php index f3577846800c..e9113b00f538 100644 --- a/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php +++ b/typo3/sysext/backend/Tests/Unit/Utility/BackendUtilityTest.php @@ -17,21 +17,11 @@ declare(strict_types=1); namespace TYPO3\CMS\Backend\Tests\Unit\Utility; -use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher; use TYPO3\CMS\Backend\Tests\Unit\Utility\Fixtures\LabelFromItemListMergedReturnsCorrectFieldsFixture; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; -use TYPO3\CMS\Core\Cache\CacheManager; -use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; -use TYPO3\CMS\Core\Cache\Frontend\NullFrontend; -use TYPO3\CMS\Core\Configuration\Loader\PageTsConfigLoader; -use TYPO3\CMS\Core\Configuration\PageTsConfig; -use TYPO3\CMS\Core\Configuration\Parser\PageTsConfigParser; use TYPO3\CMS\Core\Database\RelationHandler; -use TYPO3\CMS\Core\EventDispatcher\NoopEventDispatcher; use TYPO3\CMS\Core\Localization\LanguageService; -use TYPO3\CMS\Core\Site\Entity\Site; -use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\TestingFramework\Core\Unit\UnitTestCase; @@ -1076,44 +1066,6 @@ class BackendUtilityTest extends UnitTestCase self::assertSame($expected, $result); } - /** - * Tests if the method getPagesTSconfig can be called without having a GLOBAL['BE_USER'] object. - * However, this test also shows all the various other dependencies this method has. - * - * @test - */ - public function getPagesTSconfigWorksWithoutInitializedBackendUser(): void - { - $expected = ['called.' => ['config']]; - $pageId = 13; - $eventDispatcher = new NoopEventDispatcher(); - $loader = new PageTsConfigLoader($eventDispatcher); - $parserMock = $this->createMock(PageTsConfigParser::class); - $parserMock->method('parse')->willReturn($expected); - $configuration = new PageTsConfig(new NullFrontend('runtimeCache'), $loader, $parserMock); - GeneralUtility::addInstance(PageTsConfig::class, $configuration); - - GeneralUtility::addInstance(ConditionMatcher::class, $this->createMock(ConditionMatcher::class)); - - $siteFinderMock = $this->createMock(SiteFinder::class); - $siteFinderMock->method('getSiteByPageId')->willReturn( - new Site('dummy', $pageId, ['base' => 'https://example.com']) - )->with($pageId); - GeneralUtility::addInstance(SiteFinder::class, $siteFinderMock); - - $cacheManagerMock = $this->createMock(CacheManager::class); - $cacheMock = $this->createMock(FrontendInterface::class); - $cacheManagerMock->method('getCache')->willReturn($cacheMock)->with('runtime'); - $cacheMock->method('has')->willReturn(false); - $cacheMock->method('set')->willReturn(false); - $cacheMock->method('get')->willReturn(['13--1' => []])->with('backendUtilityBeGetRootLine'); - $cacheMock->method('get')->willReturn(false)->withAnyParameters(); - GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerMock); - - $result = BackendUtility::getPagesTSconfig($pageId); - self::assertEquals($expected, $result); - } - /** * @test */ -- GitLab