[+TASK] Extbase: Move static typoscript utility methods to a service
authorBastian Waidelich <bastian@typo3.org>
Tue, 7 Jun 2011 14:53:17 +0000 (16:53 +0200)
committerBastian Waidelich <bastian@typo3.org>
Tue, 7 Jun 2011 14:53:17 +0000 (16:53 +0200)
Change-Id: Ifa6b40669f85083e3dd2ceddc2077a8ab784a1ef
Related: #13864

typo3/sysext/extbase/Classes/Configuration/AbstractConfigurationManager.php
typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php
typo3/sysext/extbase/Classes/Configuration/FrontendConfigurationManager.php
typo3/sysext/extbase/Classes/Service/TypoScriptService.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Utility/TypoScript.php
typo3/sysext/extbase/Tests/Unit/Configuration/AbstractConfigurationManagerTest.php
typo3/sysext/extbase/Tests/Unit/Configuration/BackendConfigurationManagerTest.php
typo3/sysext/extbase/Tests/Unit/Configuration/FrontendConfigurationManagerTest.php
typo3/sysext/extbase/Tests/Unit/Service/TypoScriptServiceTest.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Utility/TypoScriptTest.php [deleted file]

index fcf257d..c5c94a1 100644 (file)
@@ -53,6 +53,11 @@ abstract class Tx_Extbase_Configuration_AbstractConfigurationManager implements
        protected $objectManager;
 
        /**
+        * @var Tx_Extbase_Service_TypoScriptService
+        */
+       protected $typoScriptService;
+
+       /**
         * name of the extension this Configuration Manager instance belongs to
         * @var string
         */
@@ -72,7 +77,7 @@ abstract class Tx_Extbase_Configuration_AbstractConfigurationManager implements
        protected $configurationCache = array();
 
        /**
-        * @param Tx_Extbase_Object_ManagerInterface $objectManager
+        * @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
         * @return void
         */
        public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) {
@@ -80,6 +85,14 @@ abstract class Tx_Extbase_Configuration_AbstractConfigurationManager implements
        }
 
        /**
+        * @param Tx_Extbase_Service_TypoScriptService $typoScriptService
+        * @return void
+        */
+       public function injectTypoScriptService(Tx_Extbase_Service_TypoScriptService $typoScriptService) {
+               $this->typoScriptService = $typoScriptService;
+       }
+
+       /**
         * @param tslib_cObj $contentObject
         * @return void
         */
@@ -107,7 +120,7 @@ abstract class Tx_Extbase_Configuration_AbstractConfigurationManager implements
 
                $this->extensionName = $configuration['extensionName'];
                $this->pluginName = $configuration['pluginName'];
-               $this->configuration = Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($configuration);
+               $this->configuration = $this->typoScriptService->convertTypoScriptArrayToPlainArray($configuration);
        }
 
        /**
@@ -166,7 +179,7 @@ abstract class Tx_Extbase_Configuration_AbstractConfigurationManager implements
                                 * and apply the stdWrap to the storagePid
                                 */
                        Tx_Extbase_Utility_FrontendSimulator::simulateFrontendEnvironment($this->getContentObject());
-                       $conf = Tx_Extbase_Utility_TypoScript::convertPlainArrayToTypoScriptArray($frameworkConfiguration['persistence']);
+                       $conf = $this->typoScriptService->convertPlainArrayToTypoScriptArray($frameworkConfiguration['persistence']);
                        $frameworkConfiguration['persistence']['storagePid'] = $GLOBALS['TSFE']->cObj->stdWrap($conf['storagePid'], $conf['storagePid.']);
                        Tx_Extbase_Utility_FrontendSimulator::resetFrontendEnvironment();
                }
@@ -185,7 +198,7 @@ abstract class Tx_Extbase_Configuration_AbstractConfigurationManager implements
                $setup = $this->getTypoScriptSetup();
                $extbaseConfiguration = array();
                if (isset($setup['config.']['tx_extbase.'])) {
-                       $extbaseConfiguration = Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($setup['config.']['tx_extbase.']);
+                       $extbaseConfiguration = $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['config.']['tx_extbase.']);
                }
                return $extbaseConfiguration;
        }
index a4c36d8..0dbacd8 100644 (file)
@@ -71,11 +71,11 @@ class Tx_Extbase_Configuration_BackendConfigurationManager extends Tx_Extbase_Co
                $setup = $this->getTypoScriptSetup();
                $pluginConfiguration = array();
                if (is_array($setup['module.']['tx_' . strtolower($extensionName) . '.'])) {
-                       $pluginConfiguration = Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($setup['module.']['tx_' . strtolower($extensionName) . '.']);
+                       $pluginConfiguration = $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['module.']['tx_' . strtolower($extensionName) . '.']);
                }
                $pluginSignature = strtolower($extensionName . '_' . $pluginName);
                if (is_array($setup['module.']['tx_' . $pluginSignature . '.'])) {
-                       $pluginConfiguration = t3lib_div::array_merge_recursive_overrule($pluginConfiguration, Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($setup['module.']['tx_' . $pluginSignature . '.']));
+                       $pluginConfiguration = t3lib_div::array_merge_recursive_overrule($pluginConfiguration, $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['module.']['tx_' . $pluginSignature . '.']));
                }
                return $pluginConfiguration;
        }
index 6dea99b..8a095f9 100644 (file)
@@ -68,11 +68,11 @@ class Tx_Extbase_Configuration_FrontendConfigurationManager extends Tx_Extbase_C
                $setup = $this->getTypoScriptSetup();
                $pluginConfiguration = array();
                if (is_array($setup['plugin.']['tx_' . strtolower($extensionName) . '.'])) {
-                       $pluginConfiguration = Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_' . strtolower($extensionName) . '.']);
+                       $pluginConfiguration = $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_' . strtolower($extensionName) . '.']);
                }
                $pluginSignature = strtolower($extensionName . '_' . $pluginName);
                if (is_array($setup['plugin.']['tx_' . $pluginSignature . '.'])) {
-                       $pluginConfiguration = t3lib_div::array_merge_recursive_overrule($pluginConfiguration, Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_' . $pluginSignature . '.']));
+                       $pluginConfiguration = t3lib_div::array_merge_recursive_overrule($pluginConfiguration, $this->typoScriptService->convertTypoScriptArrayToPlainArray($setup['plugin.']['tx_' . $pluginSignature . '.']));
                }
                return $pluginConfiguration;
        }
@@ -152,7 +152,7 @@ class Tx_Extbase_Configuration_FrontendConfigurationManager extends Tx_Extbase_C
                $pluginSignature = strtolower($frameworkConfiguration['extensionName'] . '_' . $frameworkConfiguration['pluginName']);
                $pluginConfiguration = $setup['plugin.']['tx_' . $pluginSignature . '.'];
                if (is_array($pluginConfiguration)) {
-                       $pluginConfiguration = Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($pluginConfiguration);
+                       $pluginConfiguration = $this->typoScriptService->convertTypoScriptArrayToPlainArray($pluginConfiguration);
                        $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $pluginConfiguration, 'settings');
                        $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $pluginConfiguration, 'persistence');
                        $frameworkConfiguration = $this->mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $pluginConfiguration, 'view');
diff --git a/typo3/sysext/extbase/Classes/Service/TypoScriptService.php b/typo3/sysext/extbase/Classes/Service/TypoScriptService.php
new file mode 100644 (file)
index 0000000..87d46e8
--- /dev/null
@@ -0,0 +1,92 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Christian Müller <christian@kitsunet.de>
+*  (c) 2011 Bastian Waidelich <bastian@typo3.org>
+*  All rights reserved
+*
+*  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!
+***************************************************************/
+
+/**
+ * Utilities to manage and convert TypoScript
+ *
+ * @package Extbase
+ * @subpackage Service
+ */
+class Tx_Extbase_Service_TypoScriptService implements t3lib_Singleton {
+
+       /**
+        * Removes all trailing dots recursively from TS settings array
+        *
+        * Extbase converts the "classical" TypoScript (with trailing dot) to a format without trailing dot,
+        * to be more future-proof and not to have any conflicts with Fluid object accessor syntax.
+        *
+        * @param array $typoScriptArray The TypoScript array (e.g. array('foo' => 'TEXT', 'foo.' => array('bar' => 'baz')))
+        * @return void
+        * @api
+        */
+       public function convertTypoScriptArrayToPlainArray(array $typoScriptArray) {
+               foreach ($typoScriptArray as $key => &$value) {
+                       if(substr($key, -1) === '.') {
+                               $keyWithoutDot = substr($key, 0, -1);
+                               $hasNodeWithoutDot = array_key_exists($keyWithoutDot, $typoScriptArray);
+                               $typoScriptNodeValue = $hasNodeWithoutDot ? $typoScriptArray[$keyWithoutDot] : NULL;
+                               if(is_array($value)) {
+                                       $typoScriptArray[$keyWithoutDot] = $this->convertTypoScriptArrayToPlainArray($value);
+                                       if(!is_null($typoScriptNodeValue)) {
+                                               $typoScriptArray[$keyWithoutDot]['_typoScriptNodeValue']  = $typoScriptNodeValue;
+                                       }
+                                       unset($typoScriptArray[$key]);
+                               } else {
+                                       $typoScriptArray[$keyWithoutDot] = NULL;
+                               }
+                       }
+               }
+               return $typoScriptArray;
+       }
+
+       /**
+        * Returns an array with Typoscript the old way (with dot).
+        *
+        * Extbase converts the "classical" TypoScript (with trailing dot) to a format without trailing dot,
+        * to be more future-proof and not to have any conflicts with Fluid object accessor syntax.
+        * However, if you want to call legacy TypoScript objects, you somehow need the "old" syntax (because this is what TYPO3 is used to).
+        * With this method, you can convert the extbase TypoScript to classical TYPO3 TypoScript which is understood by the rest of TYPO3.
+        *
+        * @param array $plainArray An TypoScript Array with Extbase Syntax (without dot but with _typoScriptNodeValue)
+        * @return array array with TypoScript as usual (with dot)
+        * @api
+        */
+       public function convertPlainArrayToTypoScriptArray(array $plainArray) {
+               $typoScriptArray = array();
+               foreach ($plainArray as $key => $value) {
+                       if (is_array($value)) {
+                               if (isset($value['_typoScriptNodeValue'])) {
+                                       $typoScriptArray[$key] = $value['_typoScriptNodeValue'];
+                                       unset($value['_typoScriptNodeValue']);
+                               }
+                               $typoScriptArray[$key . '.'] = $this->convertPlainArrayToTypoScriptArray($value);
+                       } else {
+                               $typoScriptArray[$key] = $value;
+                       }
+               }
+               return $typoScriptArray;
+       }
+}
+?>
\ No newline at end of file
index 0224b56..6144664 100644 (file)
  *
  * @package Extbase
  * @subpackage Utility
- * @version $ID:$
- * @api
+ * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0. Please use Tx_Extbase_Service_TypoScriptService instead
  */
 class Tx_Extbase_Utility_TypoScript {
 
        /**
+        * @var Tx_Extbase_Service_TypoScriptService
+        */
+       protected static $typoScriptService = NULL;
+
+       /**
+        * @return void
+        */
+       static protected function getTypoScriptService() {
+               if (self::$typoScriptService === NULL) {
+                       require_once t3lib_extMgm::extPath('extbase', 'Classes/Service/TypoScriptService.php');
+                       $objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
+                       self::$typoScriptService = $objectManager->get('Tx_Extbase_Service_TypoScriptService');
+               }
+               return self::$typoScriptService;
+       }
+
+       /**
         * Removes all trailing dots recursively from TS settings array
         *
         * Extbase converts the "classical" TypoScript (with trailing dot) to a format without trailing dot,
@@ -40,26 +56,12 @@ class Tx_Extbase_Utility_TypoScript {
         *
         * @param array $settings The settings array
         * @return void
-        * @api
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0 - Use Tx_Extbase_Service_TypoScriptService instead
         */
        static public function convertTypoScriptArrayToPlainArray(array $settings) {
-               foreach ($settings as $key => &$value) {
-                       if(substr($key, -1) === '.') {
-                               $keyWithoutDot = substr($key, 0, -1);
-                               $hasNodeWithoutDot = array_key_exists($keyWithoutDot, $settings);
-                               $typoScriptNodeValue = $hasNodeWithoutDot ? $settings[$keyWithoutDot] : NULL;
-                               if(is_array($value)) {
-                                       $settings[$keyWithoutDot] = self::convertTypoScriptArrayToPlainArray($value);
-                                       if(!is_null($typoScriptNodeValue)) {
-                                               $settings[$keyWithoutDot]['_typoScriptNodeValue']  = $typoScriptNodeValue;
-                                       }
-                                       unset($settings[$key]);
-                               } else {
-                                       $settings[$keyWithoutDot] = NULL;
-                               }
-                       }
-               }
-               return $settings;
+               t3lib_div::logDeprecatedFunction();
+               $typoScriptService = self::getTypoScriptService();
+               return $typoScriptService->convertTypoScriptArrayToPlainArray($settings);
        }
 
        /**
@@ -72,24 +74,15 @@ class Tx_Extbase_Utility_TypoScript {
         *
         * @param array $plainArray An Typoscript Array with Extbase Syntax (without dot but with _typoScriptNodeValue)
         * @return array array with Typoscript as usual (with dot)
-        * @api
+        * @deprecated since Extbase 1.4.0; will be removed in Extbase 1.6.0 - Use Tx_Extbase_Service_TypoScriptService instead
         */
        static public function convertPlainArrayToTypoScriptArray($plainArray) {
-               $typoScriptArray = array();
-               if (is_array($plainArray)) {
-                       foreach ($plainArray as $key => $value) {
-                               if (is_array($value)) {
-                                       if (isset($value['_typoScriptNodeValue'])) {
-                                               $typoScriptArray[$key] = $value['_typoScriptNodeValue'];
-                                               unset($value['_typoScriptNodeValue']);
-                                       }
-                                       $typoScriptArray[$key.'.'] = self::convertPlainArrayToTypoScriptArray($value);
-                               } else {
-                                       $typoScriptArray[$key] = $value;
-                               }
-                       }
+               t3lib_div::logDeprecatedFunction();
+               if (!is_array($plainArray)) {
+                       return array();
                }
-               return $typoScriptArray;
+               $typoScriptService = self::getTypoScriptService();
+               return $typoScriptService->convertPlainArrayToTypoScriptArray($plainArray);
        }
 }
 ?>
\ No newline at end of file
index 3a06f95..01e0a7e 100644 (file)
@@ -32,6 +32,11 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
        protected $abstractConfigurationManager;
 
        /**
+        * @var Tx_Extbase_Service_TypoScriptService
+        */
+       protected $mockTypoScriptService;
+
+       /**
         * @var array
         */
        protected $testTypoScriptSetup = array(
@@ -57,6 +62,29 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
        /**
         * @var array
         */
+       protected $testTypoScriptSetupConverted = array(
+               'foo' => array(
+                       'bar' => 'baz'
+               ),
+               'config' => array(
+                       'tx_extbase' => array(
+                               'settings' => array(
+                                       'setting1' => 'value1',
+                                       'setting2' => 'value2',
+                               ),
+                               'view' => array(
+                                       'viewSub' => array(
+                                               'key1' => 'value1',
+                                               'key2' => 'value2',
+                                       )
+                               )
+                       ),
+               ),
+       );
+
+       /**
+        * @var array
+        */
        protected $testPluginConfiguration = array(
                'settings' => array(
                        'setting1' => 'overriddenValue1',
@@ -91,6 +119,8 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
         */
        public function setUp() {
                $this->abstractConfigurationManager = $this->getAccessibleMock('Tx_Extbase_Configuration_AbstractConfigurationManager', array('getContextSpecificFrameworkConfiguration', 'getTypoScriptSetup', 'getPluginConfiguration', 'getSwitchableControllerActions'));
+               $this->mockTypoScriptService = $this->getAccessibleMock('Tx_Extbase_Service_TypoScriptService');
+               $this->abstractConfigurationManager->injectTypoScriptService($this->mockTypoScriptService);
        }
 
        /**
@@ -129,6 +159,7 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
                        'settings' => array('foo' => 'bar'),
                        'view' => array('subkey' => array('subsubkey' => 'subsubvalue'))
                );
+               $this->mockTypoScriptService->expects($this->atLeastOnce())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($expectedResult));
                $this->abstractConfigurationManager->setConfiguration($configuration);
                $this->assertEquals($expectedResult, $this->abstractConfigurationManager->_get('configuration'));
        }
@@ -170,6 +201,7 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
                $this->abstractConfigurationManager->_set('extensionName', 'CurrentExtensionName');
                $this->abstractConfigurationManager->_set('pluginName', 'CurrentPluginName');
                $this->abstractConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
+               $this->mockTypoScriptService->expects($this->atLeastOnce())->method('convertTypoScriptArrayToPlainArray')->with($this->testTypoScriptSetup['config.']['tx_extbase.'])->will($this->returnValue($this->testTypoScriptSetupConverted['config']['tx_extbase']));
                $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
                $expectedResult = array(
                        'settings' => array(
@@ -200,6 +232,7 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
        public function getConfigurationRecursivelyMergesPluginConfigurationOfSpecifiedPluginWithFrameworkConfiguration() {
                $this->abstractConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
                $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('SomeExtensionName', 'SomePluginName')->will($this->returnValue($this->testPluginConfiguration));
+               $this->mockTypoScriptService->expects($this->atLeastOnce())->method('convertTypoScriptArrayToPlainArray')->with($this->testTypoScriptSetup['config.']['tx_extbase.'])->will($this->returnValue($this->testTypoScriptSetupConverted['config']['tx_extbase']));
                $expectedResult = array(
                        'settings' => array(
                                'setting1' => 'overriddenValue1',
@@ -288,6 +321,7 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
         */
        public function switchableControllerActionsAreNotOverriddenIfPluginNameIsSpecified() {
                $abstractConfigurationManager = $this->getAccessibleMock('Tx_Extbase_Configuration_AbstractConfigurationManager', array('overrideSwitchableControllerActions', 'getContextSpecificFrameworkConfiguration', 'getTypoScriptSetup', 'getPluginConfiguration', 'getSwitchableControllerActions'));
+               $abstractConfigurationManager->injectTypoScriptService($this->mockTypoScriptService);
                $abstractConfigurationManager->setConfiguration(array('switchableControllerActions' => array('overriddenSwitchableControllerActions')));
                $abstractConfigurationManager->expects($this->any())->method('getPluginConfiguration')->will($this->returnValue(array()));
                $abstractConfigurationManager->expects($this->never())->method('overrideSwitchableControllerActions');
@@ -298,8 +332,11 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
         * @test
         */
        public function switchableControllerActionsAreOverriddenIfSpecifiedPluginIsTheCurrentPlugin() {
+               $configuration = array('extensionName' => 'CurrentExtensionName', 'pluginName' => 'CurrentPluginName', 'switchableControllerActions' => array('overriddenSwitchableControllerActions'));
                $abstractConfigurationManager = $this->getAccessibleMock('Tx_Extbase_Configuration_AbstractConfigurationManager', array('overrideSwitchableControllerActions', 'getContextSpecificFrameworkConfiguration', 'getTypoScriptSetup', 'getPluginConfiguration', 'getSwitchableControllerActions'));
-               $abstractConfigurationManager->setConfiguration(array('extensionName' => 'CurrentExtensionName', 'pluginName' => 'CurrentPluginName', 'switchableControllerActions' => array('overriddenSwitchableControllerActions')));
+               $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
+               $abstractConfigurationManager->injectTypoScriptService($this->mockTypoScriptService);
+               $abstractConfigurationManager->setConfiguration($configuration);
                $abstractConfigurationManager->expects($this->any())->method('getPluginConfiguration')->will($this->returnValue(array()));
                $abstractConfigurationManager->expects($this->once())->method('overrideSwitchableControllerActions');
                $abstractConfigurationManager->getConfiguration('CurrentExtensionName', 'CurrentPluginName');
@@ -309,8 +346,11 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
         * @test
         */
        public function switchableControllerActionsAreOverriddenIfPluginNameIsNotSpecified() {
+               $configuration = array('switchableControllerActions' => array('overriddenSwitchableControllerActions'));
                $abstractConfigurationManager = $this->getAccessibleMock('Tx_Extbase_Configuration_AbstractConfigurationManager', array('overrideSwitchableControllerActions', 'getContextSpecificFrameworkConfiguration', 'getTypoScriptSetup', 'getPluginConfiguration', 'getSwitchableControllerActions'));
-               $abstractConfigurationManager->setConfiguration(array('switchableControllerActions' => array('overriddenSwitchableControllerActions')));
+               $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
+               $abstractConfigurationManager->injectTypoScriptService($this->mockTypoScriptService);
+               $abstractConfigurationManager->setConfiguration($configuration);
                $abstractConfigurationManager->expects($this->any())->method('getPluginConfiguration')->will($this->returnValue(array()));
                $abstractConfigurationManager->expects($this->once())->method('overrideSwitchableControllerActions');
                $abstractConfigurationManager->getConfiguration();
@@ -327,6 +367,7 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
                                'Controller1' => array('action2', 'action1', 'action3'),
                        )
                );
+               $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
                $this->abstractConfigurationManager->setConfiguration($configuration);
                $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
                $this->abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testSwitchableControllerActions));
@@ -352,6 +393,7 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
                                'Controller1' => array('action2', 'action1', 'action3', 'newAction'),
                        )
                );
+               $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
                $this->abstractConfigurationManager->setConfiguration($configuration);
                $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
                $this->abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testSwitchableControllerActions));
@@ -377,6 +419,7 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
                                'NewController' => array('action1', 'action2'),
                        )
                );
+               $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
                $this->abstractConfigurationManager->setConfiguration($configuration);
                $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
                $this->abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testSwitchableControllerActions));
@@ -399,6 +442,7 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
                                'Controller2' => array('newAction2', 'action4', 'action5'),
                        )
                );
+               $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($configuration)->will($this->returnValue($configuration));
                $this->abstractConfigurationManager->setConfiguration($configuration);
                $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testPluginConfiguration));
                $this->abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($this->testSwitchableControllerActions));
@@ -420,22 +464,34 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
        /**
         * @test
         */
-       public function setStoragePidWithStdWrap() {
-
-               unset($this->abstractConfigurationManager);
-               $this->abstractConfigurationManager = $this->getMock('Tx_Extbase_Configuration_AbstractConfigurationManager', array('getSwitchableControllerActions', 'getContextSpecificFrameworkConfiguration', 'getTypoScriptSetup', 'getPluginConfiguration'));
-
-               $pluginConfiguration = $this->testPluginConfiguration;
-               $pluginConfiguration['persistence']['storagePid'] = array(
+       public function getConfigurationParsesCObjectsForStoragePid() {
+               $this->markTestIncomplete('This can\'t be tested as we currently cannot mock the FE environment');
+               $storagePidSettings = array(
                        'cObject' => array(
                                'value' => '8,3',
                                '_typoScriptNodeValue' => 'TEXT'
                        )
                );
+               $storagePidSettingsConverted = array(
+                       'cObject' => 'TEXT',
+                       'cObject.' => array(
+                               'value' => '8,3',
+                       )
+               );
+               $pluginConfiguration = $pluginConfigurationConverted = $this->testPluginConfiguration;
+               $pluginConfiguration['persistence']['storagePid'] = $storagePidSettings;
+               $pluginConfigurationConverted['persistence']['storagePid'] = $storagePidSettingsConverted;
 
-               $this->abstractConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
-               $this->abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($pluginConfiguration));
-               $this->abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue(NULL));
+
+               $abstractConfigurationManager = $this->getMock('Tx_Extbase_Configuration_AbstractConfigurationManager', array('getSwitchableControllerActions', 'getContextSpecificFrameworkConfiguration', 'getTypoScriptSetup', 'getPluginConfiguration'));
+               $this->mockTypoScriptService->expects($this->any())->method('convertPlainArrayToTypoScriptArray')->with($storagePidSettings)->will($this->returnValue($storagePidSettingsConverted));
+               $this->mockTypoScriptService->expects($this->atLeastOnce())->method('convertTypoScriptArrayToPlainArray')->with($this->testTypoScriptSetup['config.']['tx_extbase.'])->will($this->returnValue($this->testTypoScriptSetupConverted['config']['tx_extbase']));
+
+               $abstractConfigurationManager->injectTypoScriptService($this->mockTypoScriptService);
+
+               $abstractConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($this->testTypoScriptSetup));
+               $abstractConfigurationManager->expects($this->once())->method('getPluginConfiguration')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue($pluginConfiguration));
+               $abstractConfigurationManager->expects($this->once())->method('getSwitchableControllerActions')->with('CurrentExtensionName', 'CurrentPluginName')->will($this->returnValue(NULL));
 
                $expectedResult = array(
                        'settings' => array(
@@ -456,7 +512,7 @@ class Tx_Extbase_Tests_Unit_Configuration_AbstractConfigurationManagerTest exten
                        'controllerConfiguration' => NULL
                );
 
-               $actualResult = $this->abstractConfigurationManager->getConfiguration('CurrentExtensionName', 'CurrentPluginName');
+               $actualResult = $abstractConfigurationManager->getConfiguration('CurrentExtensionName', 'CurrentPluginName');
                $this->assertEquals($expectedResult, $actualResult);
        }
 }
index 7923ce2..f380bcd 100644 (file)
@@ -53,6 +53,11 @@ class Tx_Extbase_Tests_Unit_Configuration_BackendConfigurationManagerTest extend
        protected $backendConfigurationManager;
 
        /**
+        * @var Tx_Extbase_Service_TypoScriptService
+        */
+       protected $mockTypoScriptService;
+
+       /**
         * Sets up this testcase
         */
        public function setUp() {
@@ -65,6 +70,8 @@ class Tx_Extbase_Tests_Unit_Configuration_BackendConfigurationManagerTest extend
                $this->extConfBackup = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase'];
 
                $this->backendConfigurationManager = $this->getAccessibleMock('Tx_Extbase_Configuration_BackendConfigurationManager', array('getTypoScriptSetup'));
+               $this->mockTypoScriptService = $this->getAccessibleMock('Tx_Extbase_Service_TypoScriptService');
+               $this->backendConfigurationManager->injectTypoScriptService($this->mockTypoScriptService);
        }
 
        /**
@@ -189,15 +196,22 @@ class Tx_Extbase_Tests_Unit_Configuration_BackendConfigurationManagerTest extend
         * @test
         */
        public function getPluginConfigurationReturnsExtensionConfiguration() {
+               $testSettings = array(
+                       'settings.' => array(
+                               'foo' => 'bar'
+                       )
+               );
+               $testSettingsConverted = array(
+                       'settings' => array(
+                               'foo' => 'bar'
+                       )
+               );
                $testSetup = array(
                        'module.' => array(
-                               'tx_someextensionname.' => array(
-                                       'settings.' => array(
-                                               'foo' => 'bar'
-                                       )
-                               ),
+                               'tx_someextensionname.' => $testSettings,
                        ),
                );
+               $this->mockTypoScriptService->expects($this->any())->method('convertTypoScriptArrayToPlainArray')->with($testSettings)->will($this->returnValue($testSettingsConverted));
                $this->backendConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($testSetup));
                $expectedResult = array(
                        'settings' => array(
@@ -212,15 +226,22 @@ class Tx_Extbase_Tests_Unit_Configuration_BackendConfigurationManagerTest extend
         * @test
         */
        public function getPluginConfigurationReturnsPluginConfiguration() {
+               $testSettings = array(
+                       'settings.' => array(
+                               'foo' => 'bar'
+                       )
+               );
+               $testSettingsConverted = array(
+                       'settings' => array(
+                               'foo' => 'bar'
+                       )
+               );
                $testSetup = array(
                        'module.' => 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));
                $this->backendConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($testSetup));
                $expectedResult = array(
                        'settings' => array(
@@ -235,26 +256,46 @@ class Tx_Extbase_Tests_Unit_Configuration_BackendConfigurationManagerTest extend
         * @test
         */
        public function getPluginConfigurationRecursivelyMergesExtensionAndPluginConfiguration() {
-               $testSetup = array(
-                       'module.' => array(
-                               'tx_someextensionname.' => array(
-                                       'settings.' => array(
-                                               'foo' => 'bar',
-                                               'some.' => array(
-                                                       'nested' => 'value'
-                                               ),
-                                       ),
+               $testExtensionSettings = array(
+                       'settings.' => array(
+                               'foo' => 'bar',
+                               'some.' => array(
+                                       'nested' => 'value'
                                ),
-                               'tx_someextensionname_somepluginname.' => array(
-                                       'settings.' => array(
-                                               'some.' => array(
-                                                       'nested' => 'valueOverridde',
-                                                       'new' => '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(
+                       'module.' => array(
+                               '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));
                $this->backendConfigurationManager->expects($this->once())->method('getTypoScriptSetup')->will($this->returnValue($testSetup));
                $expectedResult = array(
                        'settings' => array(
index 61c63e7..efa5eb6 100644 (file)
@@ -48,6 +48,11 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
        protected $extConfBackup;
 
        /**
+        * @var Tx_Extbase_Service_TypoScriptService
+        */
+       protected $mockTypoScriptService;
+
+       /**
         * Sets up this testcase
         */
        public function setUp() {
@@ -56,6 +61,8 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
                $this->extConfBackup = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase'];
                $this->frontendConfigurationManager = $this->getAccessibleMock('Tx_Extbase_Configuration_FrontendConfigurationManager', array('dummy'));
                $this->frontendConfigurationManager->_set('contentObject', $this->mockContentObject);
+               $this->mockTypoScriptService = $this->getAccessibleMock('Tx_Extbase_Service_TypoScriptService');
+               $this->frontendConfigurationManager->injectTypoScriptService($this->mockTypoScriptService);
        }
 
        /**
@@ -88,15 +95,22 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
         * @test
         */
        public function getPluginConfigurationReturnsExtensionConfiguration() {
+               $testSettings = array(
+                       'settings.' => array(
+                               'foo' => 'bar'
+                       )
+               );
+               $testSettingsConverted = array(
+                       'settings' => array(
+                               'foo' => 'bar'
+                       )
+               );
                $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(
@@ -111,15 +125,22 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
         * @test
         */
        public function getPluginConfigurationReturnsPluginConfiguration() {
+               $testSettings = array(
+                       'settings.' => array(
+                               'foo' => 'bar'
+                       )
+               );
+               $testSettingsConverted = array(
+                       'settings' => array(
+                               'foo' => 'bar'
+                       )
+               );
                $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(
@@ -134,26 +155,46 @@ class Tx_Extbase_Tests_Unit_Configuration_FrontendConfigurationManagerTest exten
         * @test
         */
        public function getPluginConfigurationRecursivelyMergesExtensionAndPluginConfiguration() {
-               $testSetup = array(
-                       'plugin.' => array(
-                               'tx_someextensionname.' => array(
-                                       'settings.' => array(
-                                               'foo' => 'bar',
-                                               'some.' => array(
-                                                       'nested' => 'value'
-                                               ),
-                                       ),
+               $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',
                                ),
-                               'tx_someextensionname_somepluginname.' => array(
-                                       'settings.' => array(
-                                               'some.' => array(
-                                                       'nested' => 'valueOverridde',
-                                                       'new' => 'value',
-                                               ),
-                                       ),
+                       )
+               );
+               $testPluginSettingsConverted = array(
+                       'settings' => array(
+                               'some' => array(
+                                       'nested' => 'valueOverridde',
+                                       'new' => 'value',
                                ),
+                       )
+               );
+               $testSetup = array(
+                       'plugin.' => array(
+                               '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(
diff --git a/typo3/sysext/extbase/Tests/Unit/Service/TypoScriptServiceTest.php b/typo3/sysext/extbase/Tests/Unit/Service/TypoScriptServiceTest.php
new file mode 100644 (file)
index 0000000..499a2f0
--- /dev/null
@@ -0,0 +1,244 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2009 Christian Müller <christian@kitsunet.de>
+*  (c) 2011 Bastian Waidelich <bastian@typo3.org>
+*  All rights reserved
+*
+*  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!
+***************************************************************/
+
+
+/**
+ * Testcase for class Tx_Extbase_Service_TypoScriptService
+ *
+ * @package Extbase
+ */
+class Tx_Extbase_Tests_Unit_Service_TypoScriptServiceTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
+
+       /**
+        * @return array
+        */
+       public function convertTypoScriptArrayToPlainArrayTestdata(){
+               $testdata = array();
+               //convert TypoScript Array To Plain Array Removes Trailing Dots
+               $testdata[0] = array(
+                       'typoScriptSettings' => array(
+                               '10.' => array(
+                                       'value' => 'Hello World!',
+                                       'foo.' => array(
+                                               'bar' => 5,
+                                               ),
+                                       ),
+                               '10' => 'TEXT', // This line was moved down
+                               ),
+                       'expectedSettings' => array(
+                               '10' => array(
+                                       'value' => 'Hello World!',
+                                       'foo' => array(
+                                               'bar' => 5,
+                                               ),
+                                       '_typoScriptNodeValue' => 'TEXT',
+                               ),
+                       )
+               );
+
+               //convert TypoScript Array To Plain Array Removes Trailing Dots With Changed Order In The TypoScript Array
+               $testdata[1] = array(
+                       'typoScriptSettings' => array(
+                               '10' => 'TEXT',
+                               '10.' => array(
+                                       'value' => 'Hello World!',
+                                       'foo.' => array(
+                                               'bar' => 5,
+                                       ),
+                               ),
+                       ),
+                       'expectedSettings' => array(
+                               '10' => array(
+                                       'value' => 'Hello World!',
+                                       'foo' => array(
+                                               'bar' => 5,
+                                               ),
+                                       '_typoScriptNodeValue' => 'TEXT',
+                               ),
+                       )
+               );
+
+               $testdata[2] = array(
+                       'typoScriptSettings' => array(
+                               '10' => 'COA',
+                               '10.' => array(
+                                       '10' => 'TEXT',
+                                       '10.' => array(
+                                               'value' => 'Hello World!',
+                                               'foo.' => array(
+                                                       'bar' => 5,
+                                               )
+                                       ),
+                                       '20' => 'COA',
+                                       '20.' => array(
+                                               '10' => 'TEXT',
+                                               '10.' => array(
+                                                       'value' => 'Test',
+                                                       'wrap' => '[|]'
+                                               ),
+                                               '20' => 'TEXT',
+                                               '20.' => array(
+                                                       'value' => 'Test',
+                                                       'wrap' => '[|]'
+                                               )
+                                       ),
+                                       '30' => 'custom'
+                               ),
+                       ),
+                       'expectedSettings' => array(
+                               '10' => array(
+                                       '10' => array(
+                                               'value' => 'Hello World!',
+                                               'foo' => array(
+                                                       'bar' => 5,
+                                                       ),
+                                               '_typoScriptNodeValue' => 'TEXT'
+                                       ),
+                                       '20' => array(
+                                                       '10' => array(
+                                                               'value' => 'Test',
+                                                               'wrap' => '[|]',
+                                                               '_typoScriptNodeValue' => 'TEXT',
+                                                       ),
+                                                       '20' => array(
+                                                               'value' => 'Test',
+                                                               'wrap' => '[|]',
+                                                               '_typoScriptNodeValue' => 'TEXT',
+                                                       ),
+                                                       '_typoScriptNodeValue' => 'COA',
+                                               ),
+                                       '30' => 'custom',
+                                       '_typoScriptNodeValue' => 'COA',
+                               ),
+                       )
+               );
+
+               return $testdata;
+
+       }
+
+       /**
+        * @test
+        * @dataProvider convertTypoScriptArrayToPlainArrayTestdata
+        */
+       public function convertTypoScriptArrayToPlainArrayRemovesTrailingDotsWithChangedOrderInTheTypoScriptArray($typoScriptSettings,$expectedSettings) {
+               $typoScriptService = new Tx_Extbase_Service_TypoScriptService();
+               $processedSettings = $typoScriptService->convertTypoScriptArrayToPlainArray($typoScriptSettings);
+               $this->assertEquals($expectedSettings, $processedSettings);
+       }
+
+
+       /**
+        * Dataprovider for testcase "convertPlainArrayToTypoScriptArray"
+        *
+        * @return array
+        */
+       public function convertPlainArrayToTypoScriptArrayTestdata() {
+               $testdata = array();
+
+               $testdata[0] = array(
+                       'extbaseTS' => array(
+                               '10' => array(
+                                       'value' => 'Hallo',
+                                       '_typoScriptNodeValue' => 'TEXT'
+                               )
+                       ),
+
+                       'classic' => array(
+                               '10' => 'TEXT',
+                               '10.' => array(
+                                       'value' => 'Hallo'
+                               )
+                       )
+               );
+
+               $testdata[1] = array(
+                       'extbaseTS' => array(
+                               '10' => array(
+                                       '10' => array(
+                                               'value' => 'Hello World!',
+                                               'foo' => array(
+                                                       'bar' => 5,
+                                                       ),
+                                               '_typoScriptNodeValue' => 'TEXT'
+                                       ),
+                                       '20' => array(
+                                                       '10' => array(
+                                                               'value' => 'Test',
+                                                               'wrap' => '[|]',
+                                                               '_typoScriptNodeValue' => 'TEXT',
+                                                       ),
+                                                       '20' => array(
+                                                               'value' => 'Test',
+                                                               'wrap' => '[|]',
+                                                               '_typoScriptNodeValue' => 'TEXT',
+                                                       ),
+                                                       '_typoScriptNodeValue' => 'COA',
+                                               ),
+                                       '_typoScriptNodeValue' => 'COA',
+                               ),
+                       ),
+
+                       'classic' => array(
+                               '10' => 'COA',
+                               '10.' => array(
+                                       '10' => 'TEXT',
+                                       '10.' => array(
+                                               'value' => 'Hello World!',
+                                               'foo.' => array(
+                                                       'bar' => 5,
+                                               )
+                                       ),
+                                       '20' => 'COA',
+                                       '20.' => array(
+                                               '10' => 'TEXT',
+                                               '10.' => array(
+                                                       'value' => 'Test',
+                                                       'wrap' => '[|]'
+                                               ),
+                                               '20' => 'TEXT',
+                                               '20.' => array(
+                                                       'value' => 'Test',
+                                                       'wrap' => '[|]'
+                                               )
+                                       )
+                               )
+                       )
+               );
+
+               return $testdata;
+       }
+
+       /**
+        * @test
+        * @dataProvider convertPlainArrayToTypoScriptArrayTestdata
+        */
+       public function convertPlainArrayToTypoScriptArray($extbaseTS, $classic) {
+               $typoScriptService = new Tx_Extbase_Service_TypoScriptService();
+               $converted = $typoScriptService->convertPlainArrayToTypoScriptArray($extbaseTS);
+               $this->assertEquals($converted, $classic);
+       }
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Tests/Unit/Utility/TypoScriptTest.php b/typo3/sysext/extbase/Tests/Unit/Utility/TypoScriptTest.php
deleted file mode 100644 (file)
index 9590b0f..0000000
+++ /dev/null
@@ -1,243 +0,0 @@
-<?php
-/***************************************************************
-*  Copyright notice
-*
-*  (c) 2009 Christian Müller <christian@kitsunet.de>
-*  All rights reserved
-*
-*  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!
-***************************************************************/
-
-
-/**
- * Testcase for class Tx_Extbase_Utility_TypoScript
- *
- * @package Extbase
- * @subpackage extbase
- */
-
-class Tx_Extbase_Tests_Unit_Utility_TypoScriptTest extends tx_phpunit_testcase {
-
-       /**
-        * @return array
-        */
-       public function convertTypoScriptArrayToPlainArrayTestdata(){
-               $testdata = array();
-               //convert TypoScript Array To Plain Array Removes Trailing Dots
-               $testdata[0] = array(
-                       'typoScriptSettings' => array(
-                               '10.' => array(
-                                       'value' => 'Hello World!',
-                                       'foo.' => array(
-                                               'bar' => 5,
-                                               ),
-                                       ),
-                               '10' => 'TEXT', // This line was moved down
-                               ),
-                       'expectedSettings' => array(
-                               '10' => array(
-                                       'value' => 'Hello World!',
-                                       'foo' => array(
-                                               'bar' => 5,
-                                               ),
-                                       '_typoScriptNodeValue' => 'TEXT',
-                               ),
-                       )
-               );
-
-               //convert TypoScript Array To Plain Array Removes Trailing Dots With Changed Order In The TypoScript Array
-               $testdata[1] = array(
-                       'typoScriptSettings' => array(
-                               '10' => 'TEXT',
-                               '10.' => array(
-                                       'value' => 'Hello World!',
-                                       'foo.' => array(
-                                               'bar' => 5,
-                                       ),
-                               ),
-                       ),
-                       'expectedSettings' => array(
-                               '10' => array(
-                                       'value' => 'Hello World!',
-                                       'foo' => array(
-                                               'bar' => 5,
-                                               ),
-                                       '_typoScriptNodeValue' => 'TEXT',
-                               ),
-                       )
-               );
-
-               $testdata[2] = array(
-                       'typoScriptSettings' => array(
-                               '10' => 'COA',
-                               '10.' => array(
-                                       '10' => 'TEXT',
-                                       '10.' => array(
-                                               'value' => 'Hello World!',
-                                               'foo.' => array(
-                                                       'bar' => 5,
-                                               )
-                                       ),
-                                       '20' => 'COA',
-                                       '20.' => array(
-                                               '10' => 'TEXT',
-                                               '10.' => array(
-                                                       'value' => 'Test',
-                                                       'wrap' => '[|]'
-                                               ),
-                                               '20' => 'TEXT',
-                                               '20.' => array(
-                                                       'value' => 'Test',
-                                                       'wrap' => '[|]'
-                                               )
-                                       ),
-                                       '30' => 'custom'
-                               ),
-                       ),
-                       'expectedSettings' => array(
-                               '10' => array(
-                                       '10' => array(
-                                               'value' => 'Hello World!',
-                                               'foo' => array(
-                                                       'bar' => 5,
-                                                       ),
-                                               '_typoScriptNodeValue' => 'TEXT'
-                                       ),
-                                       '20' => array(
-                                                       '10' => array(
-                                                               'value' => 'Test',
-                                                               'wrap' => '[|]',
-                                                               '_typoScriptNodeValue' => 'TEXT',
-                                                       ),
-                                                       '20' => array(
-                                                               'value' => 'Test',
-                                                               'wrap' => '[|]',
-                                                               '_typoScriptNodeValue' => 'TEXT',
-                                                       ),
-                                                       '_typoScriptNodeValue' => 'COA',
-                                               ),
-                                       '30' => 'custom',
-                                       '_typoScriptNodeValue' => 'COA',
-                               ),
-                       )
-               );
-
-               return $testdata;
-
-       }
-
-       /**
-        * @test
-        * @dataProvider convertTypoScriptArrayToPlainArrayTestdata
-        */
-       public function convertTypoScriptArrayToPlainArrayRemovesTrailingDotsWithChangedOrderInTheTypoScriptArray($typoScriptSettings,$expectedSettings) {
-               $processedSettings = Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($typoScriptSettings);
-               $this->assertEquals($expectedSettings, $processedSettings);
-       }
-
-
-       /**
-        * Dataprovider for testcase "convertPlainArrayToTypoScriptArray"
-        *
-        * @return array
-        */
-       public function convertPlainArrayToTypoScriptArrayTestdata() {
-               $testdata = array();
-
-               $testdata[0] = array(
-                       'extbaseTS' => array(
-                               '10' => array(
-                                       'value' => 'Hallo',
-                                       '_typoScriptNodeValue' => 'TEXT'
-                               )
-                       ),
-
-                       'classic' => array(
-                               '10' => 'TEXT',
-                               '10.' => array(
-                                       'value' => 'Hallo'
-                               )
-                       )
-               );
-
-               $testdata[1] = array(
-                       'extbaseTS' => array(
-                               '10' => array(
-                                       '10' => array(
-                                               'value' => 'Hello World!',
-                                               'foo' => array(
-                                                       'bar' => 5,
-                                                       ),
-                                               '_typoScriptNodeValue' => 'TEXT'
-                                       ),
-                                       '20' => array(
-                                                       '10' => array(
-                                                               'value' => 'Test',
-                                                               'wrap' => '[|]',
-                                                               '_typoScriptNodeValue' => 'TEXT',
-                                                       ),
-                                                       '20' => array(
-                                                               'value' => 'Test',
-                                                               'wrap' => '[|]',
-                                                               '_typoScriptNodeValue' => 'TEXT',
-                                                       ),
-                                                       '_typoScriptNodeValue' => 'COA',
-                                               ),
-                                       '_typoScriptNodeValue' => 'COA',
-                               ),
-                       ),
-
-                       'classic' => array(
-                               '10' => 'COA',
-                               '10.' => array(
-                                       '10' => 'TEXT',
-                                       '10.' => array(
-                                               'value' => 'Hello World!',
-                                               'foo.' => array(
-                                                       'bar' => 5,
-                                               )
-                                       ),
-                                       '20' => 'COA',
-                                       '20.' => array(
-                                               '10' => 'TEXT',
-                                               '10.' => array(
-                                                       'value' => 'Test',
-                                                       'wrap' => '[|]'
-                                               ),
-                                               '20' => 'TEXT',
-                                               '20.' => array(
-                                                       'value' => 'Test',
-                                                       'wrap' => '[|]'
-                                               )
-                                       )
-                               )
-                       )
-               );
-
-               return $testdata;
-       }
-
-       /**
-        * @test
-        * @dataProvider convertPlainArrayToTypoScriptArrayTestdata
-        */
-       public function convertPlainArrayToTypoScriptArray($extbaseTS, $classic) {
-               $converted = Tx_Extbase_Utility_TypoScript::convertPlainArrayToTypoScriptArray($extbaseTS);
-               $this->assertEquals($converted, $classic);
-       }
-}
-?>
\ No newline at end of file