16 use Prophecy\Prophecy\ObjectProphecy;
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
39 protected function setUp()
41 $this->backendConfigurationManager = $this->getAccessibleMock(\
TYPO3\CMS\
Extbase\Configuration\BackendConfigurationManager::class, [
'getTypoScriptSetup']);
42 $this->mockTypoScriptService = $this->getAccessibleMock(\
TYPO3\CMS\Core\TypoScript\TypoScriptService::class);
43 $this->backendConfigurationManager->_set(
'typoScriptService', $this->mockTypoScriptService);
52 $expectedResult = 123;
53 $actualResult = $this->backendConfigurationManager->_call(
'getCurrentPageId');
54 $this->assertEquals($expectedResult, $actualResult);
64 $expectedResult = 321;
65 $actualResult = $this->backendConfigurationManager->_call(
'getCurrentPageId');
66 $this->assertEquals($expectedResult, $actualResult);
74 $this->backendConfigurationManager->expects($this->once())->method(
'getTypoScriptSetup')->will($this->returnValue([
'foo' =>
'bar']));
76 $actualResult = $this->backendConfigurationManager->_call(
'getPluginConfiguration',
'SomeExtensionName',
'SomePluginName');
77 $this->assertEquals($expectedResult, $actualResult);
90 $testSettingsConverted = [
97 'tx_someextensionname.' => $testSettings
100 $this->mockTypoScriptService->expects($this->any())->method(
'convertTypoScriptArrayToPlainArray')->with($testSettings)->will($this->returnValue($testSettingsConverted));
101 $this->backendConfigurationManager->expects($this->once())->method(
'getTypoScriptSetup')->will($this->returnValue($testSetup));
107 $actualResult = $this->backendConfigurationManager->_call(
'getPluginConfiguration',
'SomeExtensionName');
108 $this->assertEquals($expectedResult, $actualResult);
121 $testSettingsConverted = [
128 'tx_someextensionname_somepluginname.' => $testSettings
131 $this->mockTypoScriptService->expects($this->any())->method(
'convertTypoScriptArrayToPlainArray')->with($testSettings)->will($this->returnValue($testSettingsConverted));
132 $this->backendConfigurationManager->expects($this->once())->method(
'getTypoScriptSetup')->will($this->returnValue($testSetup));
138 $actualResult = $this->backendConfigurationManager->_call(
'getPluginConfiguration',
'SomeExtensionName',
'SomePluginName');
139 $this->assertEquals($expectedResult, $actualResult);
147 $testExtensionSettings = [
155 $testExtensionSettingsConverted = [
163 $testPluginSettings = [
166 'nested' =>
'valueOverridde',
171 $testPluginSettingsConverted = [
174 'nested' =>
'valueOverridde',
181 'tx_someextensionname.' => $testExtensionSettings,
182 'tx_someextensionname_somepluginname.' => $testPluginSettings
185 $this->mockTypoScriptService->expects($this->at(0))->method(
'convertTypoScriptArrayToPlainArray')->with($testExtensionSettings)->will($this->returnValue($testExtensionSettingsConverted));
186 $this->mockTypoScriptService->expects($this->at(1))->method(
'convertTypoScriptArrayToPlainArray')->with($testPluginSettings)->will($this->returnValue($testPluginSettingsConverted));
187 $this->backendConfigurationManager->expects($this->once())->method(
'getTypoScriptSetup')->will($this->returnValue($testSetup));
192 'nested' =>
'valueOverridde',
197 $actualResult = $this->backendConfigurationManager->_call(
'getPluginConfiguration',
'SomeExtensionName',
'SomePluginName');
198 $this->assertEquals($expectedResult, $actualResult);
206 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'] =
null;
207 $expectedResult = [];
208 $actualResult = $this->backendConfigurationManager->_call(
'getSwitchableControllerActions',
'SomeExtensionName',
'SomePluginName');
209 $this->assertEquals($expectedResult, $actualResult);
217 $testSwitchableControllerActions = [
223 'nonCacheableActions' => [
234 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXTCONF'][
'extbase'][
'extensions'][
'SomeExtensionName'][
'modules'][
'SomePluginName'][
'controllers'] = $testSwitchableControllerActions;
235 $expectedResult = $testSwitchableControllerActions;
236 $actualResult = $this->backendConfigurationManager->_call(
'getSwitchableControllerActions',
'SomeExtensionName',
'SomePluginName');
237 $this->assertEquals($expectedResult, $actualResult);
245 $frameworkConfiguration = [
246 'pluginName' =>
'Pi1',
247 'extensionName' =>
'SomeExtension',
254 'requestHandlers' => [
255 \TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler::class =>
'SomeRequestHandler'
259 $expectedResult = $frameworkConfiguration;
260 $actualResult = $this->backendConfigurationManager->_call(
'getContextSpecificFrameworkConfiguration', $frameworkConfiguration);
261 $this->assertEquals($expectedResult, $actualResult);
269 $frameworkConfiguration = [
270 'pluginName' =>
'Pi1',
271 'extensionName' =>
'SomeExtension',
279 'pluginName' =>
'Pi1',
280 'extensionName' =>
'SomeExtension',
287 'requestHandlers' => [
288 \TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler::class => \TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler::class,
289 \TYPO3\CMS\Extbase\Mvc\Web\BackendRequestHandler::class => \TYPO3\CMS\Extbase\Mvc\Web\BackendRequestHandler::class
293 $actualResult = $this->backendConfigurationManager->_call(
'getContextSpecificFrameworkConfiguration', $frameworkConfiguration);
294 $this->assertEquals($expectedResult, $actualResult);
302 $storagePid =
'1,2,3';
306 $beUserAuthentication = $this->prophesize(\
TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class);
307 $beUserAuthentication->getPagePermsClause(1)->willReturn(
'1=1');
308 $GLOBALS[
'BE_USER'] = $beUserAuthentication->reveal();
310 $abstractConfigurationManager = $this->getAccessibleMock(\
TYPO3\CMS\
Extbase\Configuration\BackendConfigurationManager::class, [
'overrideSwitchableControllerActions',
'getContextSpecificFrameworkConfiguration',
'getTypoScriptSetup',
'getPluginConfiguration',
'getSwitchableControllerActions']);
311 $queryGenerator = $this->createMock(\
TYPO3\CMS\Core\Database\QueryGenerator::class);
312 $queryGenerator->expects($this->any())
313 ->method(
'getTreeList')
314 ->will($this->onConsecutiveCalls(
'4',
'',
'5,6'));
315 GeneralUtility::addInstance(QueryGenerator::class, $queryGenerator);
317 $expectedResult =
'4,5,6';
318 $actualResult = $abstractConfigurationManager->_call(
'getRecursiveStoragePids', $storagePid, $recursive);
319 $this->assertEquals($expectedResult, $actualResult);
327 $storagePid =
'1,2,-3';
331 $beUserAuthentication = $this->prophesize(\
TYPO3\CMS\Core\Authentication\BackendUserAuthentication::class);
332 $beUserAuthentication->getPagePermsClause(1)->willReturn(
'1=1');
333 $GLOBALS[
'BE_USER'] = $beUserAuthentication->reveal();
335 $abstractConfigurationManager = $this->getAccessibleMock(\
TYPO3\CMS\
Extbase\Configuration\BackendConfigurationManager::class, [
'overrideSwitchableControllerActions',
'getContextSpecificFrameworkConfiguration',
'getTypoScriptSetup',
'getPluginConfiguration',
'getSwitchableControllerActions',
'getQueryGenerator']);
336 $queryGenerator = $this->createMock(\
TYPO3\CMS\Core\Database\QueryGenerator::class);
337 $queryGenerator->expects($this->any())
338 ->method(
'getTreeList')
339 ->will($this->onConsecutiveCalls(
'4',
'',
'3,5,6'));
340 GeneralUtility::addInstance(QueryGenerator::class, $queryGenerator);
342 $expectedResult =
'4,3,5,6';
343 $actualResult = $abstractConfigurationManager->_call(
'getRecursiveStoragePids', $storagePid, $recursive);
344 $this->assertEquals($expectedResult, $actualResult);
352 $storagePid =
'1,2,3';
354 $abstractConfigurationManager = $this->getAccessibleMock(\
TYPO3\CMS\
Extbase\Configuration\BackendConfigurationManager::class, [
'overrideSwitchableControllerActions',
'getContextSpecificFrameworkConfiguration',
'getTypoScriptSetup',
'getPluginConfiguration',
'getSwitchableControllerActions']);
356 $expectedResult =
'1,2,3';
357 $actualResult = $abstractConfigurationManager->_call(
'getRecursiveStoragePids', $storagePid);
358 $this->assertEquals($expectedResult, $actualResult);
366 $storagePid =
'1,2,3';
369 $abstractConfigurationManager = $this->getAccessibleMock(\
TYPO3\CMS\
Extbase\Configuration\BackendConfigurationManager::class, [
'overrideSwitchableControllerActions',
'getContextSpecificFrameworkConfiguration',
'getTypoScriptSetup',
'getPluginConfiguration',
'getSwitchableControllerActions']);
371 $expectedResult =
'1,2,3';
372 $actualResult = $abstractConfigurationManager->_call(
'getRecursiveStoragePids', $storagePid, $recursive);
373 $this->assertEquals($expectedResult, $actualResult);