‪TYPO3CMS  11.5
BackendUtilityTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
7 use TYPO3\CMS\Backend\Utility\BackendUtility;
11 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
12 
13 class ‪BackendUtilityTest extends FunctionalTestCase
14 {
16 
17  protected const ‪LANGUAGE_PRESETS = [
18  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
19  'DK' => ['id' => 1, 'title' => 'Dansk', 'locale' => 'dk_DA.UTF8'],
20  'DE' => ['id' => 2, 'title' => 'German', 'locale' => 'de_DE.UTF8'],
21  ];
22 
23  public function ‪setUp(): void
24  {
25  parent::setUp();
26  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml');
27  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/tt_content.xml');
28  $this->setUpBackendUserFromFixture(1);
30  }
31 
35  public function ‪givenPageIdCanBeExpanded(): void
36  {
37  $backendUser = $this->‪getBackendUser();
38  $backendUser->groupData['webmounts'] = '1';
39 
40  BackendUtility::openPageTree(5, false);
41 
42  $expectedSiteHash = [
43  '1_5' => '1',
44  '1_1' => '1',
45  '1_0' => '1',
46  ];
47  $actualSiteHash = $backendUser->uc['BackendComponents']['States']['Pagetree']['stateHash'];
48  self::assertSame($expectedSiteHash, $actualSiteHash);
49  }
50 
54  public function ‪otherBranchesCanBeClosedWhenOpeningPage(): void
55  {
56  $backendUser = $this->‪getBackendUser();
57  $backendUser->groupData['webmounts'] = '1';
58 
59  BackendUtility::openPageTree(5, false);
60  BackendUtility::openPageTree(4, true);
61 
62  //the complete branch of uid => 5 should be closed here
63  $expectedSiteHash = [
64  '1_4' => '1',
65  '1_3' => '1',
66  '1_2' => '1',
67  '1_1' => '1',
68  '1_0' => '1',
69  ];
70  $actualSiteHash = $backendUser->uc['BackendComponents']['States']['Pagetree']['stateHash'];
71  self::assertSame($expectedSiteHash, $actualSiteHash);
72  }
73 
77  public function ‪getProcessedValueForLanguage(): void
78  {
80  'website-local',
81  $this->‪buildSiteConfiguration(1, 'http://localhost/'),
82  [
83  $this->‪buildDefaultLanguageConfiguration('EN', '/en/'),
84  $this->‪buildLanguageConfiguration('DK', '/dk/'),
85  $this->‪buildLanguageConfiguration('DE', '/de/'),
86  ]
87  );
88 
89  self::assertEquals(
90  'Dansk',
91  BackendUtility::getProcessedValue(
92  'pages',
93  'sys_language_uid',
94  '1',
95  0,
96  false,
97  false,
98  1
99  )
100  );
101 
102  self::assertEquals(
103  'German',
104  BackendUtility::getProcessedValue(
105  'tt_content',
106  'sys_language_uid',
107  '2',
108  0,
109  false,
110  false,
111  1
112  )
113  );
114  }
115 
119  public function ‪getRecordTitleForUidLabel(): void
120  {
121  ‪$GLOBALS['TCA']['tt_content']['ctrl']['label'] = 'uid';
122  unset(‪$GLOBALS['TCA']['tt_content']['ctrl']['label_alt']);
123 
124  self::assertEquals(
125  '1',
126  BackendUtility::getRecordTitle('tt_content', BackendUtility::getRecord('tt_content', 1))
127  );
128  }
129 
131  {
132  return ‪$GLOBALS['BE_USER'];
133  }
134 }
‪TYPO3\CMS\Backend\Tests\Functional\Utility\BackendUtilityTest\givenPageIdCanBeExpanded
‪givenPageIdCanBeExpanded()
Definition: BackendUtilityTest.php:34
‪TYPO3\CMS\Backend\Tests\Functional\Utility\BackendUtilityTest\otherBranchesCanBeClosedWhenOpeningPage
‪otherBranchesCanBeClosedWhenOpeningPage()
Definition: BackendUtilityTest.php:53
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:36
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildLanguageConfiguration
‪array buildLanguageConfiguration(string $identifier, string $base, array $fallbackIdentifiers=[], string $fallbackType=null)
Definition: SiteBasedTestTrait.php:144
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:58
‪TYPO3\CMS\Backend\Tests\Functional\Utility\BackendUtilityTest\LANGUAGE_PRESETS
‪const LANGUAGE_PRESETS
Definition: BackendUtilityTest.php:16
‪TYPO3\CMS\Backend\Tests\Functional\Utility\BackendUtilityTest
Definition: BackendUtilityTest.php:14
‪TYPO3\CMS\Backend\Tests\Functional\Utility\BackendUtilityTest\getProcessedValueForLanguage
‪getProcessedValueForLanguage()
Definition: BackendUtilityTest.php:76
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:126
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static initializeLanguageObject()
Definition: Bootstrap.php:598
‪TYPO3\CMS\Backend\Tests\Functional\Utility\BackendUtilityTest\getBackendUser
‪getBackendUser()
Definition: BackendUtilityTest.php:129
‪TYPO3\CMS\Backend\Tests\Functional\Utility\BackendUtilityTest\setUp
‪setUp()
Definition: BackendUtilityTest.php:22
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Backend\Tests\Functional\Utility
Definition: BackendUtilityTest.php:5
‪TYPO3\CMS\Backend\Tests\Functional\Utility\BackendUtilityTest\getRecordTitleForUidLabel
‪getRecordTitleForUidLabel()
Definition: BackendUtilityTest.php:118
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:70
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:111