2 namespace TYPO3\CMS\Extensionmanager\Tests\Unit\Domain\Repository;
41 $this->configurationItemRepository = $this->getAccessibleMock(
42 \TYPO3\CMS\Extensionmanager\Domain\Repository\ConfigurationItemRepository::class,
46 $this->injectedObjectManagerMock = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class, array(), array(),
'',
false);
47 $this->configurationItemRepository->_set(
49 $this->injectedObjectManagerMock
58 $flatConfigurationItemArray = array(
61 'subcat_name' =>
'enable',
62 'subcat' =>
'a/enable/10z',
64 'label' =>
'Item 1: This is the first configuration item',
67 'default_value' =>
'one',
68 'subcat_label' =>
'Enable features',
70 'integerValue' => array(
72 'subcat_name' =>
'enable',
73 'subcat' =>
'a/enable/20z',
75 'label' =>
'Integer Value: Please insert a positive integer value',
76 'name' =>
'integerValue',
78 'default_value' =>
'1',
79 'subcat_label' =>
'Enable features',
81 'enableJquery' => array(
83 'subcat_name' =>
'file',
84 'subcat' =>
'c/file/10z',
86 'label' =>
'enableJquery: Insert jQuery plugin',
87 'name' =>
'enableJquery',
89 'default_value' =>
'1',
90 'subcat_label' =>
'Files',
95 \TYPO3\CMS\Extensionmanager\Domain\Repository\ConfigurationItemRepository::class,
96 array(
'mergeWithExistingConfiguration',
'translate')
100 $this->injectedObjectManagerMock
102 $configurationUtilityMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility::class, array(), array(),
'',
false);
103 $configurationUtilityMock
104 ->expects($this->once())
105 ->method(
'getDefaultConfigurationFromExtConfTemplateAsValuedArray')
106 ->will($this->returnValue($flatConfigurationItemArray));
107 $this->injectedObjectManagerMock
108 ->expects($this->any())
110 ->will($this->returnValue($configurationUtilityMock));
112 ->expects($this->any())
113 ->method(
'mergeWithExistingConfiguration')
114 ->will($this->returnValue($flatConfigurationItemArray));
116 $expectedArray = array(
121 'subcat_name' =>
'enable',
122 'subcat' =>
'a/enable/10z',
124 'label' =>
'Item 1: This is the first configuration item',
127 'default_value' =>
'one',
128 'subcat_label' =>
'Enable features',
131 1 =>
'This is the first configuration item'
134 'integerValue' => array(
136 'subcat_name' =>
'enable',
137 'subcat' =>
'a/enable/20z',
139 'label' =>
'Integer Value: Please insert a positive integer value',
140 'name' =>
'integerValue',
142 'default_value' =>
'1',
143 'subcat_label' =>
'Enable features',
145 0 =>
'Integer Value',
146 1 =>
'Please insert a positive integer value'
153 'enableJquery' => array(
155 'subcat_name' =>
'file',
156 'subcat' =>
'c/file/10z',
158 'label' =>
'enableJquery: Insert jQuery plugin',
159 'name' =>
'enableJquery',
161 'default_value' =>
'1',
162 'subcat_label' =>
'Files',
165 1 =>
'Insert jQuery plugin'
184 $configuration = array(
185 '__meta__' =>
'metaInformation',
186 'test123' =>
'test123'
188 $this->configurationItemRepository->_callRef(
'addMetaInformation', $configuration);
189 $this->assertEquals(array(
'test123' =>
'test123'), $configuration);
198 $configuration = array(
199 '__meta__' =>
'metaInformation',
200 'test123' =>
'test123'
202 $meta = $this->configurationItemRepository->_callRef(
'addMetaInformation', $configuration);
203 $this->assertEquals(
'metaInformation', $meta);
215 'subcat_name' =>
'enable',
216 'subcat' =>
'a/enable/z',
217 'type' =>
'user[EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationFrontend]',
218 'label' =>
'Frontend configuration check',
219 'name' =>
'checkConfigurationFE',
221 'default_value' => 0,
222 'comparisonGeneric' =>
'EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationFrontend'
228 'subcat_name' =>
'enable',
229 'subcat' =>
'a/enable/z',
230 'type' =>
'user[EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationBackend]',
231 'label' =>
'Backend configuration check',
232 'name' =>
'checkConfigurationBE',
234 'default_value' => 0,
235 'comparisonGeneric' =>
'EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->checkConfigurationBackend'
241 'subcat_name' =>
'enable',
242 'subcat' =>
'a/enable/z',
243 'type' =>
'user[EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->buildHashMethodSelectorFE]',
244 'label' =>
'Hashing method for the frontend: Defines salted hashing method to use. Choose "Portable PHP password hashing" to stay compatible with other CMS (e.g. Drupal, Wordpress). Choose "MD5 salted hashing" to reuse TYPO3 passwords for OS level authentication (other servers could use TYPO3 passwords). Choose "Blowfish salted hashing" for advanced security to reuse passwords on OS level (Blowfish might not be supported on your system TODO).',
245 'name' =>
'FE.saltedPWHashingMethod',
246 'value' => \TYPO3\CMS\Saltedpasswords\Salt\PhpassSalt::class,
247 'default_value' => \TYPO3\CMS\Saltedpasswords\Salt\PhpassSalt::class,
248 'comparisonGeneric' =>
'EXT:saltedpasswords/classes/class.tx_saltedpasswords_emconfhelper.php:TYPO3\\CMS\\Saltedpasswords\\Utility\\ExtensionManagerConfigurationUtility->buildHashMethodSelectorFE'
262 $configurationOptionModified = $this->configurationItemRepository->_callRef(
'extractInformationForConfigFieldsOfTypeUser', $configurationOption);
263 $this->assertEquals(
'user', $configurationOptionModified[
'type']);
264 $this->assertEquals($configurationOption[
'comparisonGeneric'], $configurationOptionModified[
'generic']);
275 'subcat_name' =>
'enable',
276 'subcat' =>
'a/enable/100z',
277 'type' =>
'options[Minimal (Most features disabled. Administrator needs to enable them using TypoScript. For advanced administrators only.),Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.),Demo (Show-off configuration. Includes pre-configured styles. Not for production environments.)]',
278 'label' =>
'Default configuration settings',
279 'name' =>
'defaultConfiguration',
280 'value' =>
'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)',
281 'default_value' =>
'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)',
282 'genericComparisonValue' => array(
283 'Minimal (Most features disabled. Administrator needs to enable them using TypoScript. For advanced administrators only.)' =>
'Minimal (Most features disabled. Administrator needs to enable them using TypoScript. For advanced administrators only.)',
284 'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)' =>
'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)',
285 'Demo (Show-off configuration. Includes pre-configured styles. Not for production environments.)' =>
'Demo (Show-off configuration. Includes pre-configured styles. Not for production environments.)'
287 'typeComparisonValue' =>
'options'
289 $optionModified = $this->configurationItemRepository->_callRef(
'extractInformationForConfigFieldsOfTypeOptions', $option);
290 $this->assertArrayHasKey(
'generic', $optionModified);
291 $this->assertArrayHasKey(
'type', $optionModified);
292 $this->assertArrayHasKey(
'label', $optionModified);
293 $this->assertEquals($option[
'genericComparisonValue'], $optionModified[
'generic']);
294 $this->assertEquals($option[
'typeComparisonValue'], $optionModified[
'type']);
305 'subcat_name' =>
'enable',
306 'subcat' =>
'a/enable/100z',
307 'type' =>
'options[Minimal (Most features disabled. Administrator needs to enable them using TypoScript. For advanced administrators only.)=MINIMAL,Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.) = TYPICAL,Demo (Show-off configuration. Includes pre-configured styles. Not for production environments.)=DEMO]',
308 'label' =>
'Default configuration settings',
309 'name' =>
'defaultConfiguration',
310 'value' =>
'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)',
311 'default_value' =>
'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)',
312 'genericComparisonValue' => array(
313 'Minimal (Most features disabled. Administrator needs to enable them using TypoScript. For advanced administrators only.)' =>
'MINIMAL',
314 'Typical (Most commonly used features are enabled. Select this option if you are unsure which one to use.)' =>
'TYPICAL',
315 'Demo (Show-off configuration. Includes pre-configured styles. Not for production environments.)' =>
'DEMO'
317 'typeComparisonValue' =>
'options'
319 $optionModified = $this->configurationItemRepository->_callRef(
'extractInformationForConfigFieldsOfTypeOptions', $option);
320 $this->assertArrayHasKey(
'generic', $optionModified);
321 $this->assertArrayHasKey(
'type', $optionModified);
322 $this->assertArrayHasKey(
'label', $optionModified);
323 $this->assertEquals($option[
'genericComparisonValue'], $optionModified[
'generic']);
324 $this->assertEquals($option[
'typeComparisonValue'], $optionModified[
'type']);
333 $exception = $this->getMock(
'RuntimeException');
334 $configurationManagerMock = $this->getMock(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
335 $configurationManagerMock
336 ->expects($this->once())
337 ->method(
'getConfigurationValueByPath')
338 ->will($this->throwException($exception));
339 $this->injectedObjectManagerMock
340 ->expects($this->any())
342 ->will($this->returnValue($configurationManagerMock));
344 $this->configurationItemRepository->_call(
345 'mergeWithExistingConfiguration',
347 $this->getUniqueId(
'not_existing_extension')
357 $exception = $this->getMock(
'RuntimeException');
358 $configurationManagerMock = $this->getMock(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
359 $configurationManagerMock
360 ->expects($this->once())
361 ->method(
'getConfigurationValueByPath')
362 ->will($this->throwException($exception));
363 $this->injectedObjectManagerMock
364 ->expects($this->any())
366 ->will($this->returnValue($configurationManagerMock));
367 $defaultConfiguration = array(
370 $configuration = $this->configurationItemRepository->_call(
371 'mergeWithExistingConfiguration',
372 $defaultConfiguration,
373 $this->getUniqueId(
'not_existing_extension')
375 $this->assertEquals($defaultConfiguration, $configuration);
384 $localConfiguration = serialize(array(
387 'saltedPWHashingMethod' => \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface_sha1::class
394 $configurationManagerMock = $this->getMock(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
395 $configurationManagerMock
396 ->expects($this->once())
397 ->method(
'getConfigurationValueByPath')
398 ->with(
'EXT/extConf/testextensionkey')
399 ->will($this->returnValue($localConfiguration));
401 $this->injectedObjectManagerMock
402 ->expects($this->any())
404 ->will($this->returnValue($configurationManagerMock));
406 $defaultConfiguration = array(
407 'FE.enabled' => array(
410 'FE.saltedPWHashingMethod' => array(
411 'value' => \TYPO3\CMS\Saltedpasswords\Salt\Md5Salt::class
413 'BE.enabled' => array(
416 'BE.saltedPWHashingMethod' => array(
417 'value' => \TYPO3\CMS\Saltedpasswords\Salt\Md5Salt::class
421 $expectedResult = array(
422 'FE.enabled' => array(
425 'FE.saltedPWHashingMethod' => array(
426 'value' => \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface_sha1::class
428 'BE.enabled' => array(
431 'BE.saltedPWHashingMethod' => array(
432 'value' => \TYPO3\CMS\Saltedpasswords\Salt\Md5Salt::class
434 'CLI.enabled' => array(
439 $actualResult = $this->configurationItemRepository->_call(
440 'mergeWithExistingConfiguration',
441 $defaultConfiguration,
445 $this->assertEquals($expectedResult, $actualResult);