[BUGFIX] Fix test isolation and pre-requisites 70/57570/5
authorSusanne Moog <susanne.moog@typo3.org>
Thu, 12 Jul 2018 10:37:06 +0000 (12:37 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Thu, 12 Jul 2018 10:55:08 +0000 (12:55 +0200)
FormDefinitionValidationServiceTest modified the encryption key in
test data-provider functions. Those functions are executed prior to
actually executing the tests and causes side-effects during running
the test suite.

Resolves: #85539
Releases: master, 9.3, 8.7
Change-Id: I9fbd60905eb37470fa3661225b681476ff9df3c3
Reviewed-on: https://review.typo3.org/57570
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
typo3/sysext/core/Tests/Unit/Session/Backend/RedisSessionBackendTest.php
typo3/sysext/form/Tests/Unit/Controller/FormEditorControllerTest.php
typo3/sysext/form/Tests/Unit/Domain/Configuration/FormDefinitionValidationServiceTest.php
typo3/sysext/form/Tests/Unit/Mvc/Property/TypeConverter/FormDefinitionArrayConverterTest.php

index 1daa25f..38e7a27 100644 (file)
@@ -28,6 +28,7 @@ class RedisSessionBackendTest extends UnitTestCase
         if (!class_exists(\Redis::class)) {
             $this->markTestSkipped('Redis class needs to be available to test RedisSessionBackend');
         }
+        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
     }
 
     /**
index 359969f..ddf9dbb 100644 (file)
@@ -38,7 +38,7 @@ class FormEditorControllerTest extends UnitTestCase
     public function setUp()
     {
         parent::setUp();
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 12345;
+        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
     }
 
     /**
index bdb098e..74348b6 100644 (file)
@@ -24,6 +24,11 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
 
 class FormDefinitionValidationServiceTest extends UnitTestCase
 {
+    protected function setUp()
+    {
+        parent::setUp();
+        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
+    }
 
     /**
      * @test
@@ -346,7 +351,7 @@ class FormDefinitionValidationServiceTest extends UnitTestCase
     public function validateAllPropertyValuesFromCreatableFormElementDataProvider(): array
     {
         $encryptionKeyBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 12345;
+        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
 
         $sessionToken = '54321';
         $identifier = 'text-1';
@@ -368,6 +373,9 @@ class FormDefinitionValidationServiceTest extends UnitTestCase
             ],
         ];
 
+        // be aware that backup globals does not impact globals used in data providers as these are called before the setUp/tearDown is done
+        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = $encryptionKeyBackup;
+
         return [
             [
                 [
@@ -467,7 +475,7 @@ class FormDefinitionValidationServiceTest extends UnitTestCase
     public function validateAllPropertyValuesFromCreatablePropertyCollectionElementDataProvider(): array
     {
         $encryptionKeyBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 12345;
+        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
 
         $sessionToken = '54321';
         $identifier = 'text-1';
@@ -489,6 +497,7 @@ class FormDefinitionValidationServiceTest extends UnitTestCase
             ],
         ];
 
+        // be aware that backup globals does not impact globals used in data providers as these are called before the setUp/tearDown is done
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = $encryptionKeyBackup;
 
         return [
index 3c4e398..67dfb02 100644 (file)
@@ -37,7 +37,7 @@ class FormDefinitionArrayConverterTest extends UnitTestCase
     public function setUp()
     {
         parent::setUp();
-        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = 12345;
+        $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345';
     }
 
     /**