Skip to content

Commit

Permalink
[TASK] Add tests for list menu with folder as root storage
Browse files Browse the repository at this point in the history
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/+/72769
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
  • Loading branch information
bmack authored and o-ba committed Dec 23, 2021
1 parent 3698b49 commit 107a3f6
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
Expand Up @@ -169,3 +169,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'}
Expand Up @@ -19,6 +19,7 @@

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;
Expand Down Expand Up @@ -73,6 +74,10 @@ protected function setUp(): void
'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();
Expand Down Expand Up @@ -1063,6 +1068,7 @@ public function listMenuIsGeneratedDataProvider(): array
[1100, 1600, 1700, 1800, 1520],
0,
0,
[],
[
[
'title' => 'EN: Welcome',
Expand All @@ -1084,6 +1090,7 @@ public function listMenuIsGeneratedDataProvider(): array
[1100, 1600, 1700, 1800, 1520],
1,
1,
[],
[
[
'title' => 'EN: Welcome to ACME Inc',
Expand All @@ -1099,26 +1106,78 @@ public function listMenuIsGeneratedDataProvider(): array
],
],
],
'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',
],
],
],
],
],
];
}

/**
* @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)
Expand Down

0 comments on commit 107a3f6

Please sign in to comment.