diff --git a/typo3/sysext/extbase/Tests/Unit/Utility/LocalizationUtilityTest.php b/typo3/sysext/extbase/Tests/Functional/Utility/LocalizationUtilityTest.php similarity index 87% rename from typo3/sysext/extbase/Tests/Unit/Utility/LocalizationUtilityTest.php rename to typo3/sysext/extbase/Tests/Functional/Utility/LocalizationUtilityTest.php index 97513ea87af1..b808873c645f 100644 --- a/typo3/sysext/extbase/Tests/Unit/Utility/LocalizationUtilityTest.php +++ b/typo3/sysext/extbase/Tests/Functional/Utility/LocalizationUtilityTest.php @@ -15,23 +15,17 @@ * The TYPO3 project - inspiring people to share! */ -namespace TYPO3\CMS\Extbase\Tests\Unit\Utility; +namespace TYPO3\CMS\Extbase\Tests\Functional\Utility; use PHPUnit\Framework\MockObject\MockObject; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; -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\Localization\Locales; -use TYPO3\CMS\Core\Localization\LocalizationFactory; -use TYPO3\CMS\Core\Package\PackageManager; +use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; -use TYPO3\TestingFramework\Core\Unit\UnitTestCase; +use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; -class LocalizationUtilityTest extends UnitTestCase +class LocalizationUtilityTest extends FunctionalTestCase { protected ConfigurationManagerInterface&MockObject $configurationManagerInterfaceMock; @@ -183,10 +177,6 @@ protected function setUp(): void $property = $reflectionClass->getProperty('configurationManager'); $property->setAccessible(true); $property->setValue($this->configurationManagerInterfaceMock); - - $localizationFactoryMock = $this->createMock(LocalizationFactory::class); - $localizationFactoryMock->method('getParsedData')->with(self::anything())->willReturn([]); - GeneralUtility::setSingletonInstance(LocalizationFactory::class, $localizationFactoryMock); } /** @@ -342,7 +332,6 @@ public function translateTestWithExplicitLanguageParameters( array $altLanguageKeys = [], array $arguments = null ): void { - $packageManagerMock = $this->createMock(PackageManager::class); $this->configurationManagerInterfaceMock ->method('getConfiguration') ->with('Framework', 'core', null) @@ -353,12 +342,7 @@ public function translateTestWithExplicitLanguageParameters( $property = $reflectionClass->getProperty('LOCAL_LANG'); $property->setAccessible(true); $property->setValue($this->LOCAL_LANG); - $cacheManagerMock = $this->createMock(CacheManager::class); - $cacheFrontendMock = $this->createMock(FrontendInterface::class); - $cacheManagerMock->method('getCache')->with('l10n')->willReturn($cacheFrontendMock); - $cacheFrontendMock->method('get')->with(self::anything())->willReturn(false); - $cacheFrontendMock->method('set')->with(self::anything())->willReturn(null); - $GLOBALS['LANG'] = new LanguageService(new Locales(), new LocalizationFactory(new LanguageStore($packageManagerMock), $cacheManagerMock), $cacheFrontendMock); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); self::assertEquals($expected, LocalizationUtility::translate($key, 'core', $arguments, $languageKey, $altLanguageKeys)); } @@ -488,7 +472,6 @@ public function loadTypoScriptLabels(array $LOCAL_LANG, array $typoScriptLocalLa */ public function clearLabelWithTypoScript(): void { - $packageManagerMock = $this->createMock(PackageManager::class); $reflectionClass = new \ReflectionClass(LocalizationUtility::class); $property = $reflectionClass->getProperty('LOCAL_LANG'); @@ -514,12 +497,7 @@ public function clearLabelWithTypoScript(): void $method->setAccessible(true); $method->invoke(null, 'core', $this->languageFilePath); - $cacheManagerMock = $this->createMock(CacheManager::class); - $cacheFrontendMock = $this->createMock(FrontendInterface::class); - $cacheManagerMock->method('getCache')->with('l10n')->willReturn($cacheFrontendMock); - $cacheFrontendMock->method('get')->with(self::anything())->willReturn(false); - $cacheFrontendMock->method('set')->with(self::anything())->willReturn(null); - $GLOBALS['LANG'] = new LanguageService(new Locales(), new LocalizationFactory(new LanguageStore($packageManagerMock), $cacheManagerMock), $cacheFrontendMock); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $result = LocalizationUtility::translate('key1', 'core', null, 'dk'); self::assertNotNull($result); @@ -541,7 +519,6 @@ public function translateThrowsExceptionWithEmptyExtensionNameIfKeyIsNotPrefixed */ public function translateWillReturnLabelsFromTsEvenIfNoXlfFileExists(): void { - $packageManagerMock = $this->createMock(PackageManager::class); $reflectionClass = new \ReflectionClass(LocalizationUtility::class); $typoScriptLocalLang = [ @@ -563,12 +540,7 @@ public function translateWillReturnLabelsFromTsEvenIfNoXlfFileExists(): void $method->setAccessible(true); $method->invoke(null, 'core', ''); // setting the language file path to an empty string here - $cacheManagerMock = $this->createMock(CacheManager::class); - $cacheFrontendMock = $this->createMock(FrontendInterface::class); - $cacheManagerMock->method('getCache')->with('l10n')->willReturn($cacheFrontendMock); - $cacheFrontendMock->method('get')->with(self::anything())->willReturn(false); - $cacheFrontendMock->method('set')->with(self::anything())->willReturn(null); - $GLOBALS['LANG'] = new LanguageService(new Locales(), new LocalizationFactory(new LanguageStore($packageManagerMock), $cacheManagerMock), $cacheFrontendMock); + $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default'); $result = LocalizationUtility::translate('key1', 'core', null, 'dk'); self::assertNotNull($result);