‪TYPO3CMS  9.5
StateUtilityTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
24 class ‪StateUtilityTest extends UnitTestCase
25 {
26 
31  {
32  ‪$GLOBALS['BE_USER'] = false;
34  self::assertFalse($isEnabled);
35  }
36 
41  {
42  ‪$GLOBALS['BE_USER'] = $this->prophesize(BackendUserAuthentication::class)->reveal();
44  self::assertFalse($isEnabled);
45  }
46 
47  public function ‪tsConfigEnabledDataProvider(): array
48  {
49  return [
50  '1 module enabled' => [
51  [
52  'admPanel.' => [
53  'enable.' => [
54  'preview' => 1
55  ]
56  ]
57  ]
58  ],
59  'all modules enabled' => [
60  [
61  'admPanel.' => [
62  'enable.' => [
63  'all' => 1
64  ]
65  ]
66  ]
67  ]
68  ];
69  }
70 
76  public function ‪isEnabledReturnsTrueIfAtLeastOneModuleIsEnabled(array $tsConfig): void
77  {
78  $beUserProphecy = $this->prophesize(FrontendBackendUserAuthentication::class);
79  $beUserProphecy->getTSConfig()->willReturn($tsConfig);
80  ‪$GLOBALS['BE_USER'] = $beUserProphecy->reveal();
82  self::assertTrue($isEnabled);
83  }
84 
85  public function ‪tsConfigDisabledDataProvider(): array
86  {
87  return [
88  'no config set' => [
89  []
90  ],
91  'all modules disabled' => [
92  'admPanel.' => [
93  'enable.' => [
94  'all' => 0
95  ]
96  ]
97  ],
98  'single module configured, disabled' => [
99  'admPanel.' => [
100  'enable.' => [
101  'preview' => 0
102  ]
103  ]
104  ]
105  ];
106  }
107 
113  public function ‪isEnabledReturnsFalseIfNoModulesEnabled(array $tsConfig): void
114  {
115  $beUserProphecy = $this->prophesize(FrontendBackendUserAuthentication::class);
116  $beUserProphecy->getTSConfig()->willReturn($tsConfig);
117  ‪$GLOBALS['BE_USER'] = $beUserProphecy->reveal();
119  self::assertFalse($isEnabled);
120  }
121 }
‪TYPO3\CMS\Adminpanel\Tests\Unit\Utility
Definition: StateUtilityTest.php:4
‪TYPO3\CMS\Adminpanel\Tests\Unit\Utility\StateUtilityTest\isEnabledReturnsFalseIfNoBackendUserInFrontendContextIsLoggedIn
‪isEnabledReturnsFalseIfNoBackendUserInFrontendContextIsLoggedIn()
Definition: StateUtilityTest.php:40
‪TYPO3\CMS\Adminpanel\Utility\StateUtility\isActivatedForUser
‪static bool isActivatedForUser()
Definition: StateUtility.php:33
‪TYPO3\CMS\Adminpanel\Tests\Unit\Utility\StateUtilityTest
Definition: StateUtilityTest.php:25
‪TYPO3\CMS\Adminpanel\Tests\Unit\Utility\StateUtilityTest\tsConfigDisabledDataProvider
‪tsConfigDisabledDataProvider()
Definition: StateUtilityTest.php:85
‪TYPO3\CMS\Backend\FrontendBackendUserAuthentication
Definition: FrontendBackendUserAuthentication.php:35
‪TYPO3\CMS\Adminpanel\Tests\Unit\Utility\StateUtilityTest\isEnabledReturnsFalseIfNoBackendUserExists
‪isEnabledReturnsFalseIfNoBackendUserExists()
Definition: StateUtilityTest.php:30
‪TYPO3\CMS\Adminpanel\Utility\StateUtility
Definition: StateUtility.php:27
‪TYPO3\CMS\Adminpanel\Tests\Unit\Utility\StateUtilityTest\tsConfigEnabledDataProvider
‪tsConfigEnabledDataProvider()
Definition: StateUtilityTest.php:47
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Adminpanel\Tests\Unit\Utility\StateUtilityTest\isEnabledReturnsTrueIfAtLeastOneModuleIsEnabled
‪isEnabledReturnsTrueIfAtLeastOneModuleIsEnabled(array $tsConfig)
Definition: StateUtilityTest.php:76
‪TYPO3\CMS\Adminpanel\Tests\Unit\Utility\StateUtilityTest\isEnabledReturnsFalseIfNoModulesEnabled
‪isEnabledReturnsFalseIfNoModulesEnabled(array $tsConfig)
Definition: StateUtilityTest.php:113