[!!!][TASK] Rename GFX settings referring to IM in their name
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Unit / Service / SilentConfigurationUpgradeServiceTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Service;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
18 use TYPO3\CMS\Core\Package\PackageManager;
19 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
20 use TYPO3\CMS\Install\Controller\Exception\RedirectException;
21
22 /**
23 * Test case
24 */
25 class SilentConfigurationUpgradeServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
26 {
27 /**
28 * @var ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject
29 */
30 protected $configurationManager;
31
32 /**
33 * @param array $methods
34 */
35 protected function createConfigurationManagerWithMockedMethods(array $methods)
36 {
37 $this->configurationManager = $this->getMock(
38 ConfigurationManager::class,
39 $methods
40 );
41 }
42
43 /**
44 * Dataprovider for configureBackendLoginSecurity
45 *
46 * @return array
47 */
48 public function configureBackendLoginSecurityLocalconfiguration()
49 {
50 return array(
51 array('', 'rsa', true, false),
52 array('normal', 'rsa', true, true),
53 array('rsa', 'normal', false, true),
54 );
55 }
56
57 /**
58 * @test
59 * @dataProvider configureBackendLoginSecurityLocalconfiguration
60 * @param string $current
61 * @param string $setting
62 * @param bool $isPackageActive
63 * @param bool $hasLocalConfig
64 */
65 public function configureBackendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig)
66 {
67 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
68 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
69 SilentConfigurationUpgradeService::class,
70 array('dummy'),
71 array(),
72 '',
73 false
74 );
75
76 /** @var $packageManager PackageManager|\PHPUnit_Framework_MockObject_MockObject */
77 $packageManager = $this->getMock(PackageManager::class, array(), array(), '', false);
78 $packageManager->expects($this->any())
79 ->method('isPackageActive')
80 ->will($this->returnValue($isPackageActive));
81 ExtensionManagementUtility::setPackageManager($packageManager);
82
83 $currentLocalConfiguration = array(
84 array('BE/loginSecurityLevel', $current)
85 );
86 $closure = function () {
87 throw new \RuntimeException('Path does not exist in array', 1341397869);
88 };
89
90 $this->createConfigurationManagerWithMockedMethods(
91 array(
92 'getLocalConfigurationValueByPath',
93 'setLocalConfigurationValueByPath',
94 )
95 );
96 if ($hasLocalConfig) {
97 $this->configurationManager->expects($this->once())
98 ->method('getLocalConfigurationValueByPath')
99 ->will($this->returnValueMap($currentLocalConfiguration));
100 } else {
101 $this->configurationManager->expects($this->once())
102 ->method('getLocalConfigurationValueByPath')
103 ->will($this->returnCallback($closure));
104 }
105 $this->configurationManager->expects($this->once())
106 ->method('setLocalConfigurationValueByPath')
107 ->with($this->equalTo('BE/loginSecurityLevel'), $this->equalTo($setting));
108
109 $this->setExpectedException(RedirectException::class);
110
111 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
112
113 $silentConfigurationUpgradeServiceInstance->_call('configureBackendLoginSecurity');
114 }
115
116 /**
117 * @test
118 */
119 public function removeObsoleteLocalConfigurationSettingsIfThereAreOldSettings()
120 {
121 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
122 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
123 SilentConfigurationUpgradeService::class,
124 array('dummy'),
125 array(),
126 '',
127 false
128 );
129
130 $obsoleteLocalConfigurationSettings = array(
131 'SYS/form_enctype',
132 );
133
134 $currentLocalConfiguration = array(
135 array($obsoleteLocalConfigurationSettings, true)
136 );
137 $this->createConfigurationManagerWithMockedMethods(
138 array(
139 'removeLocalConfigurationKeysByPath',
140 )
141 );
142 $this->configurationManager->expects($this->exactly(1))
143 ->method('removeLocalConfigurationKeysByPath')
144 ->will($this->returnValueMap($currentLocalConfiguration));
145
146 $this->setExpectedException(RedirectException::class);
147
148 $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
149 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
150
151 $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
152 }
153
154 /**
155 * @test
156 */
157 public function doNotRemoveObsoleteLocalConfigurationSettingsIfThereAreNoOldSettings()
158 {
159 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
160 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
161 SilentConfigurationUpgradeService::class,
162 array('dummy'),
163 array(),
164 '',
165 false
166 );
167
168 $obsoleteLocalConfigurationSettings = array(
169 'SYS/form_enctype',
170 );
171
172 $currentLocalConfiguration = array(
173 array($obsoleteLocalConfigurationSettings, false)
174 );
175 $this->createConfigurationManagerWithMockedMethods(
176 array(
177 'removeLocalConfigurationKeysByPath',
178 )
179 );
180 $this->configurationManager->expects($this->exactly(1))
181 ->method('removeLocalConfigurationKeysByPath')
182 ->will($this->returnValueMap($currentLocalConfiguration));
183
184 $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
185 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
186
187 $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
188 }
189
190 /**
191 * @test
192 */
193 public function configureSaltedPasswordsWithDefaultConfiguration()
194 {
195 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
196 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
197 SilentConfigurationUpgradeService::class,
198 array('dummy'),
199 array(),
200 '',
201 false
202 );
203 $config = 'a:2:{s:3:"BE.";a:3:{s:11:"forceSalted";i:0;s:15:"onlyAuthService";i:0;s:12:"updatePasswd";i:1;}s:3:"FE.";a:4:{s:7:"enabled";i:0;s:11:"forceSalted";i:0;s:15:"onlyAuthService";i:0;s:12:"updatePasswd";i:1;}}';
204 $defaultConfiguration = array();
205 $defaultConfiguration['EXT']['extConf']['saltedpasswords'] = $config;
206
207 $closure = function () {
208 throw new \RuntimeException('Path does not exist in array', 1341397869);
209 };
210
211 $this->createConfigurationManagerWithMockedMethods(
212 array(
213 'getDefaultConfiguration',
214 'getLocalConfigurationValueByPath',
215 'setLocalConfigurationValueByPath',
216 )
217 );
218 $this->configurationManager->expects($this->exactly(1))
219 ->method('getDefaultConfiguration')
220 ->will($this->returnValue($defaultConfiguration));
221 $this->configurationManager->expects($this->exactly(1))
222 ->method('getLocalConfigurationValueByPath')
223 ->will($this->returnCallback($closure));
224 $this->configurationManager->expects($this->once())
225 ->method('setLocalConfigurationValueByPath')
226 ->with($this->equalTo('EXT/extConf/saltedpasswords'), $this->equalTo($config));
227
228 $this->setExpectedException(RedirectException::class);
229
230 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
231
232 $silentConfigurationUpgradeServiceInstance->_call('configureSaltedPasswords');
233 }
234
235 /**
236 * @test
237 */
238 public function configureSaltedPasswordsWithExtensionConfigurationBeEnabled()
239 {
240 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
241 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
242 SilentConfigurationUpgradeService::class,
243 array('dummy'),
244 array(),
245 '',
246 false
247 );
248 $config = 'a:2:{s:3:"BE.";a:1:{s:21:"saltedPWHashingMethod";}s:3:"FE.";a:2:{s:7:"enabled";i:0;s:11:"forceSalted";i:0;}}';
249 $defaultConfiguration = array();
250 $defaultConfiguration['EXT']['extConf']['saltedpasswords'] = $config;
251
252 $currentLocalConfiguration = array(
253 array('EXT/extConf/saltedpasswords', 'a:2:{s:3:"BE.";a:1:{s:7:"enabled";i:1;}s:3:"FE.";a:1:{s:7:"enabled";i:0;}}')
254 );
255 $newConfig = 'a:2:{s:3:"BE.";a:0:{}s:3:"FE.";a:1:{s:7:"enabled";i:0;}}';
256 $this->createConfigurationManagerWithMockedMethods(
257 array(
258 'getDefaultConfiguration',
259 'getLocalConfigurationValueByPath',
260 'setLocalConfigurationValueByPath',
261 )
262 );
263 $this->configurationManager->expects($this->exactly(1))
264 ->method('getDefaultConfiguration')
265 ->will($this->returnValue($defaultConfiguration));
266 $this->configurationManager->expects($this->exactly(1))
267 ->method('getLocalConfigurationValueByPath')
268 ->will($this->returnValueMap($currentLocalConfiguration));
269 $this->configurationManager->expects($this->once())
270 ->method('setLocalConfigurationValueByPath')
271 ->with($this->equalTo('EXT/extConf/saltedpasswords'), $this->equalTo($newConfig));
272
273 $this->setExpectedException(RedirectException::class);
274
275 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
276
277 $silentConfigurationUpgradeServiceInstance->_call('configureSaltedPasswords');
278 }
279
280 /**
281 * @test
282 */
283 public function configureSaltedPasswordsWithExtensionConfigurationBeNotEnabled()
284 {
285 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
286 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
287 SilentConfigurationUpgradeService::class,
288 array('dummy'),
289 array(),
290 '',
291 false
292 );
293 $config = 'a:2:{s:3:"BE.";a:1:{s:15:"onlyAuthService";i:0;}s:3:"FE.";a:2:{s:7:"enabled";i:0;s:11:"forceSalted";i:0;}}';
294 $defaultConfiguration = array();
295 $defaultConfiguration['EXT']['extConf']['saltedpasswords'] = $config;
296
297 $currentLocalConfiguration = array(
298 array('EXT/extConf/saltedpasswords', 'a:2:{s:3:"BE.";a:2:{s:7:"enabled";i:0;s:12:"updatePasswd";i:1;}s:3:"FE.";a:1:{s:7:"enabled";i:0;}}')
299 );
300 $newConfig = 'a:2:{s:3:"BE.";a:1:{s:15:"onlyAuthService";i:0;}s:3:"FE.";a:1:{s:7:"enabled";i:0;}}';
301 $this->createConfigurationManagerWithMockedMethods(
302 array(
303 'getDefaultConfiguration',
304 'getLocalConfigurationValueByPath',
305 'setLocalConfigurationValueByPath',
306 )
307 );
308 $this->configurationManager->expects($this->exactly(1))
309 ->method('getDefaultConfiguration')
310 ->will($this->returnValue($defaultConfiguration));
311 $this->configurationManager->expects($this->exactly(1))
312 ->method('getLocalConfigurationValueByPath')
313 ->will($this->returnValueMap($currentLocalConfiguration));
314 $this->configurationManager->expects($this->once())
315 ->method('setLocalConfigurationValueByPath')
316 ->with($this->equalTo('EXT/extConf/saltedpasswords'), $this->equalTo($newConfig));
317
318 $this->setExpectedException(RedirectException::class);
319
320 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
321
322 $silentConfigurationUpgradeServiceInstance->_call('configureSaltedPasswords');
323 }
324
325 /**
326 * @test
327 */
328 public function noProxyAuthSchemeSetInLocalConfiguration()
329 {
330 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
331 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
332 SilentConfigurationUpgradeService::class,
333 array('dummy'),
334 array(),
335 '',
336 false
337 );
338
339 $closure = function () {
340 throw new \RuntimeException('Path does not exist in array', 1341397869);
341 };
342
343 $this->createConfigurationManagerWithMockedMethods(
344 array(
345 'getLocalConfigurationValueByPath',
346 'removeLocalConfigurationKeysByPath',
347 )
348 );
349 $this->configurationManager->expects($this->exactly(1))
350 ->method('getLocalConfigurationValueByPath')
351 ->will($this->returnCallback($closure));
352 $this->configurationManager->expects($this->never())
353 ->method('removeLocalConfigurationKeysByPath');
354
355 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
356
357 $silentConfigurationUpgradeServiceInstance->_call('setProxyAuthScheme');
358 }
359
360 /**
361 * @test
362 */
363 public function proxyAuthSchemeIsDigest()
364 {
365 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
366 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
367 SilentConfigurationUpgradeService::class,
368 array('dummy'),
369 array(),
370 '',
371 false
372 );
373
374 $currentLocalConfiguration = array(
375 array('HTTP/proxy_auth_scheme', 'digest')
376 );
377
378 $this->createConfigurationManagerWithMockedMethods(
379 array(
380 'getLocalConfigurationValueByPath',
381 'removeLocalConfigurationKeysByPath',
382 )
383 );
384 $this->configurationManager->expects($this->exactly(1))
385 ->method('getLocalConfigurationValueByPath')
386 ->will($this->returnValueMap($currentLocalConfiguration));
387 $this->configurationManager->expects($this->never())
388 ->method('removeLocalConfigurationKeysByPath');
389
390 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
391
392 $silentConfigurationUpgradeServiceInstance->_call('setProxyAuthScheme');
393 }
394
395 /**
396 * @test
397 */
398 public function proxyAuthSchemeIsBasic()
399 {
400 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
401 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
402 SilentConfigurationUpgradeService::class,
403 array('dummy'),
404 array(),
405 '',
406 false
407 );
408
409 $currentLocalConfiguration = array(
410 array('HTTP/proxy_auth_scheme', 'basic')
411 );
412
413 $this->createConfigurationManagerWithMockedMethods(
414 array(
415 'getLocalConfigurationValueByPath',
416 'removeLocalConfigurationKeysByPath',
417 )
418 );
419 $this->configurationManager->expects($this->exactly(1))
420 ->method('getLocalConfigurationValueByPath')
421 ->will($this->returnValueMap($currentLocalConfiguration));
422 $this->configurationManager->expects($this->once())
423 ->method('removeLocalConfigurationKeysByPath')
424 ->with($this->equalTo(array('HTTP/proxy_auth_scheme')));
425
426 $this->setExpectedException(RedirectException::class);
427
428 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
429
430 $silentConfigurationUpgradeServiceInstance->_call('setProxyAuthScheme');
431 }
432
433 /**
434 * @test
435 */
436 public function doNotGenerateEncryptionKeyIfExists()
437 {
438 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
439 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
440 SilentConfigurationUpgradeService::class,
441 array('dummy'),
442 array(),
443 '',
444 false
445 );
446
447 $currentLocalConfiguration = array(
448 array('SYS/encryptionKey', 'EnCrYpTiOnKeY')
449 );
450
451 $this->createConfigurationManagerWithMockedMethods(
452 array(
453 'getLocalConfigurationValueByPath',
454 'setLocalConfigurationValueByPath',
455 )
456 );
457 $this->configurationManager->expects($this->exactly(1))
458 ->method('getLocalConfigurationValueByPath')
459 ->will($this->returnValueMap($currentLocalConfiguration));
460 $this->configurationManager->expects($this->never())
461 ->method('setLocalConfigurationValueByPath');
462
463 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
464
465 $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
466 }
467
468 /**
469 * @test
470 */
471 public function generateEncryptionKeyIfNotExists()
472 {
473 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
474 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
475 SilentConfigurationUpgradeService::class,
476 array('dummy'),
477 array(),
478 '',
479 false
480 );
481
482 $closure = function () {
483 throw new \RuntimeException('Path does not exist in array', 1341397869);
484 };
485
486 $this->createConfigurationManagerWithMockedMethods(
487 array(
488 'getLocalConfigurationValueByPath',
489 'setLocalConfigurationValueByPath',
490 )
491 );
492 $this->configurationManager->expects($this->exactly(1))
493 ->method('getLocalConfigurationValueByPath')
494 ->will($this->returnCallback($closure));
495 $this->configurationManager->expects($this->once())
496 ->method('setLocalConfigurationValueByPath')
497 ->with($this->equalTo('SYS/encryptionKey'), $this->isType('string'));
498
499 $this->setExpectedException(RedirectException::class);
500
501 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
502
503 $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
504 }
505
506 /**
507 * Dataprovider for transferDeprecatedCurlSettings
508 *
509 * @return array
510 */
511 public function curlProxySettingsToHttpSettingsMapping()
512 {
513 return array(
514 array('http://proxy:3128/', 'proxy', '3128'),
515 array('http://proxy:3128', 'proxy', '3128'),
516 array('proxy:3128', 'proxy', '3128'),
517 array('https://proxy:3128/', 'proxy', '3128'),
518 );
519 }
520
521 /**
522 * @test
523 * @dataProvider curlProxySettingsToHttpSettingsMapping
524 * @param string $curlProxyServer
525 * @param string $proxyHost
526 * @param string $proxyPort
527 */
528 public function transferDeprecatedCurlSettings($curlProxyServer, $proxyHost, $proxyPort)
529 {
530 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
531 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
532 SilentConfigurationUpgradeService::class,
533 array('dummy'),
534 array(),
535 '',
536 false
537 );
538
539 $currentLocalConfiguration = array(
540 array('SYS/curlProxyServer', $curlProxyServer),
541 array('HTTP/proxy_host', ''),
542 array('SYS/curlProxyUserPass', ''),
543 array('HTTP/proxy_user', ''),
544 array('SYS/curlUse', false)
545 );
546 $this->createConfigurationManagerWithMockedMethods(
547 array(
548 'getLocalConfigurationValueByPath',
549 'setLocalConfigurationValueByPath',
550 'getConfigurationValueByPath'
551 )
552 );
553 $this->configurationManager->expects($this->exactly(5))
554 ->method('getLocalConfigurationValueByPath')
555 ->will($this->returnValueMap($currentLocalConfiguration));
556 $this->configurationManager->expects($this->exactly(2))
557 ->method('setLocalConfigurationValueByPath')
558 ->withConsecutive(
559 array('HTTP/proxy_host', $proxyHost),
560 array('HTTP/proxy_port', $proxyPort)
561 );
562
563 $this->setExpectedException(RedirectException::class);
564
565 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
566
567 $silentConfigurationUpgradeServiceInstance->_call('transferDeprecatedCurlSettings');
568 }
569
570 /**
571 * @test
572 */
573 public function curlProxyServerDoesNotOverwriteHttpSettings()
574 {
575 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
576 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
577 SilentConfigurationUpgradeService::class,
578 array('dummy'),
579 array(),
580 '',
581 false
582 );
583
584 $currentLocalConfiguration = array(
585 array('SYS/curlProxyServer', 'http://proxyOld:3128/'),
586 array('SYS/curlProxyUserPass', 'userOld:passOld'),
587 array('HTTP/proxy_host', 'proxyNew'),
588 array('HTTP/proxy_port', '3128'),
589 array('HTTP/proxy_user', 'userNew'),
590 array('HTTP/proxy_pass', 'passNew'),
591 array('SYS/curlUse', false)
592 );
593 $this->createConfigurationManagerWithMockedMethods(
594 array(
595 'getLocalConfigurationValueByPath',
596 'setLocalConfigurationValueByPath',
597 'getConfigurationValueByPath'
598 )
599 );
600 $this->configurationManager->expects($this->exactly(5))
601 ->method('getLocalConfigurationValueByPath')
602 ->will($this->returnValueMap($currentLocalConfiguration));
603 $this->configurationManager->expects($this->never())
604 ->method('setLocalConfigurationValueByPath');
605
606 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
607
608 $silentConfigurationUpgradeServiceInstance->_call('transferDeprecatedCurlSettings');
609 }
610
611 /**
612 * @test
613 */
614 public function curlAdapterUsedIfCurlUse()
615 {
616 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
617 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
618 SilentConfigurationUpgradeService::class,
619 array('dummy'),
620 array(),
621 '',
622 false
623 );
624
625 $currentLocalConfiguration = array(
626 array('SYS/curlProxyServer', ''),
627 array('SYS/curlProxyUserPass', ''),
628 array('HTTP/proxy_host', 'proxyNew'),
629 array('HTTP/proxy_user', 'userNew'),
630 array('SYS/curlUse', true)
631 );
632 $this->createConfigurationManagerWithMockedMethods(
633 array(
634 'getLocalConfigurationValueByPath',
635 'getConfigurationValueByPath',
636 'setLocalConfigurationValueByPath',
637 )
638 );
639 $this->configurationManager->expects($this->exactly(5))
640 ->method('getLocalConfigurationValueByPath')
641 ->will($this->returnValueMap($currentLocalConfiguration));
642 $this->configurationManager->expects($this->once())
643 ->method('setLocalConfigurationValueByPath')
644 ->withConsecutive(
645 array('HTTP/adapter', 'curl')
646 );
647
648 $this->setExpectedException(RedirectException::class);
649
650 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
651
652 $silentConfigurationUpgradeServiceInstance->_call('transferDeprecatedCurlSettings');
653 }
654
655 /**
656 * @test
657 */
658 public function disableImageMagickDetailSettingsIfImageMagickIsDisabled()
659 {
660 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
661 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
662 SilentConfigurationUpgradeService::class,
663 array('dummy'),
664 array(),
665 '',
666 false
667 );
668
669 $currentLocalConfiguration = array(
670 array('GFX/im', 0),
671 array('GFX/im_path', ''),
672 array('GFX/im_path_lzw', ''),
673 array('GFX/imagefile_ext', 'gif,jpg,png'),
674 array('GFX/thumbnails', 0)
675 );
676 $this->createConfigurationManagerWithMockedMethods(
677 array(
678 'getLocalConfigurationValueByPath',
679 'getDefaultConfigurationValueByPath',
680 'setLocalConfigurationValuesByPathValuePairs',
681 )
682 );
683 $this->configurationManager->expects($this->exactly(5))
684 ->method('getLocalConfigurationValueByPath')
685 ->will($this->returnValueMap($currentLocalConfiguration));
686 $this->configurationManager->expects($this->never())
687 ->method('getDefaultConfigurationValueByPath');
688 $this->configurationManager->expects($this->once())
689 ->method('setLocalConfigurationValuesByPathValuePairs')
690 ->withConsecutive(
691 array(array('GFX/imagefile_ext' => 'gif,jpg,jpeg,png'))
692 );
693
694 $this->setExpectedException(RedirectException::class);
695
696 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
697
698 $silentConfigurationUpgradeServiceInstance->_call('disableImageMagickDetailSettingsIfImageMagickIsDisabled');
699 }
700
701 /**
702 * @test
703 */
704 public function doNotDisableImageMagickDetailSettingsIfImageMagickIsEnabled()
705 {
706 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
707 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
708 SilentConfigurationUpgradeService::class,
709 array('dummy'),
710 array(),
711 '',
712 false
713 );
714
715 $currentLocalConfiguration = array(
716 array('GFX/im', 1),
717 array('GFX/im_path', ''),
718 array('GFX/im_path_lzw', ''),
719 array('GFX/imagefile_ext', 'gif,jpg,jpeg,png'),
720 array('GFX/thumbnails', 0)
721 );
722 $this->createConfigurationManagerWithMockedMethods(
723 array(
724 'getLocalConfigurationValueByPath',
725 'getDefaultConfigurationValueByPath',
726 'setLocalConfigurationValuesByPathValuePairs',
727 )
728 );
729 $this->configurationManager->expects($this->exactly(5))
730 ->method('getLocalConfigurationValueByPath')
731 ->will($this->returnValueMap($currentLocalConfiguration));
732 $this->configurationManager->expects($this->never())
733 ->method('getDefaultConfigurationValueByPath');
734 $this->configurationManager->expects($this->never())
735 ->method('setLocalConfigurationValuesByPathValuePairs');
736
737 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
738
739 $silentConfigurationUpgradeServiceInstance->_call('disableImageMagickDetailSettingsIfImageMagickIsDisabled');
740 }
741
742 /**
743 * @test
744 */
745 public function setImageMagickDetailSettings()
746 {
747 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
748 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
749 SilentConfigurationUpgradeService::class,
750 array('dummy'),
751 array(),
752 '',
753 false
754 );
755
756 $currentLocalConfiguration = array(
757 array('GFX/processor', 'GraphicsMagick'),
758 array('GFX/processor_allowTemporaryMasksAsPng', 1),
759 array('GFX/processor_effects', 0)
760 );
761 $this->createConfigurationManagerWithMockedMethods(
762 array(
763 'getLocalConfigurationValueByPath',
764 'getDefaultConfigurationValueByPath',
765 'setLocalConfigurationValuesByPathValuePairs',
766 )
767 );
768 $this->configurationManager->expects($this->exactly(3))
769 ->method('getLocalConfigurationValueByPath')
770 ->will($this->returnValueMap($currentLocalConfiguration));
771 $this->configurationManager->expects($this->never())
772 ->method('getDefaultConfigurationValueByPath');
773 $this->configurationManager->expects($this->once())
774 ->method('setLocalConfigurationValuesByPathValuePairs')
775 ->withConsecutive(
776 array(array('GFX/processor_allowTemporaryMasksAsPng' => 0,
777 'GFX/processor_effects' => -1))
778 );
779
780 $this->setExpectedException(RedirectException::class);
781
782 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
783
784 $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
785 }
786
787 /**
788 * @test
789 */
790 public function doNotSetImageMagickDetailSettings()
791 {
792 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
793 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
794 SilentConfigurationUpgradeService::class,
795 array('dummy'),
796 array(),
797 '',
798 false
799 );
800
801 $currentLocalConfiguration = array(
802 array('GFX/processor', ''),
803 array('GFX/processor_allowTemporaryMasksAsPng', 0),
804 array('GFX/processor_effects', 0)
805 );
806 $this->createConfigurationManagerWithMockedMethods(
807 array(
808 'getLocalConfigurationValueByPath',
809 'getDefaultConfigurationValueByPath',
810 'setLocalConfigurationValuesByPathValuePairs',
811 )
812 );
813 $this->configurationManager->expects($this->exactly(3))
814 ->method('getLocalConfigurationValueByPath')
815 ->will($this->returnValueMap($currentLocalConfiguration));
816 $this->configurationManager->expects($this->never())
817 ->method('getDefaultConfigurationValueByPath');
818 $this->configurationManager->expects($this->never())
819 ->method('setLocalConfigurationValuesByPathValuePairs');
820
821 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
822
823 $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
824 }
825 }