‪TYPO3CMS  10.4
LocalizationFactoryTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Prophecy\Argument;
28 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
29 
33 class ‪LocalizationFactoryTest extends UnitTestCase
34 {
35  public function ‪tearDown(): void
36  {
37  // Drop created singletons again
38  GeneralUtility::purgeInstances();
39  parent::tearDown();
40  }
41 
46  {
47  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
48  $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
49  $cacheManagerProphecy->getCache('l10n')->willReturn($cacheFrontendProphecy->reveal());
50  $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
51  $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
52 
53  $store = new ‪LanguageStore();
54  $subject = new ‪LocalizationFactory($store, $cacheManagerProphecy->reveal());
55 
56  $unique = 'locallangXMLOverrideTest' . substr(‪StringUtility::getUniqueId(), 0, 10);
57  $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
58  <T3locallang>
59  <data type="array">
60  <languageKey index="default" type="array">
61  <label index="buttons.logout">EXIT</label>
62  </languageKey>
63  </data>
64  </T3locallang>';
65  $file = ‪Environment::getVarPath() . '/tests/' . $unique . '.xml';
67  $this->testFilesToDelete[] = $file;
68 
69  // Get default value
70  $defaultLL = $subject->getParsedData('EXT:core/Resources/Private/Language/locallang_core.xlf', 'default');
71 
72  // Set override file
73  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:core/Resources/Private/Language/locallang_core.xlf'][$unique] = $file;
74 
75  $store->flushData('EXT:core/Resources/Private/Language/locallang_core.xlf');
76 
77  // Get override value
78  $overrideLL = $subject->getParsedData('EXT:core/Resources/Private/Language/locallang_core.xlf', 'default');
79 
80  self::assertNotEquals($overrideLL['default']['buttons.logout'][0]['target'], '');
81  self::assertNotEquals($defaultLL['default']['buttons.logout'][0]['target'], $overrideLL['default']['buttons.logout'][0]['target']);
82  self::assertEquals($overrideLL['default']['buttons.logout'][0]['target'], 'EXIT');
83  }
84 }
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Localization\LocalizationFactoryTest\getParsedDataHandlesLocallangXMLOverride
‪getParsedDataHandlesLocallangXMLOverride()
Definition: LocalizationFactoryTest.php:45
‪TYPO3\CMS\Core\Localization\LocalizationFactory
Definition: LocalizationFactory.php:28
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Localization\LocalizationFactoryTest
Definition: LocalizationFactoryTest.php:34
‪TYPO3\CMS\Core\Localization\LanguageStore
Definition: LanguageStore.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility\writeFileToTypo3tempDir
‪static string writeFileToTypo3tempDir($filepath, $content)
Definition: GeneralUtility.php:1928
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Localization
Definition: LocalizationFactoryTest.php:18
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:35
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:22
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:92
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Core\Tests\UnitDeprecated\Localization\LocalizationFactoryTest\tearDown
‪tearDown()
Definition: LocalizationFactoryTest.php:35
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:192