50381784cf2e8b663360c3a795905a7566445bed
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Tests / Unit / Utility / ConfigurationUtilityTest.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012 Oliver Hader <oliver.hader@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * @package Extension Manager
29 * @subpackage Tests
30 */
31 class ConfigurationUtilityTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
32
33 /**
34 * @param array $configuration
35 * @param array $expected
36 * @dataProvider convertValuedToNestedConfigurationDataProvider
37 * @test
38 */
39 public function convertValuedToNestedConfiguration(array $configuration, array $expected) {
40 /** @var $fixture \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility */
41 $fixture = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility');
42 $this->assertEquals($expected, $fixture->convertValuedToNestedConfiguration($configuration));
43 }
44
45 /**
46 * @return array
47 */
48 public function convertValuedToNestedConfigurationDataProvider() {
49 return array(
50 'plain array' => array(
51 array(
52 'first' => array(
53 'value' => 'value1'
54 ),
55 'second' => array(
56 'value' => 'value2'
57 )
58 ),
59 array(
60 'first' => 'value1',
61 'second' => 'value2'
62 )
63 ),
64 'nested value with 2 levels' => array(
65 array(
66 'first.firstSub' => array(
67 'value' => 'value1'
68 ),
69 'second.secondSub' => array(
70 'value' => 'value2'
71 )
72 ),
73 array(
74 'first.' => array(
75 'firstSub' => 'value1'
76 ),
77 'second.' => array(
78 'secondSub' => 'value2'
79 )
80 )
81 ),
82 'nested value with 3 levels' => array(
83 array(
84 'first.firstSub.firstSubSub' => array(
85 'value' => 'value1'
86 ),
87 'second.secondSub.secondSubSub' => array(
88 'value' => 'value2'
89 )
90 ),
91 array(
92 'first.' => array(
93 'firstSub.' => array(
94 'firstSubSub' => 'value1'
95 )
96 ),
97 'second.' => array(
98 'secondSub.' => array(
99 'secondSubSub' => 'value2'
100 )
101 )
102 )
103 ),
104 'mixed nested value with 2 levels' => array(
105 array(
106 'first' => array(
107 'value' => 'firstValue'
108 ),
109 'first.firstSub' => array(
110 'value' => 'value1'
111 ),
112 'second.secondSub' => array(
113 'value' => 'value2'
114 )
115 ),
116 array(
117 'first' => 'firstValue',
118 'first.' => array(
119 'firstSub' => 'value1'
120 ),
121 'second.' => array(
122 'secondSub' => 'value2'
123 )
124 )
125 )
126 );
127 }
128
129 }
130
131
132 ?>