2 declare(strict_types = 1);
21 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerFactory;
22 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter;
23 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\Internal\TypoScriptInstruction;
24 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
25 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
36 private $siteTitle =
'A Company that Manufactures Everything Inc';
45 parent::setUpBeforeClass();
46 static::initializeDatabaseSnapshot();
51 static::destroyDatabaseSnapshot();
52 parent::tearDownAfterClass();
55 protected function setUp()
60 $this->internalRequestContext = (
new InternalRequestContext())
61 ->withGlobalSettings([
'TYPO3_CONF_VARS' => static::TYPO3_CONF_VARS]);
63 $this->withDatabaseSnapshot(
function () {
70 $backendUser = $this->setUpBackendUserFromFixture(1);
73 $scenarioFile = __DIR__ .
'/Fixtures/PlainScenario.yaml';
74 $factory = DataHandlerFactory::fromYamlFile($scenarioFile);
75 $writer = DataHandlerWriter::withBackendUser($backendUser);
76 $writer->invokeFactory($factory);
77 static::failIfArrayIsNotEmpty(
81 $this->setUpFrontendRootPage(
84 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkGenerator.typoscript',
87 'title' =>
'ACME Root',
88 'sitetitle' => $this->siteTitle,
91 $this->setUpFrontendRootPage(
94 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkGenerator.typoscript',
97 'title' =>
'ACME Blog',
98 'sitetitle' => $this->siteTitle,
105 unset($this->internalRequestContext);
116 [1100, 1000,
'index.php?id=acme-root'],
117 [1100, 1100,
'index.php?id=acme-first'],
118 [1100, 1200,
'index.php?id=1200'],
119 [1100, 1210,
'index.php?id=1210'],
120 [1100, 404,
'index.php?id=404'],
122 [1100, 1300,
'index.php?id=1300'],
123 [1100, 1310,
'index.php?id=1310'],
125 [1100, 2000,
'index.php?id=blog-root'],
126 [1100, 2100,
'index.php?id=2100'],
127 [1100, 2110,
'index.php?id=2110'],
128 [1100, 2111,
'index.php?id=2111'],
130 [2100, 1000,
'index.php?id=acme-root'],
131 [2100, 1100,
'index.php?id=acme-first'],
132 [2100, 1200,
'index.php?id=1200'],
133 [2100, 1210,
'index.php?id=1210'],
134 [2100, 404,
'index.php?id=404'],
136 [2100, 1300,
'index.php?id=1300'],
137 [2100, 1310,
'index.php?id=1310'],
140 return $this->keysFromTemplate(
154 public function linkIsGenerated(
int $sourcePageId,
int $targetPageId,
string $expectation)
156 $response = $this->executeFrontendRequest(
157 (
new InternalRequest())
158 ->withPageId($sourcePageId)
160 $this->createTypoLinkUrlInstruction([
161 'parameter' => $targetPageId,
164 $this->internalRequestContext
167 static::assertSame($expectation, (
string)$response->getBody());
177 [[7100, 1700], 7110, 1000,
'index.php?id=acme-root'],
178 [[7100, 1700], 7110, 1100,
'index.php?id=acme-first'],
179 [[7100, 1700], 7110, 1200,
'index.php?id=1200'],
180 [[7100, 1700], 7110, 1210,
'index.php?id=1210'],
181 [[7100, 1700], 7110, 404,
'index.php?id=404'],
183 [[7100, 1700], 7110, 1300,
'index.php?id=1300'],
184 [[7100, 1700], 7110, 1310,
'index.php?id=1310'],
186 [[7100, 1700], 7110, 2000,
'index.php?id=blog-root'],
187 [[7100, 1700], 7110, 2100,
'index.php?id=2100'],
188 [[7100, 1700], 7110, 2110,
'index.php?id=2110'],
189 [[7100, 1700], 7110, 2111,
'index.php?id=2111'],
191 [[7100, 2700], 7110, 1000,
'index.php?id=acme-root'],
192 [[7100, 2700], 7110, 1100,
'index.php?id=acme-first'],
193 [[7100, 2700], 7110, 1200,
'index.php?id=1200'],
194 [[7100, 2700], 7110, 1210,
'index.php?id=1210'],
195 [[7100, 2700], 7110, 404,
'index.php?id=404'],
197 [[7100, 2700], 7110, 1300,
'index.php?id=1300'],
198 [[7100, 2700], 7110, 1310,
'index.php?id=1310'],
201 return $this->keysFromTemplate(
203 '%2$d->%3$d (mount:%1$s)',
204 function (array $items) {
209 [implode(
'->', $items[0])]
229 $this->markTestSkipped(
'Mount points currently cannot be resolved in legacy mode');
231 $response = $this->executeFrontendRequest(
232 (
new InternalRequest())
233 ->withMountPoint(...$pageMount)
234 ->withPageId($sourcePageId)
236 $this->createTypoLinkUrlInstruction([
237 'parameter' => $targetPageId,
240 $this->internalRequestContext
243 static::assertSame($expectation, (
string)$response->getBody());
253 [1100, 1100, 0,
'index.php?id=acme-first&L=0'],
254 [1100, 1100, 1,
'index.php?id=acme-first&L=1'],
255 [1100, 1100, 2,
'index.php?id=acme-first&L=2'],
256 [1100, 1101, 0,
'index.php?id=acme-first&L=1'],
257 [1100, 1102, 0,
'index.php?id=acme-first&L=2'],
259 [1100, 1300, 0,
'index.php?id=1300&L=0'],
260 [1100, 1310, 0,
'index.php?id=1310&L=0'],
263 [1100, 1410, 1,
'index.php?id=1410&L=1'],
264 [1100, 1410, 2,
'index.php?id=1410&L=2'],
265 [1100, 1411, 0,
'index.php?id=1410&L=1'],
266 [1100, 1412, 0,
'index.php?id=1410&L=2'],
268 [1100, 3100, 0,
'index.php?id=3100&L=0'],
269 [1100, 3100, 1,
'index.php?id=3100&L=1'],
270 [1100, 3100, 2,
'index.php?id=3100&L=2'],
271 [1100, 3101, 0,
'index.php?id=3100&L=1'],
272 [1100, 3102, 0,
'index.php?id=3100&L=2'],
274 [2100, 1100, 0,
'index.php?id=acme-first&L=0'],
275 [2100, 1100, 1,
'index.php?id=acme-first&L=1'],
276 [2100, 1100, 2,
'index.php?id=acme-first&L=2'],
277 [2100, 1101, 0,
'index.php?id=acme-first&L=1'],
278 [2100, 1102, 0,
'index.php?id=acme-first&L=2'],
280 [2100, 3100, 0,
'index.php?id=3100&L=0'],
281 [2100, 3100, 1,
'index.php?id=3100&L=1'],
282 [2100, 3100, 2,
'index.php?id=3100&L=2'],
283 [2100, 3101, 0,
'index.php?id=3100&L=1'],
284 [2100, 3102, 0,
'index.php?id=3100&L=2'],
286 [2100, 1300, 0,
'index.php?id=1300&L=0'],
287 [2100, 1310, 0,
'index.php?id=1310&L=0'],
290 return $this->keysFromTemplate(
292 '%1$d->%2$d (lang:%3$d)'
307 $response = $this->executeFrontendRequest(
308 (
new InternalRequest())
309 ->withPageId($sourcePageId)
311 $this->createTypoLinkUrlInstruction([
312 'parameter' => $targetPageId,
313 'additionalParams' =>
'&L=' . $targetLanguageId,
316 $this->internalRequestContext
319 static::assertSame($expectation, (
string)$response->getBody());
329 [1100, 1000,
'index.php?id=acme-root&testing%5Bvalue%5D=1&cHash=7d1f13fa91159dac7feb3c824936b39d'],
330 [1100, 1100,
'index.php?id=acme-first&testing%5Bvalue%5D=1&cHash=f42b850e435f0cedd366f5db749fc1af'],
331 [1100, 1200,
'index.php?id=1200&testing%5Bvalue%5D=1&cHash=784e11c50ea1a13fd7d969df4ec53ea3'],
332 [1100, 1210,
'index.php?id=1210&testing%5Bvalue%5D=1&cHash=ccb7067022b9835ebfd8f720722bc708'],
333 [1100, 404,
'index.php?id=404&testing%5Bvalue%5D=1&cHash=864e96f586a78a53452f3bf0f4d24591'],
335 [1100, 1300,
'index.php?id=1300&testing%5Bvalue%5D=1&cHash=dbd6597d72ed5098cce3d03eac1eeefe'],
336 [1100, 1310,
'index.php?id=1310&testing%5Bvalue%5D=1&cHash=e64bfc7ab7dd6b70d161e4d556be9726'],
338 [1100, 2000,
'index.php?id=blog-root&testing%5Bvalue%5D=1&cHash=a14da633e46dba71640cb85226cd12c5'],
339 [1100, 2100,
'index.php?id=2100&testing%5Bvalue%5D=1&cHash=d23d74cb50383f8788a9930ec8ba679f'],
340 [1100, 2110,
'index.php?id=2110&testing%5Bvalue%5D=1&cHash=bf25eea89f44a9a79dabdca98f38a432'],
341 [1100, 2111,
'index.php?id=2111&testing%5Bvalue%5D=1&cHash=42dbaeb9172b6b1ca23b49941e194db2'],
343 [2100, 1000,
'index.php?id=acme-root&testing%5Bvalue%5D=1&cHash=7d1f13fa91159dac7feb3c824936b39d'],
344 [2100, 1100,
'index.php?id=acme-first&testing%5Bvalue%5D=1&cHash=f42b850e435f0cedd366f5db749fc1af'],
345 [2100, 1200,
'index.php?id=1200&testing%5Bvalue%5D=1&cHash=784e11c50ea1a13fd7d969df4ec53ea3'],
346 [2100, 1210,
'index.php?id=1210&testing%5Bvalue%5D=1&cHash=ccb7067022b9835ebfd8f720722bc708'],
347 [2100, 404,
'index.php?id=404&testing%5Bvalue%5D=1&cHash=864e96f586a78a53452f3bf0f4d24591'],
349 [2100, 1300,
'index.php?id=1300&testing%5Bvalue%5D=1&cHash=dbd6597d72ed5098cce3d03eac1eeefe'],
350 [2100, 1310,
'index.php?id=1310&testing%5Bvalue%5D=1&cHash=e64bfc7ab7dd6b70d161e4d556be9726'],
353 return $this->keysFromTemplate(
369 $response = $this->executeFrontendRequest(
370 (
new InternalRequest())
371 ->withPageId($sourcePageId)
373 $this->createTypoLinkUrlInstruction([
374 'parameter' => $targetPageId,
375 'additionalParams' =>
'&testing[value]=1',
379 $this->internalRequestContext
382 static::assertSame($expectation, (
string)$response->getBody());
398 [1100, 1510, 1,
'index.php?id=1510'],
399 [1100, 1511, 1,
'index.php?id=1511'],
400 [1100, 1512, 1,
'index.php?id=1512'],
405 [1100, 1510, 2,
'index.php?id=1510'],
406 [1100, 1511, 2,
'index.php?id=1511'],
408 [1100, 1515, 2,
'index.php?id=1515'],
409 [1100, 1520, 2,
'index.php?id=1520'],
410 [1100, 1521, 2,
'index.php?id=1521'],
412 [1100, 1510, 3,
'index.php?id=1510'],
413 [1100, 1511, 3,
'index.php?id=1511'],
414 [1100, 1512, 3,
'index.php?id=1512'],
415 [1100, 1515, 3,
'index.php?id=1515'],
416 [1100, 1520, 3,
'index.php?id=1520'],
417 [1100, 1521, 3,
'index.php?id=1521'],
420 return $this->keysFromTemplate(
422 '%1$d->%2$d (user:%3$d)'
437 $response = $this->executeFrontendRequest(
438 (
new InternalRequest())
439 ->withPageId($sourcePageId)
441 $this->createTypoLinkUrlInstruction([
442 'parameter' => $targetPageId,
445 $this->internalRequestContext
446 ->withFrontendUserId($frontendUserId)
449 static::assertSame($expectation, (
string)$response->getBody());
459 [1100, 1510, 1500, 0,
'index.php?id=1500&pageId=1510'],
461 [1100, 1512, 1500, 0,
'index.php?id=1500&pageId=1512'],
462 [1100, 1515, 1500, 0,
'index.php?id=1500&pageId=1515'],
463 [1100, 1520, 1500, 0,
'index.php?id=1500&pageId=1520'],
466 [1100, 1510, 1500, 1,
'index.php?id=1510'],
467 [1100, 1511, 1500, 1,
'index.php?id=1511'],
468 [1100, 1512, 1500, 1,
'index.php?id=1512'],
469 [1100, 1515, 1500, 1,
'index.php?id=1500&pageId=1515'],
470 [1100, 1520, 1500, 1,
'index.php?id=1500&pageId=1520'],
473 [1100, 1510, 1500, 2,
'index.php?id=1510'],
474 [1100, 1511, 1500, 2,
'index.php?id=1511'],
475 [1100, 1512, 1500, 2,
'index.php?id=1500&pageId=1512'],
476 [1100, 1515, 1500, 2,
'index.php?id=1515'],
477 [1100, 1520, 1500, 2,
'index.php?id=1520'],
478 [1100, 1521, 1500, 2,
'index.php?id=1521'],
480 [1100, 1510, 1500, 3,
'index.php?id=1510'],
481 [1100, 1511, 1500, 3,
'index.php?id=1511'],
482 [1100, 1512, 1500, 3,
'index.php?id=1512'],
483 [1100, 1515, 1500, 3,
'index.php?id=1515'],
484 [1100, 1520, 1500, 3,
'index.php?id=1520'],
485 [1100, 1521, 1500, 3,
'index.php?id=1521'],
488 return $this->keysFromTemplate(
490 '%1$d->%2$d (via: %3$d, user:%4$d)'
506 $response = $this->executeFrontendRequest(
507 (
new InternalRequest())
508 ->withPageId($sourcePageId)
510 (
new TypoScriptInstruction(TemplateService::class))
513 'typolinkLinkAccessRestrictedPages' => $loginPageId,
514 'typolinkLinkAccessRestrictedPages_addParams' =>
'&pageId=###PAGE_ID###'
517 $this->createTypoLinkUrlInstruction([
518 'parameter' => $targetPageId,
521 $this->internalRequestContext
522 ->withFrontendUserId($frontendUserId)
525 static::assertSame($expectation, (
string)$response->getBody());
535 [1100, 1100,
false,
'index.php?id=acme-first'],
536 [1100, 1100,
true,
'index.php?id=acme-first'],
537 [1100, 1950,
false,
'index.php?id=1950'],
538 [1100, 1950,
true,
'index.php?id={targetPageId}'],
540 [2100, 1100,
false,
'index.php?id=acme-first'],
542 [2100, 1100,
true,
'index.php?id=acme-first'],
543 [2100, 1950,
false,
'index.php?id=1950'],
545 [2100, 1950,
true,
'index.php?id={targetPageId}'],
548 return $this->keysFromTemplate(
550 '%1$d->%2$d (resolve:%3$d)'
567 if ($resolveVersion) {
576 $response = $this->executeFrontendRequest(
577 (
new InternalRequest())
578 ->withPageId($sourcePageId)
580 $this->createTypoLinkUrlInstruction([
581 'parameter' => $targetPageId,
584 $this->internalRequestContext
585 ->withWorkspaceId($workspaceId)
586 ->withBackendUserId($backendUserId)
589 $expectation = str_replace(
595 static::assertSame($expectation, (
string)$response->getBody());
607 [
'title' =>
'EN: Welcome',
'link' =>
'index.php?id=acme-first'],
609 'title' =>
'EN: Features',
610 'link' =>
'index.php?id=1200',
613 'title' =>
'EN: Frontend Editing',
614 'link' =>
'index.php?id=1210',
619 'title' =>
'EN: Products',
620 'link' =>
'index.php?id=1300',
623 'title' =>
'EN: Planets',
624 'link' =>
'index.php?id=1310',
627 'title' =>
'EN: Spaceships',
628 'link' =>
'index.php?id=1320',
631 'title' =>
'EN: Dark Matter',
632 'link' =>
'index.php?id=1330',
636 [
'title' =>
'EN: ACME in your Region',
'link' =>
'index.php?id=1400'],
637 [
'title' =>
'Internal',
'link' =>
'index.php?id=1500'],
638 [
'title' =>
'About us',
'link' =>
'index.php?id=1600'],
640 'title' =>
'Announcements & News',
641 'link' =>
'index.php?id=1700',
644 'title' =>
'Markets',
645 'link' =>
'index.php?id=7110&MP=7100-1700',
648 'title' =>
'Products',
649 'link' =>
'index.php?id=7120&MP=7100-1700',
652 'title' =>
'Partners',
653 'link' =>
'index.php?id=7130&MP=7100-1700',
657 [
'title' =>
'Page not found',
'link' =>
'index.php?id=404'],
658 [
'title' =>
'Our Blog',
'link' =>
'index.php?id=2100'],
665 'title' =>
'Authors',
666 'link' =>
'index.php?id=2100',
669 'title' =>
'John Doe',
670 'link' =>
'index.php?id=2110',
673 'title' =>
'Jane Doe',
674 'link' =>
'index.php?id=2120',
680 'title' =>
'Announcements & News',
681 'link' =>
'index.php?id=2700',
684 'title' =>
'Markets',
685 'link' =>
'index.php?id=7110&MP=7100-2700',
688 'title' =>
'Products',
689 'link' =>
'index.php?id=7120&MP=7100-2700',
692 'title' =>
'Partners',
693 'link' =>
'index.php?id=7130&MP=7100-2700',
697 [
'title' =>
'ACME Inc',
'link' =>
'index.php?id=acme-first'],
712 $response = $this->executeFrontendRequest(
713 (
new InternalRequest())
714 ->withPageId($sourcePageId)
716 $this->createHierarchicalMenuProcessorInstruction([
720 'includeSpacer' => 1,
721 'titleField' =>
'title',
725 $this->internalRequestContext
728 $json = json_decode((
string)$response->getBody(),
true);
729 $json = $this->filterMenu($json);
731 static::assertSame($expectation, $json);
743 [
'title' =>
'Default',
'link' =>
'index.php?id=acme-first&L=0'],
744 [
'title' =>
'French',
'link' =>
'index.php?id=acme-first&L=1'],
745 [
'title' =>
'Franco-Canadian',
'link' =>
'index.php?id=acme-first&L=2'],
751 [
'title' =>
'Default',
'link' =>
'index.php?id=2100&L=0'],
752 [
'title' =>
'French',
'link' =>
'index.php?id=2100&L=1'],
753 [
'title' =>
'Franco-Canadian',
'link' =>
'index.php?id=2100&L=2'],
768 $response = $this->executeFrontendRequest(
769 (
new InternalRequest())
770 ->withPageId($sourcePageId)
772 $this->createLanguageMenuProcessorInstruction([
773 'languages' =>
'auto',
776 $this->internalRequestContext
779 $json = json_decode((
string)$response->getBody(),
true);
780 $json = $this->filterMenu($json);
782 static::assertSame($expectation, $json);