From 255039c142f075094b84bf4298323c1449676866 Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Thu, 11 Jul 2024 19:12:37 +0200 Subject: [PATCH] [TASK] Add test extension "test_classic_content" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds a new fixture extension with a content element with a relation to an inline table. Resolves: #104369 Releases: main Change-Id: I777d5dbdebaad4f278bab2dc2b87ebd92f331515 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85227 Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Benni Mack <benni@typo3.org> --- .../Configuration/TCA/Overrides/carousel.php | 43 ++++++++++++ .../TCA/test_content_carousel_item.php | 68 +++++++++++++++++++ .../test_classic_content/composer.json | 14 ++++ .../test_classic_content/ext_emconf.php | 21 ++++++ .../Fixtures/ContentScenario.yaml | 7 ++ .../Partials/SingleContent.html | 4 ++ .../Partials/SingleContent.html | 4 ++ .../PageContentFetchingProcessorTest.php | 5 ++ .../RecordTransformationProcessorTest.php | 4 ++ 9 files changed, 170 insertions(+) create mode 100644 typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/Configuration/TCA/Overrides/carousel.php create mode 100644 typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/Configuration/TCA/test_content_carousel_item.php create mode 100644 typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/composer.json create mode 100644 typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/ext_emconf.php diff --git a/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/Configuration/TCA/Overrides/carousel.php b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/Configuration/TCA/Overrides/carousel.php new file mode 100644 index 000000000000..d8f4ec4e3846 --- /dev/null +++ b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/Configuration/TCA/Overrides/carousel.php @@ -0,0 +1,43 @@ +<?php + +// Add a Content Type called "test_carousel" +$CType = 'test_carousel'; +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTcaSelectItem( + 'tt_content', + 'CType', + [ + 'label' => 'Carousel', + 'value' => $CType, + 'icon' => 'content-carousel-item-textandimage', + 'group' => 'default', + ], + 'textmedia', + 'after' +); + +// Add a new icon +$GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes'][$CType] = 'content-carousel-item-textandimage'; +// Add the "showitem" type +$GLOBALS['TCA']['tt_content']['types'][$CType] = $GLOBALS['TCA']['tt_content']['types']['header']; + +// Add a new relational field for carousel_item DB table +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns( + 'tt_content', + [ + 'carousel_items' => [ + 'label' => 'Carousel Items', + 'config' => [ + 'type' => 'inline', + 'foreign_table' => 'test_content_carousel_item', + 'foreign_field' => 'carousel_content_element', + ], + ], + ] +); +\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes( + 'tt_content', + 'carousel_items', + $CType, + // after a palette or tab would be "cool" + 'after:header', +); diff --git a/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/Configuration/TCA/test_content_carousel_item.php b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/Configuration/TCA/test_content_carousel_item.php new file mode 100644 index 000000000000..22f691104fd5 --- /dev/null +++ b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/Configuration/TCA/test_content_carousel_item.php @@ -0,0 +1,68 @@ +<?php + +return [ + 'ctrl' => [ + 'title' => 'Carousel Item', + 'label' => 'header', + 'label_alt' => 'header_link', + 'label_alt_force' => 1, + 'default_sortby' => 'ORDER BY header', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'delete' => 'deleted', + 'languageField' => 'sys_language_uid', + 'enablecolumns' => [ + 'disabled' => 'hidden', + ], + 'security' => [ + 'ignorePageTypeRestriction' => true, + ], + 'iconfile' => 'EXT:core/Resources/Public/Icons/T3Icons/content/content-carousel.svg', + ], + 'columns' => [ + 'header' => [ + 'label' => 'Header', + 'config' => [ + 'type' => 'input', + ], + ], + 'header_link' => [ + 'label' => 'Header Link', + 'config' => [ + 'type' => 'link', + ], + ], + 'bodytext' => [ + 'label' => 'Bodytext', + 'config' => [ + 'type' => 'text', + 'enableRichtext' => true, + 'cols' => 40, + 'rows' => 15, + ], + ], + 'carousel_content_element' => [ + 'label' => 'Content Element', + 'config' => [ + 'type' => 'passthrough', + ], + ], + 'image' => [ + 'label' => 'Image', + 'config' => [ + 'type' => 'file', + 'maxitems' => 1, + ], + ], + ], + 'types' => [ + '0' => [ + 'showitem' => 'header, header_link, bodytext, image', + ], + ], + 'palettes' => [ + 'language' => [ + 'showitem' => 'sys_language_uid, l10n_parent', + ], + ], +]; diff --git a/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/composer.json b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/composer.json new file mode 100644 index 000000000000..5276ec864166 --- /dev/null +++ b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/composer.json @@ -0,0 +1,14 @@ +{ + "name": "typo3tests/test-classic-content", + "type": "typo3-cms-extension", + "description": "This extension adds example tt_content CTypes", + "license": "GPL-2.0-or-later", + "require": { + "typo3/cms-core": "13.3.*@dev" + }, + "extra": { + "typo3/cms": { + "extension-key": "test_classic_content" + } + } +} diff --git a/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/ext_emconf.php b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/ext_emconf.php new file mode 100644 index 000000000000..d64b732fc4bf --- /dev/null +++ b/typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content/ext_emconf.php @@ -0,0 +1,21 @@ +<?php + +declare(strict_types=1); + +$EM_CONF[$_EXTKEY] = [ + 'title' => 'This extension adds example tt_content CTypes.', + 'description' => 'This extension adds example tt_content CTypes.', + 'category' => 'example', + 'version' => '13.3.0', + 'state' => 'stable', + 'author' => 'Benni Mack', + 'author_email' => 'benniYYYY@typo3.org', + 'author_company' => '', + 'constraints' => [ + 'depends' => [ + 'typo3' => '13.3.0', + ], + 'conflicts' => [], + 'suggests' => [], + ], +]; diff --git a/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/ContentScenario.yaml b/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/ContentScenario.yaml index dc6d1b4892c4..c3615189cce1 100644 --- a/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/ContentScenario.yaml +++ b/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/ContentScenario.yaml @@ -33,6 +33,9 @@ entitySettings: aside: {colPos: 2} footer: {colPos: 5} flashInfo: {colPos: 10} + carousel_items: + tableName: 'test_content_carousel_item' + languageColumnNames: ['l10n_parent'] entities: page: @@ -40,8 +43,12 @@ entities: entities: content: - self: {title: 'Welcome to ACME guitars', type: *contentText, area: 'stage'} + - self: {id: 234, title: 'Our latest and greatest products', type: 'test_carousel', area: 'stage', carousel_items: '1,2'} - self: {text: '<p>Great to see you here</p>', type: *contentText, area: 'main'} - self: {text: '<p>If you read this you are at the end.</p>', type: *contentText, area: 'footer'} + carousel_items: + - self: {header: 'Meet us at Guitar Brussels in 2035', carousel_content_element: 234} + - self: {header: 'Check out our latest Hero guitars', carousel_content_element: 234} children: - self: {id: 1100, title: 'Our Products', slug: '/products', backendLayout: 'default'} entities: diff --git a/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/PageContentProcessor/Partials/SingleContent.html b/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/PageContentProcessor/Partials/SingleContent.html index 3b93ad1a4501..c4b93052867f 100644 --- a/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/PageContentProcessor/Partials/SingleContent.html +++ b/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/PageContentProcessor/Partials/SingleContent.html @@ -3,4 +3,8 @@ <h3>{record.header}</h3> <p>{record.bodytext}</p> </f:case> + <f:case value="test_carousel"> + <h3>{record.header}</h3> + <p>Carousel Items will show up: {record.carousel_items}</p> + </f:case> </f:switch> diff --git a/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/RecordTransform/Partials/SingleContent.html b/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/RecordTransform/Partials/SingleContent.html index 3b93ad1a4501..c4b93052867f 100644 --- a/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/RecordTransform/Partials/SingleContent.html +++ b/typo3/sysext/frontend/Tests/Functional/DataProcessing/Fixtures/RecordTransform/Partials/SingleContent.html @@ -3,4 +3,8 @@ <h3>{record.header}</h3> <p>{record.bodytext}</p> </f:case> + <f:case value="test_carousel"> + <h3>{record.header}</h3> + <p>Carousel Items will show up: {record.carousel_items}</p> + </f:case> </f:switch> diff --git a/typo3/sysext/frontend/Tests/Functional/DataProcessing/PageContentFetchingProcessorTest.php b/typo3/sysext/frontend/Tests/Functional/DataProcessing/PageContentFetchingProcessorTest.php index f1cec9890db5..a57486f9c8bd 100644 --- a/typo3/sysext/frontend/Tests/Functional/DataProcessing/PageContentFetchingProcessorTest.php +++ b/typo3/sysext/frontend/Tests/Functional/DataProcessing/PageContentFetchingProcessorTest.php @@ -34,6 +34,10 @@ final class PageContentFetchingProcessorTest extends FunctionalTestCase 'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en-US'], ]; + protected array $testExtensionsToLoad = [ + 'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content', + ]; + protected function setUp(): void { parent::setUp(); @@ -76,6 +80,7 @@ final class PageContentFetchingProcessorTest extends FunctionalTestCase $response = $this->executeFrontendSubRequest((new InternalRequest('https://acme.com/'))->withPageId(1000)); $body = (string)$response->getBody(); self::assertStringContainsString('Welcome to ACME guitars', $body); + self::assertStringContainsString('Carousel Items will show up: 2', $body); self::assertStringContainsString('Great to see you here', $body); self::assertStringContainsString('If you read this you are at the end.', $body); } diff --git a/typo3/sysext/frontend/Tests/Functional/DataProcessing/RecordTransformationProcessorTest.php b/typo3/sysext/frontend/Tests/Functional/DataProcessing/RecordTransformationProcessorTest.php index 95c60af23e88..1f3ac93adf97 100644 --- a/typo3/sysext/frontend/Tests/Functional/DataProcessing/RecordTransformationProcessorTest.php +++ b/typo3/sysext/frontend/Tests/Functional/DataProcessing/RecordTransformationProcessorTest.php @@ -30,6 +30,10 @@ final class RecordTransformationProcessorTest extends FunctionalTestCase { use SiteBasedTestTrait; + protected array $testExtensionsToLoad = [ + 'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_classic_content', + ]; + protected const LANGUAGE_PRESETS = [ 'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en-US'], ]; -- GitLab