diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/AbstractLocalizedPagesTestCase.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/AbstractLocalizedPagesTestCase.php index 66e8b279089869b8ac137a8a0f495721470a9003..08f5494f3c0b71c2387cda25beb3aa7e4df37644 100644 --- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/AbstractLocalizedPagesTestCase.php +++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/AbstractLocalizedPagesTestCase.php @@ -147,4 +147,23 @@ abstract class AbstractLocalizedPagesTestCase extends AbstractTestCase self::assertSame($expectation, $json); } + + protected function createLanguageMenu(string $url): array + { + $this->setUpFrontendRootPage( + 1000, + ['typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkGenerator.typoscript'], + ['title' => 'ACME Root'] + ); + + $response = $this->executeFrontendSubRequest( + (new InternalRequest($url))->withInstructions([$this->createLanguageMenuProcessorInstruction(['languages' => 'auto'])]), + $this->internalRequestContext + ); + + $json = json_decode((string)$response->getBody(), true); + $json = $this->filterMenu($json); + + return $json; + } } diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/Fixtures/ScenarioD.yaml b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/Fixtures/ScenarioD.yaml index 844262ed94f4e499cf9e22be26cfa36ce891febb..aa9b3713657d4773a591df487f672e7a9be78c32 100644 --- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/Fixtures/ScenarioD.yaml +++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/Fixtures/ScenarioD.yaml @@ -52,3 +52,4 @@ entities: - self: {id: 1500, title: 'EN: Company', slug: '/company'} languageVariants: - self: {id: 1501, title: 'DE: Unternehmen', language: 1, slug: '/shortcut-to-about', type: *pageShortcut, shortcut: 1200, shortcut_mode: 0, l18n_cfg: 0, l10n_state: '{"shortcut":"custom","shortcut_mode":"custom"}'} + - self: {id: 1502, title: 'DE-CH: Unternehmen', language: 2, slug: '/unternehmen'} diff --git a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioDTest.php b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioDTest.php index e74e115b860e62955333eb14b56d6a4050e4df74..1af7c67240c99431cef18a6c7b59830788b97d0e 100644 --- a/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioDTest.php +++ b/typo3/sysext/frontend/Tests/Functional/SiteHandling/LocalizedPageRendering/ScenarioDTest.php @@ -175,6 +175,7 @@ class ScenarioDTest extends AbstractLocalizedPagesTestCase ['title' => 'DE-CH: Ãœber uns', 'link' => '/de-ch/ueber-uns'], ['title' => 'DE-CH: Produkte', 'link' => '/de-ch/produkte'], ['title' => 'EN: Shortcut to welcome', 'link' => ''], + ['title' => 'DE-CH: Unternehmen', 'link' => '/de-ch/unternehmen'], ], ], ]; @@ -191,4 +192,18 @@ class ScenarioDTest extends AbstractLocalizedPagesTestCase { $this->assertMenu($url, $expectedMenu); } + + /** + * @test + */ + public function languageMenuHasLanguageShortcutsWithLanguageSpecificUrls(): void + { + $expectedMenu = [ + ['title' => 'English', 'link' => '/en/company'], + ['title' => 'German', 'link' => '/de/ueber-uns'], + ['title' => 'Swiss German', 'link' => '/de-ch/unternehmen'], + ]; + + self::assertSame($expectedMenu, $this->createLanguageMenu('https://acme.com/de-ch/unternehmen')); + } }