[FEATURE] Install tool: Remove obsolete keys from LocalConfiguration
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Configuration / ConfigurationManagerTest.php
index 4257ff0..507e9f6 100644 (file)
@@ -291,6 +291,66 @@ class ConfigurationManagerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->fixture->setLocalConfigurationValuesByPathValuePairs($pairs);
        }
 
+       /**
+        * @test
+        */
+       public function removeLocalConfigurationKeysByPathRemovesGivenPathsFromConfigurationAndReturnsTrue() {
+               $currentLocalConfiguration = array(
+                       'toRemove1' => 'foo',
+                       'notChanged' => 23,
+                       'toRemove2' => 'bar',
+               );
+               $expectedConfiguration = array(
+                       'notChanged' => 23,
+               );
+
+               $this->createFixtureWithMockedMethods(
+                       array(
+                               'getLocalConfiguration',
+                               'writeLocalConfiguration',
+                       )
+               );
+               $this->fixture->expects($this->once())
+                       ->method('getLocalConfiguration')
+                       ->will($this->returnValue($currentLocalConfiguration));
+               $this->fixture->expects($this->once())
+                       ->method('writeLocalConfiguration')
+                       ->with($expectedConfiguration);
+
+               $removePaths = array(
+                       'toRemove1',
+                       'toRemove2',
+               );
+               $this->assertTrue($this->fixture->removeLocalConfigurationKeysByPath($removePaths));
+       }
+
+       /**
+        * @test
+        */
+       public function removeLocalConfigurationKeysByPathReturnsFalseIfNothingIsRemoved() {
+               $currentLocalConfiguration = array(
+                       'notChanged' => 23,
+               );
+               $expectedConfiguration = array(
+                       'notChanged' => 23,
+               );
+               $this->createFixtureWithMockedMethods(
+                       array(
+                               'getLocalConfiguration',
+                               'writeLocalConfiguration',
+                       )
+               );
+               $this->fixture->expects($this->once())
+                       ->method('getLocalConfiguration')
+                       ->will($this->returnValue($currentLocalConfiguration));
+               $this->fixture->expects($this->once())
+                       ->method('writeLocalConfiguration')
+                       ->with($expectedConfiguration);
+
+               $removePaths = array();
+               $this->assertFalse($this->fixture->removeLocalConfigurationKeysByPath($removePaths));
+       }
+
        /**
         * @test
         */