From 73d14124b462367e965066b28231464ecc5ce317 Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Wed, 18 Dec 2024 18:17:07 +0100 Subject: [PATCH] [TASK] run content_defender tests on v13 --- Build/Scripts/runTests.sh | 4 +-- .../AbstractContentDefender.php | 34 +++++++++++++++++++ .../ContentDefender/CopyContainerTest.php | 10 +----- .../ContentDefender/DefaultLanguageTest.php | 10 +----- .../ContentDefender/LocalizationTest.php | 10 +----- .../ContentDefender/MaxItemsTest.php | 9 +---- 6 files changed, 40 insertions(+), 37 deletions(-) create mode 100644 Tests/Functional/Datahandler/ContentDefender/AbstractContentDefender.php diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index 626c9793..49ab56ed 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -598,7 +598,7 @@ case ${TEST_SUITE} in composer require typo3/cms-core:^11.5 ichhabrecht/content-defender --dev -W --no-progress --no-interaction composer prepare-tests elif [ ${TYPO3} -eq 13 ]; then - composer require typo3/cms-core:^13.4 --dev -W --no-progress --no-interaction + composer require typo3/cms-core:^13.4 ichhabrecht/content-defender --dev -W --no-progress --no-interaction composer prepare-tests else composer require typo3/cms-core:^12.4 ichhabrecht/content-defender --dev -W --no-progress --no-interaction @@ -620,7 +620,7 @@ case ${TEST_SUITE} in composer require typo3/cms-core:^11.5 ichhabrecht/content-defender --dev -W --no-progress --no-interaction composer prepare-tests elif [ ${TYPO3} -eq 13 ]; then - composer require typo3/cms-core:^13.0 --dev -W --no-progress --no-interaction + composer require typo3/cms-core:^13.4 ichhabrecht/content-defender --dev -W --no-progress --no-interaction composer prepare-tests else composer require typo3/cms-core:^12.4 ichhabrecht/content-defender --dev -W --no-progress --no-interaction diff --git a/Tests/Functional/Datahandler/ContentDefender/AbstractContentDefender.php b/Tests/Functional/Datahandler/ContentDefender/AbstractContentDefender.php new file mode 100644 index 00000000..607a8904 --- /dev/null +++ b/Tests/Functional/Datahandler/ContentDefender/AbstractContentDefender.php @@ -0,0 +1,34 @@ +getMajorVersion() === 12) { + // content_defender calls FormDataCompiler which wants access global variable TYPO3_REQUEST + $GLOBALS['TYPO3_REQUEST'] = null; + } elseif ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 12) { + // content_defender always returns true for restrictions if global variable TYPO3_REQUEST is null + $GLOBALS['TYPO3_REQUEST'] = (new ServerRequest())->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE); + } + } +} \ No newline at end of file diff --git a/Tests/Functional/Datahandler/ContentDefender/CopyContainerTest.php b/Tests/Functional/Datahandler/ContentDefender/CopyContainerTest.php index 3593fe16..a36f866b 100644 --- a/Tests/Functional/Datahandler/ContentDefender/CopyContainerTest.php +++ b/Tests/Functional/Datahandler/ContentDefender/CopyContainerTest.php @@ -12,11 +12,7 @@ * of the License, or any later version. */ -use B13\Container\Tests\Functional\Datahandler\AbstractDatahandler; -use TYPO3\CMS\Core\Information\Typo3Version; -use TYPO3\CMS\Core\Utility\GeneralUtility; - -class CopyContainerTest extends AbstractDatahandler +class CopyContainerTest extends AbstractContentDefender { /** * @var non-empty-string[] @@ -30,10 +26,6 @@ class CopyContainerTest extends AbstractDatahandler protected function setUp(): void { parent::setUp(); - if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 11) { - // content_defender calls FormDataCompiler which wants access global variable TYPO3_REQUEST - $GLOBALS['TYPO3_REQUEST'] = null; - } $this->importCSVDataSet(__DIR__ . '/Fixtures/copy_container.csv'); } diff --git a/Tests/Functional/Datahandler/ContentDefender/DefaultLanguageTest.php b/Tests/Functional/Datahandler/ContentDefender/DefaultLanguageTest.php index 49692fa8..acd36183 100644 --- a/Tests/Functional/Datahandler/ContentDefender/DefaultLanguageTest.php +++ b/Tests/Functional/Datahandler/ContentDefender/DefaultLanguageTest.php @@ -12,11 +12,7 @@ * of the License, or any later version. */ -use B13\Container\Tests\Functional\Datahandler\AbstractDatahandler; -use TYPO3\CMS\Core\Information\Typo3Version; -use TYPO3\CMS\Core\Utility\GeneralUtility; - -class DefaultLanguageTest extends AbstractDatahandler +class DefaultLanguageTest extends AbstractContentDefender { /** * @var non-empty-string[] @@ -30,10 +26,6 @@ class DefaultLanguageTest extends AbstractDatahandler protected function setUp(): void { parent::setUp(); - if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 11) { - // content_defender calls FormDataCompiler which wants access global variable TYPO3_REQUEST - $GLOBALS['TYPO3_REQUEST'] = null; - } $this->importCSVDataSet(__DIR__ . '/Fixtures/DefaultLanguage/setup.csv'); } diff --git a/Tests/Functional/Datahandler/ContentDefender/LocalizationTest.php b/Tests/Functional/Datahandler/ContentDefender/LocalizationTest.php index 8eebaf27..9c337fa3 100644 --- a/Tests/Functional/Datahandler/ContentDefender/LocalizationTest.php +++ b/Tests/Functional/Datahandler/ContentDefender/LocalizationTest.php @@ -12,11 +12,7 @@ * of the License, or any later version. */ -use B13\Container\Tests\Functional\Datahandler\AbstractDatahandler; -use TYPO3\CMS\Core\Information\Typo3Version; -use TYPO3\CMS\Core\Utility\GeneralUtility; - -class LocalizationTest extends AbstractDatahandler +class LocalizationTest extends AbstractContentDefender { /** * @var non-empty-string[] @@ -30,10 +26,6 @@ class LocalizationTest extends AbstractDatahandler protected function setUp(): void { parent::setUp(); - if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 11) { - // content_defender calls FormDataCompiler which wants access global variable TYPO3_REQUEST - $GLOBALS['TYPO3_REQUEST'] = null; - } $this->importCSVDataSet(__DIR__ . '/Fixtures/Localization/setup.csv'); } diff --git a/Tests/Functional/Datahandler/ContentDefender/MaxItemsTest.php b/Tests/Functional/Datahandler/ContentDefender/MaxItemsTest.php index d7324ab6..3d61fa98 100644 --- a/Tests/Functional/Datahandler/ContentDefender/MaxItemsTest.php +++ b/Tests/Functional/Datahandler/ContentDefender/MaxItemsTest.php @@ -12,12 +12,9 @@ * of the License, or any later version. */ -use B13\Container\Tests\Functional\Datahandler\AbstractDatahandler; -use TYPO3\CMS\Core\Information\Typo3Version; -use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\StringUtility; -class MaxItemsTest extends AbstractDatahandler +class MaxItemsTest extends AbstractContentDefender { /** * @var non-empty-string[] @@ -31,10 +28,6 @@ class MaxItemsTest extends AbstractDatahandler protected function setUp(): void { parent::setUp(); - if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() > 11) { - // content_defender calls FormDataCompiler which wants access global variable TYPO3_REQUEST - $GLOBALS['TYPO3_REQUEST'] = null; - } $this->linkSiteConfigurationIntoTestInstance(); }