[TASK] Add missing unit tests for SilentConfigurationUpgradeService (5)
[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\Install\Controller\Exception\RedirectException;
18 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
19
20
21 /**
22 * Test case
23 */
24 class SilentConfigurationUpgradeServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
25
26 /**
27 * @var \TYPO3\CMS\Core\Configuration\ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject
28 */
29 protected $configurationManager;
30
31 /**
32 * @param array $methods
33 */
34 protected function createConfigurationManagerWithMockedMethods(array $methods) {
35 $this->configurationManager = $this->getMock(
36 \TYPO3\CMS\Core\Configuration\ConfigurationManager::class,
37 $methods
38 );
39 }
40
41 /**
42 * Dataprovider for configureBackendLoginSecurity
43 *
44 * @return array
45 */
46 public function configureBackendLoginSecurityLocalconfiguration() {
47 return array(
48 array('', 'rsa', TRUE, FALSE),
49 array('normal', 'rsa', TRUE, TRUE),
50 array('rsa', 'normal', FALSE, TRUE),
51 );
52 }
53
54 /**
55 * @test
56 * @dataProvider configureBackendLoginSecurityLocalconfiguration
57 */
58 public function configureBackendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig) {
59 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
60 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
61 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
62 array('dummy'),
63 array(),
64 '',
65 FALSE
66 );
67
68 /** @var $packageManager \TYPO3\CMS\Core\Package\PackageManager|\PHPUnit_Framework_MockObject_MockObject */
69 $packageManager = $this->getMock(\TYPO3\CMS\Core\Package\PackageManager::class, array(), array(), '', FALSE);
70 $packageManager->expects($this->any())
71 ->method('isPackageActive')
72 ->will($this->returnValue($isPackageActive));
73 ExtensionManagementUtility::setPackageManager($packageManager);
74
75 $currentLocalConfiguration = array(
76 array('BE/loginSecurityLevel', $current)
77 );
78 $closure = function () {
79 throw new \RuntimeException('Path does not exist in array', 1341397869);
80 };
81
82 $this->createConfigurationManagerWithMockedMethods(
83 array(
84 'getLocalConfigurationValueByPath',
85 'setLocalConfigurationValueByPath',
86 )
87 );
88 if ($hasLocalConfig) {
89 $this->configurationManager->expects($this->once())
90 ->method('getLocalConfigurationValueByPath')
91 ->will($this->returnValueMap($currentLocalConfiguration));
92 } else {
93 $this->configurationManager->expects($this->once())
94 ->method('getLocalConfigurationValueByPath')
95 ->will($this->returnCallback($closure));
96 }
97 $this->configurationManager->expects($this->once())
98 ->method('setLocalConfigurationValueByPath')
99 ->with($this->equalTo('BE/loginSecurityLevel'), $this->equalTo($setting));
100
101 $this->setExpectedException(\TYPO3\CMS\Install\Controller\Exception\RedirectException::class);
102
103 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
104
105 $silentConfigurationUpgradeServiceInstance->_call('configureBackendLoginSecurity');
106 }
107
108 /**
109 * @test
110 */
111 public function removeObsoleteLocalConfigurationSettingsIfThereAreOldSettings() {
112 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
113 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
114 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
115 array('dummy'),
116 array(),
117 '',
118 FALSE
119 );
120
121 $obsoleteLocalConfigurationSettings = array(
122 'SYS/form_enctype',
123 );
124
125 $currentLocalConfiguration = array(
126 array($obsoleteLocalConfigurationSettings, TRUE)
127 );
128 $this->createConfigurationManagerWithMockedMethods(
129 array(
130 'removeLocalConfigurationKeysByPath',
131 )
132 );
133 $this->configurationManager->expects($this->exactly(1))
134 ->method('removeLocalConfigurationKeysByPath')
135 ->will($this->returnValueMap($currentLocalConfiguration));
136
137 $this->setExpectedException(\TYPO3\CMS\Install\Controller\Exception\RedirectException::class);
138
139 $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
140 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
141
142 $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
143 }
144
145 /**
146 * @test
147 */
148 public function doNotRemoveObsoleteLocalConfigurationSettingsIfThereAreNoOldSettings() {
149 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
150 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
151 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
152 array('dummy'),
153 array(),
154 '',
155 FALSE
156 );
157
158 $obsoleteLocalConfigurationSettings = array(
159 'SYS/form_enctype',
160 );
161
162 $currentLocalConfiguration = array(
163 array($obsoleteLocalConfigurationSettings, FALSE)
164 );
165 $this->createConfigurationManagerWithMockedMethods(
166 array(
167 'removeLocalConfigurationKeysByPath',
168 )
169 );
170 $this->configurationManager->expects($this->exactly(1))
171 ->method('removeLocalConfigurationKeysByPath')
172 ->will($this->returnValueMap($currentLocalConfiguration));
173
174 $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
175 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
176
177 $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
178 }
179
180 /**
181 * @test
182 */
183 public function configureSaltedPasswordsWithDefaultConfiguration() {
184 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
185 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
186 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
187 array('dummy'),
188 array(),
189 '',
190 FALSE
191 );
192 $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;}}';
193 $defaultConfiguration = array();
194 $defaultConfiguration['EXT']['extConf']['saltedpasswords'] = $config;
195
196 $closure = function () {
197 throw new \RuntimeException('Path does not exist in array', 1341397869);
198 };
199
200 $this->createConfigurationManagerWithMockedMethods(
201 array(
202 'getDefaultConfiguration',
203 'getLocalConfigurationValueByPath',
204 'setLocalConfigurationValueByPath',
205 )
206 );
207 $this->configurationManager->expects($this->exactly(1))
208 ->method('getDefaultConfiguration')
209 ->will($this->returnValue($defaultConfiguration));
210 $this->configurationManager->expects($this->exactly(1))
211 ->method('getLocalConfigurationValueByPath')
212 ->will($this->returnCallback($closure));
213 $this->configurationManager->expects($this->once())
214 ->method('setLocalConfigurationValueByPath')
215 ->with($this->equalTo('EXT/extConf/saltedpasswords'), $this->equalTo($config));
216
217 $this->setExpectedException(\TYPO3\CMS\Install\Controller\Exception\RedirectException::class);
218
219 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
220
221 $silentConfigurationUpgradeServiceInstance->_call('configureSaltedPasswords');
222 }
223
224 /**
225 * @test
226 */
227 public function configureSaltedPasswordsWithExtensionConfigurationBeEnabled() {
228 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
229 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
230 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
231 array('dummy'),
232 array(),
233 '',
234 FALSE
235 );
236 $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;}}';
237 $defaultConfiguration = array();
238 $defaultConfiguration['EXT']['extConf']['saltedpasswords'] = $config;
239
240 $currentLocalConfiguration = array(
241 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;}}')
242 );
243 $newConfig = 'a:2:{s:3:"BE.";a:0:{}s:3:"FE.";a:1:{s:7:"enabled";i:0;}}';
244 $this->createConfigurationManagerWithMockedMethods(
245 array(
246 'getDefaultConfiguration',
247 'getLocalConfigurationValueByPath',
248 'setLocalConfigurationValueByPath',
249 )
250 );
251 $this->configurationManager->expects($this->exactly(1))
252 ->method('getDefaultConfiguration')
253 ->will($this->returnValue($defaultConfiguration));
254 $this->configurationManager->expects($this->exactly(1))
255 ->method('getLocalConfigurationValueByPath')
256 ->will($this->returnValueMap($currentLocalConfiguration));
257 $this->configurationManager->expects($this->once())
258 ->method('setLocalConfigurationValueByPath')
259 ->with($this->equalTo('EXT/extConf/saltedpasswords'), $this->equalTo($newConfig));
260
261 $this->setExpectedException(\TYPO3\CMS\Install\Controller\Exception\RedirectException::class);
262
263 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
264
265 $silentConfigurationUpgradeServiceInstance->_call('configureSaltedPasswords');
266 }
267
268 /**
269 * @test
270 */
271 public function configureSaltedPasswordsWithExtensionConfigurationBeNotEnabled() {
272 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
273 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
274 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
275 array('dummy'),
276 array(),
277 '',
278 FALSE
279 );
280 $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;}}';
281 $defaultConfiguration = array();
282 $defaultConfiguration['EXT']['extConf']['saltedpasswords'] = $config;
283
284 $currentLocalConfiguration = array(
285 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;}}')
286 );
287 $newConfig = 'a:2:{s:3:"BE.";a:1:{s:15:"onlyAuthService";i:0;}s:3:"FE.";a:1:{s:7:"enabled";i:0;}}';
288 $this->createConfigurationManagerWithMockedMethods(
289 array(
290 'getDefaultConfiguration',
291 'getLocalConfigurationValueByPath',
292 'setLocalConfigurationValueByPath',
293 )
294 );
295 $this->configurationManager->expects($this->exactly(1))
296 ->method('getDefaultConfiguration')
297 ->will($this->returnValue($defaultConfiguration));
298 $this->configurationManager->expects($this->exactly(1))
299 ->method('getLocalConfigurationValueByPath')
300 ->will($this->returnValueMap($currentLocalConfiguration));
301 $this->configurationManager->expects($this->once())
302 ->method('setLocalConfigurationValueByPath')
303 ->with($this->equalTo('EXT/extConf/saltedpasswords'), $this->equalTo($newConfig));
304
305 $this->setExpectedException(\TYPO3\CMS\Install\Controller\Exception\RedirectException::class);
306
307 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
308
309 $silentConfigurationUpgradeServiceInstance->_call('configureSaltedPasswords');
310 }
311
312 /**
313 * @test
314 */
315 public function noProxyAuthSchemeSetInLocalConfiguration() {
316 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
317 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
318 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
319 array('dummy'),
320 array(),
321 '',
322 FALSE
323 );
324
325 $closure = function ($param) {
326 throw new \RuntimeException('Path does not exist in array', 1341397869);
327 };
328
329 $this->createConfigurationManagerWithMockedMethods(
330 array(
331 'getLocalConfigurationValueByPath',
332 'removeLocalConfigurationKeysByPath',
333 )
334 );
335 $this->configurationManager->expects($this->exactly(1))
336 ->method('getLocalConfigurationValueByPath')
337 ->will($this->returnCallback($closure));
338 $this->configurationManager->expects($this->never())
339 ->method('removeLocalConfigurationKeysByPath');
340
341 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
342
343 $silentConfigurationUpgradeServiceInstance->_call('setProxyAuthScheme');
344 }
345
346 /**
347 * @test
348 */
349 public function proxyAuthSchemeIsDigest() {
350 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
351 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
352 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
353 array('dummy'),
354 array(),
355 '',
356 FALSE
357 );
358
359 $currentLocalConfiguration = array(
360 array('HTTP/proxy_auth_scheme', 'digest')
361 );
362
363 $this->createConfigurationManagerWithMockedMethods(
364 array(
365 'getLocalConfigurationValueByPath',
366 'removeLocalConfigurationKeysByPath',
367 )
368 );
369 $this->configurationManager->expects($this->exactly(1))
370 ->method('getLocalConfigurationValueByPath')
371 ->will($this->returnValueMap($currentLocalConfiguration));
372 $this->configurationManager->expects($this->never())
373 ->method('removeLocalConfigurationKeysByPath');
374
375 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
376
377 $silentConfigurationUpgradeServiceInstance->_call('setProxyAuthScheme');
378 }
379
380 /**
381 * @test
382 */
383 public function proxyAuthSchemeIsBasic() {
384 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
385 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
386 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
387 array('dummy'),
388 array(),
389 '',
390 FALSE
391 );
392
393 $currentLocalConfiguration = array(
394 array('HTTP/proxy_auth_scheme', 'basic')
395 );
396
397 $this->createConfigurationManagerWithMockedMethods(
398 array(
399 'getLocalConfigurationValueByPath',
400 'removeLocalConfigurationKeysByPath',
401 )
402 );
403 $this->configurationManager->expects($this->exactly(1))
404 ->method('getLocalConfigurationValueByPath')
405 ->will($this->returnValueMap($currentLocalConfiguration));
406 $this->configurationManager->expects($this->once())
407 ->method('removeLocalConfigurationKeysByPath')
408 ->with($this->equalTo(array('HTTP/proxy_auth_scheme')));
409
410 $this->setExpectedException(\TYPO3\CMS\Install\Controller\Exception\RedirectException::class);
411
412 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
413
414 $silentConfigurationUpgradeServiceInstance->_call('setProxyAuthScheme');
415 }
416
417 /**
418 * @test
419 */
420 public function doNotGenerateEncryptionKeyIfExists() {
421 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
422 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
423 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
424 array('dummy'),
425 array(),
426 '',
427 FALSE
428 );
429
430 $currentLocalConfiguration = array(
431 array('SYS/encryptionKey', 'EnCrYpTiOnKeY')
432 );
433
434 $this->createConfigurationManagerWithMockedMethods(
435 array(
436 'getLocalConfigurationValueByPath',
437 'setLocalConfigurationValueByPath',
438 )
439 );
440 $this->configurationManager->expects($this->exactly(1))
441 ->method('getLocalConfigurationValueByPath')
442 ->will($this->returnValueMap($currentLocalConfiguration));
443 $this->configurationManager->expects($this->never())
444 ->method('setLocalConfigurationValueByPath');
445
446 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
447
448 $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
449 }
450
451 /**
452 * @test
453 */
454 public function generateEncryptionKeyIfNotExists() {
455 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
456 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
457 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
458 array('dummy'),
459 array(),
460 '',
461 FALSE
462 );
463
464 $closure = function () {
465 throw new \RuntimeException('Path does not exist in array', 1341397869);
466 };
467
468 $this->createConfigurationManagerWithMockedMethods(
469 array(
470 'getLocalConfigurationValueByPath',
471 'setLocalConfigurationValueByPath',
472 )
473 );
474 $this->configurationManager->expects($this->exactly(1))
475 ->method('getLocalConfigurationValueByPath')
476 ->will($this->returnCallback($closure));
477 $this->configurationManager->expects($this->once())
478 ->method('setLocalConfigurationValueByPath')
479 ->with($this->equalTo('SYS/encryptionKey'), $this->isType('string'));
480
481 $this->setExpectedException(\TYPO3\CMS\Install\Controller\Exception\RedirectException::class);
482
483 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
484
485 $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
486 }
487
488 /**
489 * Dataprovider for transferDeprecatedCurlSettings
490 *
491 * @return array
492 */
493 public function curlProxySettingsToHttpSettingsMapping() {
494 return array(
495 array('http://proxy:3128/', 'proxy', '3128'),
496 array('http://proxy:3128', 'proxy', '3128'),
497 array('proxy:3128', 'proxy', '3128'),
498 array('https://proxy:3128/', 'proxy', '3128'),
499 );
500 }
501
502 /**
503 * @test
504 * @dataProvider curlProxySettingsToHttpSettingsMapping
505 */
506 public function transferDeprecatedCurlSettings($curlProxyServer, $proxyHost, $proxyPort) {
507 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
508 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
509 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
510 array('dummy'),
511 array(),
512 '',
513 FALSE
514 );
515
516 $currentLocalConfiguration = array(
517 array('SYS/curlProxyServer', $curlProxyServer),
518 array('HTTP/proxy_host', ''),
519 array('SYS/curlProxyUserPass', ''),
520 array('HTTP/proxy_user', ''),
521 array('SYS/curlUse', FALSE)
522 );
523 $this->createConfigurationManagerWithMockedMethods(
524 array(
525 'getLocalConfigurationValueByPath',
526 'setLocalConfigurationValueByPath',
527 'getConfigurationValueByPath'
528 )
529 );
530 $this->configurationManager->expects($this->exactly(5))
531 ->method('getLocalConfigurationValueByPath')
532 ->will($this->returnValueMap($currentLocalConfiguration));
533 $this->configurationManager->expects($this->exactly(2))
534 ->method('setLocalConfigurationValueByPath')
535 ->withConsecutive(
536 array('HTTP/proxy_host', $proxyHost),
537 array('HTTP/proxy_port', $proxyPort)
538 );
539
540 $this->setExpectedException(\TYPO3\CMS\Install\Controller\Exception\RedirectException::class);
541
542 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
543
544 $silentConfigurationUpgradeServiceInstance->_call('transferDeprecatedCurlSettings');
545 }
546
547 /**
548 * @test
549 */
550 public function curlProxyServerDoesNotOverwriteHttpSettings() {
551 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
552 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
553 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
554 array('dummy'),
555 array(),
556 '',
557 FALSE
558 );
559
560 $currentLocalConfiguration = array(
561 array('SYS/curlProxyServer', 'http://proxyOld:3128/'),
562 array('SYS/curlProxyUserPass', 'userOld:passOld'),
563 array('HTTP/proxy_host', 'proxyNew'),
564 array('HTTP/proxy_port', '3128'),
565 array('HTTP/proxy_user', 'userNew'),
566 array('HTTP/proxy_pass', 'passNew'),
567 array('SYS/curlUse', FALSE)
568 );
569 $this->createConfigurationManagerWithMockedMethods(
570 array(
571 'getLocalConfigurationValueByPath',
572 'setLocalConfigurationValueByPath',
573 'getConfigurationValueByPath'
574 )
575 );
576 $this->configurationManager->expects($this->exactly(5))
577 ->method('getLocalConfigurationValueByPath')
578 ->will($this->returnValueMap($currentLocalConfiguration));
579 $this->configurationManager->expects($this->never())
580 ->method('setLocalConfigurationValueByPath');
581
582 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
583
584 $silentConfigurationUpgradeServiceInstance->_call('transferDeprecatedCurlSettings');
585 }
586
587 /**
588 * @test
589 */
590 public function curlAdapterUsedIfCurlUse() {
591 /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
592 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
593 \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
594 array('dummy'),
595 array(),
596 '',
597 FALSE
598 );
599
600 $currentLocalConfiguration = array(
601 array('SYS/curlProxyServer', ''),
602 array('SYS/curlProxyUserPass', ''),
603 array('HTTP/proxy_host', 'proxyNew'),
604 array('HTTP/proxy_user', 'userNew'),
605 array('SYS/curlUse', TRUE)
606 );
607 $this->createConfigurationManagerWithMockedMethods(
608 array(
609 'getLocalConfigurationValueByPath',
610 'getConfigurationValueByPath',
611 'setLocalConfigurationValueByPath',
612 )
613 );
614 $this->configurationManager->expects($this->exactly(5))
615 ->method('getLocalConfigurationValueByPath')
616 ->will($this->returnValueMap($currentLocalConfiguration));
617 $this->configurationManager->expects($this->once())
618 ->method('setLocalConfigurationValueByPath')
619 ->withConsecutive(
620 array('HTTP/adapter', 'curl')
621 );
622
623 $this->setExpectedException(\TYPO3\CMS\Install\Controller\Exception\RedirectException::class);
624
625 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
626
627 $silentConfigurationUpgradeServiceInstance->_call('transferDeprecatedCurlSettings');
628 }
629
630 }