2 declare(strict_types = 1);
19 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerFactory;
20 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter;
21 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
22 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
23 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
66 private $siteTitle =
'A Company that Manufactures Board Games and Everything Inc';
75 parent::setUpBeforeClass();
76 static::initializeDatabaseSnapshot();
81 static::destroyDatabaseSnapshot();
82 parent::tearDownAfterClass();
85 protected function setUp(): void
90 $this->internalRequestContext = (
new InternalRequestContext())
91 ->withGlobalSettings([
'TYPO3_CONF_VARS' => static::TYPO3_CONF_VARS]);
128 $this->withDatabaseSnapshot(
function () {
135 $backendUser = $this->setUpBackendUserFromFixture(1);
138 $scenarioFile = __DIR__ .
'/Fixtures/MountPointScenario.yaml';
139 $factory = DataHandlerFactory::fromYamlFile($scenarioFile);
140 $writer = DataHandlerWriter::withBackendUser($backendUser);
141 $writer->invokeFactory($factory);
142 static::failIfArrayIsNotEmpty(
146 $this->setUpFrontendRootPage(
149 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkGenerator.typoscript',
152 'title' =>
'ACME Global',
153 'sitetitle' => $this->siteTitle,
156 $this->setUpFrontendRootPage(
159 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkGenerator.typoscript',
162 'title' =>
'ACME Canada',
163 'sitetitle' => $this->siteTitle,
166 $this->setUpFrontendRootPage(
169 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkGenerator.typoscript',
172 'title' =>
'ACME US',
173 'sitetitle' => $this->siteTitle,
176 $this->setUpFrontendRootPage(
179 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkGenerator.typoscript',
182 'title' =>
'ACME Archive',
183 'sitetitle' => $this->siteTitle,
190 unset($this->internalRequestContext);
199 $siteMapOfMainPage = [
200 [
'title' =>
'EN: Welcome',
'link' =>
'/welcome'],
202 'title' =>
'EN: Features',
203 'link' =>
'/features',
206 'title' =>
'EN: Frontend Editing',
207 'link' =>
'/features/frontend-editing',
212 'title' =>
'EN: Products',
213 'link' =>
'/products',
216 'title' =>
'EN: Toys',
217 'link' =>
'/products/toys',
220 'title' =>
'EN: Card Games',
221 'link' =>
'/products/card-games',
224 'title' =>
'EN: Board Games',
225 'link' =>
'/products/board-games',
228 'title' =>
'EN: Monopoly',
229 'link' =>
'/products/monopoly',
232 'title' =>
'EN: Catan',
233 'link' =>
'/products/board-games/catan',
236 'title' =>
'EN: Risk',
242 'title' =>
'Archived Products',
243 'link' =>
'/products/archive',
246 'title' =>
'EN: Games of the 1980s',
247 'link' =>
'/products/archive/games-of-the-1980s',
250 'title' =>
'EN: Games of the 1990s',
251 'link' =>
'/products/archive/games-of-the-1990s',
254 'title' =>
'Uno - The famous classic',
255 'link' =>
'/products/archive/uno',
262 'title' =>
'See our Archives',
263 'link' =>
'/archive',
266 'title' =>
'EN: Archived Products',
267 'link' =>
'/archive/products',
270 'title' =>
'EN: Games of the 1980s',
271 'link' =>
'/archive/products/games-of-the-1980s',
274 'title' =>
'EN: Games of the 1990s',
275 'link' =>
'/archive/products/games-of-the-1990s',
278 'title' =>
'Uno - The famous classic',
279 'link' =>
'/archive/uno',
284 'title' =>
'EN: Archived News',
285 'link' =>
'/archive/news',
288 'title' =>
'EN: Whats new in 2020',
289 'link' =>
'/archive/news/latest-releases-2020',
292 'title' =>
'EN: Whats new in 2019',
293 'link' =>
'/archive/news/latest-releases-2019',
299 [
'title' =>
'About us',
'link' =>
'/about'],
300 [
'title' =>
'Page not found',
'link' =>
'/404'],
302 [
'title' =>
'ACME in Canada',
'link' =>
'https://acme.ca/news/'],
304 $siteMapOfCanadianPage = [
306 'title' =>
'News of Canada',
310 'title' =>
'New Games in Canada 2020',
311 'link' =>
'/news/games-in-canada-2020',
314 'title' =>
'New Games in Canada 2019',
315 'link' =>
'/slug-with-a-mistake-which-never-changed/games-in-canada-2019',
320 'title' =>
'Products',
321 'link' =>
'/products',
324 'title' =>
'EN: Toys',
325 'link' =>
'/products/toys',
328 'title' =>
'EN: Card Games',
329 'link' =>
'/products/card-games',
332 'title' =>
'EN: Board Games',
333 'link' =>
'/products/board-games',
336 'title' =>
'EN: Monopoly',
337 'link' =>
'/products/monopoly',
340 'title' =>
'EN: Catan',
341 'link' =>
'/products/board-games/catan',
344 'title' =>
'EN: Risk',
345 'link' =>
'/products/risk',
350 'title' =>
'Archived Products',
351 'link' =>
'/products/archive',
354 'title' =>
'EN: Games of the 1980s',
355 'link' =>
'/products/archive/games-of-the-1980s',
358 'title' =>
'EN: Games of the 1990s',
359 'link' =>
'/products/archive/games-of-the-1990s',
362 'title' =>
'Uno - The famous classic',
364 'link' =>
'/products/archive/uno',
371 'title' =>
'All News',
372 'link' =>
'/all-news',
375 'title' =>
'News of Canada',
377 'link' =>
'/all-news/canada/',
380 'title' =>
'New Games in Canada 2020',
384 'link' =>
'/all-news/canada/games-in-canada-2020',
387 'title' =>
'New Games in Canada 2019',
389 'link' =>
'/all-news/canada/slug-with-a-mistake-which-never-changed/games-in-canada-2019',
394 'title' =>
'Archived News',
395 'link' =>
'/all-news/archive',
398 'title' =>
'EN: Whats new in 2020',
399 'link' =>
'/all-news/archive/latest-releases-2020',
402 'title' =>
'EN: Whats new in 2019',
403 'link' =>
'/all-news/archive/latest-releases-2019',
409 [
'title' =>
'Link To Our Worldwide Site',
'link' =>
'https://acme.com/welcome'],
413 'https://acme.com/welcome',
416 'ACME Canada First Subpage in EN' => [
417 'https://acme.ca/all-news',
418 $siteMapOfCanadianPage
420 'ACME Canada Subpage of mounted Products page' => [
421 'https://acme.ca/products/risk',
422 $siteMapOfCanadianPage
436 $response = $this->executeFrontendRequest(
437 (
new InternalRequest($accessedUrl))
439 $this->createHierarchicalMenuProcessorInstruction([
443 'includeSpacer' => 1,
444 'titleField' =>
'title',
447 $this->internalRequestContext
450 $json = json_decode((
string)$response->getBody(),
true);
451 $json = $this->filterMenu($json);
453 self::assertSame($expectation, $json);
459 'regular page on global site' => [
460 'https://acme.com/welcome',
465 'mountpoint to a different site with same slug on global site' => [
466 'https://acme.com/products/archive',
471 'subpage of mountpoint to a different site with same slug on global site' => [
472 'https://acme.com/products/archive/uno',
477 'subpage of mountpoint to a different site on global site' => [
478 'https://acme.com/archive/products/games-of-the-1980s',
496 $this->setUpFrontendRootPage(
499 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkRequest.typoscript',
502 'title' =>
'ACME Root',
503 'sitetitle' => $this->siteTitle,
506 $response = $this->executeFrontendRequest(
507 (
new InternalRequest($uri)),
508 $this->internalRequestContext
510 $responseData = json_decode((
string)$response->getBody(),
true);
511 self::assertSame(200, $response->getStatusCode());
512 self::assertSame($expectedPageId, $responseData[
'pageId']);
513 self::assertSame($expectedMountPointParameter, $responseData[
'dynamicArguments'][
'MP'] ??
null);
522 'Show content of MountPoint Page' => [
523 'https://acme.ca/all-news/archive',
524 'Content of MountPoint Page'
526 'Show content of Mounted Page' => [
527 'https://acme.ca/all-news/canada',
528 'See a list of all games distributed in canada'
530 'Show content of Mounted Page for second site' => [
531 'https://acme.us/all-news/us',
532 'See a list of all games distributed in the US'
547 $this->setUpFrontendRootPage(
550 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript',
551 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/JsonRenderer.typoscript',
554 'title' =>
'ACME Root',
555 'sitetitle' => $this->siteTitle,
558 $this->setUpFrontendRootPage(
561 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript',
562 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/JsonRenderer.typoscript',
565 'title' =>
'ACME Root',
566 'sitetitle' => $this->siteTitle,
569 $response = $this->executeFrontendRequest(
570 (
new InternalRequest($uri)),
571 $this->internalRequestContext
573 self::assertSame(200, $response->getStatusCode());
574 $responseStructure = ResponseContent::fromString(
575 (
string)$response->getBody()
577 $responseRecords = $responseStructure->getSection(
'Default')->getRecords();
578 $firstContent =
null;
580 foreach ($responseRecords as $identifier => $record) {
581 if (strpos($identifier,
'tt_content:') === 0) {
582 $firstContent = $record;
587 self::assertStringContainsString($expected, $firstContent[
'header'] ??
'');
589 self::assertEmpty($firstContent);