From e0c6719be8acaa6362805025b77040971c36ebb7 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 --- .github/workflows/ci.yml | 14 +- Build/Scripts/runTests.sh | 4 +- Build/phpstan-baseline-11-7.4.neon | 5 - Build/phpstan-baseline-11.neon | 5 - .../Backend/ContentDefenderCest.php | 131 +++++++++++++----- Tests/Acceptance/Backend/LayoutCest.php | 36 ++--- Tests/Acceptance/Support/BackendTester.php | 8 ++ .../Extension/BackendContainerEnvironment.php | 12 -- .../AbstractContentDefender.php | 34 +++++ .../ContentDefender/CopyContainerTest.php | 10 +- .../ContentDefender/DefaultLanguageTest.php | 10 +- .../ContentDefender/LocalizationTest.php | 10 +- .../ContentDefender/MaxItemsTest.php | 9 +- 13 files changed, 160 insertions(+), 128 deletions(-) create mode 100644 Tests/Functional/Datahandler/ContentDefender/AbstractContentDefender.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ee22060..f38a342d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,22 +48,12 @@ jobs: - name: Unit Tests run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s unit - - name: Functional Tests v12/v11 - if: matrix.TYPO3 != '13' + - name: Functional Tests run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s functional - - name: Functional Tests v13 - if: matrix.TYPO3 == '13' - run: PHPUNIT_EXCLUDE_GROUPS=content_defender Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s functional - - - name: Acceptance Tests v12/v11 - if: matrix.TYPO3 != '13' + - name: Acceptance Tests run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s acceptance -- --fail-fast - - name: Acceptance Tests v13 - if: matrix.TYPO3 == '13' - run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -t ${{ matrix.TYPO3 }} -s acceptance -- --fail-fast --skip-group=content_defender - - name: Archive acceptance tests results uses: actions/upload-artifact@v4 if: always() 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/Build/phpstan-baseline-11-7.4.neon b/Build/phpstan-baseline-11-7.4.neon index ca39e44e..c19f2c57 100644 --- a/Build/phpstan-baseline-11-7.4.neon +++ b/Build/phpstan-baseline-11-7.4.neon @@ -30,11 +30,6 @@ parameters: count: 1 path: ../Tests/Acceptance/Support/BackendTester.php - - - message: "#^Call to an undefined static method TYPO3\\\\TestingFramework\\\\Core\\\\Acceptance\\\\Extension\\\\BackendEnvironment\\:\\:_initialize\\(\\)\\.$#" - count: 1 - path: ../Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php - - message: "#^Property TYPO3\\\\TestingFramework\\\\Core\\\\Acceptance\\\\Helper\\\\AbstractPageTree\\:\\:\\$tester \\(AcceptanceTester\\) does not accept B13\\\\Container\\\\Tests\\\\Acceptance\\\\Support\\\\BackendTester\\.$#" count: 1 diff --git a/Build/phpstan-baseline-11.neon b/Build/phpstan-baseline-11.neon index 89d06bde..89ab997a 100644 --- a/Build/phpstan-baseline-11.neon +++ b/Build/phpstan-baseline-11.neon @@ -30,11 +30,6 @@ parameters: count: 1 path: ../Tests/Acceptance/Support/BackendTester.php - - - message: "#^Call to an undefined static method TYPO3\\\\TestingFramework\\\\Core\\\\Acceptance\\\\Extension\\\\BackendEnvironment\\:\\:_initialize\\(\\)\\.$#" - count: 1 - path: ../Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php - - message: "#^Property TYPO3\\\\TestingFramework\\\\Core\\\\Acceptance\\\\Helper\\\\AbstractPageTree\\:\\:\\$tester \\(AcceptanceTester\\) does not accept B13\\\\Container\\\\Tests\\\\Acceptance\\\\Support\\\\BackendTester\\.$#" count: 1 diff --git a/Tests/Acceptance/Backend/ContentDefenderCest.php b/Tests/Acceptance/Backend/ContentDefenderCest.php index 66bc709e..9125a89e 100644 --- a/Tests/Acceptance/Backend/ContentDefenderCest.php +++ b/Tests/Acceptance/Backend/ContentDefenderCest.php @@ -14,6 +14,7 @@ use B13\Container\Tests\Acceptance\Support\BackendTester; use B13\Container\Tests\Acceptance\Support\PageTree; +use B13\Container\Tests\Acceptance\Support\PageTreeV13; use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -30,32 +31,44 @@ public function _before(BackendTester $I) /** * @group content_defender */ - public function canCreateChildIn2ColsContainerWithNoContentDefenderRestrictionsDefined(BackendTester $I, PageTree $pageTree): void + public function canCreateChildIn2ColsContainerWithNoContentDefenderRestrictionsDefined(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13): void { $I->click('Page'); - $I->waitForElement('#typo3-pagetree-tree .nodes .node'); - $pageTree->openPath(['home', 'pageWithDifferentContainers']); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { + $I->waitForElement('#typo3-pagetree-tree .nodes .node'); + $pageTree->openPath(['home', 'pageWithDifferentContainers']); + } else { + $pageTreeV13->openPath(['home', 'pageWithDifferentContainers']); + } $I->wait(0.5); $I->switchToContentFrame(); $dataColPos = $I->getDataColPos(300, 200); $I->waitForElement('#element-tt_content-300 [data-colpos="' . $dataColPos . '"]'); $newContentElementLabel = $I->getNewContentElementLabel(); + $I->click($newContentElementLabel, '#element-tt_content-300 [data-colpos="' . $dataColPos . '"]'); $I->switchToIFrame(); $I->waitForElement('.modal-dialog'); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) { + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default\"]').click()"); + } $I->waitForText('Header Only'); $I->see('Header Only'); - $I->see('Table'); + $I->see('Images Only'); } /** * @group content_defender */ - public function doNotSeeNotAllowedContentElementsInNewContentElementWizard(BackendTester $I, PageTree $pageTree): void + public function doNotSeeNotAllowedContentElementsInNewContentElementWizard(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13): void { $I->click('Page'); - $I->waitForElement('#typo3-pagetree-tree .nodes .node'); - $pageTree->openPath(['home', 'pageWithContainer-3']); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { + $I->waitForElement('#typo3-pagetree-tree .nodes .node'); + $pageTree->openPath(['home', 'pageWithContainer-3']); + } else { + $pageTreeV13->openPath(['home', 'pageWithContainer-3']); + } $I->wait(0.5); $I->switchToContentFrame(); $dataColPos = $I->getDataColPos(800, 200); @@ -64,18 +77,25 @@ public function doNotSeeNotAllowedContentElementsInNewContentElementWizard(Backe $I->click($newContentElementLabel, '#element-tt_content-800 [data-colpos="' . $dataColPos . '"]'); $I->switchToIFrame(); $I->waitForElement('.modal-dialog'); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) { + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default\"]').click()"); + } $I->waitForText('Header Only'); - $I->dontSee('Table'); + $I->dontSee('Images Only'); } /** * @group content_defender */ - public function doNotSeeNotAllowedContentElementsInNewContentElementWizardTriggeredByContextMenu(BackendTester $I, PageTree $pageTree): void + public function doNotSeeNotAllowedContentElementsInNewContentElementWizardTriggeredByContextMenu(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13): void { $I->click('Page'); - $I->waitForElement('#typo3-pagetree-tree .nodes .node'); - $pageTree->openPath(['home', 'pageWithContainer-3']); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { + $I->waitForElement('#typo3-pagetree-tree .nodes .node'); + $pageTree->openPath(['home', 'pageWithContainer-3']); + } else { + $pageTreeV13->openPath(['home', 'pageWithContainer-3']); + } $I->wait(0.5); $I->switchToContentFrame(); $typo3Version = GeneralUtility::makeInstance(Typo3Version::class); @@ -100,18 +120,25 @@ public function doNotSeeNotAllowedContentElementsInNewContentElementWizardTrigge } $I->switchToIFrame(); $I->waitForElement('.modal-dialog'); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) { + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default\"]').click()"); + } $I->waitForText('Header Only'); - $I->dontSee('Table'); + $I->dontSee('Images Only'); } /** * @group content_defender */ - public function doNotSeeNotAllowedContentElementsInCTypeSelectBoxWhenCreateNewElement(BackendTester $I, PageTree $pageTree) + public function doNotSeeNotAllowedContentElementsInCTypeSelectBoxWhenCreateNewElement(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13) { $I->click('Page'); - $I->waitForElement('#typo3-pagetree-tree .nodes .node'); - $pageTree->openPath(['home', 'pageWithContainer-4']); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { + $I->waitForElement('#typo3-pagetree-tree .nodes .node'); + $pageTree->openPath(['home', 'pageWithContainer-4']); + } else { + $pageTreeV13->openPath(['home', 'pageWithContainer-4']); + } $I->wait(0.5); $I->switchToContentFrame(); $dataColPos = $I->getDataColPos(801, 200); @@ -120,44 +147,59 @@ public function doNotSeeNotAllowedContentElementsInCTypeSelectBoxWhenCreateNewEl $I->click($newContentElementLabel, '#element-tt_content-801 [data-colpos="' . $dataColPos . '"]'); $I->switchToIFrame(); $I->waitForElement('.modal-dialog'); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) { + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default\"]').click()"); + } $I->waitForText('Header Only'); $typo3Version = GeneralUtility::makeInstance(Typo3Version::class); if ($typo3Version->getMajorVersion() < 12) { $I->click('Header Only'); } else { - $I->executeJS("document.querySelector('typo3-backend-new-content-element-wizard').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()"); + if ($typo3Version->getMajorVersion() < 13) { + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()"); + } else { + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default_header\"]').click()"); + } } $I->switchToContentFrame(); $I->wait(0.5); $I->see('textmedia', 'select'); - $I->dontSee('Table', 'select'); + $I->dontSee('Images Only', 'select'); } /** * @group content_defender */ - public function doNotSeeNotAllowedContentElementsInCTypeSelectBoxWhenEditAnElement(BackendTester $I, PageTree $pageTree) + public function doNotSeeNotAllowedContentElementsInCTypeSelectBoxWhenEditAnElement(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13) { $I->click('Page'); - $I->waitForElement('#typo3-pagetree-tree .nodes .node'); - $pageTree->openPath(['home', 'contentTCASelectCtype']); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { + $I->waitForElement('#typo3-pagetree-tree .nodes .node'); + $pageTree->openPath(['home', 'contentTCASelectCtype']); + } else { + $pageTreeV13->openPath(['home', 'contentTCASelectCtype']); + } $I->wait(0.5); $I->switchToContentFrame(); $I->waitForElement('#element-tt_content-502 a[title="Edit"]'); $I->click('#element-tt_content-502 a[title="Edit"]'); $I->waitForElement('#EditDocumentController'); $I->see('textmedia', 'select'); - $I->dontSee('Table', 'select'); + $I->dontSee('Images Only', 'select'); } /** * @group content_defender */ - public function canSeeNewContentButtonIfMaxitemsIsNotReached(BackendTester $I, PageTree $pageTree) + public function canSeeNewContentButtonIfMaxitemsIsNotReached(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13) { $I->click('Page'); - $I->waitForElement('#typo3-pagetree-tree .nodes .node'); - $pageTree->openPath(['home', 'contentDefenderMaxitems']); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { + $I->waitForElement('#typo3-pagetree-tree .nodes .node'); + $pageTree->openPath(['home', 'contentDefenderMaxitems']); + } else { + $pageTreeV13->openPath(['home', 'contentDefenderMaxitems']); + } $I->wait(0.5); $I->switchToContentFrame(); $dataColPos = $I->getDataColPos(402, 202); @@ -168,11 +210,15 @@ public function canSeeNewContentButtonIfMaxitemsIsNotReached(BackendTester $I, P /** * @group content_defender */ - public function canNotSeeNewContentButtonIfMaxitemsIsReached(BackendTester $I, PageTree $pageTree) + public function canNotSeeNewContentButtonIfMaxitemsIsReached(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13) { $I->click('Page'); - $I->waitForElement('#typo3-pagetree-tree .nodes .node'); - $pageTree->openPath(['home', 'contentDefenderMaxitems']); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { + $I->waitForElement('#typo3-pagetree-tree .nodes .node'); + $pageTree->openPath(['home', 'contentDefenderMaxitems']); + } else { + $pageTreeV13->openPath(['home', 'contentDefenderMaxitems']); + } $I->wait(0.5); $I->switchToContentFrame(); $dataColPos = $I->getDataColPos(401, 202); @@ -184,11 +230,15 @@ public function canNotSeeNewContentButtonIfMaxitemsIsReached(BackendTester $I, P /** * @group content_defender */ - public function canCreateNewChildInContainerIfMaxitemsIsReachedInOtherContainer(BackendTester $I, PageTree $pageTree) + public function canCreateNewChildInContainerIfMaxitemsIsReachedInOtherContainer(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13) { $I->click('Page'); - $I->waitForElement('#typo3-pagetree-tree .nodes .node'); - $pageTree->openPath(['home', 'contentDefenderMaxitems']); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { + $I->waitForElement('#typo3-pagetree-tree .nodes .node'); + $pageTree->openPath(['home', 'contentDefenderMaxitems']); + } else { + $pageTreeV13->openPath(['home', 'contentDefenderMaxitems']); + } $I->wait(0.5); $I->switchToContentFrame(); $dataColPos = $I->getDataColPos(402, 202); @@ -197,12 +247,19 @@ public function canCreateNewChildInContainerIfMaxitemsIsReachedInOtherContainer( $I->click($newContentElementLabel, '#element-tt_content-402 [data-colpos="' . $dataColPos . '"]'); $I->switchToIFrame(); $I->waitForElement('.modal-dialog'); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() > 12) { + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default\"]').click()"); + } $I->waitForText('Header Only'); $typo3Version = GeneralUtility::makeInstance(Typo3Version::class); if ($typo3Version->getMajorVersion() < 12) { $I->click('Header Only'); } else { - $I->executeJS("document.querySelector('typo3-backend-new-content-element-wizard').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()"); + if ($typo3Version->getMajorVersion() < 13) { + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()"); + } else { + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default_header\"]').click()"); + } } $I->switchToContentFrame(); $I->waitForText('Create new Page Content on page'); @@ -213,11 +270,15 @@ public function canCreateNewChildInContainerIfMaxitemsIsReachedInOtherContainer( /** * @group content_defender */ - public function seeEditDocumentWhenAddingChildrenToColposWhereOnlyHeaderIsAllowed(BackendTester $I, PageTree $pageTree) + public function seeEditDocumentWhenAddingChildrenToColposWhereOnlyHeaderIsAllowed(BackendTester $I, PageTree $pageTree, PageTreeV13 $pageTreeV13) { $I->click('Page'); - $I->waitForElement('#typo3-pagetree-tree .nodes .node'); - $pageTree->openPath(['home', 'pageWithDifferentContainers']); + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { + $I->waitForElement('#typo3-pagetree-tree .nodes .node'); + $pageTree->openPath(['home', 'pageWithDifferentContainers']); + } else { + $pageTreeV13->openPath(['home', 'pageWithDifferentContainers']); + } $I->wait(0.5); $I->switchToContentFrame(); $dataColPos = $I->getDataColPos(300, 201); @@ -228,7 +289,7 @@ public function seeEditDocumentWhenAddingChildrenToColposWhereOnlyHeaderIsAllowe $I->switchToContentFrame(); $I->wait(0.5); $I->see('header', 'select'); - $I->dontSee('Table', 'select'); + $I->dontSee('Images Only', 'select'); } } diff --git a/Tests/Acceptance/Backend/LayoutCest.php b/Tests/Acceptance/Backend/LayoutCest.php index ecc05e95..85e53fd5 100644 --- a/Tests/Acceptance/Backend/LayoutCest.php +++ b/Tests/Acceptance/Backend/LayoutCest.php @@ -155,9 +155,9 @@ public function canCreateContainerContentElement(BackendTester $I, PageTree $pag $I->click('Container'); $I->click('2 Column Container With Header'); } else { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').filter('container')"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').filter('container')"); $I->wait(0.5); - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"container_b13-2cols-with-header-container\"]').click()"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"container_b13-2cols-with-header-container\"]').click()"); } $I->switchToContentFrame(); $I->click('Save'); @@ -200,23 +200,15 @@ public function canCreateContainerContentElementSaveAndClose(BackendTester $I, P // b13-2cols $I->click('2 Column Some Description of the Container'); } else { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').filter('container')"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').filter('container')"); $I->wait(0.5); - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"container_b13-2cols\"]').click()"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"container_b13-2cols\"]').click()"); } $I->switchToContentFrame(); $I->waitForText('2-cols-left'); $I->canSee('2-cols-left', '.t3-grid-container'); } - protected function getNewRecordWizardSelector(): string - { - if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { - return 'typo3-backend-new-content-element-wizard'; - } - return 'typo3-backend-new-record-wizard'; - } - /** * @param BackendTester $I * @param PageTree $pageTree @@ -279,12 +271,12 @@ public function newElementInHeaderColumnHasExpectedColPosAndParentSelected(Backe $I->waitForText('Header Only'); $I->click('Header Only'); } else { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').filter('header ')"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').filter('header ')"); $I->waitForText('Header Only'); if ($typo3Version->getMajorVersion() < 13) { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()"); } else { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default_header\"]').click()"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default_header\"]').click()"); } } $I->switchToContentFrame(); @@ -323,12 +315,12 @@ public function canCreateContentElementInContainer(BackendTester $I, PageTree $p $I->waitForText('Header Only'); $I->click('Header Only'); } else { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').filter('header ')"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').filter('header ')"); $I->waitForText('Header Only'); if ($typo3Version->getMajorVersion() < 13) { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()"); } else { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default_header\"]').click()"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default_header\"]').click()"); } } $I->switchToContentFrame(); @@ -382,12 +374,12 @@ public function canCreateContentElementInTranslatedContainerInFreeMode(BackendTe $I->waitForText('Header Only'); $I->click('Header Only'); } else { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').filter('header ')"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').filter('header ')"); $I->waitForText('Header Only'); if ($typo3Version->getMajorVersion() < 13) { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"common_header\"]').click()"); } else { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default_header\"]').click()"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').shadowRoot.querySelector('button[data-identifier=\"default_header\"]').click()"); } } $I->switchToContentFrame(); @@ -522,7 +514,7 @@ public function canSeeDescriptionOfContainerInNewContentElementWizard(BackendTes if ($typo3Version->getMajorVersion() < 12) { $I->click('Container'); } else { - $I->executeJS("document.querySelector('" . $this->getNewRecordWizardSelector() . "').filter('container')"); + $I->executeJS("document.querySelector('" . $I->getNewRecordWizardSelector() . "').filter('container')"); $I->wait(0.5); } $I->see('Some Description of the Container'); diff --git a/Tests/Acceptance/Support/BackendTester.php b/Tests/Acceptance/Support/BackendTester.php index 6a18e306..a5f43f77 100644 --- a/Tests/Acceptance/Support/BackendTester.php +++ b/Tests/Acceptance/Support/BackendTester.php @@ -60,4 +60,12 @@ public function getNewContentElementLabel(): string } return 'Create new content'; } + + public function getNewRecordWizardSelector(): string + { + if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) { + return 'typo3-backend-new-content-element-wizard'; + } + return 'typo3-backend-new-record-wizard'; + } } diff --git a/Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php b/Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php index d903e375..81cb00f3 100644 --- a/Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php +++ b/Tests/Acceptance/Support/Extension/BackendContainerEnvironment.php @@ -66,16 +66,4 @@ class BackendContainerEnvironment extends BackendEnvironment __DIR__ . '/../../Fixtures/be_groups.csv', ], ]; - - public function _initialize(): void - { - $typo3Version = GeneralUtility::makeInstance(Typo3Version::class); - if ($typo3Version->getMajorVersion() === 13) { - $this->localConfig['testExtensionsToLoad'] = [ - 'b13/container', - 'b13/container-example', - ]; - } - parent::_initialize(); - } } 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(); }