[TASK] Remove unneeded SingletonInstance resets in recent extbase tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Configuration / FrontendConfigurationManagerTest.php
1 <?php
2 declare(strict_types = 1);
3
4 namespace TYPO3\CMS\Extbase\Tests\Unit\Configuration;
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
19 use TYPO3\CMS\Core\Service\FlexFormService;
20 use TYPO3\CMS\Core\TypoScript\TypoScriptService;
21 use TYPO3\CMS\Extbase\Configuration\Exception\ParseErrorException;
22 use TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager;
23 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
24 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26
27 /**
28 * Test case
29 */
30 class FrontendConfigurationManagerTest extends UnitTestCase
31 {
32 /**
33 * @var ContentObjectRenderer|\PHPUnit_Framework_MockObject_MockObject
34 */
35 protected $mockContentObject;
36
37 /**
38 * @var FrontendConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface
39 */
40 protected $frontendConfigurationManager;
41
42 /**
43 * @var TypoScriptService|\PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface
44 */
45 protected $mockTypoScriptService;
46
47 /**
48 * Sets up this testcase
49 */
50 protected function setUp(): void
51 {
52 parent::setUp();
53 $GLOBALS['TSFE'] = new \stdClass();
54 $GLOBALS['TSFE']->tmpl = new \stdClass();
55 $this->mockContentObject = $this->getMockBuilder(ContentObjectRenderer::class)
56 ->setMethods(['getTreeList'])
57 ->getMock();
58 $this->frontendConfigurationManager = $this->getAccessibleMock(
59 FrontendConfigurationManager::class,
60 ['dummy'],
61 [],
62 '',
63 false
64 );
65 $this->frontendConfigurationManager->_set('contentObject', $this->mockContentObject);
66 $this->mockTypoScriptService = $this->getAccessibleMock(TypoScriptService::class);
67 $this->frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
68 }
69
70 /**
71 * @test
72 */
73 public function getTypoScriptSetupReturnsSetupFromTsfe(): void
74 {
75 $GLOBALS['TSFE']->tmpl->setup = ['foo' => 'bar'];
76 $this->assertEquals(['foo' => 'bar'], $this->frontendConfigurationManager->_call('getTypoScriptSetup'));
77 }
78
79 /**
80 * @test
81 */
82 public function getPluginConfigurationReturnsEmptyArrayIfNoPluginConfigurationWasFound(): void
83 {
84 $GLOBALS['TSFE']->tmpl->setup = ['foo' => 'bar'];
85 $expectedResult = [];
86 $actualResult = $this->frontendConfigurationManager->_call(
87 'getPluginConfiguration',
88 'SomeExtensionName',
89 'SomePluginName'
90 );
91 $this->assertEquals($expectedResult, $actualResult);
92 }
93
94 /**
95 * @test
96 */
97 public function getPluginConfigurationReturnsExtensionConfiguration(): void
98 {
99 $testSettings = [
100 'settings.' => [
101 'foo' => 'bar'
102 ]
103 ];
104 $testSettingsConverted = [
105 'settings' => [
106 'foo' => 'bar'
107 ]
108 ];
109 $testSetup = [
110 'plugin.' => [
111 'tx_someextensionname.' => $testSettings
112 ]
113 ];
114 $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($testSettings)->will($this->returnValue($testSettingsConverted));
115 $GLOBALS['TSFE']->tmpl->setup = $testSetup;
116 $expectedResult = [
117 'settings' => [
118 'foo' => 'bar'
119 ]
120 ];
121 $actualResult = $this->frontendConfigurationManager->_call('getPluginConfiguration', 'SomeExtensionName');
122 $this->assertEquals($expectedResult, $actualResult);
123 }
124
125 /**
126 * @test
127 */
128 public function getPluginConfigurationReturnsPluginConfiguration(): void
129 {
130 $testSettings = [
131 'settings.' => [
132 'foo' => 'bar'
133 ]
134 ];
135 $testSettingsConverted = [
136 'settings' => [
137 'foo' => 'bar'
138 ]
139 ];
140 $testSetup = [
141 'plugin.' => [
142 'tx_someextensionname_somepluginname.' => $testSettings
143 ]
144 ];
145 $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($testSettings)->will($this->returnValue($testSettingsConverted));
146 $GLOBALS['TSFE']->tmpl->setup = $testSetup;
147 $expectedResult = [
148 'settings' => [
149 'foo' => 'bar'
150 ]
151 ];
152 $actualResult = $this->frontendConfigurationManager->_call(
153 'getPluginConfiguration',
154 'SomeExtensionName',
155 'SomePluginName'
156 );
157 $this->assertEquals($expectedResult, $actualResult);
158 }
159
160 /**
161 * @test
162 */
163 public function getPluginConfigurationRecursivelyMergesExtensionAndPluginConfiguration(): void
164 {
165 $testExtensionSettings = [
166 'settings.' => [
167 'foo' => 'bar',
168 'some.' => [
169 'nested' => 'value'
170 ]
171 ]
172 ];
173 $testExtensionSettingsConverted = [
174 'settings' => [
175 'foo' => 'bar',
176 'some' => [
177 'nested' => 'value'
178 ]
179 ]
180 ];
181 $testPluginSettings = [
182 'settings.' => [
183 'some.' => [
184 'nested' => 'valueOverridde',
185 'new' => 'value'
186 ]
187 ]
188 ];
189 $testPluginSettingsConverted = [
190 'settings' => [
191 'some' => [
192 'nested' => 'valueOverridde',
193 'new' => 'value'
194 ]
195 ]
196 ];
197 $testSetup = [
198 'plugin.' => [
199 'tx_someextensionname.' => $testExtensionSettings,
200 'tx_someextensionname_somepluginname.' => $testPluginSettings
201 ]
202 ];
203 $this->mockTypoScriptService->expects($this->at(0))->method('convertTypoScriptArrayToPlainArray')->with($testExtensionSettings)->will($this->returnValue($testExtensionSettingsConverted));
204 $this->mockTypoScriptService->expects($this->at(1))->method('convertTypoScriptArrayToPlainArray')->with($testPluginSettings)->will($this->returnValue($testPluginSettingsConverted));
205 $GLOBALS['TSFE']->tmpl->setup = $testSetup;
206 $expectedResult = [
207 'settings' => [
208 'foo' => 'bar',
209 'some' => [
210 'nested' => 'valueOverridde',
211 'new' => 'value'
212 ]
213 ]
214 ];
215 $actualResult = $this->frontendConfigurationManager->_call(
216 'getPluginConfiguration',
217 'SomeExtensionName',
218 'SomePluginName'
219 );
220 $this->assertEquals($expectedResult, $actualResult);
221 }
222
223 /**
224 * @test
225 */
226 public function getSwitchableControllerActionsReturnsEmptyArrayByDefault(): void
227 {
228 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase'] = null;
229 $expectedResult = [];
230 $actualResult = $this->frontendConfigurationManager->_call(
231 'getSwitchableControllerActions',
232 'SomeExtensionName',
233 'SomePluginName'
234 );
235 $this->assertEquals($expectedResult, $actualResult);
236 }
237
238 /**
239 * @test
240 */
241 public function getSwitchableControllerActionsReturnsConfigurationStoredInExtconf(): void
242 {
243 $testSwitchableControllerActions = [
244 'Controller1' => [
245 'actions' => [
246 'action1',
247 'action2'
248 ],
249 'nonCacheableActions' => [
250 'action1'
251 ]
252 ],
253 'Controller2' => [
254 'actions' => [
255 'action3',
256 'action4'
257 ]
258 ]
259 ];
260 $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['SomeExtensionName']['plugins']['SomePluginName']['controllers'] = $testSwitchableControllerActions;
261 $expectedResult = $testSwitchableControllerActions;
262 $actualResult = $this->frontendConfigurationManager->_call(
263 'getSwitchableControllerActions',
264 'SomeExtensionName',
265 'SomePluginName'
266 );
267 $this->assertEquals($expectedResult, $actualResult);
268 }
269
270 /**
271 * @test
272 */
273 public function overrideSwitchableControllerActionsFromFlexFormReturnsUnchangedFrameworkConfigurationIfNoFlexFormConfigurationIsFound(
274 ): void {
275 $frameworkConfiguration = [
276 'pluginName' => 'Pi1',
277 'extensionName' => 'SomeExtension',
278 'controllerConfiguration' => [
279 'Controller1' => [
280 'controller' => 'Controller1',
281 'actions' => 'action1 , action2'
282 ],
283 'Controller2' => [
284 'controller' => 'Controller2',
285 'actions' => 'action2 , action1,action3',
286 'nonCacheableActions' => 'action2, action3'
287 ]
288 ]
289 ];
290 $flexFormConfiguration = [];
291 $actualResult = $this->frontendConfigurationManager->_call(
292 'overrideSwitchableControllerActionsFromFlexForm',
293 $frameworkConfiguration,
294 $flexFormConfiguration
295 );
296 $this->assertSame($frameworkConfiguration, $actualResult);
297 }
298
299 /**
300 * @test
301 */
302 public function overrideSwitchableControllerActionsFromFlexFormMergesNonCacheableActions(): void
303 {
304 $frameworkConfiguration = [
305 'pluginName' => 'Pi1',
306 'extensionName' => 'SomeExtension',
307 'controllerConfiguration' => [
308 'MyExtension\\Controller\\Controller1' => [
309 'alias' => 'Controller1',
310 'actions' => ['action1 , action2']
311 ],
312 'MyExtension\\Controller\\Controller2' => [
313 'alias' => 'Controller2',
314 'actions' => ['action2', 'action1', 'action3'],
315 'nonCacheableActions' => ['action2', 'action3']
316 ]
317 ]
318 ];
319 $flexFormConfiguration = [
320 'switchableControllerActions' => 'Controller1 -> action2;\\MyExtension\\Controller\\Controller2->action3; Controller2->action1'
321 ];
322 $expectedResult = [
323 'pluginName' => 'Pi1',
324 'extensionName' => 'SomeExtension',
325 'controllerConfiguration' => [
326 'MyExtension\\Controller\\Controller1' => [
327 'className' => 'MyExtension\\Controller\\Controller1',
328 'alias' => 'Controller1',
329 'actions' => ['action2']
330 ],
331 'MyExtension\\Controller\\Controller2' => [
332 'className' => 'MyExtension\\Controller\\Controller2',
333 'alias' => 'Controller2',
334 'actions' => ['action3', 'action1'],
335 'nonCacheableActions' => [1 => 'action3']
336 ]
337 ]
338 ];
339 $actualResult = $this->frontendConfigurationManager->_call(
340 'overrideSwitchableControllerActionsFromFlexForm',
341 $frameworkConfiguration,
342 $flexFormConfiguration
343 );
344 $this->assertEquals($expectedResult, $actualResult);
345 }
346
347 /**
348 * @test
349 */
350 public function overrideSwitchableControllerActionsThrowsExceptionIfFlexFormConfigurationIsInvalid(): void
351 {
352 $this->expectException(ParseErrorException::class);
353 $this->expectExceptionCode(1257146403);
354 $frameworkConfiguration = [
355 'pluginName' => 'Pi1',
356 'extensionName' => 'SomeExtension',
357 'controllerConfiguration' => [
358 'Controller1' => [
359 'actions' => ['action1 , action2']
360 ],
361 'Controller2' => [
362 'actions' => ['action2', 'action1', 'action3'],
363 'nonCacheableActions' => ['action2', 'action3']
364 ]
365 ]
366 ];
367 $flexFormConfiguration = [
368 'switchableControllerActions' => 'Controller1->;Controller2->action3;Controller2->action1'
369 ];
370 $this->frontendConfigurationManager->_call(
371 'overrideSwitchableControllerActionsFromFlexForm',
372 $frameworkConfiguration,
373 $flexFormConfiguration
374 );
375 }
376
377 /**
378 * @test
379 */
380 public function getContextSpecificFrameworkConfigurationCorrectlyCallsOverrideMethods(): void
381 {
382 $frameworkConfiguration = [
383 'some' => [
384 'framework' => 'configuration'
385 ]
386 ];
387 /** @var FrontendConfigurationManager|\PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface */
388 $frontendConfigurationManager = $this->getAccessibleMock(
389 FrontendConfigurationManager::class,
390 [
391 'overrideStoragePidIfStartingPointIsSet',
392 'overrideConfigurationFromPlugin',
393 'overrideConfigurationFromFlexForm'
394 ],
395 [],
396 '',
397 false
398 );
399 $frontendConfigurationManager->expects($this->at(0))->method('overrideStoragePidIfStartingPointIsSet')->with($frameworkConfiguration)->will($this->returnValue(['overridden' => 'storagePid']));
400 $frontendConfigurationManager->expects($this->at(1))->method('overrideConfigurationFromPlugin')->with(['overridden' => 'storagePid'])->will($this->returnValue(['overridden' => 'pluginConfiguration']));
401 $frontendConfigurationManager->expects($this->at(2))->method('overrideConfigurationFromFlexForm')->with(['overridden' => 'pluginConfiguration'])->will($this->returnValue(['overridden' => 'flexFormConfiguration']));
402 $expectedResult = ['overridden' => 'flexFormConfiguration'];
403 $actualResult = $frontendConfigurationManager->_call(
404 'getContextSpecificFrameworkConfiguration',
405 $frameworkConfiguration
406 );
407 $this->assertEquals($expectedResult, $actualResult);
408 }
409
410 /**
411 * @test
412 */
413 public function storagePidsAreExtendedIfRecursiveSearchIsConfigured(): void
414 {
415 $storagePids = [3, 5, 9];
416 $recursive = 99;
417 /** @var $abstractConfigurationManager FrontendConfigurationManager */
418 $abstractConfigurationManager = $this->getAccessibleMock(
419 FrontendConfigurationManager::class,
420 [
421 'overrideSwitchableControllerActions',
422 'getContextSpecificFrameworkConfiguration',
423 'getTypoScriptSetup',
424 'getPluginConfiguration',
425 'getSwitchableControllerActions'
426 ],
427 [],
428 '',
429 false
430 );
431 /** @var $cObjectMock ContentObjectRenderer */
432 $cObjectMock = $this->createMock(ContentObjectRenderer::class);
433 $cObjectMock->expects($this->any())
434 ->method('getTreeList')
435 ->will($this->onConsecutiveCalls('4', '', '898,12'));
436 $abstractConfigurationManager->setContentObject($cObjectMock);
437
438 $expectedResult = [4, 898, 12];
439 $actualResult = $abstractConfigurationManager->_call('getRecursiveStoragePids', $storagePids, $recursive);
440 $this->assertEquals($expectedResult, $actualResult);
441 }
442
443 /**
444 * @test
445 */
446 public function storagePidsAreExtendedIfRecursiveSearchIsConfiguredAndWithPidIncludedForNegativePid(): void
447 {
448 $storagePids = [-3, 5, 9];
449 $recursive = 99;
450 /** @var $abstractConfigurationManager FrontendConfigurationManager */
451 $abstractConfigurationManager = $this->getAccessibleMock(
452 FrontendConfigurationManager::class,
453 [
454 'overrideSwitchableControllerActions',
455 'getContextSpecificFrameworkConfiguration',
456 'getTypoScriptSetup',
457 'getPluginConfiguration',
458 'getSwitchableControllerActions'
459 ],
460 [],
461 '',
462 false
463 );
464 /** @var $cObjectMock ContentObjectRenderer */
465 $cObjectMock = $this->createMock(ContentObjectRenderer::class);
466 $cObjectMock->expects($this->any())
467 ->method('getTreeList')
468 ->will($this->onConsecutiveCalls('3,4', '', '898,12'));
469 $abstractConfigurationManager->setContentObject($cObjectMock);
470
471 $expectedResult = [3, 4, 898, 12];
472 $actualResult = $abstractConfigurationManager->_call('getRecursiveStoragePids', $storagePids, $recursive);
473 $this->assertEquals($expectedResult, $actualResult);
474 }
475
476 /**
477 * @test
478 */
479 public function storagePidsAreNotExtendedIfRecursiveSearchIsNotConfigured(): void
480 {
481 $storagePids = [1, 2, 3];
482
483 /** @var $abstractConfigurationManager FrontendConfigurationManager */
484 $abstractConfigurationManager = $this->getAccessibleMock(
485 FrontendConfigurationManager::class,
486 [
487 'overrideSwitchableControllerActions',
488 'getContextSpecificFrameworkConfiguration',
489 'getTypoScriptSetup',
490 'getPluginConfiguration',
491 'getSwitchableControllerActions'
492 ],
493 [],
494 '',
495 false
496 );
497 /** @var $cObjectMock ContentObjectRenderer */
498 $cObjectMock = $this->createMock(ContentObjectRenderer::class);
499 $cObjectMock->expects($this->never())->method('getTreeList');
500 $abstractConfigurationManager->setContentObject($cObjectMock);
501
502 $expectedResult = [1, 2, 3];
503 $actualResult = $abstractConfigurationManager->_call('getRecursiveStoragePids', $storagePids);
504 $this->assertEquals($expectedResult, $actualResult);
505 }
506
507 /**
508 * @test
509 */
510 public function storagePidsAreNotExtendedIfRecursiveSearchIsConfiguredForZeroLevels(): void
511 {
512 $storagePids = [1, 2, 3];
513 $recursive = 0;
514
515 $abstractConfigurationManager = $this->getAccessibleMock(
516 FrontendConfigurationManager::class,
517 [
518 'overrideSwitchableControllerActions',
519 'getContextSpecificFrameworkConfiguration',
520 'getTypoScriptSetup',
521 'getPluginConfiguration',
522 'getSwitchableControllerActions'
523 ],
524 [],
525 '',
526 false
527 );
528
529 /** @var $cObjectMock ContentObjectRenderer */
530 $cObjectMock = $this->createMock(ContentObjectRenderer::class);
531 $cObjectMock->expects($this->never())->method('getTreeList');
532 $abstractConfigurationManager->setContentObject($cObjectMock);
533
534 $expectedResult = [1, 2, 3];
535 $actualResult = $abstractConfigurationManager->_call('getRecursiveStoragePids', $storagePids, $recursive);
536 $this->assertEquals($expectedResult, $actualResult);
537 }
538
539 /**
540 * @test
541 */
542 public function mergeConfigurationIntoFrameworkConfigurationWorksAsExpected(): void
543 {
544 $configuration = [
545 'persistence' => [
546 'storagePid' => '0,1,2,3'
547 ]
548 ];
549
550 $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
551 $this->assertSame(
552 ['persistence' => ['storagePid' => '0,1,2,3']],
553 $this->frontendConfigurationManager->_call(
554 'mergeConfigurationIntoFrameworkConfiguration',
555 $frameworkConfiguration,
556 $configuration,
557 'persistence'
558 )
559 );
560 }
561
562 /**
563 * @test
564 */
565 public function overrideStoragePidIfStartingPointIsSetOverridesCorrectly(): void
566 {
567 $this->mockContentObject->expects($this->any())->method('getTreeList')->will($this->returnValue('1,2,3'));
568 $this->mockContentObject->data = ['pages' => '0', 'recursive' => 1];
569
570 $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
571 $this->assertSame(
572 ['persistence' => ['storagePid' => '0,1,2,3']],
573 $this->frontendConfigurationManager->_call(
574 'overrideStoragePidIfStartingPointIsSet',
575 $frameworkConfiguration
576 )
577 );
578 }
579
580 /**
581 * @test
582 */
583 public function overrideStoragePidIfStartingPointIsSetCorrectlyHandlesEmptyValuesFromGetTreeList(): void
584 {
585 $this->mockContentObject->expects($this->any())->method('getTreeList')->will($this->returnValue(''));
586 $this->mockContentObject->data = ['pages' => '0', 'recursive' => 1];
587
588 $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
589 $this->assertSame(
590 ['persistence' => ['storagePid' => '0']],
591 $this->frontendConfigurationManager->_call(
592 'overrideStoragePidIfStartingPointIsSet',
593 $frameworkConfiguration
594 )
595 );
596 }
597
598 /**
599 * @test
600 */
601 public function overrideConfigurationFromFlexFormChecksForDataIsString(): void
602 {
603 /** @var $flexFormService FlexFormService|\PHPUnit_Framework_MockObject_MockObject */
604 $flexFormService = $this->getMockBuilder(FlexFormService::class)
605 ->setMethods(['convertFlexFormContentToArray'])
606 ->getMock();
607 $flexFormService->expects($this->once())->method('convertFlexFormContentToArray')->will($this->returnValue([
608 'persistence' => [
609 'storagePid' => '0,1,2,3'
610 ]
611 ]));
612
613 $this->frontendConfigurationManager->_set('flexFormService', $flexFormService);
614 $this->mockContentObject->data = ['pi_flexform' => '<XML_ARRAY>'];
615
616 $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
617 $this->assertSame(
618 ['persistence' => ['storagePid' => '0,1,2,3']],
619 $this->frontendConfigurationManager->_call('overrideConfigurationFromFlexForm', $frameworkConfiguration)
620 );
621 }
622
623 /**
624 * @test
625 */
626 public function overrideConfigurationFromFlexFormChecksForDataIsStringAndEmpty(): void
627 {
628 /** @var $flexFormService FlexFormService|\PHPUnit_Framework_MockObject_MockObject */
629 $flexFormService = $this->getMockBuilder(FlexFormService::class)
630 ->setMethods(['convertFlexFormContentToArray'])
631 ->getMock();
632 $flexFormService->expects($this->never())->method('convertFlexFormContentToArray');
633
634 $this->frontendConfigurationManager->_set('flexFormService', $flexFormService);
635 $this->mockContentObject->data = ['pi_flexform' => ''];
636
637 $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
638 $this->assertSame(
639 ['persistence' => ['storagePid' => '98']],
640 $this->frontendConfigurationManager->_call('overrideConfigurationFromFlexForm', $frameworkConfiguration)
641 );
642 }
643
644 /**
645 * @test
646 */
647 public function overrideConfigurationFromFlexFormChecksForDataIsArray(): void
648 {
649 /** @var $flexFormService FlexFormService|\PHPUnit_Framework_MockObject_MockObject */
650 $flexFormService = $this->getMockBuilder(FlexFormService::class)
651 ->setMethods(['convertFlexFormContentToArray'])
652 ->getMock();
653 $flexFormService->expects($this->never())->method('convertFlexFormContentToArray');
654
655 $this->frontendConfigurationManager->_set('flexFormService', $flexFormService);
656 $this->mockContentObject->data = ['pi_flexform' => ['persistence' => ['storagePid' => '0,1,2,3']]];
657
658 $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
659 $this->assertSame(
660 ['persistence' => ['storagePid' => '0,1,2,3']],
661 $this->frontendConfigurationManager->_call('overrideConfigurationFromFlexForm', $frameworkConfiguration)
662 );
663 }
664
665 /**
666 * @test
667 */
668 public function overrideConfigurationFromFlexFormChecksForDataIsArrayAndEmpty(): void
669 {
670 /** @var $flexFormService FlexFormService|\PHPUnit_Framework_MockObject_MockObject */
671 $flexFormService = $this->getMockBuilder(FlexFormService::class)
672 ->setMethods(['convertFlexFormContentToArray'])
673 ->getMock();
674 $flexFormService->expects($this->never())->method('convertFlexFormContentToArray');
675
676 $this->frontendConfigurationManager->_set('flexFormService', $flexFormService);
677 $this->mockContentObject->data = ['pi_flexform' => []];
678
679 $frameworkConfiguration = ['persistence' => ['storagePid' => '98']];
680 $this->assertSame(
681 ['persistence' => ['storagePid' => '98']],
682 $this->frontendConfigurationManager->_call('overrideConfigurationFromFlexForm', $frameworkConfiguration)
683 );
684 }
685
686 /**
687 * @test
688 */
689 public function overrideConfigurationFromPluginOverridesCorrectly(): void
690 {
691 /** @var $frontendConfigurationManager FrontendConfigurationManager */
692 $frontendConfigurationManager = $this->getAccessibleMock(
693 FrontendConfigurationManager::class,
694 ['getTypoScriptSetup'],
695 [],
696 '',
697 false
698 );
699 $frontendConfigurationManager->_set('contentObject', $this->mockContentObject);
700 $frontendConfigurationManager->_set('typoScriptService', $this->mockTypoScriptService);
701
702 $this->mockTypoScriptService->expects($this->once())->method('convertTypoScriptArrayToPlainArray')->will($this->returnValue([
703 'persistence' => [
704 'storagePid' => '0,1,2,3'
705 ],
706 'settings' => [
707 'foo' => 'bar'
708 ],
709 'view' => [
710 'foo' => 'bar'
711 ],
712 ]));
713 $frontendConfigurationManager->expects($this->any())->method('getTypoScriptSetup')->will($this->returnValue([
714 'plugin.' => [
715 'tx_ext_pi1.' => [
716 'persistence.' => [
717 'storagePid' => '0,1,2,3'
718 ],
719 'settings.' => [
720 'foo' => 'bar'
721 ],
722 'view.' => [
723 'foo' => 'bar'
724 ],
725 ]
726 ]
727 ]));
728
729 $frameworkConfiguration = [
730 'extensionName' => 'ext',
731 'pluginName' => 'pi1',
732 'persistence' => [
733 'storagePid' => '1'
734 ],
735 'settings' => [
736 'foo' => 'qux'
737 ],
738 'view' => [
739 'foo' => 'qux'
740 ],
741 ];
742 $this->assertSame(
743 [
744 'extensionName' => 'ext',
745 'pluginName' => 'pi1',
746 'persistence' => [
747 'storagePid' => '0,1,2,3',
748 ],
749 'settings' => [
750 'foo' => 'bar'
751 ],
752 'view' => [
753 'foo' => 'bar'
754 ],
755 ],
756 $frontendConfigurationManager->_call('overrideConfigurationFromPlugin', $frameworkConfiguration)
757 );
758 }
759 }