‪TYPO3CMS  9.5
DatabaseSystemLanguageRowsTest.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;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
29 class ‪DatabaseSystemLanguageRowsTest extends UnitTestCase
30 {
35  {
36  $this->expectException(\LogicException::class);
37  $this->expectExceptionCode(1534952559);
38  (new ‪DatabaseSystemLanguageRows())->addData([]);
39  }
40 
45  {
46  $languageService = $this->prophesize(LanguageService::class);
47  ‪$GLOBALS['LANG'] = $languageService->reveal();
48  $languageService->sL(Argument::cetera())->willReturnArgument(0);
49  $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
50  ‪$GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
51 
52  $siteProphecy = $this->prophesize(Site::class);
53  $siteLanguageMinusOne = $this->prophesize(SiteLanguage::class);
54  $siteLanguageMinusOne->getLanguageId()->willReturn(-1);
55  $siteLanguageMinusOne->getTitle()->willReturn('All');
56  $siteLanguageMinusOne->getFlagIdentifier()->willReturn('flags-multiple');
57  $siteLanguageZero = $this->prophesize(SiteLanguage::class);
58  $siteLanguageZero->getLanguageId()->willReturn(0);
59  $siteLanguageZero->getTitle()->willReturn('English');
60  $siteLanguageZero->getFlagIdentifier()->willReturn('empty-empty');
61  $siteLanguageOne = $this->prophesize(SiteLanguage::class);
62  $siteLanguageOne->getLanguageId()->willReturn(1);
63  $siteLanguageOne->getTitle()->willReturn('Dutch');
64  $siteLanguageOne->getFlagIdentifier()->willReturn('flag-nl');
65  $siteLanguageOne->getTwoLetterIsoCode()->willReturn('NL');
66  $siteLanguages = [
67  $siteLanguageMinusOne->reveal(),
68  $siteLanguageZero->reveal(),
69  $siteLanguageOne->reveal(),
70  ];
71  $siteProphecy->getAvailableLanguages(Argument::cetera())->willReturn($siteLanguages);
72  $input = [
73  'effectivePid' => 42,
74  'site' => $siteProphecy->reveal(),
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  $this->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:44
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:39
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage
Definition: SiteLanguage.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseSystemLanguageRowsTest\addDataThrowsExceptionIfSiteObjectIsNotSet
‪addDataThrowsExceptionIfSiteObjectIsNotSet()
Definition: DatabaseSystemLanguageRowsTest.php:34
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:29
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows
Definition: DatabaseSystemLanguageRows.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:3