2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Utility;
26 public function getCurrentConfigurationReturnsExtensionConfigurationAsValuedConfiguration()
29 $configurationUtility = $this->getMock(
30 \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility::class,
31 array(
'getDefaultConfigurationFromExtConfTemplateAsValuedArray')
34 ->expects($this->once())
35 ->method(
'getDefaultConfigurationFromExtConfTemplateAsValuedArray')
36 ->will($this->returnValue(array()));
37 $extensionKey = $this->getUniqueId(
'some-extension');
39 $currentConfiguration = array(
50 'key2.subkey1' => array(
55 $GLOBALS[
'TYPO3_CONF_VARS'][
'EXT'][
'extConf'][$extensionKey] = serialize($currentConfiguration);
56 $actual = $configurationUtility->getCurrentConfiguration($extensionKey);
57 $this->assertEquals($expected, $actual);
63 public function getDefaultConfigurationFromExtConfTemplateAsValuedArrayReturnsExpectedExampleArray()
66 $configurationUtility = $this->getAccessibleMock(
67 \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility::class,
68 array(
'getDefaultConfigurationRawString',
'getExtensionPathInformation')
71 ->expects($this->once())
72 ->method(
'getDefaultConfigurationRawString')
73 ->will($this->returnValue(
'foo'));
76 ->expects($this->once())
77 ->method(
'getExtensionPathInformation')
78 ->will($this->returnValue(null));
80 $tsStyleConfig = $this->getMock(\TYPO3\CMS\Core\TypoScript\ConfigurationForm::class);
82 $objectManagerMock = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
83 $configurationUtility->_set(
'objectManager', $objectManagerMock);
85 ->expects($this->once())
87 ->with(\TYPO3\CMS\Core\TypoScript\ConfigurationForm::class)
88 ->will($this->returnValue($tsStyleConfig));
91 'checkConfigurationFE' => array(
93 'subcat_name' =>
'enable',
94 'subcat' =>
'a/enable/z',
95 'type' =>
'user[TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]',
96 'label' =>
'Frontend configuration check',
97 'name' =>
'checkConfigurationFE',
99 'default_value' =>
'0'
101 'BE.forceSalted' => array(
102 'cat' =>
'advancedbackend',
105 'label' =>
'Force salted passwords: Enforce usage of SaltedPasswords. Old MD5 hashed passwords will stop working.',
106 'name' =>
'BE.forceSalted',
108 'default_value' =>
'0'
112 ->expects($this->once())
113 ->method(
'ext_initTSstyleConfig')
114 ->will($this->returnValue($constants));
116 $setupTsConstantEditor = array(
117 'advancedbackend.' => array(
118 '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!',
119 1 =>
'BE.forceSalted'
122 $tsStyleConfig->setup[
'constants'][
'TSConstantEditor.'] = $setupTsConstantEditor;
125 'checkConfigurationFE' => array(
127 'subcat_name' =>
'enable',
128 'subcat' =>
'a/enable/z',
129 'type' =>
'user[TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]',
130 'label' =>
'Frontend configuration check',
131 'name' =>
'checkConfigurationFE',
133 'default_value' =>
'0',
134 'subcat_label' =>
'Enable features',
136 'BE.forceSalted' => array(
137 'cat' =>
'advancedbackend',
140 'label' =>
'Force salted passwords: Enforce usage of SaltedPasswords. Old MD5 hashed passwords will stop working.',
141 'name' =>
'BE.forceSalted',
143 'default_value' =>
'0',
147 'advancedbackend' => array(
148 '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!'
153 $result = $configurationUtility->getDefaultConfigurationFromExtConfTemplateAsValuedArray($this->getUniqueId(
'some_extension'));
154 $this->assertEquals($expected, $result);
165 'plain array' => array(
179 'nested value with 2 levels' => array(
181 'first.firstSub' => array(
184 'second.secondSub' => array(
190 'firstSub' =>
'value1'
193 'secondSub' =>
'value2'
197 'nested value with 3 levels' => array(
199 'first.firstSub.firstSubSub' => array(
202 'second.secondSub.secondSubSub' => array(
208 'firstSub.' => array(
209 'firstSubSub' =>
'value1'
213 'secondSub.' => array(
214 'secondSubSub' =>
'value2'
219 'mixed nested value with 2 levels' => array(
222 'value' =>
'firstValue'
224 'first.firstSub' => array(
227 'second.secondSub' => array(
232 'first' =>
'firstValue',
234 'firstSub' =>
'value1'
237 'secondSub' =>
'value2'
252 public function convertValuedToNestedConfiguration(array $configuration, array $expected)
255 $subject = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility::class, array(
'dummy'), array(),
'',
false);
256 $this->assertEquals($expected, $subject->convertValuedToNestedConfiguration($configuration));
267 'plain array' => array(
273 'first' => array(
'value' =>
'value1'),
274 'second' => array(
'value' =>
'value2'),
277 'two levels' => array(
279 'first.' => array(
'firstSub' =>
'value1'),
280 'second.' => array(
'firstSub' =>
'value2'),
283 'first.firstSub' => array(
'value' =>
'value1'),
284 'second.firstSub' => array(
'value' =>
'value2'),
287 'three levels' => array(
289 'first.' => array(
'firstSub.' => array(
'firstSubSub' =>
'value1')),
290 'second.' => array(
'firstSub.' => array(
'firstSubSub' =>
'value2'))
293 'first.firstSub.firstSubSub' => array(
'value' =>
'value1'),
294 'second.firstSub.firstSubSub' => array(
'value' =>
'value2'),
299 'first.' => array(
'firstSub' =>
'value1'),
300 'second.' => array(
'firstSub.' => array(
'firstSubSub' =>
'value2')),
304 'first.firstSub' => array(
'value' =>
'value1'),
305 'second.firstSub.firstSubSub' => array(
'value' =>
'value2'),
306 'third' => array(
'value' =>
'value3')
320 public function convertNestedToValuedConfiguration(array $configuration, array $expected)
323 $subject = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility::class, array(
'dummy'), array(),
'',
false);
324 $this->assertEquals($expected, $subject->convertNestedToValuedConfiguration($configuration));