‪TYPO3CMS  9.5
LocalesTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
19 
23 class ‪LocalesTest extends UnitTestCase
24 {
29  {
30  return [
31  'german' => [
32  'de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4',
33  'de',
34  ],
35  'english as default' => [
36  'en-US;q=0.8,en;q=0.6;de-DE,de;q=0.4',
37  'default',
38  ],
39  'chinese simplified' => [
40  'zh-CN,en-US;q=0.5,en;q=0.3',
41  'ch'
42  ],
43  'chinese simplified han' => [
44  'zh-Hans-CN,zh-Hans;q=0.8,en-US;q=0.5,en;q=0.3',
45  'ch'
46  ],
47  ];
48  }
49 
57  public function ‪browserLanguageDetectionWorks(string $acceptLanguageHeader, string $expected)
58  {
59  $detectedLanguage = (new ‪Locales)->getPreferredClientLanguage(
60  $acceptLanguageHeader
61  );
62  $this->assertSame($expected, $detectedLanguage);
63  }
64 }
‪TYPO3\CMS\Core\Localization\Locales
Definition: Locales.php:29
‪TYPO3\CMS\Core\Tests\Unit\Localization\LocalesTest\browserLanguageDetectionWorksDataProvider
‪array browserLanguageDetectionWorksDataProvider()
Definition: LocalesTest.php:28
‪TYPO3\CMS\Core\Tests\Unit\Localization\LocalesTest\browserLanguageDetectionWorks
‪browserLanguageDetectionWorks(string $acceptLanguageHeader, string $expected)
Definition: LocalesTest.php:57
‪TYPO3\CMS\Core\Tests\Unit\Localization
Definition: LocalesTest.php:2
‪TYPO3\CMS\Core\Tests\Unit\Localization\LocalesTest
Definition: LocalesTest.php:24