From 245c13b629dc6aa32fb2c3dd52c6abcf6548ed97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Sat, 9 Oct 2021 14:04:40 +0200
Subject: [PATCH] [BUGFIX] Initialize backenduser for RedirectServiceTest

RedirectsServiceTests simulate frontend requests
without executing them really, which prevents from
running through the FE Bootstrap stack, thus not all
needed stuff are setup correctly, thus throwing a
warning that $GLOBALS['BE_USER'] is not defined.

This patch initialize a backenduser for the
RedirectServiceTest to setup a correct BackendUser
object, thus mitigating this warning.

Resolves: #95548
Releases: master
Change-Id: I8318738e22761f172383db3b981779e331043f3f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71518
Reviewed-by: Guido Schmechel <guido.schmechel@brandung.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Jochen <rothjochen@gmail.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Tests/Functional/Service/RedirectServiceTest.php        | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php b/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php
index 8d207300147c..ca9fe589b190 100644
--- a/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php
+++ b/typo3/sysext/redirects/Tests/Functional/Service/RedirectServiceTest.php
@@ -45,6 +45,12 @@ class RedirectServiceTest extends FunctionalTestCase
 
     protected array $testFilesToDelete = [];
 
+    protected function setUp(): void
+    {
+        parent::setUp();
+        $this->setUpBackendUserFromFixture(1);
+    }
+
     protected function tearDown(): void
     {
         foreach ($this->testFilesToDelete as $filename) {
-- 
GitLab