‪TYPO3CMS  11.5
FrontendConfigurationManagerTest.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\MockObject\MockObject;
24 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
25 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
28 class ‪FrontendConfigurationManagerTest extends UnitTestCase
29 {
33  protected ‪$mockContentObject;
34 
39 
43  protected ‪$mockTypoScriptService;
44 
45  protected function ‪setUp(): void
46  {
47  parent::setUp();
48  ‪$GLOBALS['TSFE'] = new \stdClass();
49  ‪$GLOBALS['TSFE']->tmpl = new \stdClass();
50  $this->mockContentObject = $this->getMockBuilder(ContentObjectRenderer::class)
51  ->onlyMethods(['getTreeList'])
52  ->getMock();
53  $this->frontendConfigurationManager = $this->getAccessibleMock(
54  FrontendConfigurationManager::class,
55  ['dummy'],
56  [],
57  '',
58  false
59  );
60  $this->frontendConfigurationManager->_set('contentObject', $this->mockContentObject);
61  $this->mockTypoScriptService = $this->getAccessibleMock(TypoScriptService::class);
62  $this->frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
63  }
64 
69  {
70  $frameworkConfiguration = [
71  'pluginName' => 'Pi1',
72  'extensionName' => 'SomeExtension',
73  'controllerConfiguration' => [
74  'MyExtension\\Controller\\Controller1' => [
75  'alias' => 'Controller1',
76  'actions' => ['action1 , action2'],
77  ],
78  'MyExtension\\Controller\\Controller2' => [
79  'alias' => 'Controller2',
80  'actions' => ['action2', 'action1', 'action3'],
81  'nonCacheableActions' => ['action2', 'action3'],
82  ],
83  ],
84  ];
85  $flexFormConfiguration = [
86  'switchableControllerActions' => 'Controller1 -> action2;\\MyExtension\\Controller\\Controller2->action3; Controller2->action1',
87  ];
88  $expectedResult = [
89  'pluginName' => 'Pi1',
90  'extensionName' => 'SomeExtension',
91  'controllerConfiguration' => [
92  'MyExtension\\Controller\\Controller1' => [
93  'className' => 'MyExtension\\Controller\\Controller1',
94  'alias' => 'Controller1',
95  'actions' => ['action2'],
96  ],
97  'MyExtension\\Controller\\Controller2' => [
98  'className' => 'MyExtension\\Controller\\Controller2',
99  'alias' => 'Controller2',
100  'actions' => ['action3', 'action1'],
101  'nonCacheableActions' => [1 => 'action3'],
102  ],
103  ],
104  ];
105  $actualResult = $this->frontendConfigurationManager->_call(
106  'overrideControllerConfigurationWithSwitchableControllerActionsFromFlexForm',
107  $frameworkConfiguration,
108  $flexFormConfiguration
109  );
110  self::assertEquals($expectedResult, $actualResult);
111  }
112 
117  ): void {
118  $frameworkConfiguration = [
119  'pluginName' => 'Pi1',
120  'extensionName' => 'SomeExtension',
121  'controllerConfiguration' => [
122  'Controller1' => [
123  'controller' => 'Controller1',
124  'actions' => 'action1 , action2',
125  ],
126  'Controller2' => [
127  'controller' => 'Controller2',
128  'actions' => 'action2 , action1,action3',
129  'nonCacheableActions' => 'action2, action3',
130  ],
131  ],
132  ];
133  $flexFormConfiguration = [];
134  $actualResult = $this->frontendConfigurationManager->_call(
135  'overrideControllerConfigurationWithSwitchableControllerActionsFromFlexForm',
136  $frameworkConfiguration,
137  $flexFormConfiguration
138  );
139  self::assertSame($frameworkConfiguration, $actualResult);
140  }
141 
146  {
147  $this->expectException(ParseErrorException::class);
148  $this->expectExceptionCode(1257146403);
149  $frameworkConfiguration = [
150  'pluginName' => 'Pi1',
151  'extensionName' => 'SomeExtension',
152  'controllerConfiguration' => [
153  'Controller1' => [
154  'actions' => ['action1 , action2'],
155  ],
156  'Controller2' => [
157  'actions' => ['action2', 'action1', 'action3'],
158  'nonCacheableActions' => ['action2', 'action3'],
159  ],
160  ],
161  ];
162  $flexFormConfiguration = [
163  'switchableControllerActions' => 'Controller1->;Controller2->action3;Controller2->action1',
164  ];
165  $this->frontendConfigurationManager->_call(
166  'overrideControllerConfigurationWithSwitchableControllerActionsFromFlexForm',
167  $frameworkConfiguration,
168  $flexFormConfiguration
169  );
170  }
171 }
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Configuration\FrontendConfigurationManagerTest\$mockContentObject
‪ContentObjectRenderer MockObject $mockContentObject
Definition: FrontendConfigurationManagerTest.php:32
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Configuration\FrontendConfigurationManagerTest\$mockTypoScriptService
‪TypoScriptService MockObject AccessibleObjectInterface $mockTypoScriptService
Definition: FrontendConfigurationManagerTest.php:40
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Configuration
Definition: AbstractConfigurationManagerTest.php:18
‪TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager
Definition: FrontendConfigurationManager.php:33
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Configuration\FrontendConfigurationManagerTest\$frontendConfigurationManager
‪FrontendConfigurationManager MockObject AccessibleObjectInterface $frontendConfigurationManager
Definition: FrontendConfigurationManagerTest.php:36
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Configuration\FrontendConfigurationManagerTest
Definition: FrontendConfigurationManagerTest.php:29
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Configuration\FrontendConfigurationManagerTest\setUp
‪setUp()
Definition: FrontendConfigurationManagerTest.php:42
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Configuration\FrontendConfigurationManagerTest\overrideControllerConfigurationWithSwitchableControllerActionsFromFlexFormMergesNonCacheableActions
‪overrideControllerConfigurationWithSwitchableControllerActionsFromFlexFormMergesNonCacheableActions()
Definition: FrontendConfigurationManagerTest.php:65
‪TYPO3\CMS\Extbase\Configuration\Exception\ParseErrorException
Definition: ParseErrorException.php:25
‪TYPO3\CMS\Core\TypoScript\TypoScriptService
Definition: TypoScriptService.php:25
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Configuration\FrontendConfigurationManagerTest\overrideControllerConfigurationWithSwitchableControllerActionsFromFlexFormReturnsUnchangedFrameworkConfigurationIfNoFlexFormConfigurationIsFound
‪overrideControllerConfigurationWithSwitchableControllerActionsFromFlexFormReturnsUnchangedFrameworkConfigurationIfNoFlexFormConfigurationIsFound()
Definition: FrontendConfigurationManagerTest.php:113
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Configuration\FrontendConfigurationManagerTest\overrideControllerConfigurationWithSwitchableControllerActionsThrowsExceptionIfFlexFormConfigurationIsInvalid
‪overrideControllerConfigurationWithSwitchableControllerActionsThrowsExceptionIfFlexFormConfigurationIsInvalid()
Definition: FrontendConfigurationManagerTest.php:142
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25