Commit 4d980f4e authored by Benni Mack's avatar Benni Mack Committed by Oliver Bartsch
Browse files

[TASK] Add tests for list menu with folder as root storage

This change adds test to document the behavior that excludeDoktypes
needs to be set to render folders in a menus as well.

Resolves: #93924
Releases: main, 11.5
Change-Id: I870e2ef5cd07d5365d93ad04752b74a4edaebd64
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72790


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent dc749a15
......@@ -175,3 +175,10 @@ entities:
- self: {id: 7110, title: 'Markets', slug: '/common/markets'}
- self: {id: 7120, title: 'Products', slug: '/common/products'}
- self: {id: 7130, title: 'Partners', slug: '/common/partners'}
- self: {id: 8000, title: 'Usual Collection Non-Root', root: true, slug: '/usual'}
children:
- self: {id: 8100, title: 'Announcements & News', type: *pageFolder, slug: '/usual/news-folder'}
children:
- self: {id: 8110, title: 'Markets', slug: '/usual/markets'}
- self: {id: 8120, title: 'Products', slug: '/usual/products'}
- self: {id: 8130, title: 'Partners', slug: '/usual/partners'}
......@@ -19,6 +19,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\SiteHandling;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\TypoScript\TemplateService;
use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerFactory;
use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter;
......@@ -73,6 +74,10 @@ class SlugLinkGeneratorTest extends AbstractTestCase
'common-collection',
$this->buildSiteConfiguration(7000, 'https://common.acme.com/')
);
$this->writeSiteConfiguration(
'usual-collection',
$this->buildSiteConfiguration(8000, 'https://usual.acme.com/')
);
$this->withDatabaseSnapshot(function () {
$this->setUpDatabase();
......@@ -1063,6 +1068,7 @@ class SlugLinkGeneratorTest extends AbstractTestCase
[1100, 1600, 1700, 1800, 1520],
0,
0,
[],
[
[
'title' => 'EN: Welcome',
......@@ -1084,6 +1090,7 @@ class SlugLinkGeneratorTest extends AbstractTestCase
[1100, 1600, 1700, 1800, 1520],
1,
1,
[],
[
[
'title' => 'EN: Welcome to ACME Inc',
......@@ -1099,6 +1106,58 @@ class SlugLinkGeneratorTest extends AbstractTestCase
],
],
],
'Folder as base directory, needs to set excludeDoktypes in order to show the folder itself' => [
'https://acme.us/',
1100,
[7000],
0,
0,
[
'levels' => 2,
'expandAll' => 1,
'excludeDoktypes' => PageRepository::DOKTYPE_BE_USER_SECTION,
],
[
[
'title' => 'Common Collection',
// @todo Folders should not be linked in frontend menus, as they are not accessible there.
// @todo Folder as rootpage - reconsider if this should be a valid use/test case, as marking
// it as root_page is not possible if page is doktype sysfolder first.
'link' => 'https://common.acme.com/common',
'children' => [
[
'title' => 'Announcements & News',
'link' => 'https://common.acme.com/common/news',
],
],
],
],
],
'Non-Rootpage Sysfolder, needs to set excludeDoktypes in order to show the folder itself' => [
'https://acme.us/',
1100,
[8000],
0,
0,
[
'levels' => 2,
'expandAll' => 1,
'excludeDoktypes' => PageRepository::DOKTYPE_BE_USER_SECTION,
],
[
[
'title' => 'Usual Collection Non-Root',
'link' => 'https://usual.acme.com/usual',
'children' => [
[
'title' => 'Announcements & News',
// @todo Folders should not be linked in frontend menus, as they are not accessible there.
'link' => 'https://usual.acme.com/usual/news-folder',
],
],
],
],
],
];
}
......@@ -1106,19 +1165,19 @@ class SlugLinkGeneratorTest extends AbstractTestCase
* @test
* @dataProvider listMenuIsGeneratedDataProvider
*/
public function listMenuIsGenerated(string $hostPrefix, int $sourcePageId, array $menuPageIds, int $backendUserId, int $workspaceId, array $expectation): void
public function listMenuIsGenerated(string $hostPrefix, int $sourcePageId, array $menuPageIds, int $backendUserId, int $workspaceId, array $additionalMenuConfiguration, array $expectation): void
{
$response = $this->executeFrontendSubRequest(
(new InternalRequest($hostPrefix))
->withPageId($sourcePageId)
->withInstructions([
$this->createHierarchicalMenuProcessorInstruction([
$this->createHierarchicalMenuProcessorInstruction(array_replace_recursive([
'special' => 'list',
'special.' => [
'value' => implode(',', $menuPageIds),
],
'titleField' => 'title',
]),
], $additionalMenuConfiguration)),
]),
(new InternalRequestContext())
->withWorkspaceId($backendUserId !== 0 ? $workspaceId : 0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment