2 declare(strict_types = 1);
24 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
50 protected function setUp():
void
53 $GLOBALS[
'TSFE']->tmpl = new \stdClass();
54 $this->mockContentObject = $this->getMockBuilder(ContentObjectRenderer::class)
55 ->setMethods([
'getTreeList'])
57 $this->frontendConfigurationManager = $this->getAccessibleMock(FrontendConfigurationManager::class, [
'dummy']);
58 $this->frontendConfigurationManager->_set(
'contentObject', $this->mockContentObject);
59 $this->mockTypoScriptService = $this->getAccessibleMock(TypoScriptService::class);
60 $this->frontendConfigurationManager->_set(
'typoScriptService', $this->mockTypoScriptService);
68 $GLOBALS[
'TSFE']->tmpl->setup = [
'foo' =>
'bar'];
69 $this->assertEquals([
'foo' =>
'bar'], $this->frontendConfigurationManager->_call(
'getTypoScriptSetup'));
77 $GLOBALS[
'TSFE']->tmpl->setup = [
'foo' =>
'bar'];
79 $actualResult = $this->frontendConfigurationManager->_call(
80 'getPluginConfiguration',
84 $this->assertEquals($expectedResult, $actualResult);
97 $testSettingsConverted = [
104 'tx_someextensionname.' => $testSettings
107 $this->mockTypoScriptService->expects($this->any())->method(
'convertTypoScriptArrayToPlainArray')->with($testSettings)->will($this->returnValue($testSettingsConverted));
108 $GLOBALS[
'TSFE']->tmpl->setup = $testSetup;
114 $actualResult = $this->frontendConfigurationManager->_call(
'getPluginConfiguration',
'SomeExtensionName');
115 $this->assertEquals($expectedResult, $actualResult);
128 $testSettingsConverted = [
135 'tx_someextensionname_somepluginname.' => $testSettings
138 $this->mockTypoScriptService->expects($this->any())->method(
'convertTypoScriptArrayToPlainArray')->with($testSettings)->will($this->returnValue($testSettingsConverted));
139 $GLOBALS[
'TSFE']->tmpl->setup = $testSetup;
145 $actualResult = $this->frontendConfigurationManager->_call(
146 'getPluginConfiguration',
150 $this->assertEquals($expectedResult, $actualResult);
158 $testExtensionSettings = [
166 $testExtensionSettingsConverted = [
174 $testPluginSettings = [
177 'nested' =>
'valueOverridde',
182 $testPluginSettingsConverted = [
185 'nested' =>
'valueOverridde',
192 'tx_someextensionname.' => $testExtensionSettings,
193 'tx_someextensionname_somepluginname.' => $testPluginSettings
196 $this->mockTypoScriptService->expects($this->at(0))->method(
'convertTypoScriptArrayToPlainArray')->with($testExtensionSettings)->will($this->returnValue($testExtensionSettingsConverted));
197 $this->mockTypoScriptService->expects($this->at(1))->method(
'convertTypoScriptArrayToPlainArray')->with($testPluginSettings)->will($this->returnValue($testPluginSettingsConverted));
198 $GLOBALS[
'TSFE']->tmpl->setup = $testSetup;
203 'nested' =>
'valueOverridde',
208 $actualResult = $this->frontendConfigurationManager->_call(
209 'getPluginConfiguration',
213 $this->assertEquals($expectedResult, $actualResult);
221 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'] =
null;
222 $expectedResult = [];
223 $actualResult = $this->frontendConfigurationManager->_call(
224 'getSwitchableControllerActions',
228 $this->assertEquals($expectedResult, $actualResult);
236 $testSwitchableControllerActions = [
242 'nonCacheableActions' => [
253 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][
'SomeExtensionName'][
'plugins'][
'SomePluginName'][
'controllers'] = $testSwitchableControllerActions;
254 $expectedResult = $testSwitchableControllerActions;
255 $actualResult = $this->frontendConfigurationManager->_call(
256 'getSwitchableControllerActions',
260 $this->assertEquals($expectedResult, $actualResult);
268 $frameworkConfiguration = [
269 'pluginName' =>
'Pi1',
270 'extensionName' =>
'SomeExtension',
271 'controllerConfiguration' => [
273 'controller' =>
'Controller1',
274 'actions' =>
'action1 , action2'
277 'controller' =>
'Controller2',
278 'actions' =>
'action2 , action1,action3',
279 'nonCacheableActions' =>
'action2, action3'
283 $flexFormConfiguration = [];
284 $actualResult = $this->frontendConfigurationManager->_call(
285 'overrideSwitchableControllerActionsFromFlexForm',
286 $frameworkConfiguration,
287 $flexFormConfiguration
289 $this->assertSame($frameworkConfiguration, $actualResult);
297 $frameworkConfiguration = [
298 'pluginName' =>
'Pi1',
299 'extensionName' =>
'SomeExtension',
300 'controllerConfiguration' => [
302 'actions' => [
'action1 , action2']
305 'actions' => [
'action2',
'action1',
'action3'],
306 'nonCacheableActions' => [
'action2',
'action3']
310 $flexFormConfiguration = [
311 'switchableControllerActions' =>
'Controller1 -> action2;Controller2->action3; Controller2->action1'
314 'pluginName' =>
'Pi1',
315 'extensionName' =>
'SomeExtension',
316 'controllerConfiguration' => [
318 'actions' => [
'action2']
321 'actions' => [
'action3',
'action1'],
322 'nonCacheableActions' => [1 =>
'action3']
326 $actualResult = $this->frontendConfigurationManager->_call(
327 'overrideSwitchableControllerActionsFromFlexForm',
328 $frameworkConfiguration,
329 $flexFormConfiguration
331 $this->assertEquals($expectedResult, $actualResult);
339 $this->expectException(ParseErrorException::class);
340 $this->expectExceptionCode(1257146403);
341 $frameworkConfiguration = [
342 'pluginName' =>
'Pi1',
343 'extensionName' =>
'SomeExtension',
344 'controllerConfiguration' => [
346 'actions' => [
'action1 , action2']
349 'actions' => [
'action2',
'action1',
'action3'],
350 'nonCacheableActions' => [
'action2',
'action3']
354 $flexFormConfiguration = [
355 'switchableControllerActions' =>
'Controller1->;Controller2->action3;Controller2->action1'
357 $this->frontendConfigurationManager->_call(
358 'overrideSwitchableControllerActionsFromFlexForm',
359 $frameworkConfiguration,
360 $flexFormConfiguration
369 $frameworkConfiguration = [
371 'framework' =>
'configuration'
376 'overrideStoragePidIfStartingPointIsSet',
377 'overrideConfigurationFromPlugin',
378 'overrideConfigurationFromFlexForm'
380 $frontendConfigurationManager->expects($this->at(0))->method(
'overrideStoragePidIfStartingPointIsSet')->with($frameworkConfiguration)->will($this->returnValue([
'overridden' =>
'storagePid']));
381 $frontendConfigurationManager->expects($this->at(1))->method(
'overrideConfigurationFromPlugin')->with([
'overridden' =>
'storagePid'])->will($this->returnValue([
'overridden' =>
'pluginConfiguration']));
382 $frontendConfigurationManager->expects($this->at(2))->method(
'overrideConfigurationFromFlexForm')->with([
'overridden' =>
'pluginConfiguration'])->will($this->returnValue([
'overridden' =>
'flexFormConfiguration']));
383 $expectedResult = [
'overridden' =>
'flexFormConfiguration'];
385 'getContextSpecificFrameworkConfiguration',
386 $frameworkConfiguration
388 $this->assertEquals($expectedResult, $actualResult);
396 $storagePid =
'3,5,9';
399 $abstractConfigurationManager = $this->getAccessibleMock(FrontendConfigurationManager::class, [
400 'overrideSwitchableControllerActions',
401 'getContextSpecificFrameworkConfiguration',
402 'getTypoScriptSetup',
403 'getPluginConfiguration',
404 'getSwitchableControllerActions'
407 $cObjectMock = $this->createMock(ContentObjectRenderer::class);
408 $cObjectMock->expects($this->any())
409 ->method(
'getTreeList')
410 ->will($this->onConsecutiveCalls(
'4',
'',
'898,12'));
411 $abstractConfigurationManager->setContentObject($cObjectMock);
413 $expectedResult =
'4,898,12';
414 $actualResult = $abstractConfigurationManager->_call(
'getRecursiveStoragePids', $storagePid, $recursive);
415 $this->assertEquals($expectedResult, $actualResult);
423 $storagePid =
'-3,5,9';
426 $abstractConfigurationManager = $this->getAccessibleMock(FrontendConfigurationManager::class, [
427 'overrideSwitchableControllerActions',
428 'getContextSpecificFrameworkConfiguration',
429 'getTypoScriptSetup',
430 'getPluginConfiguration',
431 'getSwitchableControllerActions'
434 $cObjectMock = $this->createMock(ContentObjectRenderer::class);
435 $cObjectMock->expects($this->any())
436 ->method(
'getTreeList')
437 ->will($this->onConsecutiveCalls(
'3,4',
'',
'898,12'));
438 $abstractConfigurationManager->setContentObject($cObjectMock);
440 $expectedResult =
'3,4,898,12';
441 $actualResult = $abstractConfigurationManager->_call(
'getRecursiveStoragePids', $storagePid, $recursive);
442 $this->assertEquals($expectedResult, $actualResult);
450 $storagePid =
'1,2,3';
453 $abstractConfigurationManager = $this->getAccessibleMock(FrontendConfigurationManager::class, [
454 'overrideSwitchableControllerActions',
455 'getContextSpecificFrameworkConfiguration',
456 'getTypoScriptSetup',
457 'getPluginConfiguration',
458 'getSwitchableControllerActions'
461 $cObjectMock = $this->createMock(ContentObjectRenderer::class);
462 $cObjectMock->expects($this->never())->method(
'getTreeList');
463 $abstractConfigurationManager->setContentObject($cObjectMock);
465 $expectedResult =
'1,2,3';
466 $actualResult = $abstractConfigurationManager->_call(
'getRecursiveStoragePids', $storagePid);
467 $this->assertEquals($expectedResult, $actualResult);
475 $storagePid =
'1,2,3';
478 $abstractConfigurationManager = $this->getAccessibleMock(FrontendConfigurationManager::class, [
479 'overrideSwitchableControllerActions',
480 'getContextSpecificFrameworkConfiguration',
481 'getTypoScriptSetup',
482 'getPluginConfiguration',
483 'getSwitchableControllerActions'
487 $cObjectMock = $this->createMock(ContentObjectRenderer::class);
488 $cObjectMock->expects($this->never())->method(
'getTreeList');
489 $abstractConfigurationManager->setContentObject($cObjectMock);
491 $expectedResult =
'1,2,3';
492 $actualResult = $abstractConfigurationManager->_call(
'getRecursiveStoragePids', $storagePid, $recursive);
493 $this->assertEquals($expectedResult, $actualResult);
503 'storagePid' =>
'0,1,2,3'
507 $frameworkConfiguration = [
'persistence' => [
'storagePid' =>
'98']];
509 [
'persistence' => [
'storagePid' =>
'0,1,2,3']],
510 $this->frontendConfigurationManager->_call(
511 'mergeConfigurationIntoFrameworkConfiguration',
512 $frameworkConfiguration,
524 $this->mockContentObject->expects($this->any())->method(
'getTreeList')->will($this->returnValue(
'1,2,3'));
525 $this->mockContentObject->data = [
'pages' =>
'0',
'recursive' => 1];
527 $frameworkConfiguration = [
'persistence' => [
'storagePid' =>
'98']];
529 [
'persistence' => [
'storagePid' =>
'0,1,2,3']],
530 $this->frontendConfigurationManager->_call(
531 'overrideStoragePidIfStartingPointIsSet',
532 $frameworkConfiguration
542 $this->mockContentObject->expects($this->any())->method(
'getTreeList')->will($this->returnValue(
''));
543 $this->mockContentObject->data = [
'pages' =>
'0',
'recursive' => 1];
545 $frameworkConfiguration = [
'persistence' => [
'storagePid' =>
'98']];
547 [
'persistence' => [
'storagePid' =>
'0']],
548 $this->frontendConfigurationManager->_call(
549 'overrideStoragePidIfStartingPointIsSet',
550 $frameworkConfiguration
561 $flexFormService = $this->getMockBuilder(FlexFormService::class)
562 ->setMethods([
'convertFlexFormContentToArray'])
564 $flexFormService->expects($this->once())->method(
'convertFlexFormContentToArray')->will($this->returnValue([
566 'storagePid' =>
'0,1,2,3'
570 $this->frontendConfigurationManager->_set(
'flexFormService', $flexFormService);
571 $this->mockContentObject->data = [
'pi_flexform' =>
'<XML_ARRAY>'];
573 $frameworkConfiguration = [
'persistence' => [
'storagePid' =>
'98']];
575 [
'persistence' => [
'storagePid' =>
'0,1,2,3']],
576 $this->frontendConfigurationManager->_call(
'overrideConfigurationFromFlexForm', $frameworkConfiguration)
586 $flexFormService = $this->getMockBuilder(FlexFormService::class)
587 ->setMethods([
'convertFlexFormContentToArray'])
589 $flexFormService->expects($this->never())->method(
'convertFlexFormContentToArray');
591 $this->frontendConfigurationManager->_set(
'flexFormService', $flexFormService);
592 $this->mockContentObject->data = [
'pi_flexform' =>
''];
594 $frameworkConfiguration = [
'persistence' => [
'storagePid' =>
'98']];
596 [
'persistence' => [
'storagePid' =>
'98']],
597 $this->frontendConfigurationManager->_call(
'overrideConfigurationFromFlexForm', $frameworkConfiguration)
607 $flexFormService = $this->getMockBuilder(FlexFormService::class)
608 ->setMethods([
'convertFlexFormContentToArray'])
610 $flexFormService->expects($this->never())->method(
'convertFlexFormContentToArray');
612 $this->frontendConfigurationManager->_set(
'flexFormService', $flexFormService);
613 $this->mockContentObject->data = [
'pi_flexform' => [
'persistence' => [
'storagePid' =>
'0,1,2,3']]];
615 $frameworkConfiguration = [
'persistence' => [
'storagePid' =>
'98']];
617 [
'persistence' => [
'storagePid' =>
'0,1,2,3']],
618 $this->frontendConfigurationManager->_call(
'overrideConfigurationFromFlexForm', $frameworkConfiguration)
628 $flexFormService = $this->getMockBuilder(FlexFormService::class)
629 ->setMethods([
'convertFlexFormContentToArray'])
631 $flexFormService->expects($this->never())->method(
'convertFlexFormContentToArray');
633 $this->frontendConfigurationManager->_set(
'flexFormService', $flexFormService);
634 $this->mockContentObject->data = [
'pi_flexform' => []];
636 $frameworkConfiguration = [
'persistence' => [
'storagePid' =>
'98']];
638 [
'persistence' => [
'storagePid' =>
'98']],
639 $this->frontendConfigurationManager->_call(
'overrideConfigurationFromFlexForm', $frameworkConfiguration)
650 FrontendConfigurationManager::class,
651 [
'getTypoScriptSetup']
656 $this->mockTypoScriptService->expects($this->once())->method(
'convertTypoScriptArrayToPlainArray')->will($this->returnValue([
658 'storagePid' =>
'0,1,2,3'
671 'storagePid' =>
'0,1,2,3'
683 $frameworkConfiguration = [
684 'extensionName' =>
'ext',
685 'pluginName' =>
'pi1',
698 'extensionName' =>
'ext',
699 'pluginName' =>
'pi1',
701 'storagePid' =>
'0,1,2,3',