‪TYPO3CMS  ‪main
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\Attributes\Test;
21 use PHPUnit\Framework\MockObject\MockObject;
31 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
32 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
33 
34 final class ‪FrontendConfigurationManagerTest extends UnitTestCase
35 {
36  protected bool ‪$resetSingletonInstances = true;
37 
38  protected ‪FrontendConfigurationManager&MockObject&AccessibleObjectInterface ‪$frontendConfigurationManager;
40 
41  protected array ‪$testTypoScriptSetup = [
42  'foo.' => [
43  'bar' => 'baz',
44  ],
45  'config.' => [
46  'tx_extbase.' => [
47  'settings.' => [
48  'setting1' => 'value1',
49  'setting2' => 'value2',
50  ],
51  'view.' => [
52  'viewSub.' => [
53  'key1' => 'value1',
54  'key2' => 'value2',
55  ],
56  ],
57  ],
58  ],
59  ];
60 
62  'foo' => [
63  'bar' => 'baz',
64  ],
65  'config' => [
66  'tx_extbase' => [
67  'settings' => [
68  'setting1' => 'value1',
69  'setting2' => 'value2',
70  ],
71  'view' => [
72  'viewSub' => [
73  'key1' => 'value1',
74  'key2' => 'value2',
75  ],
76  ],
77  ],
78  ],
79  ];
80 
81  protected array ‪$testPluginConfiguration = [
82  'settings' => [
83  'setting1' => 'overriddenValue1',
84  'setting3' => 'additionalValue',
85  ],
86  'view' => [
87  'viewSub' => [
88  'key1' => 'overridden',
89  'key3' => 'new key',
90  ],
91  ],
92  'persistence' => [
93  'storagePid' => '123',
94  ],
95  ];
96 
97  protected function ‪setUp(): void
98  {
99  parent::setUp();
100  $this->frontendConfigurationManager = $this->getAccessibleMock(FrontendConfigurationManager::class, null, [], '', false);
101  $this->mockTypoScriptService = $this->getMockBuilder(TypoScriptService::class)->getMock();
102  $this->frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
103  $this->frontendConfigurationManager->_set('eventDispatcher', $this->createMock(EventDispatcher::class));
104  }
105 
106  #[Test]
108  {
109  $this->frontendConfigurationManager->_set('configurationCache', ['foo' => 'bar']);
110  $this->frontendConfigurationManager->setConfiguration([]);
111  self::assertEquals([], $this->frontendConfigurationManager->_get('configurationCache'));
112  }
113 
114  #[Test]
116  {
117  $configuration = [
118  'extensionName' => 'SomeExtensionName',
119  'pluginName' => 'SomePluginName',
120  ];
121  $this->frontendConfigurationManager->setConfiguration($configuration);
122  self::assertEquals('SomeExtensionName', $this->frontendConfigurationManager->_get('extensionName'));
123  self::assertEquals('SomePluginName', $this->frontendConfigurationManager->_get('pluginName'));
124  }
125 
126  #[Test]
128  {
129  $configuration = [
130  'foo' => 'bar',
131  'settings.' => ['foo' => 'bar'],
132  'view.' => ['subkey.' => ['subsubkey' => 'subsubvalue']],
133  ];
134  $expectedResult = [
135  'foo' => 'bar',
136  'settings' => ['foo' => 'bar'],
137  'view' => ['subkey' => ['subsubkey' => 'subsubvalue']],
138  ];
139  $this->mockTypoScriptService->expects(self::atLeastOnce())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->willReturn($expectedResult);
140  $this->frontendConfigurationManager->setConfiguration($configuration);
141  self::assertEquals($expectedResult, $this->frontendConfigurationManager->_get('configuration'));
142  }
143 
144  #[Test]
146  {
147  $this->frontendConfigurationManager->_set('extensionName', 'CurrentExtensionName');
148  $this->frontendConfigurationManager->_set('pluginName', 'CurrentPluginName');
149  $this->frontendConfigurationManager->_set('configurationCache', [
150  'currentextensionname_currentpluginname' => ['foo' => 'bar'],
151  'someotherextension_somepluginname' => ['baz' => 'shouldnotbereturned'],
152  ]);
153  $expectedResult = ['foo' => 'bar'];
154  $actualResult = $this->frontendConfigurationManager->getConfiguration();
155  self::assertEquals($expectedResult, $actualResult);
156  }
157 
158  #[Test]
160  {
161  $this->frontendConfigurationManager->_set('configurationCache', [
162  'someextensionname_somepluginname' => ['foo' => 'bar'],
163  'someotherextension_somepluginname' => ['baz' => 'shouldnotbereturned'],
164  ]);
165  $expectedResult = ['foo' => 'bar'];
166  $actualResult = $this->frontendConfigurationManager->getConfiguration('SomeExtensionName', 'SomePluginName');
167  self::assertEquals($expectedResult, $actualResult);
168  }
169 
170  #[Test]
172  {
173  ‪$frontendConfigurationManager = $this->getAccessibleMock(
174  FrontendConfigurationManager::class,
175  [
176  'getContextSpecificFrameworkConfiguration',
177  'getTypoScriptSetup',
178  'getPluginConfiguration',
179  'getControllerConfiguration',
180  'getRecursiveStoragePids',
181  ],
182  [],
183  '',
184  false
185  );
186  ‪$frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
187  ‪$frontendConfigurationManager->_set('extensionName', 'CurrentExtensionName');
188  ‪$frontendConfigurationManager->_set('pluginName', 'CurrentPluginName');
189  ‪$frontendConfigurationManager->expects(self::once())->method('getTypoScriptSetup')->willReturn($this->testTypoScriptSetup);
190  $this->mockTypoScriptService->expects(self::atLeastOnce())->method('convertTypoScriptArrayToPlainArray')->with($this->testTypoScriptSetup['config.']['tx_extbase.'])->willReturn($this->testTypoScriptSetupConverted['config']['tx_extbase']);
191  ‪$frontendConfigurationManager->expects(self::once())->method('getPluginConfiguration')->with(
192  'CurrentExtensionName',
193  'CurrentPluginName'
194  )->willReturn($this->testPluginConfiguration);
195  $expectedResult = [
196  'settings' => [
197  'setting1' => 'overriddenValue1',
198  'setting2' => 'value2',
199  'setting3' => 'additionalValue',
200  ],
201  'view' => [
202  'viewSub' => [
203  'key1' => 'overridden',
204  'key2' => 'value2',
205  'key3' => 'new key',
206  ],
207  ],
208  'persistence' => [
209  'storagePid' => '123',
210  ],
211  'controllerConfiguration' => [],
212  ];
213  ‪$frontendConfigurationManager->expects(self::once())->method('getContextSpecificFrameworkConfiguration')->with($expectedResult)->willReturn($expectedResult);
215  self::assertEquals($expectedResult, $actualResult);
216  }
217 
218  #[Test]
220  {
221  ‪$frontendConfigurationManager = $this->getAccessibleMock(
222  FrontendConfigurationManager::class,
223  [
224  'getContextSpecificFrameworkConfiguration',
225  'getTypoScriptSetup',
226  'getPluginConfiguration',
227  'getControllerConfiguration',
228  'getRecursiveStoragePids',
229  ],
230  [],
231  '',
232  false
233  );
234  ‪$frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
235  ‪$frontendConfigurationManager->expects(self::once())->method('getTypoScriptSetup')->willReturn($this->testTypoScriptSetup);
236  ‪$frontendConfigurationManager->expects(self::once())->method('getPluginConfiguration')->with(
237  'SomeExtensionName',
238  'SomePluginName'
239  )->willReturn($this->testPluginConfiguration);
240  $this->mockTypoScriptService->expects(self::atLeastOnce())->method('convertTypoScriptArrayToPlainArray')->with($this->testTypoScriptSetup['config.']['tx_extbase.'])->willReturn($this->testTypoScriptSetupConverted['config']['tx_extbase']);
241  $expectedResult = [
242  'settings' => [
243  'setting1' => 'overriddenValue1',
244  'setting2' => 'value2',
245  'setting3' => 'additionalValue',
246  ],
247  'view' => [
248  'viewSub' => [
249  'key1' => 'overridden',
250  'key2' => 'value2',
251  'key3' => 'new key',
252  ],
253  ],
254  'persistence' => [
255  'storagePid' => '123',
256  ],
257  'controllerConfiguration' => [],
258  ];
259  ‪$frontendConfigurationManager->expects(self::never())->method('getContextSpecificFrameworkConfiguration');
260  $actualResult = ‪$frontendConfigurationManager->‪getConfiguration('SomeExtensionName', 'SomePluginName');
261  self::assertEquals($expectedResult, $actualResult);
262  }
263 
264  #[Test]
266  {
267  ‪$frontendConfigurationManager = $this->getAccessibleMock(
268  FrontendConfigurationManager::class,
269  [
270  'getContextSpecificFrameworkConfiguration',
271  'getTypoScriptSetup',
272  'getPluginConfiguration',
273  'getControllerConfiguration',
274  'getRecursiveStoragePids',
275  ],
276  [],
277  '',
278  false
279  );
280  ‪$frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
281  ‪$frontendConfigurationManager->expects(self::never())->method('getContextSpecificFrameworkConfiguration');
282  ‪$frontendConfigurationManager->‪getConfiguration('SomeExtensionName', 'SomePluginName');
283  }
284 
285  #[Test]
287  {
288  ‪$frontendConfigurationManager = $this->getAccessibleMock(
289  FrontendConfigurationManager::class,
290  [
291  'getContextSpecificFrameworkConfiguration',
292  'getTypoScriptSetup',
293  'getPluginConfiguration',
294  'getControllerConfiguration',
295  'getRecursiveStoragePids',
296  ],
297  [],
298  '',
299  false
300  );
301  ‪$frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
302  ‪$frontendConfigurationManager->expects(self::once())->method('getTypoScriptSetup')->willReturn($this->testTypoScriptSetup);
303  ‪$frontendConfigurationManager->expects(self::once())->method('getPluginConfiguration')->with()->willReturn($this->testPluginConfiguration);
304  $contextSpecificFrameworkConfiguration = [
305  'context' => [
306  'specific' => 'framework',
307  'conf' => 'iguration',
308  ],
309  ];
310  ‪$frontendConfigurationManager->expects(self::once())->method('getContextSpecificFrameworkConfiguration')->willReturn($contextSpecificFrameworkConfiguration);
312  self::assertEquals($contextSpecificFrameworkConfiguration, $actualResult);
313  }
314 
315  #[Test]
317  {
318  ‪$frontendConfigurationManager = $this->getAccessibleMock(
319  FrontendConfigurationManager::class,
320  [
321  'getContextSpecificFrameworkConfiguration',
322  'getTypoScriptSetup',
323  'getPluginConfiguration',
324  'getControllerConfiguration',
325  'getRecursiveStoragePids',
326  ],
327  [],
328  '',
329  false
330  );
331  ‪$frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
332  ‪$frontendConfigurationManager->_set('extensionName', 'CurrentExtensionName');
333  ‪$frontendConfigurationManager->_set('pluginName', 'CurrentPluginName');
334  ‪$frontendConfigurationManager->expects(self::once())->method('getTypoScriptSetup')->willReturn($this->testTypoScriptSetup);
335  ‪$frontendConfigurationManager->expects(self::once())->method('getPluginConfiguration')->with(
336  'CurrentExtensionName',
337  'CurrentPluginName'
338  )->willReturn($this->testPluginConfiguration);
339  $contextSpecificFrameworkConfiguration = [
340  'context' => [
341  'specific' => 'framework',
342  'conf' => 'iguration',
343  ],
344  ];
345  ‪$frontendConfigurationManager->expects(self::once())->method('getContextSpecificFrameworkConfiguration')->willReturn($contextSpecificFrameworkConfiguration);
347  'CurrentExtensionName',
348  'CurrentPluginName'
349  );
350  self::assertEquals($contextSpecificFrameworkConfiguration, $actualResult);
351  }
352 
353  #[Test]
355  {
356  ‪$frontendConfigurationManager = $this->getAccessibleMock(
357  FrontendConfigurationManager::class,
358  [
359  'getContextSpecificFrameworkConfiguration',
360  'getTypoScriptSetup',
361  'getPluginConfiguration',
362  'getControllerConfiguration',
363  'getRecursiveStoragePids',
364  ],
365  [],
366  '',
367  false
368  );
369  ‪$frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
370  ‪$frontendConfigurationManager->_set('extensionName', 'CurrentExtensionName');
371  ‪$frontendConfigurationManager->_set('pluginName', 'CurrentPluginName');
372  ‪$frontendConfigurationManager->method('getPluginConfiguration')->willReturn(['foo' => 'bar']);
374  ‪$frontendConfigurationManager->‪getConfiguration('SomeOtherExtensionName', 'SomeOtherCurrentPluginName');
375  $expectedResult = [
376  'currentextensionname_currentpluginname',
377  'someotherextensionname_someothercurrentpluginname',
378  ];
379  $actualResult = array_keys(‪$frontendConfigurationManager->_get('configurationCache'));
380  self::assertEquals($expectedResult, $actualResult);
381  }
382 
383  #[Test]
385  {
386  ‪$frontendConfigurationManager = $this->getAccessibleMock(
387  FrontendConfigurationManager::class,
388  [
389  'getContextSpecificFrameworkConfiguration',
390  'getTypoScriptSetup',
391  'getPluginConfiguration',
392  'getControllerConfiguration',
393  'getRecursiveStoragePids',
394  ],
395  [],
396  '',
397  false
398  );
399  ‪$frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
400  $pluginConfiguration = [
401  'persistence' => [
402  'storagePid' => 1,
403  'recursive' => 99,
404  ],
405  ];
406  ‪$frontendConfigurationManager->expects(self::once())->method('getPluginConfiguration')->willReturn($pluginConfiguration);
407  ‪$frontendConfigurationManager->expects(self::once())->method('getRecursiveStoragePids')->with([1]);
408  ‪$frontendConfigurationManager->‪getConfiguration('SomeOtherExtensionName', 'SomeOtherCurrentPluginName');
409  }
410 
411  #[Test]
413  {
414  ‪$frontendConfigurationManager = $this->getAccessibleMock(
415  FrontendConfigurationManager::class,
416  [
417  'getContextSpecificFrameworkConfiguration',
418  'getTypoScriptSetup',
419  'getPluginConfiguration',
420  'getControllerConfiguration',
421  'getRecursiveStoragePids',
422  ],
423  [],
424  '',
425  false
426  );
427  ‪$frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
428  $pluginConfiguration = [
429  'persistence' => [
430  'storagePid' => '1,25',
431  'recursive' => 99,
432  ],
433  ];
434  ‪$frontendConfigurationManager->expects(self::once())->method('getPluginConfiguration')->willReturn($pluginConfiguration);
435  ‪$frontendConfigurationManager->expects(self::once())->method('getRecursiveStoragePids')->with([1, 25]);
436  ‪$frontendConfigurationManager->‪getConfiguration('SomeOtherExtensionName', 'SomeOtherCurrentPluginName');
437  }
438 
439  #[Test]
441  {
442  $frontendTypoScript = new ‪FrontendTypoScript(new ‪RootNode(), [], [], []);
443  $frontendTypoScript->setSetupArray(['foo' => 'bar']);
444  ‪$GLOBALS['TYPO3_REQUEST'] = (new ‪ServerRequest())->withAttribute('frontend.typoscript', $frontendTypoScript);
445  self::assertEquals(['foo' => 'bar'], $this->frontendConfigurationManager->_call('getTypoScriptSetup'));
446  }
447 
448  #[Test]
450  {
451  $frontendTypoScript = new ‪FrontendTypoScript(new ‪RootNode(), [], [], []);
452  $frontendTypoScript->setSetupArray(['foo' => 'bar']);
453  ‪$GLOBALS['TYPO3_REQUEST'] = (new ‪ServerRequest())->withAttribute('frontend.typoscript', $frontendTypoScript);
454  $expectedResult = [];
455  $actualResult = $this->frontendConfigurationManager->_call(
456  'getPluginConfiguration',
457  'SomeExtensionName',
458  'SomePluginName'
459  );
460  self::assertEquals($expectedResult, $actualResult);
461  }
462 
463  #[Test]
465  {
466  $testSettings = [
467  'settings.' => [
468  'foo' => 'bar',
469  ],
470  ];
471  $testSettingsConverted = [
472  'settings' => [
473  'foo' => 'bar',
474  ],
475  ];
476  $testSetup = [
477  'plugin.' => [
478  'tx_someextensionname.' => $testSettings,
479  ],
480  ];
481  $this->mockTypoScriptService->method('convertTypoScriptArrayToPlainArray')->with($testSettings)->willReturn($testSettingsConverted);
482  $frontendTypoScript = new ‪FrontendTypoScript(new ‪RootNode(), [], [], []);
483  $frontendTypoScript->setSetupArray($testSetup);
484  ‪$GLOBALS['TYPO3_REQUEST'] = (new ‪ServerRequest())->withAttribute('frontend.typoscript', $frontendTypoScript);
485  $expectedResult = [
486  'settings' => [
487  'foo' => 'bar',
488  ],
489  ];
490  $actualResult = $this->frontendConfigurationManager->_call('getPluginConfiguration', 'SomeExtensionName');
491  self::assertEquals($expectedResult, $actualResult);
492  }
493 
494  #[Test]
496  {
497  $testSettings = [
498  'settings.' => [
499  'foo' => 'bar',
500  ],
501  ];
502  $testSettingsConverted = [
503  'settings' => [
504  'foo' => 'bar',
505  ],
506  ];
507  $testSetup = [
508  'plugin.' => [
509  'tx_someextensionname_somepluginname.' => $testSettings,
510  ],
511  ];
512  $this->mockTypoScriptService->method('convertTypoScriptArrayToPlainArray')->with($testSettings)->willReturn($testSettingsConverted);
513  $frontendTypoScript = new ‪FrontendTypoScript(new ‪RootNode(), [], [], []);
514  $frontendTypoScript->setSetupArray($testSetup);
515  ‪$GLOBALS['TYPO3_REQUEST'] = (new ‪ServerRequest())->withAttribute('frontend.typoscript', $frontendTypoScript);
516  $expectedResult = [
517  'settings' => [
518  'foo' => 'bar',
519  ],
520  ];
521  $actualResult = $this->frontendConfigurationManager->_call(
522  'getPluginConfiguration',
523  'SomeExtensionName',
524  'SomePluginName'
525  );
526  self::assertEquals($expectedResult, $actualResult);
527  }
528 
529  #[Test]
531  {
532  $testExtensionSettings = [
533  'settings.' => [
534  'foo' => 'bar',
535  'some.' => [
536  'nested' => 'value',
537  ],
538  ],
539  ];
540  $testExtensionSettingsConverted = [
541  'settings' => [
542  'foo' => 'bar',
543  'some' => [
544  'nested' => 'value',
545  ],
546  ],
547  ];
548  $testPluginSettings = [
549  'settings.' => [
550  'some.' => [
551  'nested' => 'valueOverride',
552  'new' => 'value',
553  ],
554  ],
555  ];
556  $testPluginSettingsConverted = [
557  'settings' => [
558  'some' => [
559  'nested' => 'valueOverride',
560  'new' => 'value',
561  ],
562  ],
563  ];
564  $testSetup = [
565  'plugin.' => [
566  'tx_someextensionname.' => $testExtensionSettings,
567  'tx_someextensionname_somepluginname.' => $testPluginSettings,
568  ],
569  ];
570  $series = [
571  [$testExtensionSettings, $testExtensionSettingsConverted],
572  [$testPluginSettings, $testPluginSettingsConverted],
573  ];
574  $this->mockTypoScriptService->expects(self::exactly(2))->method('convertTypoScriptArrayToPlainArray')
575  ->willReturnCallback(function (array $settings) use (&$series): array {
576  $arguments = array_shift($series);
577  self::assertSame($settings, $arguments[0]);
578  return $arguments[1];
579  });
580  $frontendTypoScript = new ‪FrontendTypoScript(new ‪RootNode(), [], [], []);
581  $frontendTypoScript->setSetupArray($testSetup);
582  ‪$GLOBALS['TYPO3_REQUEST'] = (new ‪ServerRequest())->withAttribute('frontend.typoscript', $frontendTypoScript);
583  $expectedResult = [
584  'settings' => [
585  'foo' => 'bar',
586  'some' => [
587  'nested' => 'valueOverride',
588  'new' => 'value',
589  ],
590  ],
591  ];
592  $actualResult = $this->frontendConfigurationManager->_call(
593  'getPluginConfiguration',
594  'SomeExtensionName',
595  'SomePluginName'
596  );
597  self::assertEquals($expectedResult, $actualResult);
598  }
599 
600  #[Test]
602  {
603  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase'] = null;
604  $expectedResult = [];
605  $actualResult = $this->frontendConfigurationManager->_call(
606  'getControllerConfiguration',
607  'SomeExtensionName',
608  'SomePluginName'
609  );
610  self::assertEquals($expectedResult, $actualResult);
611  }
612 
613  #[Test]
615  {
616  $controllerConfiguration = [
617  'Controller1' => [
618  'actions' => [
619  'action1',
620  'action2',
621  ],
622  'nonCacheableActions' => [
623  'action1',
624  ],
625  ],
626  'Controller2' => [
627  'actions' => [
628  'action3',
629  'action4',
630  ],
631  ],
632  ];
633  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['SomeExtensionName']['plugins']['SomePluginName']['controllers'] = $controllerConfiguration;
634  $expectedResult = $controllerConfiguration;
635  $actualResult = $this->frontendConfigurationManager->_call(
636  'getControllerConfiguration',
637  'SomeExtensionName',
638  'SomePluginName'
639  );
640  self::assertEquals($expectedResult, $actualResult);
641  }
642 
643  #[Test]
645  {
646  $frameworkConfiguration = [
647  'some' => [
648  'framework' => 'configuration',
649  ],
650  ];
651  ‪$frontendConfigurationManager = $this->getAccessibleMock(
652  FrontendConfigurationManager::class,
653  [
654  'overrideStoragePidIfStartingPointIsSet',
655  'overrideConfigurationFromPlugin',
656  'overrideConfigurationFromFlexForm',
657  ],
658  [],
659  '',
660  false
661  );
662  ‪$frontendConfigurationManager->expects(self::once())->method('overrideStoragePidIfStartingPointIsSet')->with($frameworkConfiguration)->willReturn(['overridden' => 'storagePid']);
663  ‪$frontendConfigurationManager->expects(self::once())->method('overrideConfigurationFromPlugin')->with(['overridden' => 'storagePid'])->willReturn(['overridden' => 'pluginConfiguration']);
664  ‪$frontendConfigurationManager->expects(self::once())->method('overrideConfigurationFromFlexForm')->with(['overridden' => 'pluginConfiguration'])->willReturn(['overridden' => 'flexFormConfiguration']);
665  $expectedResult = ['overridden' => 'flexFormConfiguration'];
666  $actualResult = ‪$frontendConfigurationManager->_call(
667  'getContextSpecificFrameworkConfiguration',
668  $frameworkConfiguration
669  );
670  self::assertEquals($expectedResult, $actualResult);
671  }
672 
673  #[Test]
675  {
676  $configuration = [
677  'persistence' => [
678  'storagePid' => '0,1,2,3',
679  ],
680  ];
681 
682  $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
683  self::assertSame(
684  ['persistence' => ['storagePid' => '0,1,2,3']],
685  $this->frontendConfigurationManager->_call(
686  'mergeConfigurationIntoFrameworkConfiguration',
687  $frameworkConfiguration,
688  $configuration,
689  'persistence'
690  )
691  );
692  }
693 
694  #[Test]
696  {
697  $contentObject = new ‪ContentObjectRenderer();
698  $contentObject->data = ['pages' => '0', 'recursive' => 1];
699  $request = (new ‪ServerRequest())->withAttribute('currentContentObject', $contentObject);
700  $this->frontendConfigurationManager->setRequest($request);
701 
702  $pageRepositoryMock = $this->createMock(PageRepository::class);
703  $pageRepositoryMock->method('getPageIdsRecursive')->willReturn([0, 1, 2, 3]);
704  $this->frontendConfigurationManager->_set('pageRepository', $pageRepositoryMock);
705  $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
706  self::assertSame(
707  ['persistence' => ['storagePid' => '0,1,2,3']],
708  $this->frontendConfigurationManager->_call(
709  'overrideStoragePidIfStartingPointIsSet',
710  $frameworkConfiguration
711  )
712  );
713  }
714 
715  #[Test]
717  {
718  $contentObject = new ‪ContentObjectRenderer();
719  $contentObject->data = ['pages' => '0', 'recursive' => 1];
720  $request = (new ‪ServerRequest())->withAttribute('currentContentObject', $contentObject);
721  $this->frontendConfigurationManager->setRequest($request);
722 
723  $pageRepositoryMock = $this->createMock(PageRepository::class);
724  $pageRepositoryMock->method('getPageIdsRecursive')->willReturn([0]);
725  $this->frontendConfigurationManager->_set('pageRepository', $pageRepositoryMock);
726 
727  $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
728  self::assertSame(
729  ['persistence' => ['storagePid' => '0']],
730  $this->frontendConfigurationManager->_call(
731  'overrideStoragePidIfStartingPointIsSet',
732  $frameworkConfiguration
733  )
734  );
735  }
736 
737  #[Test]
739  {
740  $flexFormService = $this->getMockBuilder(FlexFormService::class)
741  ->onlyMethods(['convertFlexFormContentToArray'])
742  ->getMock();
743  $flexFormService->expects(self::once())->method('convertFlexFormContentToArray')->willReturn([
744  'persistence' => [
745  'storagePid' => '0,1,2,3',
746  ],
747  ]);
748 
749  $this->frontendConfigurationManager->_set('flexFormService', $flexFormService);
750  $contentObject = new ‪ContentObjectRenderer();
751  $contentObject->data = ['pi_flexform' => '<XML_ARRAY>'];
752  $request = (new ‪ServerRequest())->withAttribute('currentContentObject', $contentObject);
753  $this->frontendConfigurationManager->setRequest($request);
754 
755  $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
756  self::assertSame(
757  ['persistence' => ['storagePid' => '0,1,2,3']],
758  $this->frontendConfigurationManager->_call('overrideConfigurationFromFlexForm', $frameworkConfiguration)
759  );
760  }
761 
762  #[Test]
764  {
765  $flexFormService = $this->getMockBuilder(FlexFormService::class)
766  ->onlyMethods(['convertFlexFormContentToArray'])
767  ->getMock();
768  $flexFormService->expects(self::never())->method('convertFlexFormContentToArray');
769 
770  $this->frontendConfigurationManager->_set('flexFormService', $flexFormService);
771  $contentObject = new ‪ContentObjectRenderer();
772  $contentObject->data = ['pi_flexform' => ''];
773  $request = (new ‪ServerRequest())->withAttribute('currentContentObject', $contentObject);
774  $this->frontendConfigurationManager->setRequest($request);
775 
776  $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
777  self::assertSame(
778  ['persistence' => ['storagePid' => '98']],
779  $this->frontendConfigurationManager->_call('overrideConfigurationFromFlexForm', $frameworkConfiguration)
780  );
781  }
782 
783  #[Test]
785  {
786  $flexFormService = $this->getMockBuilder(FlexFormService::class)
787  ->onlyMethods(['convertFlexFormContentToArray'])
788  ->getMock();
789  $flexFormService->expects(self::never())->method('convertFlexFormContentToArray');
790 
791  $this->frontendConfigurationManager->_set('flexFormService', $flexFormService);
792  $contentObject = new ‪ContentObjectRenderer();
793  $contentObject->data = ['pi_flexform' => ['persistence' => ['storagePid' => '0,1,2,3']]];
794  $request = (new ‪ServerRequest())->withAttribute('currentContentObject', $contentObject);
795  $this->frontendConfigurationManager->setRequest($request);
796 
797  $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
798  self::assertSame(
799  ['persistence' => ['storagePid' => '0,1,2,3']],
800  $this->frontendConfigurationManager->_call('overrideConfigurationFromFlexForm', $frameworkConfiguration)
801  );
802  }
803 
804  #[Test]
806  {
807  $flexFormService = $this->getMockBuilder(FlexFormService::class)
808  ->onlyMethods(['convertFlexFormContentToArray'])
809  ->getMock();
810  $flexFormService->expects(self::never())->method('convertFlexFormContentToArray');
811 
812  $this->frontendConfigurationManager->_set('flexFormService', $flexFormService);
813  $contentObject = new ‪ContentObjectRenderer();
814  $contentObject->data = ['pi_flexform' => []];
815  $request = (new ‪ServerRequest())->withAttribute('currentContentObject', $contentObject);
816  $this->frontendConfigurationManager->setRequest($request);
817 
818  $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
819  self::assertSame(
820  ['persistence' => ['storagePid' => '98']],
821  $this->frontendConfigurationManager->_call('overrideConfigurationFromFlexForm', $frameworkConfiguration)
822  );
823  }
824 
825  #[Test]
827  {
828  ‪$frontendConfigurationManager = $this->getAccessibleMock(
829  FrontendConfigurationManager::class,
830  ['getTypoScriptSetup'],
831  [],
832  '',
833  false
834  );
835  ‪$frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
836 
837  $this->mockTypoScriptService->expects(self::once())->method('convertTypoScriptArrayToPlainArray')->willReturn([
838  'persistence' => [
839  'storagePid' => '0,1,2,3',
840  ],
841  'settings' => [
842  'foo' => 'bar',
843  ],
844  'view' => [
845  'foo' => 'bar',
846  ],
847  ]);
848  ‪$frontendConfigurationManager->method('getTypoScriptSetup')->willReturn([
849  'plugin.' => [
850  'tx_ext_pi1.' => [
851  'persistence.' => [
852  'storagePid' => '0,1,2,3',
853  ],
854  'settings.' => [
855  'foo' => 'bar',
856  ],
857  'view.' => [
858  'foo' => 'bar',
859  ],
860  ],
861  ],
862  ]);
863 
864  $frameworkConfiguration = [
865  'extensionName' => 'ext',
866  'pluginName' => 'pi1',
867  'persistence' => [
868  'storagePid' => '1',
869  ],
870  'settings' => [
871  'foo' => 'qux',
872  ],
873  'view' => [
874  'foo' => 'qux',
875  ],
876  ];
877  self::assertSame(
878  [
879  'extensionName' => 'ext',
880  'pluginName' => 'pi1',
881  'persistence' => [
882  'storagePid' => '0,1,2,3',
883  ],
884  'settings' => [
885  'foo' => 'bar',
886  ],
887  'view' => [
888  'foo' => 'bar',
889  ],
890  ],
891  ‪$frontendConfigurationManager->_call('overrideConfigurationFromPlugin', $frameworkConfiguration)
892  );
893  }
894 }
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getConfigurationOverridesConfigurationWithContextSpecificFrameworkConfigurationIfNoPluginWasSpecified
‪getConfigurationOverridesConfigurationWithContextSpecificFrameworkConfigurationIfNoPluginWasSpecified()
Definition: FrontendConfigurationManagerTest.php:286
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\setConfigurationSetsExtensionAndPluginName
‪setConfigurationSetsExtensionAndPluginName()
Definition: FrontendConfigurationManagerTest.php:115
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\$testTypoScriptSetupConverted
‪array $testTypoScriptSetupConverted
Definition: FrontendConfigurationManagerTest.php:61
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration
Definition: FrontendConfigurationManagerTest.php:18
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getConfigurationRetrievesStoragePidIncludingGivenStoragePidWithRecursiveSetForSingleStoragePid
‪getConfigurationRetrievesStoragePidIncludingGivenStoragePidWithRecursiveSetForSingleStoragePid()
Definition: FrontendConfigurationManagerTest.php:384
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getConfigurationReturnsCachedResultForGivenExtension
‪getConfigurationReturnsCachedResultForGivenExtension()
Definition: FrontendConfigurationManagerTest.php:159
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\overrideStoragePidIfStartingPointIsSetCorrectlyHandlesEmptyValuesFromPageRepository
‪overrideStoragePidIfStartingPointIsSetCorrectlyHandlesEmptyValuesFromPageRepository()
Definition: FrontendConfigurationManagerTest.php:716
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\$mockTypoScriptService
‪TypoScriptService &MockObject $mockTypoScriptService
Definition: FrontendConfigurationManagerTest.php:39
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getControllerConfigurationReturnsEmptyArrayByDefault
‪getControllerConfigurationReturnsEmptyArrayByDefault()
Definition: FrontendConfigurationManagerTest.php:601
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getConfigurationRecursivelyMergesCurrentPluginConfigurationWithFrameworkConfiguration
‪getConfigurationRecursivelyMergesCurrentPluginConfigurationWithFrameworkConfiguration()
Definition: FrontendConfigurationManagerTest.php:171
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\overrideStoragePidIfStartingPointIsSetOverridesCorrectly
‪overrideStoragePidIfStartingPointIsSetOverridesCorrectly()
Definition: FrontendConfigurationManagerTest.php:695
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: FrontendConfigurationManagerTest.php:36
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\setConfigurationConvertsTypoScriptArrayToPlainArray
‪setConfigurationConvertsTypoScriptArrayToPlainArray()
Definition: FrontendConfigurationManagerTest.php:127
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\setConfigurationResetsConfigurationCache
‪setConfigurationResetsConfigurationCache()
Definition: FrontendConfigurationManagerTest.php:107
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\overrideConfigurationFromFlexFormChecksForDataIsStringAndEmpty
‪overrideConfigurationFromFlexFormChecksForDataIsStringAndEmpty()
Definition: FrontendConfigurationManagerTest.php:763
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\$frontendConfigurationManager
‪FrontendConfigurationManager &MockObject &AccessibleObjectInterface $frontendConfigurationManager
Definition: FrontendConfigurationManagerTest.php:38
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getPluginConfigurationRecursivelyMergesExtensionAndPluginConfiguration
‪getPluginConfigurationRecursivelyMergesExtensionAndPluginConfiguration()
Definition: FrontendConfigurationManagerTest.php:530
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getPluginConfigurationReturnsPluginConfiguration
‪getPluginConfigurationReturnsPluginConfiguration()
Definition: FrontendConfigurationManagerTest.php:495
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\mergeConfigurationIntoFrameworkConfigurationWorksAsExpected
‪mergeConfigurationIntoFrameworkConfigurationWorksAsExpected()
Definition: FrontendConfigurationManagerTest.php:674
‪TYPO3\CMS\Core\Service\FlexFormService
Definition: FlexFormService.php:25
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getContextSpecificFrameworkConfigurationCorrectlyCallsOverrideMethods
‪getContextSpecificFrameworkConfigurationCorrectlyCallsOverrideMethods()
Definition: FrontendConfigurationManagerTest.php:644
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\overrideConfigurationFromPluginOverridesCorrectly
‪overrideConfigurationFromPluginOverridesCorrectly()
Definition: FrontendConfigurationManagerTest.php:826
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest
Definition: FrontendConfigurationManagerTest.php:35
‪TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager
Definition: FrontendConfigurationManager.php:38
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\overrideConfigurationFromFlexFormChecksForDataIsString
‪overrideConfigurationFromFlexFormChecksForDataIsString()
Definition: FrontendConfigurationManagerTest.php:738
‪TYPO3\CMS\Core\EventDispatcher\EventDispatcher
Definition: EventDispatcher.php:30
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getPluginConfigurationReturnsEmptyArrayIfNoPluginConfigurationWasFound
‪getPluginConfigurationReturnsEmptyArrayIfNoPluginConfigurationWasFound()
Definition: FrontendConfigurationManagerTest.php:449
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\$testTypoScriptSetup
‪array $testTypoScriptSetup
Definition: FrontendConfigurationManagerTest.php:41
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getConfigurationStoresResultInConfigurationCache
‪getConfigurationStoresResultInConfigurationCache()
Definition: FrontendConfigurationManagerTest.php:354
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getTypoScriptSetupReturnsSetupFromRequest
‪getTypoScriptSetupReturnsSetupFromRequest()
Definition: FrontendConfigurationManagerTest.php:440
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\setUp
‪setUp()
Definition: FrontendConfigurationManagerTest.php:97
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getConfigurationRecursivelyMergesPluginConfigurationOfSpecifiedPluginWithFrameworkConfiguration
‪getConfigurationRecursivelyMergesPluginConfigurationOfSpecifiedPluginWithFrameworkConfiguration()
Definition: FrontendConfigurationManagerTest.php:219
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getConfigurationDoesNotOverrideConfigurationWithContextSpecificFrameworkConfigurationIfDifferentPluginIsSpecified
‪getConfigurationDoesNotOverrideConfigurationWithContextSpecificFrameworkConfigurationIfDifferentPluginIsSpecified()
Definition: FrontendConfigurationManagerTest.php:265
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:39
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\$testPluginConfiguration
‪array $testPluginConfiguration
Definition: FrontendConfigurationManagerTest.php:81
‪TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager\getConfiguration
‪array getConfiguration(?string $extensionName=null, ?string $pluginName=null)
Definition: FrontendConfigurationManager.php:105
‪TYPO3\CMS\Core\TypoScript\TypoScriptService
Definition: TypoScriptService.php:27
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\overrideConfigurationFromFlexFormChecksForDataIsArray
‪overrideConfigurationFromFlexFormChecksForDataIsArray()
Definition: FrontendConfigurationManagerTest.php:784
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getConfigurationRetrievesStoragePidIncludingGivenStoragePidWithRecursiveSetForMultipleStoragePid
‪getConfigurationRetrievesStoragePidIncludingGivenStoragePidWithRecursiveSetForMultipleStoragePid()
Definition: FrontendConfigurationManagerTest.php:412
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\TypoScript\AST\Node\RootNode
Definition: RootNode.php:26
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:102
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getConfigurationReturnsCachedResultOfCurrentPlugin
‪getConfigurationReturnsCachedResultOfCurrentPlugin()
Definition: FrontendConfigurationManagerTest.php:145
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getControllerConfigurationReturnsConfigurationStoredInExtconf
‪getControllerConfigurationReturnsConfigurationStoredInExtconf()
Definition: FrontendConfigurationManagerTest.php:614
‪TYPO3\CMS\Core\Domain\Repository\PageRepository
Definition: PageRepository.php:69
‪TYPO3\CMS\Core\TypoScript\FrontendTypoScript
Definition: FrontendTypoScript.php:30
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getPluginConfigurationReturnsExtensionConfiguration
‪getPluginConfigurationReturnsExtensionConfiguration()
Definition: FrontendConfigurationManagerTest.php:464
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\overrideConfigurationFromFlexFormChecksForDataIsArrayAndEmpty
‪overrideConfigurationFromFlexFormChecksForDataIsArrayAndEmpty()
Definition: FrontendConfigurationManagerTest.php:805
‪TYPO3\CMS\Extbase\Tests\Unit\Configuration\FrontendConfigurationManagerTest\getConfigurationOverridesConfigurationWithContextSpecificFrameworkConfigurationIfSpecifiedPluginIsTheCurrentPlugin
‪getConfigurationOverridesConfigurationWithContextSpecificFrameworkConfigurationIfSpecifiedPluginIsTheCurrentPlugin()
Definition: FrontendConfigurationManagerTest.php:316