d5427c610849b442668ab19d6ec9cb9565728b0b
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Unit / Service / SilentConfigurationUpgradeServiceTest.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Install\Tests\Unit\Service;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use Prophecy\Prophecy\ObjectProphecy;
19 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
20 use TYPO3\CMS\Core\Package\PackageManager;
21 use TYPO3\CMS\Core\Tests\Unit\Utility\AccessibleProxies\ExtensionManagementUtilityAccessibleProxy;
22 use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException;
23 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
24 use TYPO3\CMS\Install\Service\Exception\ConfigurationChangedException;
25 use TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27
28 /**
29 * Test case
30 */
31 class SilentConfigurationUpgradeServiceTest extends UnitTestCase
32 {
33 /**
34 * @var ConfigurationManager|\PHPUnit_Framework_MockObject_MockObject
35 */
36 protected $configurationManager;
37
38 /**
39 * @var \TYPO3\CMS\Core\Package\UnitTestPackageManager A backup of unit test package manager
40 */
41 protected $backupPackageManager;
42
43 /**
44 * Set up
45 */
46 protected function setUp()
47 {
48 $this->backupPackageManager = ExtensionManagementUtilityAccessibleProxy::getPackageManager();
49 }
50
51 /**
52 * Tear down
53 */
54 protected function tearDown()
55 {
56 ExtensionManagementUtilityAccessibleProxy::setPackageManager($this->backupPackageManager);
57 parent::tearDown();
58 }
59
60 /**
61 * @param array $methods
62 */
63 protected function createConfigurationManagerWithMockedMethods(array $methods)
64 {
65 $this->configurationManager = $this->getMockBuilder(ConfigurationManager::class)
66 ->setMethods($methods)
67 ->getMock();
68 }
69
70 /**
71 * Dataprovider for configureBackendLoginSecurity
72 *
73 * @return array
74 */
75 public function configureBackendLoginSecurityLocalconfiguration(): array
76 {
77 return [
78 ['', 'rsa', true, false],
79 ['normal', 'rsa', true, true],
80 ['rsa', 'normal', false, true],
81 ];
82 }
83
84 /**
85 * @test
86 * @dataProvider configureBackendLoginSecurityLocalconfiguration
87 * @param string $current
88 * @param string $setting
89 * @param bool $isPackageActive
90 * @param bool $hasLocalConfig
91 */
92 public function configureBackendLoginSecurity($current, $setting, $isPackageActive, $hasLocalConfig)
93 {
94 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
95 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
96 SilentConfigurationUpgradeService::class,
97 ['dummy'],
98 [],
99 '',
100 false
101 );
102
103 /** @var $packageManager PackageManager|\PHPUnit_Framework_MockObject_MockObject */
104 $packageManager = $this->createMock(PackageManager::class);
105 $packageManager->expects($this->any())
106 ->method('isPackageActive')
107 ->will($this->returnValue($isPackageActive));
108 ExtensionManagementUtility::setPackageManager($packageManager);
109
110 $currentLocalConfiguration = [
111 ['BE/loginSecurityLevel', $current]
112 ];
113 $closure = function () {
114 throw new MissingArrayPathException('Path does not exist in array', 1476109311);
115 };
116
117 $this->createConfigurationManagerWithMockedMethods(
118 [
119 'getLocalConfigurationValueByPath',
120 'setLocalConfigurationValueByPath',
121 ]
122 );
123 if ($hasLocalConfig) {
124 $this->configurationManager->expects($this->once())
125 ->method('getLocalConfigurationValueByPath')
126 ->will($this->returnValueMap($currentLocalConfiguration));
127 } else {
128 $this->configurationManager->expects($this->once())
129 ->method('getLocalConfigurationValueByPath')
130 ->will($this->returnCallback($closure));
131 }
132 $this->configurationManager->expects($this->once())
133 ->method('setLocalConfigurationValueByPath')
134 ->with($this->equalTo('BE/loginSecurityLevel'), $this->equalTo($setting));
135
136 $this->expectException(ConfigurationChangedException::class);
137
138 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
139
140 $silentConfigurationUpgradeServiceInstance->_call('configureBackendLoginSecurity');
141 }
142
143 /**
144 * @test
145 */
146 public function removeObsoleteLocalConfigurationSettingsIfThereAreOldSettings()
147 {
148 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
149 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
150 SilentConfigurationUpgradeService::class,
151 ['dummy'],
152 [],
153 '',
154 false
155 );
156
157 $obsoleteLocalConfigurationSettings = [
158 'SYS/form_enctype',
159 ];
160
161 $currentLocalConfiguration = [
162 [$obsoleteLocalConfigurationSettings, true]
163 ];
164 $this->createConfigurationManagerWithMockedMethods(
165 [
166 'removeLocalConfigurationKeysByPath',
167 ]
168 );
169 $this->configurationManager->expects($this->exactly(1))
170 ->method('removeLocalConfigurationKeysByPath')
171 ->will($this->returnValueMap($currentLocalConfiguration));
172
173 $this->expectException(ConfigurationChangedException::class);
174
175 $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
176 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
177
178 $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
179 }
180
181 /**
182 * @test
183 */
184 public function doNotRemoveObsoleteLocalConfigurationSettingsIfThereAreNoOldSettings()
185 {
186 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
187 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
188 SilentConfigurationUpgradeService::class,
189 ['dummy'],
190 [],
191 '',
192 false
193 );
194
195 $obsoleteLocalConfigurationSettings = [
196 'SYS/form_enctype',
197 ];
198
199 $currentLocalConfiguration = [
200 [$obsoleteLocalConfigurationSettings, false]
201 ];
202 $this->createConfigurationManagerWithMockedMethods(
203 [
204 'removeLocalConfigurationKeysByPath',
205 ]
206 );
207 $this->configurationManager->expects($this->exactly(1))
208 ->method('removeLocalConfigurationKeysByPath')
209 ->will($this->returnValueMap($currentLocalConfiguration));
210
211 $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
212 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
213
214 $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
215 }
216
217 /**
218 * @test
219 */
220 public function doNotGenerateEncryptionKeyIfExists()
221 {
222 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
223 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
224 SilentConfigurationUpgradeService::class,
225 ['dummy'],
226 [],
227 '',
228 false
229 );
230
231 $currentLocalConfiguration = [
232 ['SYS/encryptionKey', 'EnCrYpTiOnKeY']
233 ];
234
235 $this->createConfigurationManagerWithMockedMethods(
236 [
237 'getLocalConfigurationValueByPath',
238 'setLocalConfigurationValueByPath',
239 ]
240 );
241 $this->configurationManager->expects($this->exactly(1))
242 ->method('getLocalConfigurationValueByPath')
243 ->will($this->returnValueMap($currentLocalConfiguration));
244 $this->configurationManager->expects($this->never())
245 ->method('setLocalConfigurationValueByPath');
246
247 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
248
249 $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
250 }
251
252 /**
253 * @test
254 */
255 public function generateEncryptionKeyIfNotExists()
256 {
257 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
258 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
259 SilentConfigurationUpgradeService::class,
260 ['dummy'],
261 [],
262 '',
263 false
264 );
265
266 $closure = function () {
267 throw new MissingArrayPathException('Path does not exist in array', 1476109266);
268 };
269
270 $this->createConfigurationManagerWithMockedMethods(
271 [
272 'getLocalConfigurationValueByPath',
273 'setLocalConfigurationValueByPath',
274 ]
275 );
276 $this->configurationManager->expects($this->exactly(1))
277 ->method('getLocalConfigurationValueByPath')
278 ->will($this->returnCallback($closure));
279 $this->configurationManager->expects($this->once())
280 ->method('setLocalConfigurationValueByPath')
281 ->with($this->equalTo('SYS/encryptionKey'), $this->isType('string'));
282
283 $this->expectException(ConfigurationChangedException::class);
284
285 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
286
287 $silentConfigurationUpgradeServiceInstance->_call('generateEncryptionKeyIfNeeded');
288 }
289
290 /**
291 * Data provider for transferHttpSettings
292 *
293 * @return array
294 */
295 public function httpSettingsMappingDataProvider(): array
296 {
297 return [
298 'No changes overridden in Local Configuration' => [
299 ['timeout' => 100],
300 ['HTTP/timeout' => 100],
301 false
302 ],
303 'Old and unused settings removed' => [
304 ['adapter' => 'curl'],
305 [],
306 true
307 ],
308 'Old and used settings changed' => [
309 ['protocol_version' => '1.1'],
310 ['HTTP/version' => '1.1'],
311 true
312 ],
313
314 /** redirect options */
315 'Redirects moved to default' => [
316 ['follow_redirects' => true],
317 [],
318 true
319 ],
320 'Redirects moved #1' => [
321 ['follow_redirects' => true, 'max_redirects' => 200, 'strict_redirects' => false],
322 ['HTTP/allow_redirects' => ['max' => 200]],
323 true
324 ],
325 'Redirects moved #2' => [
326 ['follow_redirects' => false, 'max_redirects' => 200, 'strict_redirects' => false],
327 ['HTTP/allow_redirects' => false],
328 true
329 ],
330 'Redirects moved #3' => [
331 ['follow_redirects' => true, 'max_redirects' => 400, 'strict_redirects' => 1],
332 ['HTTP/allow_redirects' => ['max' => 400, 'strict' => true]],
333 true
334 ],
335
336 /** Proxy settings */
337 'Proxy host set' => [
338 ['proxy_host' => 'vpn.myproxy.com'],
339 ['HTTP/proxy' => 'http://vpn.myproxy.com'],
340 true
341 ],
342 'Proxy host set + port' => [
343 ['proxy_host' => 'vpn.myproxy.com', 'proxy_port' => 8080],
344 ['HTTP/proxy' => 'http://vpn.myproxy.com:8080'],
345 true
346 ],
347 'Proxy host set + port + verification' => [
348 ['proxy_host' => 'vpn.myproxy.com', 'proxy_port' => 8080, 'proxy_auth_scheme' => 'basic', 'proxy_user' => 'myuser', 'proxy_password' => 'mysecret'],
349 ['HTTP/proxy' => 'http://myuser:mysecret@vpn.myproxy.com:8080'],
350 true
351 ],
352
353 /** SSL verification */
354 'Only ssl_capath set, invalid migration' => [
355 ['ssl_capath' => '/foo/bar/'],
356 [],
357 true
358 ],
359 'Verification activated, but only ssl_capath set, using default' => [
360 ['ssl_verify_peer' => 1, 'ssl_capath' => '/foo/bar/'],
361 [],
362 true
363 ],
364 'Verification activated, with ssl_capath and ssl_cafile set' => [
365 ['ssl_verify_peer' => 1, 'ssl_capath' => '/foo/bar/', 'ssl_cafile' => 'supersecret.crt'],
366 ['HTTP/verify' => '/foo/bar/supersecret.crt'],
367 true
368 ],
369
370 /** SSL key + passphrase */
371 'SSL key certification' => [
372 ['ssl_local_cert' => '/foo/bar/supersecret.key'],
373 ['HTTP/ssl_key' => '/foo/bar/supersecret.key'],
374 true
375 ],
376 'SSL key certification + passphrase' => [
377 ['ssl_local_cert' => '/foo/bar/supersecret.key', 'ssl_passphrase' => 'donotcopypasteme'],
378 ['HTTP/ssl_key' => ['/foo/bar/supersecret.key', 'donotcopypasteme']],
379 true
380 ],
381 'SSL key passphrase only - no migration' => [
382 ['ssl_passphrase' => 'donotcopypasteme'],
383 [],
384 true
385 ],
386 ];
387 }
388
389 /**
390 * @test
391 * @dataProvider httpSettingsMappingDataProvider
392 * @param array $currentLocalConfiguration
393 * @param array $newSettings
394 * @param bool $localConfigurationNeedsUpdate
395 */
396 public function transferHttpSettingsIfSet($currentLocalConfiguration, $newSettings, $localConfigurationNeedsUpdate)
397 {
398 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
399 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
400 SilentConfigurationUpgradeService::class,
401 ['dummy'],
402 [],
403 '',
404 false
405 );
406
407 $this->createConfigurationManagerWithMockedMethods(
408 [
409 'setLocalConfigurationValuesByPathValuePairs',
410 'removeLocalConfigurationKeysByPath',
411 'getLocalConfiguration'
412 ]
413 );
414
415 $this->configurationManager->expects($this->any())
416 ->method('getLocalConfiguration')
417 ->willReturn(['HTTP' => $currentLocalConfiguration]);
418 if ($localConfigurationNeedsUpdate) {
419 if (!empty($newSettings)) {
420 $this->configurationManager->expects($this->once())
421 ->method('setLocalConfigurationValuesByPathValuePairs')
422 ->with($newSettings);
423 }
424 $this->configurationManager->expects($this->atMost(1))->method('removeLocalConfigurationKeysByPath');
425 }
426
427 if ($localConfigurationNeedsUpdate) {
428 $this->expectException(ConfigurationChangedException::class);
429 }
430
431 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
432
433 $silentConfigurationUpgradeServiceInstance->_call('transferHttpSettings');
434 }
435
436 /**
437 * @test
438 */
439 public function disableImageMagickDetailSettingsIfImageMagickIsDisabled()
440 {
441 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
442 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
443 SilentConfigurationUpgradeService::class,
444 ['dummy'],
445 [],
446 '',
447 false
448 );
449
450 $currentLocalConfiguration = [
451 ['GFX/im', 0],
452 ['GFX/im_path', ''],
453 ['GFX/im_path_lzw', ''],
454 ['GFX/imagefile_ext', 'gif,jpg,png'],
455 ['GFX/thumbnails', 0]
456 ];
457 $this->createConfigurationManagerWithMockedMethods(
458 [
459 'getLocalConfigurationValueByPath',
460 'getDefaultConfigurationValueByPath',
461 'setLocalConfigurationValuesByPathValuePairs',
462 ]
463 );
464 $this->configurationManager->expects($this->exactly(5))
465 ->method('getLocalConfigurationValueByPath')
466 ->will($this->returnValueMap($currentLocalConfiguration));
467 $this->configurationManager->expects($this->never())
468 ->method('getDefaultConfigurationValueByPath');
469 $this->configurationManager->expects($this->once())
470 ->method('setLocalConfigurationValuesByPathValuePairs')
471 ->withConsecutive(
472 [['GFX/imagefile_ext' => 'gif,jpg,jpeg,png']]
473 );
474
475 $this->expectException(ConfigurationChangedException::class);
476
477 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
478
479 $silentConfigurationUpgradeServiceInstance->_call('disableImageMagickDetailSettingsIfImageMagickIsDisabled');
480 }
481
482 /**
483 * @test
484 */
485 public function doNotDisableImageMagickDetailSettingsIfImageMagickIsEnabled()
486 {
487 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
488 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
489 SilentConfigurationUpgradeService::class,
490 ['dummy'],
491 [],
492 '',
493 false
494 );
495
496 $currentLocalConfiguration = [
497 ['GFX/im', 1],
498 ['GFX/im_path', ''],
499 ['GFX/im_path_lzw', ''],
500 ['GFX/imagefile_ext', 'gif,jpg,jpeg,png'],
501 ['GFX/thumbnails', 0]
502 ];
503 $this->createConfigurationManagerWithMockedMethods(
504 [
505 'getLocalConfigurationValueByPath',
506 'getDefaultConfigurationValueByPath',
507 'setLocalConfigurationValuesByPathValuePairs',
508 ]
509 );
510 $this->configurationManager->expects($this->exactly(5))
511 ->method('getLocalConfigurationValueByPath')
512 ->will($this->returnValueMap($currentLocalConfiguration));
513 $this->configurationManager->expects($this->never())
514 ->method('getDefaultConfigurationValueByPath');
515 $this->configurationManager->expects($this->never())
516 ->method('setLocalConfigurationValuesByPathValuePairs');
517
518 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
519
520 $silentConfigurationUpgradeServiceInstance->_call('disableImageMagickDetailSettingsIfImageMagickIsDisabled');
521 }
522
523 /**
524 * @test
525 */
526 public function setImageMagickDetailSettings()
527 {
528 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
529 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
530 SilentConfigurationUpgradeService::class,
531 ['dummy'],
532 [],
533 '',
534 false
535 );
536
537 $currentLocalConfiguration = [
538 ['GFX/processor', 'GraphicsMagick'],
539 ['GFX/processor_allowTemporaryMasksAsPng', 1],
540 ['GFX/processor_effects', 0]
541 ];
542 $this->createConfigurationManagerWithMockedMethods(
543 [
544 'getLocalConfigurationValueByPath',
545 'getDefaultConfigurationValueByPath',
546 'setLocalConfigurationValuesByPathValuePairs',
547 ]
548 );
549 $this->configurationManager->expects($this->exactly(3))
550 ->method('getLocalConfigurationValueByPath')
551 ->will($this->returnValueMap($currentLocalConfiguration));
552 $this->configurationManager->expects($this->never())
553 ->method('getDefaultConfigurationValueByPath');
554 $this->configurationManager->expects($this->once())
555 ->method('setLocalConfigurationValuesByPathValuePairs')
556 ->withConsecutive(
557 [['GFX/processor_allowTemporaryMasksAsPng' => 0]]
558 );
559
560 $this->expectException(ConfigurationChangedException::class);
561
562 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
563
564 $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
565 }
566
567 /**
568 * @test
569 */
570 public function doNotSetImageMagickDetailSettings()
571 {
572 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
573 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
574 SilentConfigurationUpgradeService::class,
575 ['dummy'],
576 [],
577 '',
578 false
579 );
580
581 $currentLocalConfiguration = [
582 ['GFX/processor', ''],
583 ['GFX/processor_allowTemporaryMasksAsPng', 0],
584 ['GFX/processor_effects', 0]
585 ];
586 $this->createConfigurationManagerWithMockedMethods(
587 [
588 'getLocalConfigurationValueByPath',
589 'getDefaultConfigurationValueByPath',
590 'setLocalConfigurationValuesByPathValuePairs',
591 ]
592 );
593 $this->configurationManager->expects($this->exactly(3))
594 ->method('getLocalConfigurationValueByPath')
595 ->will($this->returnValueMap($currentLocalConfiguration));
596 $this->configurationManager->expects($this->never())
597 ->method('getDefaultConfigurationValueByPath');
598 $this->configurationManager->expects($this->never())
599 ->method('setLocalConfigurationValuesByPathValuePairs');
600
601 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
602
603 $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
604 }
605
606 /**
607 * @test
608 */
609 public function migrateNonExistingLangDebug()
610 {
611 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
612 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
613 SilentConfigurationUpgradeService::class,
614 ['dummy'],
615 [],
616 '',
617 false
618 );
619
620 $currentLocalConfiguration = [
621 ];
622 $this->createConfigurationManagerWithMockedMethods(
623 [
624 'getLocalConfigurationValueByPath',
625 'setLocalConfigurationValueByPath',
626 ]
627 );
628
629 $this->configurationManager->expects($this->exactly(1))
630 ->method('getLocalConfigurationValueByPath')
631 ->will($this->returnValueMap($currentLocalConfiguration));
632 $this->configurationManager->expects($this->never())
633 ->method('setLocalConfigurationValueByPath');
634
635 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
636
637 $silentConfigurationUpgradeServiceInstance->_call('migrateLangDebug');
638 }
639
640 /**
641 * @test
642 */
643 public function migrateExistingLangDebug()
644 {
645 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
646 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
647 SilentConfigurationUpgradeService::class,
648 ['dummy'],
649 [],
650 '',
651 false
652 );
653
654 $currentLocalConfiguration = [
655 ['BE/lang/debug', false]
656 ];
657 $this->createConfigurationManagerWithMockedMethods(
658 [
659 'getLocalConfigurationValueByPath',
660 'setLocalConfigurationValueByPath',
661 ]
662 );
663
664 $this->configurationManager->expects($this->exactly(1))
665 ->method('getLocalConfigurationValueByPath')
666 ->will($this->returnValueMap($currentLocalConfiguration));
667 $this->configurationManager->expects($this->once())
668 ->method('setLocalConfigurationValueByPath')
669 ->with($this->equalTo('BE/languageDebug'), false);
670
671 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
672
673 $silentConfigurationUpgradeServiceInstance->_call('migrateLangDebug');
674 }
675
676 /**
677 * @test
678 */
679 public function migrateCacheHashOptions()
680 {
681 $oldConfig = [
682 'FE/cHashOnlyForParameters' => 'foo,bar',
683 'FE/cHashExcludedParameters' => 'bar,foo',
684 'FE/cHashRequiredParameters' => 'bar,baz',
685 'FE/cHashExcludedParametersIfEmpty' => '*'
686 ];
687
688 /** @var ConfigurationManager|ObjectProphecy $configurationManager */
689 $configurationManager = $this->prophesize(ConfigurationManager::class);
690
691 foreach ($oldConfig as $key => $value) {
692 $configurationManager->getLocalConfigurationValueByPath($key)
693 ->shouldBeCalled()
694 ->willReturn($value);
695 }
696
697 $configurationManager->setLocalConfigurationValuesByPathValuePairs(\Prophecy\Argument::cetera())
698 ->shouldBeCalled();
699 $configurationManager->removeLocalConfigurationKeysByPath(\Prophecy\Argument::cetera())
700 ->shouldBeCalled();
701
702 $this->expectException(ConfigurationChangedException::class);
703
704 /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
705 $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
706 SilentConfigurationUpgradeService::class,
707 ['dummy'],
708 [],
709 '',
710 false
711 );
712
713 $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $configurationManager->reveal());
714
715 $silentConfigurationUpgradeServiceInstance->_call('migrateCacheHashOptions');
716 }
717 }