‪TYPO3CMS  ‪main
DatabaseSystemLanguageRowsTest.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 PHPUnit\Framework\Attributes\Test;
27 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
28 
29 final class ‪DatabaseSystemLanguageRowsTest extends UnitTestCase
30 {
31  #[Test]
33  {
34  $this->expectException(\LogicException::class);
35  $this->expectExceptionCode(1534952559);
36  (new ‪DatabaseSystemLanguageRows())->addData([]);
37  }
38 
39  #[Test]
41  {
42  $languageService = $this->createMock(LanguageService::class);
43  ‪$GLOBALS['LANG'] = $languageService;
44  $languageService->method('sL')->withAnyParameters()->willReturnArgument(0);
45  ‪$GLOBALS['BE_USER'] = $this->createMock(BackendUserAuthentication::class);
46 
47  $siteLanguageMinusOne = new ‪SiteLanguage(
48  -1,
49  '',
50  new ‪Uri('/'),
51  ['title' => 'All', 'flag' => 'flags-multiple']
52  );
53  $siteLanguageZero = new ‪SiteLanguage(
54  0,
55  'en',
56  new ‪Uri('/en/'),
57  ['title' => 'English', 'flag' => 'empty-empty']
58  );
59  $siteLanguageOne = new ‪SiteLanguage(
60  1,
61  'nl_NL',
62  new ‪Uri('/nl/'),
63  ['title' => 'Dutch', 'flag' => 'flag-nl']
64  );
65  $siteLanguages = [
66  $siteLanguageMinusOne,
67  $siteLanguageZero,
68  $siteLanguageOne,
69  ];
70  $siteMock = $this->createMock(Site::class);
71  $siteMock->method('getAvailableLanguages')->withAnyParameters()->willReturn($siteLanguages);
72  $input = [
73  'effectivePid' => 42,
74  'site' => $siteMock,
75  ];
76  $expected = [
77  'systemLanguageRows' => [
78  -1 => [
79  'uid' => -1,
80  'title' => 'All',
81  'iso' => 'DEF',
82  'flagIconIdentifier' => 'flags-multiple',
83  ],
84  0 => [
85  'uid' => 0,
86  'title' => 'English',
87  'iso' => 'DEF',
88  'flagIconIdentifier' => 'empty-empty',
89  ],
90  1 => [
91  'uid' => 1,
92  'title' => 'Dutch',
93  'iso' => 'nl',
94  'flagIconIdentifier' => 'flag-nl',
95  ],
96  ],
97  ];
98  self::assertSame(array_merge($input, $expected), (new ‪DatabaseSystemLanguageRows())->addData($input));
99  }
100 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseSystemLanguageRowsTest
Definition: DatabaseSystemLanguageRowsTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseSystemLanguageRowsTest\addDataSetsDefaultLanguageAndAllEntries
‪addDataSetsDefaultLanguageAndAllEntries()
Definition: DatabaseSystemLanguageRowsTest.php:40
‪TYPO3\CMS\Core\Http\Uri
Definition: Uri.php:30
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:42
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage
Definition: SiteLanguage.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseSystemLanguageRowsTest\addDataThrowsExceptionIfSiteObjectIsNotSet
‪addDataThrowsExceptionIfSiteObjectIsNotSet()
Definition: DatabaseSystemLanguageRowsTest.php:32
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows
Definition: DatabaseSystemLanguageRows.php:31
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18