‪TYPO3CMS  9.5
TranslationConfigurationProviderTest.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Prophecy\Argument;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
28 class ‪TranslationConfigurationProviderTest extends UnitTestCase
29 {
33  protected ‪$subject;
34 
35  protected ‪$resetSingletonInstances = true;
36 
37  protected function ‪setUp(): void
38  {
39  parent::setUp();
40 
41  $this->subject = new ‪TranslationConfigurationProvider();
42  }
43 
47  public function ‪defaultLanguageIsAlwaysReturned(): void
48  {
49  $pageId = 1;
50  $site = new ‪Site('dummy', $pageId, ['base' => 'http://sub.domainhostname.tld/path/']);
51  $siteFinderProphecy = $this->prophesize(SiteFinder::class);
52  $siteFinderProphecy->getSiteByPageId($pageId, null)->willReturn($site);
53  GeneralUtility::addInstance(SiteFinder::class, $siteFinderProphecy->reveal());
54 
55  $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
56  $cacheFrontendProphecy->has(Argument::any())->willReturn(false);
57  $cacheFrontendProphecy->set(Argument::any(), Argument::any())->willReturn(null);
58  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
59  $cacheManagerProphecy->getCache('cache_core')->willReturn($cacheFrontendProphecy->reveal());
60  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
61 
62  $backendUserAuthentication = $this->prophesize(BackendUserAuthentication::class);
63  ‪$GLOBALS['BE_USER'] = $backendUserAuthentication->reveal();
64 
65  $languages = $this->subject->getSystemLanguages($pageId);
66  $this->assertArrayHasKey(0, $languages);
67  }
68 }
‪TYPO3\CMS\Backend\Tests\Unit\Configuration\TranslationConfigurationProviderTest\$resetSingletonInstances
‪$resetSingletonInstances
Definition: TranslationConfigurationProviderTest.php:34
‪TYPO3\CMS\Core\Site\SiteFinder
Definition: SiteFinder.php:31
‪TYPO3\CMS\Backend\Tests\Unit\Configuration
Definition: BackendUserConfigurationTest.php:3
‪TYPO3\CMS\Backend\Tests\Unit\Configuration\TranslationConfigurationProviderTest\$subject
‪TranslationConfigurationProvider $subject
Definition: TranslationConfigurationProviderTest.php:32
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:39
‪TYPO3\CMS\Backend\Tests\Unit\Configuration\TranslationConfigurationProviderTest\defaultLanguageIsAlwaysReturned
‪defaultLanguageIsAlwaysReturned()
Definition: TranslationConfigurationProviderTest.php:46
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:34
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Backend\Tests\Unit\Configuration\TranslationConfigurationProviderTest
Definition: TranslationConfigurationProviderTest.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Configuration\TranslationConfigurationProviderTest\setUp
‪setUp()
Definition: TranslationConfigurationProviderTest.php:36
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:21
‪TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider
Definition: TranslationConfigurationProvider.php:35
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45