‪TYPO3CMS  10.4
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 Prophecy\Argument;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪DatabaseSystemLanguageRowsTest extends UnitTestCase
32 {
37  {
38  $this->expectException(\LogicException::class);
39  $this->expectExceptionCode(1534952559);
40  (new ‪DatabaseSystemLanguageRows())->addData([]);
41  }
42 
47  {
48  $languageService = $this->prophesize(LanguageService::class);
49  ‪$GLOBALS['LANG'] = $languageService->reveal();
50  $languageService->sL(Argument::cetera())->willReturnArgument(0);
51  $backendUserProphecy = $this->prophesize(BackendUserAuthentication::class);
52  ‪$GLOBALS['BE_USER'] = $backendUserProphecy->reveal();
53 
54  $siteProphecy = $this->prophesize(Site::class);
55  $siteLanguageMinusOne = $this->prophesize(SiteLanguage::class);
56  $siteLanguageMinusOne->getLanguageId()->willReturn(-1);
57  $siteLanguageMinusOne->getTitle()->willReturn('All');
58  $siteLanguageMinusOne->getFlagIdentifier()->willReturn('flags-multiple');
59  $siteLanguageZero = $this->prophesize(SiteLanguage::class);
60  $siteLanguageZero->getLanguageId()->willReturn(0);
61  $siteLanguageZero->getTitle()->willReturn('English');
62  $siteLanguageZero->getFlagIdentifier()->willReturn('empty-empty');
63  $siteLanguageOne = $this->prophesize(SiteLanguage::class);
64  $siteLanguageOne->getLanguageId()->willReturn(1);
65  $siteLanguageOne->getTitle()->willReturn('Dutch');
66  $siteLanguageOne->getFlagIdentifier()->willReturn('flag-nl');
67  $siteLanguageOne->getTwoLetterIsoCode()->willReturn('NL');
68  $siteLanguages = [
69  $siteLanguageMinusOne->reveal(),
70  $siteLanguageZero->reveal(),
71  $siteLanguageOne->reveal(),
72  ];
73  $siteProphecy->getAvailableLanguages(Argument::cetera())->willReturn($siteLanguages);
74  $input = [
75  'effectivePid' => 42,
76  'site' => $siteProphecy->reveal(),
77  ];
78  $expected = [
79  'systemLanguageRows' => [
80  -1 => [
81  'uid' => -1,
82  'title' => 'All',
83  'iso' => 'DEF',
84  'flagIconIdentifier' => 'flags-multiple',
85  ],
86  0 => [
87  'uid' => 0,
88  'title' => 'English',
89  'iso' => 'DEF',
90  'flagIconIdentifier' => 'empty-empty',
91  ],
92  1 => [
93  'uid' => 1,
94  'title' => 'Dutch',
95  'iso' => 'NL',
96  'flagIconIdentifier' => 'flag-nl',
97  ]
98  ],
99  ];
100  self::assertSame(array_merge($input, $expected), (new ‪DatabaseSystemLanguageRows())->addData($input));
101  }
102 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseSystemLanguageRowsTest
Definition: DatabaseSystemLanguageRowsTest.php:32
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseSystemLanguageRowsTest\addDataSetsDefaultLanguageAndAllEntries
‪addDataSetsDefaultLanguageAndAllEntries()
Definition: DatabaseSystemLanguageRowsTest.php:46
‪TYPO3\CMS\Core\Site\Entity\Site
Definition: Site.php:40
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage
Definition: SiteLanguage.php:26
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\DatabaseSystemLanguageRowsTest\addDataThrowsExceptionIfSiteObjectIsNotSet
‪addDataThrowsExceptionIfSiteObjectIsNotSet()
Definition: DatabaseSystemLanguageRowsTest.php:36
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseSystemLanguageRows
Definition: DatabaseSystemLanguageRows.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18