[TASK] Add missing unit tests for SilentConfigurationUpgradeService (6) 33/42633/3
authorMichael Oehlhof <typo3@oehlhof.de>
Fri, 14 Aug 2015 20:18:48 +0000 (22:18 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 16 Aug 2015 16:49:04 +0000 (18:49 +0200)
Missing unit tests for removeObsoleteLocalConfigurationSettings()
are added.

Resolves: #69077
Releases: master
Change-Id: Icb78d8ba81bdd5f936238629f9fc4c565df44637
Reviewed-on: http://review.typo3.org/42633
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php

index ec9b28e..ae816a2 100644 (file)
@@ -39,6 +39,78 @@ class SilentConfigurationUpgradeServiceTest extends \TYPO3\CMS\Core\Tests\UnitTe
        /**
         * @test
         */
+       public function removeObsoleteLocalConfigurationSettingsIfThereAreOldSettings() {
+               /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
+               $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
+                       \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
+                       array('dummy'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $obsoleteLocalConfigurationSettings = array(
+                       'SYS/form_enctype',
+               );
+
+               $currentLocalConfiguration = array(
+                       array($obsoleteLocalConfigurationSettings, TRUE)
+               );
+               $this->createConfigurationManagerWithMockedMethods(
+                       array(
+                               'removeLocalConfigurationKeysByPath',
+                       )
+               );
+               $this->configurationManager->expects($this->exactly(1))
+                       ->method('removeLocalConfigurationKeysByPath')
+                       ->will($this->returnValueMap($currentLocalConfiguration));
+
+               $this->setExpectedException(\TYPO3\CMS\Install\Controller\Exception\RedirectException::class);
+
+               $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
+               $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
+
+               $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
+       }
+
+       /**
+        * @test
+        */
+       public function doNotRemoveObsoleteLocalConfigurationSettingsIfThereAreNoOldSettings() {
+               /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
+               $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
+                       \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService::class,
+                       array('dummy'),
+                       array(),
+                       '',
+                       FALSE
+               );
+
+               $obsoleteLocalConfigurationSettings = array(
+                       'SYS/form_enctype',
+               );
+
+               $currentLocalConfiguration = array(
+                       array($obsoleteLocalConfigurationSettings, FALSE)
+               );
+               $this->createConfigurationManagerWithMockedMethods(
+                       array(
+                               'removeLocalConfigurationKeysByPath',
+                       )
+               );
+               $this->configurationManager->expects($this->exactly(1))
+                       ->method('removeLocalConfigurationKeysByPath')
+                       ->will($this->returnValueMap($currentLocalConfiguration));
+
+               $silentConfigurationUpgradeServiceInstance->_set('obsoleteLocalConfigurationSettings', $obsoleteLocalConfigurationSettings);
+               $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
+
+               $silentConfigurationUpgradeServiceInstance->_call('removeObsoleteLocalConfigurationSettings');
+       }
+
+       /**
+        * @test
+        */
        public function configureSaltedPasswordsWithDefaultConfiguration() {
                /** @var $silentConfigurationUpgradeServiceInstance \TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */
                $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(