TYPO3 CMS  TYPO3_6-2
ConfigurationUtilityTest.php
Go to the documentation of this file.
1 <?php
3 
22 
26  public function getCurrentConfigurationReturnsExtensionConfigurationAsValuedConfiguration() {
28  $configurationUtility = $this->getMock(
29  'TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility',
30  array('getDefaultConfigurationFromExtConfTemplateAsValuedArray')
31  );
32  $configurationUtility
33  ->expects($this->once())
34  ->method('getDefaultConfigurationFromExtConfTemplateAsValuedArray')
35  ->will($this->returnValue(array()));
36  $extensionKey = $this->getUniqueId('some-extension');
37 
38  $currentConfiguration = array(
39  'key1' => 'value1',
40  'key2.' => array(
41  'subkey1' => 'value2'
42  )
43  );
44 
45  $expected = array(
46  'key1' => array(
47  'value' => 'value1',
48  ),
49  'key2.subkey1' => array(
50  'value' => 'value2',
51  ),
52  );
53 
54  $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey] = serialize($currentConfiguration);
55  $actual = $configurationUtility->getCurrentConfiguration($extensionKey);
56  $this->assertEquals($expected, $actual);
57  }
58 
62  public function getDefaultConfigurationFromExtConfTemplateAsValuedArrayReturnsExpectedExampleArray() {
64  $configurationUtility = $this->getAccessibleMock(
65  'TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility',
66  array('getDefaultConfigurationRawString', 'getExtensionPathInformation')
67  );
68  $configurationUtility
69  ->expects($this->once())
70  ->method('getDefaultConfigurationRawString')
71  ->will($this->returnValue('foo'));
72 
73  $configurationUtility
74  ->expects($this->once())
75  ->method('getExtensionPathInformation')
76  ->will($this->returnValue(NULL));
77 
78  $tsStyleConfig = $this->getMock('TYPO3\\CMS\\Core\\TypoScript\\ConfigurationForm');
79 
80  $objectManagerMock = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
81  $configurationUtility->_set('objectManager', $objectManagerMock);
82  $objectManagerMock
83  ->expects($this->once())
84  ->method('get')
85  ->with('TYPO3\\CMS\\Core\\TypoScript\\ConfigurationForm')
86  ->will($this->returnValue($tsStyleConfig));
87 
88  $constants = array(
89  'checkConfigurationFE' => array(
90  'cat' => 'basic',
91  'subcat_name' => 'enable',
92  'subcat' => 'a/enable/z',
93  'type' => 'user[TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]',
94  'label' => 'Frontend configuration check',
95  'name' => 'checkConfigurationFE',
96  'value' => '0',
97  'default_value' => '0'
98  ),
99  'BE.forceSalted' => array(
100  'cat' => 'advancedbackend',
101  'subcat' => 'x/z',
102  'type' => 'boolean',
103  'label' => 'Force salted passwords: Enforce usage of SaltedPasswords. Old MD5 hashed passwords will stop working.',
104  'name' => 'BE.forceSalted',
105  'value' => '0',
106  'default_value' => '0'
107  )
108  );
109  $tsStyleConfig
110  ->expects($this->once())
111  ->method('ext_initTSstyleConfig')
112  ->will($this->returnValue($constants));
113 
114  $setupTsConstantEditor = array(
115  'advancedbackend.' => array(
116  'description' => '<span style="background:red; padding:1px 2px; color:#fff; font-weight:bold;">1</span> Install tool has hardcoded md5 hashing, enabling this setting will prevent use of a install-tool-created BE user.<br />Currently same is for changin password with user setup module unless you use pending patch!',
117  1 => 'BE.forceSalted'
118  )
119  );
120  $tsStyleConfig->setup['constants']['TSConstantEditor.'] = $setupTsConstantEditor;
121 
122  $expected = array(
123  'checkConfigurationFE' => array(
124  'cat' => 'basic',
125  'subcat_name' => 'enable',
126  'subcat' => 'a/enable/z',
127  'type' => 'user[TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]',
128  'label' => 'Frontend configuration check',
129  'name' => 'checkConfigurationFE',
130  'value' => '0',
131  'default_value' => '0',
132  'subcat_label' => 'Enable features',
133  ),
134  'BE.forceSalted' => array(
135  'cat' => 'advancedbackend',
136  'subcat' => 'x/z',
137  'type' => 'boolean',
138  'label' => 'Force salted passwords: Enforce usage of SaltedPasswords. Old MD5 hashed passwords will stop working.',
139  'name' => 'BE.forceSalted',
140  'value' => '0',
141  'default_value' => '0',
142  'highlight' => 1,
143  ),
144  '__meta__' => array(
145  'advancedbackend' => array(
146  'highlightText' => '<span style="background:red; padding:1px 2px; color:#fff; font-weight:bold;">1</span> Install tool has hardcoded md5 hashing, enabling this setting will prevent use of a install-tool-created BE user.<br />Currently same is for changin password with user setup module unless you use pending patch!'
147  )
148  )
149  );
150 
151  $result = $configurationUtility->getDefaultConfigurationFromExtConfTemplateAsValuedArray($this->getUniqueId('some_extension'));
152  $this->assertEquals($expected, $result);
153  }
154 
161  return array(
162  'plain array' => array(
163  array(
164  'first' => array(
165  'value' => 'value1'
166  ),
167  'second' => array(
168  'value' => 'value2'
169  )
170  ),
171  array(
172  'first' => 'value1',
173  'second' => 'value2'
174  )
175  ),
176  'nested value with 2 levels' => array(
177  array(
178  'first.firstSub' => array(
179  'value' => 'value1'
180  ),
181  'second.secondSub' => array(
182  'value' => 'value2'
183  )
184  ),
185  array(
186  'first.' => array(
187  'firstSub' => 'value1'
188  ),
189  'second.' => array(
190  'secondSub' => 'value2'
191  )
192  )
193  ),
194  'nested value with 3 levels' => array(
195  array(
196  'first.firstSub.firstSubSub' => array(
197  'value' => 'value1'
198  ),
199  'second.secondSub.secondSubSub' => array(
200  'value' => 'value2'
201  )
202  ),
203  array(
204  'first.' => array(
205  'firstSub.' => array(
206  'firstSubSub' => 'value1'
207  )
208  ),
209  'second.' => array(
210  'secondSub.' => array(
211  'secondSubSub' => 'value2'
212  )
213  )
214  )
215  ),
216  'mixed nested value with 2 levels' => array(
217  array(
218  'first' => array(
219  'value' => 'firstValue'
220  ),
221  'first.firstSub' => array(
222  'value' => 'value1'
223  ),
224  'second.secondSub' => array(
225  'value' => 'value2'
226  )
227  ),
228  array(
229  'first' => 'firstValue',
230  'first.' => array(
231  'firstSub' => 'value1'
232  ),
233  'second.' => array(
234  'secondSub' => 'value2'
235  )
236  )
237  )
238  );
239  }
240 
249  public function convertValuedToNestedConfiguration(array $configuration, array $expected) {
251  $subject = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility', array('dummy'), array(), '', FALSE);
252  $this->assertEquals($expected, $subject->convertValuedToNestedConfiguration($configuration));
253  }
254 
261  return array(
262  'plain array' => array(
263  array(
264  'first' => 'value1',
265  'second' => 'value2'
266  ),
267  array(
268  'first' => array('value' => 'value1'),
269  'second' => array('value' => 'value2'),
270  )
271  ),
272  'two levels' => array(
273  array(
274  'first.' => array('firstSub' => 'value1'),
275  'second.' => array('firstSub' => 'value2'),
276  ),
277  array(
278  'first.firstSub' => array('value' => 'value1'),
279  'second.firstSub' => array('value' => 'value2'),
280  )
281  ),
282  'three levels' => array(
283  array(
284  'first.' => array('firstSub.' => array('firstSubSub' => 'value1')),
285  'second.' => array('firstSub.' => array('firstSubSub' => 'value2'))
286  ),
287  array(
288  'first.firstSub.firstSubSub' => array('value' => 'value1'),
289  'second.firstSub.firstSubSub' => array('value' => 'value2'),
290  )
291  ),
292  'mixed' => array(
293  array(
294  'first.' => array('firstSub' => 'value1'),
295  'second.' => array('firstSub.' => array('firstSubSub' => 'value2')),
296  'third' => 'value3'
297  ),
298  array(
299  'first.firstSub' => array('value' => 'value1'),
300  'second.firstSub.firstSubSub' => array('value' => 'value2'),
301  'third' => array('value' => 'value3')
302  )
303  )
304  );
305  }
306 
315  public function convertNestedToValuedConfiguration(array $configuration, array $expected) {
317  $subject = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\ConfigurationUtility', array('dummy'), array(), '', FALSE);
318  $this->assertEquals($expected, $subject->convertNestedToValuedConfiguration($configuration));
319  }
320 }
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]