2 declare(strict_types = 1);
22 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
50 'setting1' =>
'value1',
51 'setting2' =>
'value2'
73 'setting1' =>
'value1',
74 'setting2' =>
'value2'
91 'setting1' =>
'overriddenValue1',
92 'setting3' =>
'additionalValue'
96 'key1' =>
'overridden',
101 'storagePid' =>
'123'
110 'actions' => [
'action1',
'action2',
'action3']
113 'actions' => [
'action4',
'action5',
'action6'],
114 'nonCacheableActions' => [
'action4',
'action6']
121 protected function setUp(): void
123 $this->abstractConfigurationManager = $this->getAccessibleMock(
124 AbstractConfigurationManager::class,
126 'getContextSpecificFrameworkConfiguration',
127 'getTypoScriptSetup',
128 'getPluginConfiguration',
129 'getSwitchableControllerActions',
130 'getRecursiveStoragePids'
133 $this->mockTypoScriptService = $this->getAccessibleMock(TypoScriptService::class);
134 $this->abstractConfigurationManager->_set(
'typoScriptService', $this->mockTypoScriptService);
142 $this->abstractConfigurationManager->_set(
'configurationCache', [
'foo' =>
'bar']);
143 $this->abstractConfigurationManager->setConfiguration([]);
144 $this->assertEquals([], $this->abstractConfigurationManager->_get(
'configurationCache'));
153 'extensionName' =>
'SomeExtensionName',
154 'pluginName' =>
'SomePluginName'
156 $this->abstractConfigurationManager->setConfiguration($configuration);
157 $this->assertEquals(
'SomeExtensionName', $this->abstractConfigurationManager->_get(
'extensionName'));
158 $this->assertEquals(
'SomePluginName', $this->abstractConfigurationManager->_get(
'pluginName'));
168 'settings.' => [
'foo' =>
'bar'],
169 'view.' => [
'subkey.' => [
'subsubkey' =>
'subsubvalue']]
173 'settings' => [
'foo' =>
'bar'],
174 'view' => [
'subkey' => [
'subsubkey' =>
'subsubvalue']]
176 $this->mockTypoScriptService->expects($this->atLeastOnce())->method(
'convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($expectedResult));
177 $this->abstractConfigurationManager->setConfiguration($configuration);
178 $this->assertEquals($expectedResult, $this->abstractConfigurationManager->_get(
'configuration'));
186 $this->abstractConfigurationManager->_set(
'extensionName',
'CurrentExtensionName');
187 $this->abstractConfigurationManager->_set(
'pluginName',
'CurrentPluginName');
188 $this->abstractConfigurationManager->_set(
'configurationCache', [
189 'currentextensionname_currentpluginname' => [
'foo' =>
'bar'],
190 'someotherextension_somepluginname' => [
'baz' =>
'shouldnotbereturned']
192 $expectedResult = [
'foo' =>
'bar'];
193 $actualResult = $this->abstractConfigurationManager->getConfiguration();
194 $this->assertEquals($expectedResult, $actualResult);
202 $this->abstractConfigurationManager->_set(
'configurationCache', [
203 'someextensionname_somepluginname' => [
'foo' =>
'bar'],
204 'someotherextension_somepluginname' => [
'baz' =>
'shouldnotbereturned']
206 $expectedResult = [
'foo' =>
'bar'];
207 $actualResult = $this->abstractConfigurationManager->getConfiguration(
'SomeExtensionName',
'SomePluginName');
208 $this->assertEquals($expectedResult, $actualResult);
216 $this->abstractConfigurationManager->_set(
'extensionName',
'CurrentExtensionName');
217 $this->abstractConfigurationManager->_set(
'pluginName',
'CurrentPluginName');
218 $this->abstractConfigurationManager->expects($this->once())->method(
'getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
219 $this->mockTypoScriptService->expects($this->atLeastOnce())->method(
'convertTypoScriptArrayToPlainArray')->with($this->testTypoScriptSetup[
'config.'][
'tx_extbase.'])->will($this->returnValue($this->testTypoScriptSetupConverted[
'config'][
'tx_extbase']));
220 $this->abstractConfigurationManager->expects($this->once())->method(
'getPluginConfiguration')->with(
221 'CurrentExtensionName',
223 )->will($this->returnValue($this->testPluginConfiguration));
226 'setting1' =>
'overriddenValue1',
227 'setting2' =>
'value2',
228 'setting3' =>
'additionalValue'
232 'key1' =>
'overridden',
238 'storagePid' =>
'123'
240 'controllerConfiguration' => null
242 $this->abstractConfigurationManager->expects($this->once())->method(
'getContextSpecificFrameworkConfiguration')->with($expectedResult)->will($this->returnValue($expectedResult));
243 $actualResult = $this->abstractConfigurationManager->getConfiguration();
244 $this->assertEquals($expectedResult, $actualResult);
252 $this->abstractConfigurationManager->expects($this->once())->method(
'getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
253 $this->abstractConfigurationManager->expects($this->once())->method(
'getPluginConfiguration')->with(
256 )->will($this->returnValue($this->testPluginConfiguration));
257 $this->mockTypoScriptService->expects($this->atLeastOnce())->method(
'convertTypoScriptArrayToPlainArray')->with($this->testTypoScriptSetup[
'config.'][
'tx_extbase.'])->will($this->returnValue($this->testTypoScriptSetupConverted[
'config'][
'tx_extbase']));
260 'setting1' =>
'overriddenValue1',
261 'setting2' =>
'value2',
262 'setting3' =>
'additionalValue'
266 'key1' =>
'overridden',
272 'storagePid' =>
'123'
274 'controllerConfiguration' => null
276 $this->abstractConfigurationManager->expects($this->never())->method(
'getContextSpecificFrameworkConfiguration');
277 $actualResult = $this->abstractConfigurationManager->getConfiguration(
'SomeExtensionName',
'SomePluginName');
278 $this->assertEquals($expectedResult, $actualResult);
286 $this->abstractConfigurationManager->expects($this->never())->method(
'getContextSpecificFrameworkConfiguration');
287 $this->abstractConfigurationManager->getConfiguration(
'SomeExtensionName',
'SomePluginName');
295 $this->abstractConfigurationManager->expects($this->once())->method(
'getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
296 $this->abstractConfigurationManager->expects($this->once())->method(
'getPluginConfiguration')->with()->will($this->returnValue($this->testPluginConfiguration));
297 $contextSpecifixFrameworkConfiguration = [
299 'specific' =>
'framwork',
300 'conf' =>
'iguration'
303 $this->abstractConfigurationManager->expects($this->once())->method(
'getContextSpecificFrameworkConfiguration')->will($this->returnValue($contextSpecifixFrameworkConfiguration));
304 $actualResult = $this->abstractConfigurationManager->getConfiguration();
305 $this->assertEquals($contextSpecifixFrameworkConfiguration, $actualResult);
313 $this->abstractConfigurationManager->_set(
'extensionName',
'CurrentExtensionName');
314 $this->abstractConfigurationManager->_set(
'pluginName',
'CurrentPluginName');
315 $this->abstractConfigurationManager->expects($this->once())->method(
'getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
316 $this->abstractConfigurationManager->expects($this->once())->method(
'getPluginConfiguration')->with(
317 'CurrentExtensionName',
319 )->will($this->returnValue($this->testPluginConfiguration));
320 $contextSpecifixFrameworkConfiguration = [
322 'specific' =>
'framwork',
323 'conf' =>
'iguration'
326 $this->abstractConfigurationManager->expects($this->once())->method(
'getContextSpecificFrameworkConfiguration')->will($this->returnValue($contextSpecifixFrameworkConfiguration));
327 $actualResult = $this->abstractConfigurationManager->getConfiguration(
328 'CurrentExtensionName',
331 $this->assertEquals($contextSpecifixFrameworkConfiguration, $actualResult);
339 $this->abstractConfigurationManager->_set(
'extensionName',
'CurrentExtensionName');
340 $this->abstractConfigurationManager->_set(
'pluginName',
'CurrentPluginName');
341 $this->abstractConfigurationManager->expects($this->any())->method(
'getPluginConfiguration')->will($this->returnValue([
'foo' =>
'bar']));
342 $this->abstractConfigurationManager->getConfiguration();
343 $this->abstractConfigurationManager->getConfiguration(
'SomeOtherExtensionName',
'SomeOtherCurrentPluginName');
345 'currentextensionname_currentpluginname',
346 'someotherextensionname_someothercurrentpluginname'
348 $actualResult = array_keys($this->abstractConfigurationManager->_get(
'configurationCache'));
349 $this->assertEquals($expectedResult, $actualResult);
357 $pluginConfiguration = [
363 $this->abstractConfigurationManager->expects($this->once())->method(
'getPluginConfiguration')->will($this->returnValue($pluginConfiguration));
364 $this->abstractConfigurationManager->expects($this->once())->method(
'getRecursiveStoragePids')->with(
'-1');
365 $this->abstractConfigurationManager->getConfiguration(
'SomeOtherExtensionName',
'SomeOtherCurrentPluginName');
373 $pluginConfiguration = [
375 'storagePid' =>
'1,25',
379 $this->abstractConfigurationManager->expects($this->once())->method(
'getPluginConfiguration')->will($this->returnValue($pluginConfiguration));
380 $this->abstractConfigurationManager->expects($this->once())->method(
'getRecursiveStoragePids')->with(
'-1,-25');
381 $this->abstractConfigurationManager->getConfiguration(
'SomeOtherExtensionName',
'SomeOtherCurrentPluginName');
394 AbstractConfigurationManager::class,
396 'overrideSwitchableControllerActions',
397 'getContextSpecificFrameworkConfiguration',
398 'getTypoScriptSetup',
399 'getPluginConfiguration',
400 'getSwitchableControllerActions',
401 'getRecursiveStoragePids'
418 'extensionName' =>
'CurrentExtensionName',
419 'pluginName' =>
'CurrentPluginName',
420 'switchableControllerActions' => [
'overriddenSwitchableControllerActions']
423 AbstractConfigurationManager::class,
425 'overrideSwitchableControllerActions',
426 'getContextSpecificFrameworkConfiguration',
427 'getTypoScriptSetup',
428 'getPluginConfiguration',
429 'getSwitchableControllerActions',
430 'getRecursiveStoragePids'
433 $this->mockTypoScriptService->expects($this->any())->method(
'convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
447 $configuration = [
'switchableControllerActions' => [
'overriddenSwitchableControllerActions']];
449 AbstractConfigurationManager::class,
451 'overrideSwitchableControllerActions',
452 'getContextSpecificFrameworkConfiguration',
453 'getTypoScriptSetup',
454 'getPluginConfiguration',
455 'getSwitchableControllerActions',
456 'getRecursiveStoragePids'
459 $this->mockTypoScriptService->expects($this->any())->method(
'convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
473 'extensionName' =>
'CurrentExtensionName',
474 'pluginName' =>
'CurrentPluginName',
475 'switchableControllerActions' => [
476 'Controller1' => [
'action2',
'action1',
'action3']
479 $this->mockTypoScriptService->expects($this->any())->method(
'convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
480 $this->abstractConfigurationManager->setConfiguration($configuration);
481 $this->abstractConfigurationManager->expects($this->once())->method(
'getPluginConfiguration')->with(
482 'CurrentExtensionName',
484 )->will($this->returnValue($this->testPluginConfiguration));
485 $this->abstractConfigurationManager->expects($this->once())->method(
'getSwitchableControllerActions')->with(
486 'CurrentExtensionName',
488 )->will($this->returnValue($this->testSwitchableControllerActions));
489 $this->abstractConfigurationManager->expects($this->once())->method(
'getContextSpecificFrameworkConfiguration')->will($this->returnCallback(
function (
494 $mergedConfiguration = $this->abstractConfigurationManager->getConfiguration();
497 'actions' => [
'action2',
'action1',
'action3']
500 $actualResult = $mergedConfiguration[
'controllerConfiguration'];
501 $this->assertEquals($expectedResult, $actualResult);
510 'extensionName' =>
'CurrentExtensionName',
511 'pluginName' =>
'CurrentPluginName',
512 'switchableControllerActions' => [
513 'Controller1' => [
'action2',
'action1',
'action3',
'newAction']
516 $this->mockTypoScriptService->expects($this->any())->method(
'convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
517 $this->abstractConfigurationManager->setConfiguration($configuration);
518 $this->abstractConfigurationManager->expects($this->once())->method(
'getPluginConfiguration')->with(
519 'CurrentExtensionName',
521 )->will($this->returnValue($this->testPluginConfiguration));
522 $this->abstractConfigurationManager->expects($this->once())->method(
'getSwitchableControllerActions')->with(
523 'CurrentExtensionName',
525 )->will($this->returnValue($this->testSwitchableControllerActions));
526 $this->abstractConfigurationManager->expects($this->once())->method(
'getContextSpecificFrameworkConfiguration')->will($this->returnCallback(
function (
531 $mergedConfiguration = $this->abstractConfigurationManager->getConfiguration();
534 'actions' => [
'action2',
'action1',
'action3',
'newAction']
537 $actualResult = $mergedConfiguration[
'controllerConfiguration'];
538 $this->assertEquals($expectedResult, $actualResult);
547 'extensionName' =>
'CurrentExtensionName',
548 'pluginName' =>
'CurrentPluginName',
549 'switchableControllerActions' => [
550 'NewController' => [
'action1',
'action2']
553 $this->mockTypoScriptService->expects($this->any())->method(
'convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
554 $this->abstractConfigurationManager->setConfiguration($configuration);
555 $this->abstractConfigurationManager->expects($this->once())->method(
'getPluginConfiguration')->with(
556 'CurrentExtensionName',
558 )->will($this->returnValue($this->testPluginConfiguration));
559 $this->abstractConfigurationManager->expects($this->once())->method(
'getSwitchableControllerActions')->with(
560 'CurrentExtensionName',
562 )->will($this->returnValue($this->testSwitchableControllerActions));
563 $this->abstractConfigurationManager->expects($this->once())->method(
'getContextSpecificFrameworkConfiguration')->will($this->returnCallback(
function (
568 $mergedConfiguration = $this->abstractConfigurationManager->getConfiguration();
569 $expectedResult = [];
570 $actualResult = $mergedConfiguration[
'controllerConfiguration'];
571 $this->assertEquals($expectedResult, $actualResult);
580 'extensionName' =>
'CurrentExtensionName',
581 'pluginName' =>
'CurrentPluginName',
582 'switchableControllerActions' => [
583 'Controller1' => [
'newAction',
'action1'],
584 'Controller2' => [
'newAction2',
'action4',
'action5']
587 $this->mockTypoScriptService->expects($this->any())->method(
'convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
588 $this->abstractConfigurationManager->setConfiguration($configuration);
589 $this->abstractConfigurationManager->expects($this->once())->method(
'getPluginConfiguration')->with(
590 'CurrentExtensionName',
592 )->will($this->returnValue($this->testPluginConfiguration));
593 $this->abstractConfigurationManager->expects($this->once())->method(
'getSwitchableControllerActions')->with(
594 'CurrentExtensionName',
596 )->will($this->returnValue($this->testSwitchableControllerActions));
597 $this->abstractConfigurationManager->expects($this->once())->method(
'getContextSpecificFrameworkConfiguration')->will($this->returnCallback(
function (
602 $mergedConfiguration = $this->abstractConfigurationManager->getConfiguration();
605 'actions' => [
'newAction',
'action1']
608 'actions' => [
'newAction2',
'action4',
'action5'],
609 'nonCacheableActions' => [
'action4']
612 $actualResult = $mergedConfiguration[
'controllerConfiguration'];
613 $this->assertEquals($expectedResult, $actualResult);
621 $this->assertNull($this->abstractConfigurationManager->getContentObject());
630 $mockContentObject = $this->createMock(ContentObjectRenderer::class);
631 $this->abstractConfigurationManager->setContentObject($mockContentObject);
632 $this->assertSame($this->abstractConfigurationManager->getContentObject(), $mockContentObject);