From bea9a18c7950b4f61ffa86be94146e945f2a31a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Tue, 7 Feb 2023 19:04:46 +0100
Subject: [PATCH] [TASK] Add User- and PageTsConfig old include tag test
 coverage
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This change add additional functional tests to ensure old
import tag syntax works in PageTsConfig UserTsConfig,
from row templates and global array registration.

Resolves: #99868
Releases: main, 12.4
Change-Id: I8921242fb5af3b2b4acf2c60ed74ee31e2589783
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/79814
Tested-by: core-ci <typo3@b13.com>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Stefan Bürk <stefan@buerk.tech>
---
 .../TypoScript/PageTsConfigFactoryTest.php    | 29 +++++++++++++++++++
 .../TypoScript/UserTsConfigFactoryTest.php    | 14 +++++++++
 2 files changed, 43 insertions(+)

diff --git a/typo3/sysext/core/Tests/Functional/TypoScript/PageTsConfigFactoryTest.php b/typo3/sysext/core/Tests/Functional/TypoScript/PageTsConfigFactoryTest.php
index d0e34a6da028..9b2569b1bcaa 100644
--- a/typo3/sysext/core/Tests/Functional/TypoScript/PageTsConfigFactoryTest.php
+++ b/typo3/sysext/core/Tests/Functional/TypoScript/PageTsConfigFactoryTest.php
@@ -44,6 +44,18 @@ final class PageTsConfigFactoryTest extends FunctionalTestCase
         self::assertSame('loadedFromGlobals', $pageTsConfig->getPageTsConfigArray()['loadedFromGlobals']);
     }
 
+    /**
+     * @test
+     */
+    public function pageTsConfigLoadsSingleFileWithOldImportSyntaxFromGlobals(): void
+    {
+        $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] = '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:test_typoscript_pagetsconfigfactory/Configuration/TsConfig/tsconfig-includes.tsconfig">';
+        /** @var PageTsConfigFactory $subject */
+        $subject = $this->get(PageTsConfigFactory::class);
+        $pageTsConfig = $subject->create([], new NullSite());
+        self::assertSame('loadedFromTsconfigIncludesWithTsconfigSuffix', $pageTsConfig->getPageTsConfigArray()['loadedFromTsconfigIncludesWithTsconfigSuffix']);
+    }
+
     /**
      * @test
      */
@@ -102,6 +114,23 @@ final class PageTsConfigFactoryTest extends FunctionalTestCase
         self::assertSame('loadedFromTsconfigIncludesWithTyposcriptSuffix', $pageTsConfig->getPageTsConfigArray()['loadedFromTsconfigIncludesWithTyposcriptSuffix']);
     }
 
+    /**
+     * @test
+     */
+    public function pageTsConfigLoadsSingleFileWithOldImportSyntax(): void
+    {
+        $rootLine = [
+            [
+                'uid' => 1,
+                'TSconfig' => '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:test_typoscript_pagetsconfigfactory/Configuration/TsConfig/tsconfig-includes.tsconfig">',
+            ],
+        ];
+        /** @var PageTsConfigFactory $subject */
+        $subject = $this->get(PageTsConfigFactory::class);
+        $pageTsConfig = $subject->create($rootLine, new NullSite());
+        self::assertSame('loadedFromTsconfigIncludesWithTsconfigSuffix', $pageTsConfig->getPageTsConfigArray()['loadedFromTsconfigIncludesWithTsconfigSuffix']);
+    }
+
     /**
      * @test
      */
diff --git a/typo3/sysext/core/Tests/Functional/TypoScript/UserTsConfigFactoryTest.php b/typo3/sysext/core/Tests/Functional/TypoScript/UserTsConfigFactoryTest.php
index d029cd6df7c6..0612b3d32f70 100644
--- a/typo3/sysext/core/Tests/Functional/TypoScript/UserTsConfigFactoryTest.php
+++ b/typo3/sysext/core/Tests/Functional/TypoScript/UserTsConfigFactoryTest.php
@@ -42,6 +42,20 @@ final class UserTsConfigFactoryTest extends FunctionalTestCase
         self::assertSame('loadedFromGlobals', $userTsConfig->getUserTsConfigArray()['loadedFromGlobals']);
     }
 
+    /**
+     * @test
+     */
+    public function userTsConfigLoadsSingleFileWithOldImportSyntaxFromGlobals(): void
+    {
+        $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'] = '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:test_typoscript_usertsconfigfactory/Configuration/TsConfig/tsconfig-includes.tsconfig">';
+        $this->importCSVDataSet(__DIR__ . '/Fixtures/userTsConfigTestFixture.csv');
+        $backendUser = $this->setUpBackendUser(1);
+        /** @var UserTsConfigFactory $subject */
+        $subject = $this->get(UserTsConfigFactory::class);
+        $userTsConfig = $subject->create($backendUser);
+        self::assertSame('loadedFromTsconfigIncludesWithTsconfigSuffix', $userTsConfig->getUserTsConfigArray()['loadedFromTsconfigIncludesWithTsconfigSuffix']);
+    }
+
     /**
      * @test
      */
-- 
GitLab