[TASK] Correctly initialize environment for DataHandler in tests 69/57869/4
authorOliver Hader <oliver@typo3.org>
Sat, 11 Aug 2018 07:46:25 +0000 (09:46 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Sat, 11 Aug 2018 09:38:14 +0000 (11:38 +0200)
Since importing data scenarios in tests relies on DataHandler, it is
required to correctly initialize $GLOBALS['LANG'] as well. Since not
all tests were failing, this probably points out side effects during
test execution in terms of reusing globals settings of other tests.

Besides that, a misbehavior in typo3/testing-framework lead to the
situation that not all entities have been created - which would have
triggered DataHandler log entries that rely on previously mentioned
$GLOBALS['LANG'] instance.

Resolves: #85814
Releases: master
Change-Id: I4e2745cfeed6e2576f7ae23dd4d4ea4b49572a3f
Reviewed-on: https://review.typo3.org/57869
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
composer.json
composer.lock
typo3/sysext/core/composer.json
typo3/sysext/frontend/Tests/Functional/SiteHandling/AbstractRequestTest.php
typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/PhpError.php
typo3/sysext/frontend/Tests/Functional/SiteHandling/PlainRequestTest.php
typo3/sysext/frontend/Tests/Functional/SiteHandling/SiteRequestTest.php

index 9a7bcdb..46555e5 100644 (file)
@@ -67,7 +67,7 @@
                "fiunchinho/phpunit-randomizer": "^4.0",
                "friendsofphp/php-cs-fixer": "^2.12.2",
                "typo3/cms-styleguide": "~9.2.0",
-               "typo3/testing-framework": "~4.3.0"
+               "typo3/testing-framework": "~4.3.1"
        },
        "suggest": {
                "ext-gd": "GDlib/Freetype is required for building images with text (GIFBUILDER) and can also be used to scale images",
index a513d5b..880e0cb 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "955beaf3f2c2d0c508368071e29bb275",
+    "content-hash": "a4daba415dd0d0cbb6faf3e63e96975c",
     "packages": [
         {
             "name": "cogpowered/finediff",
         },
         {
             "name": "typo3/testing-framework",
-            "version": "4.3.0",
+            "version": "4.3.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/TYPO3/testing-framework.git",
-                "reference": "0a432e72e647bb54ace9718d58285e6daf48620f"
+                "reference": "975e3fe80c61f3cf1a15edbcc5e26f2f9c706afa"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/0a432e72e647bb54ace9718d58285e6daf48620f",
-                "reference": "0a432e72e647bb54ace9718d58285e6daf48620f",
+                "url": "https://api.github.com/repos/TYPO3/testing-framework/zipball/975e3fe80c61f3cf1a15edbcc5e26f2f9c706afa",
+                "reference": "975e3fe80c61f3cf1a15edbcc5e26f2f9c706afa",
                 "shasum": ""
             },
             "require": {
                 "tests",
                 "typo3"
             ],
-            "time": "2018-08-10T20:50:40+00:00"
+            "time": "2018-08-11T08:39:39+00:00"
         },
         {
             "name": "webmozart/assert",
index b502085..b8aa963 100644 (file)
@@ -48,7 +48,7 @@
                "fiunchinho/phpunit-randomizer": "^4.0",
                "friendsofphp/php-cs-fixer": "^2.12.2",
                "typo3/cms-styleguide": "~9.2.0",
-               "typo3/testing-framework": "~4.3.0"
+               "typo3/testing-framework": "~4.3.1"
        },
        "suggest": {
                "ext-fileinfo": "Used for proper file type detection in the file abstraction layer",
index b88861c..e2fb5aa 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling;
 
 /*
@@ -94,4 +95,19 @@ abstract class AbstractRequestTest extends FunctionalTestCase
     {
         return array_combine($array, $array);
     }
+
+    /**
+     * @param array $items
+     */
+    protected static function failIfArrayIsNotEmpty(array $items): void
+    {
+        if (empty($items)) {
+            return;
+        }
+
+        static::fail(
+            'Array was not empty as expected, but contained these items:' . LF
+            . '* ' . implode(LF . '* ', $items)
+        );
+    }
 }
index 24e0ab5..03b7547 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling;
 
 /*
@@ -14,6 +15,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\ActionService;
 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataMapFactory;
@@ -27,11 +29,6 @@ use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
 class PlainRequestTest extends AbstractRequestTest
 {
     /**
-     * @var ActionService
-     */
-    private $actionService;
-
-    /**
      * @var string
      */
     private $siteTitle = 'A Company that Manufactures Everything Inc';
@@ -41,6 +38,11 @@ class PlainRequestTest extends AbstractRequestTest
      */
     private $internalRequestContext;
 
+    /**
+     * @var ActionService
+     */
+    private $actionService;
+
     protected function setUp()
     {
         parent::setUp();
@@ -51,6 +53,7 @@ class PlainRequestTest extends AbstractRequestTest
 
         $this->setUpBackendUserFromFixture(1);
         $this->actionService = new ActionService();
+        Bootstrap::initializeLanguageObject();
 
         $scenarioFile = __DIR__ . '/Fixtures/scenario.yaml';
         $factory = DataMapFactory::fromYamlFile($scenarioFile);
@@ -59,6 +62,9 @@ class PlainRequestTest extends AbstractRequestTest
             [],
             $factory->getSuggestedIds()
         );
+        static::failIfArrayIsNotEmpty(
+            $this->actionService->getDataHandler()->errorLog
+        );
 
         $this->setUpFrontendRootPage(
             101,
index bc129d7..e997737 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+declare(strict_types = 1);
 namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling;
 
 /*
@@ -15,6 +16,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling;
  */
 
 use TYPO3\CMS\Core\Configuration\SiteConfiguration;
+use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\Fixtures\PhpError;
 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\ActionService;
 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataMapFactory;
@@ -34,16 +36,6 @@ class SiteRequestTest extends AbstractRequestTest
     ];
 
     /**
-     * @var array
-     */
-    protected $coreExtensionsToLoad = ['frontend'];
-
-    /**
-     * @var ActionService
-     */
-    private $actionService;
-
-    /**
      * @var string
      */
     private $siteTitle = 'A Company that Manufactures Everything Inc';
@@ -53,6 +45,11 @@ class SiteRequestTest extends AbstractRequestTest
      */
     private $internalRequestContext;
 
+    /**
+     * @var ActionService
+     */
+    private $actionService;
+
     protected function setUp()
     {
         parent::setUp();
@@ -63,6 +60,7 @@ class SiteRequestTest extends AbstractRequestTest
 
         $this->setUpBackendUserFromFixture(1);
         $this->actionService = new ActionService();
+        Bootstrap::initializeLanguageObject();
 
         $scenarioFile = __DIR__ . '/Fixtures/scenario.yaml';
         $factory = DataMapFactory::fromYamlFile($scenarioFile);
@@ -71,6 +69,9 @@ class SiteRequestTest extends AbstractRequestTest
             [],
             $factory->getSuggestedIds()
         );
+        static::failIfArrayIsNotEmpty(
+            $this->actionService->getDataHandler()->errorLog
+        );
 
         $this->setUpFrontendRootPage(
             101,