[TASK] Namespace classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Configuration / FrontendConfigurationManagerTest.php
index 61c63e7..380477e 100644 (file)
@@ -1,44 +1,45 @@
 <?php
 <?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
-*  All rights reserved
-*
-*  This class is a backport of the corresponding class of FLOW3.
-*  All credits go to the v5 team.
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
+namespace TYPO3\CMS\Extbase\Tests\Unit\Configuration;
 
 
-class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2009 Jochen Rau <jochen.rau@typoplanet.de>
+ *  All rights reserved
+ *
+ *  This class is a backport of the corresponding class of FLOW3.
+ *  All credits go to the v5 team.
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+class FrontendConfigurationManagerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
 
        /**
 
        /**
-        * @var tslib_fe
+        * @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
         */
        protected $tsfeBackup;
 
        /**
         */
        protected $tsfeBackup;
 
        /**
-        * @var tslib_cObj
+        * @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
         */
        protected $mockContentObject;
 
        /**
         */
        protected $mockContentObject;
 
        /**
-        * @var Tx_Extbase_Configuration_FrontendConfigurationManager
+        * @var \TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager
         */
        protected $frontendConfigurationManager;
 
         */
        protected $frontendConfigurationManager;
 
@@ -48,14 +49,21 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
        protected $extConfBackup;
 
        /**
        protected $extConfBackup;
 
        /**
+        * @var \TYPO3\CMS\Extbase\Service\TypoScriptService
+        */
+       protected $mockTypoScriptService;
+
+       /**
         * Sets up this testcase
         */
        public function setUp() {
                $this->tsfeBackup = $GLOBALS['TSFE'];
         * Sets up this testcase
         */
        public function setUp() {
                $this->tsfeBackup = $GLOBALS['TSFE'];
-               $this->mockContentObject = $this->getMock('tslib_cObj');
+               $this->mockContentObject = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
                $this->extConfBackup = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase'];
                $this->extConfBackup = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase'];
-               $this->frontendConfigurationManager = $this->getAccessibleMock('Tx_Extbase_Configuration_FrontendConfigurationManager', array('dummy'));
+               $this->frontendConfigurationManager = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Configuration\\FrontendConfigurationManager', array('dummy'));
                $this->frontendConfigurationManager->_set('contentObject', $this->mockContentObject);
                $this->frontendConfigurationManager->_set('contentObject', $this->mockContentObject);
+               $this->mockTypoScriptService = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService');
+               $this->frontendConfigurationManager->injectTypoScriptService($this->mockTypoScriptService);
        }
 
        /**
        }
 
        /**
@@ -69,7 +77,7 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
        /**
         * @test
         */
        /**
         * @test
         */
-       public function getTypoScriptSetupReturnsSetupFromTSFE() {
+       public function getTypoScriptSetupReturnsSetupFromTsfe() {
                $GLOBALS['TSFE']->tmpl->setup = array('foo' => 'bar');
                $this->assertEquals(array('foo' => 'bar'), $this->frontendConfigurationManager->_call('getTypoScriptSetup'));
        }
                $GLOBALS['TSFE']->tmpl->setup = array('foo' => 'bar');
                $this->assertEquals(array('foo' => 'bar'), $this->frontendConfigurationManager->_call('getTypoScriptSetup'));
        }
@@ -88,22 +96,29 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
         * @test
         */
        public function getPluginConfigurationReturnsExtensionConfiguration() {
         * @test
         */
        public function getPluginConfigurationReturnsExtensionConfiguration() {
+               $testSettings = array(
+                       'settings.' => array(
+                               'foo' => 'bar'
+                       )
+               );
+               $testSettingsConverted = array(
+                       'settings' => array(
+                               'foo' => 'bar'
+                       )
+               );
                $testSetup = array(
                        'plugin.' => array(
                $testSetup = array(
                        'plugin.' => array(
-                               'tx_someextensionname.' => array(
-                                       'settings.' => array(
-                                               'foo' => 'bar'
-                                       )
-                               ),
-                       ),
+                               'tx_someextensionname.' => $testSettings
+                       )
                );
                );
+               $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($testSettings)->will($this->returnValue($testSettingsConverted));
                $GLOBALS['TSFE']->tmpl->setup = $testSetup;
                $expectedResult = array(
                        'settings' => array(
                                'foo' => 'bar'
                        )
                );
                $GLOBALS['TSFE']->tmpl->setup = $testSetup;
                $expectedResult = array(
                        'settings' => array(
                                'foo' => 'bar'
                        )
                );
-               $actualResult = $this->frontendConfigurationManager->_call('getPluginConfiguration', 'SomeExtensionName', 'SomePluginName');
+               $actualResult = $this->frontendConfigurationManager->_call('getPluginConfiguration', 'SomeExtensionName');
                $this->assertEquals($expectedResult, $actualResult);
        }
 
                $this->assertEquals($expectedResult, $actualResult);
        }
 
@@ -111,15 +126,22 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
         * @test
         */
        public function getPluginConfigurationReturnsPluginConfiguration() {
         * @test
         */
        public function getPluginConfigurationReturnsPluginConfiguration() {
+               $testSettings = array(
+                       'settings.' => array(
+                               'foo' => 'bar'
+                       )
+               );
+               $testSettingsConverted = array(
+                       'settings' => array(
+                               'foo' => 'bar'
+                       )
+               );
                $testSetup = array(
                        'plugin.' => array(
                $testSetup = array(
                        'plugin.' => array(
-                               'tx_someextensionname_somepluginname.' => array(
-                                       'settings.' => array(
-                                               'foo' => 'bar'
-                                       )
-                               ),
-                       ),
+                               'tx_someextensionname_somepluginname.' => $testSettings
+                       )
                );
                );
+               $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($testSettings)->will($this->returnValue($testSettingsConverted));
                $GLOBALS['TSFE']->tmpl->setup = $testSetup;
                $expectedResult = array(
                        'settings' => array(
                $GLOBALS['TSFE']->tmpl->setup = $testSetup;
                $expectedResult = array(
                        'settings' => array(
@@ -134,26 +156,46 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
         * @test
         */
        public function getPluginConfigurationRecursivelyMergesExtensionAndPluginConfiguration() {
         * @test
         */
        public function getPluginConfigurationRecursivelyMergesExtensionAndPluginConfiguration() {
+               $testExtensionSettings = array(
+                       'settings.' => array(
+                               'foo' => 'bar',
+                               'some.' => array(
+                                       'nested' => 'value'
+                               )
+                       )
+               );
+               $testExtensionSettingsConverted = array(
+                       'settings' => array(
+                               'foo' => 'bar',
+                               'some' => array(
+                                       'nested' => 'value'
+                               )
+                       )
+               );
+               $testPluginSettings = array(
+                       'settings.' => array(
+                               'some.' => array(
+                                       'nested' => 'valueOverridde',
+                                       'new' => 'value'
+                               )
+                       )
+               );
+               $testPluginSettingsConverted = array(
+                       'settings' => array(
+                               'some' => array(
+                                       'nested' => 'valueOverridde',
+                                       'new' => 'value'
+                               )
+                       )
+               );
                $testSetup = array(
                        'plugin.' => array(
                $testSetup = array(
                        'plugin.' => array(
-                               'tx_someextensionname.' => array(
-                                       'settings.' => array(
-                                               'foo' => 'bar',
-                                               'some.' => array(
-                                                       'nested' => 'value'
-                                               ),
-                                       ),
-                               ),
-                               'tx_someextensionname_somepluginname.' => array(
-                                       'settings.' => array(
-                                               'some.' => array(
-                                                       'nested' => 'valueOverridde',
-                                                       'new' => 'value',
-                                               ),
-                                       ),
-                               ),
-                       ),
+                               'tx_someextensionname.' => $testExtensionSettings,
+                               'tx_someextensionname_somepluginname.' => $testPluginSettings
+                       )
                );
                );
+               $this->mockTypoScriptService->expects($this->at(0))->method('convertTypoScriptArrayToPlainArray')->with($testExtensionSettings)->will($this->returnValue($testExtensionSettingsConverted));
+               $this->mockTypoScriptService->expects($this->at(1))->method('convertTypoScriptArrayToPlainArray')->with($testPluginSettings)->will($this->returnValue($testPluginSettingsConverted));
                $GLOBALS['TSFE']->tmpl->setup = $testSetup;
                $expectedResult = array(
                        'settings' => array(
                $GLOBALS['TSFE']->tmpl->setup = $testSetup;
                $expectedResult = array(
                        'settings' => array(
@@ -161,8 +203,8 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
                                'some' => array(
                                        'nested' => 'valueOverridde',
                                        'new' => 'value'
                                'some' => array(
                                        'nested' => 'valueOverridde',
                                        'new' => 'value'
-                               ),
-                       ),
+                               )
+                       )
                );
                $actualResult = $this->frontendConfigurationManager->_call('getPluginConfiguration', 'SomeExtensionName', 'SomePluginName');
                $this->assertEquals($expectedResult, $actualResult);
                );
                $actualResult = $this->frontendConfigurationManager->_call('getPluginConfiguration', 'SomeExtensionName', 'SomePluginName');
                $this->assertEquals($expectedResult, $actualResult);
@@ -185,16 +227,18 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
                $testSwitchableControllerActions = array(
                        'Controller1' => array(
                                'actions' => array(
                $testSwitchableControllerActions = array(
                        'Controller1' => array(
                                'actions' => array(
-                                       'action1', 'action2'
+                                       'action1',
+                                       'action2'
                                ),
                                'nonCacheableActions' => array(
                                        'action1'
                                ),
                                'nonCacheableActions' => array(
                                        'action1'
-                               ),
+                               )
                        ),
                        'Controller2' => array(
                                'actions' => array(
                        ),
                        'Controller2' => array(
                                'actions' => array(
-                                       'action3', 'action4'
-                               ),
+                                       'action3',
+                                       'action4'
+                               )
                        )
                );
                $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['SomeExtensionName']['plugins']['SomePluginName']['controllers'] = $testSwitchableControllerActions;
                        )
                );
                $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['SomeExtensionName']['plugins']['SomePluginName']['controllers'] = $testSwitchableControllerActions;
@@ -239,7 +283,7 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
                                        'actions' => array('action1 , action2')
                                ),
                                'Controller2' => array(
                                        'actions' => array('action1 , action2')
                                ),
                                'Controller2' => array(
-                                       'actions' => array('action2', 'action1','action3'),
+                                       'actions' => array('action2', 'action1', 'action3'),
                                        'nonCacheableActions' => array('action2', 'action3')
                                )
                        )
                                        'nonCacheableActions' => array('action2', 'action3')
                                )
                        )
@@ -252,11 +296,11 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
                        'extensionName' => 'SomeExtension',
                        'controllerConfiguration' => array(
                                'Controller1' => array(
                        'extensionName' => 'SomeExtension',
                        'controllerConfiguration' => array(
                                'Controller1' => array(
-                                       'actions' => array('action2'),
+                                       'actions' => array('action2')
                                ),
                                'Controller2' => array(
                                        'actions' => array('action3', 'action1'),
                                ),
                                'Controller2' => array(
                                        'actions' => array('action3', 'action1'),
-                                       'nonCacheableActions' => array(1 => 'action3'),
+                                       'nonCacheableActions' => array(1 => 'action3')
                                )
                        )
                );
                                )
                        )
                );
@@ -266,7 +310,7 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
 
        /**
         * @test
 
        /**
         * @test
-        * @expectedException Tx_Extbase_Configuration_Exception_ParseError
+        * @expectedException \TYPO3\CMS\Extbase\Configuration\Exception\ParseError
         */
        public function overrideSwitchableControllerActionsThrowsExceptionIfFlexFormConfigurationIsInvalid() {
                $frameworkConfiguration = array(
         */
        public function overrideSwitchableControllerActionsThrowsExceptionIfFlexFormConfigurationIsInvalid() {
                $frameworkConfiguration = array(
@@ -277,7 +321,7 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
                                        'actions' => array('action1 , action2')
                                ),
                                'Controller2' => array(
                                        'actions' => array('action1 , action2')
                                ),
                                'Controller2' => array(
-                                       'actions' => array('action2', 'action1','action3'),
+                                       'actions' => array('action2', 'action1', 'action3'),
                                        'nonCacheableActions' => array('action2', 'action3')
                                )
                        )
                                        'nonCacheableActions' => array('action2', 'action3')
                                )
                        )
@@ -295,9 +339,9 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
                $frameworkConfiguration = array(
                        'some' => array(
                                'framework' => 'configuration'
                $frameworkConfiguration = array(
                        'some' => array(
                                'framework' => 'configuration'
-                       ),
+                       )
                );
                );
-               $frontendConfigurationManager = $this->getAccessibleMock('Tx_Extbase_Configuration_FrontendConfigurationManager', array('overrideStoragePidIfStartingPointIsSet', 'overrideConfigurationFromPlugin', 'overrideConfigurationFromFlexForm'));
+               $frontendConfigurationManager = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Configuration\\FrontendConfigurationManager', array('overrideStoragePidIfStartingPointIsSet', 'overrideConfigurationFromPlugin', 'overrideConfigurationFromFlexForm'));
                $frontendConfigurationManager->expects($this->at(0))->method('overrideStoragePidIfStartingPointIsSet')->with($frameworkConfiguration)->will($this->returnValue(array('overridden' => 'storagePid')));
                $frontendConfigurationManager->expects($this->at(1))->method('overrideConfigurationFromPlugin')->with(array('overridden' => 'storagePid'))->will($this->returnValue(array('overridden' => 'pluginConfiguration')));
                $frontendConfigurationManager->expects($this->at(2))->method('overrideConfigurationFromFlexForm')->with(array('overridden' => 'pluginConfiguration'))->will($this->returnValue(array('overridden' => 'flexFormConfiguration')));
                $frontendConfigurationManager->expects($this->at(0))->method('overrideStoragePidIfStartingPointIsSet')->with($frameworkConfiguration)->will($this->returnValue(array('overridden' => 'storagePid')));
                $frontendConfigurationManager->expects($this->at(1))->method('overrideConfigurationFromPlugin')->with(array('overridden' => 'storagePid'))->will($this->returnValue(array('overridden' => 'pluginConfiguration')));
                $frontendConfigurationManager->expects($this->at(2))->method('overrideConfigurationFromFlexForm')->with(array('overridden' => 'pluginConfiguration'))->will($this->returnValue(array('overridden' => 'flexFormConfiguration')));
@@ -305,5 +349,8 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
                $actualResult = $frontendConfigurationManager->_call('getContextSpecificFrameworkConfiguration', $frameworkConfiguration);
                $this->assertEquals($expectedResult, $actualResult);
        }
                $actualResult = $frontendConfigurationManager->_call('getContextSpecificFrameworkConfiguration', $frameworkConfiguration);
                $this->assertEquals($expectedResult, $actualResult);
        }
+
 }
 }
+
+
 ?>
\ No newline at end of file
 ?>
\ No newline at end of file