2 declare(strict_types = 1);
33 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerFactory;
34 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter;
35 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
36 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
48 private $siteTitle =
'A Company that Manufactures Everything Inc';
57 parent::setUpBeforeClass();
58 static::initializeDatabaseSnapshot();
63 static::destroyDatabaseSnapshot();
64 parent::tearDownAfterClass();
67 protected function setUp()
72 $this->internalRequestContext = (
new InternalRequestContext())
73 ->withGlobalSettings([
'TYPO3_CONF_VARS' => static::TYPO3_CONF_VARS]);
95 $this->withDatabaseSnapshot(
function () {
102 $backendUser = $this->setUpBackendUserFromFixture(1);
105 $scenarioFile = __DIR__ .
'/Fixtures/SlugScenario.yaml';
106 $factory = DataHandlerFactory::fromYamlFile($scenarioFile);
107 $writer = DataHandlerWriter::withBackendUser($backendUser);
108 $writer->invokeFactory($factory);
109 static::failIfArrayIsNotEmpty(
113 $this->setUpFrontendRootPage(
116 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/LinkGenerator.typoscript',
119 'title' =>
'ACME Root',
120 'sitetitle' => $this->siteTitle,
127 unset($this->internalRequestContext);
141 'routePrefix' =>
'{enhance_name}',
142 'aspectName' =>
'enhance_name',
148 ->withTargetPageId(1100)
151 'https://acme.us/welcome/enhance/[[value]][[pathSuffix]]?cHash=',
157 ->withTargetPageId(1100)
160 'https://acme.fr/bienvenue/augmenter/[[value]][[pathSuffix]]?cHash=',
166 ->withTargetPageId(3000)
169 'https://archive.acme.com/enhance/[[value]][[pathSuffix]]?cHash=',
175 ->withTargetPageId(3000)
178 'https://archive.acme.com/fr/augmenter/[[value]][[pathSuffix]]?cHash=',
183 ->withApplicableItems($builder->declareEnhancers())
187 'type' =>
'LocaleModifier',
188 'default' =>
'enhance',
192 'value' =>
'augmenter'
199 ->getTargetsForDataProvider();
211 $enhancerConfiguration = $builder->compileEnhancerConfiguration($testSet);
212 $additionalParameters = $builder->compileGenerateParameters($testSet);
214 $languageContext = $testSet->getSingleApplicable(LanguageContext::class);
215 $targetLanguageId = $languageContext->getLanguageId();
216 $expectation = $builder->compileUrl($testSet);
219 'routeEnhancers' => [
'Enhancer' => $enhancerConfiguration]
222 'routeEnhancers' => [
'Enhancer' => $enhancerConfiguration]
225 $response = $this->executeFrontendRequest(
226 (
new InternalRequest(
'https://acme.us/'))
229 $this->createTypoLinkUrlInstruction([
230 'parameter' => $testSet->getTargetPageId(),
231 'language' => $targetLanguageId,
232 'additionalParams' => $additionalParameters,
233 'forceAbsoluteUrl' => 1,
236 $this->internalRequestContext
239 static::assertStringStartsWith($expectation, (
string)$response->getBody());
252 'routePrefix' =>
'enhance',
253 'aspectName' =>
'value',
259 ->withTargetPageId(1100)
262 'https://acme.us/welcome/enhance/welcome[[pathSuffix]]',
268 ->withTargetPageId(1100)
271 'https://acme.fr/bienvenue/enhance/bienvenue[[pathSuffix]]',
276 ->withApplicableItems($builder->declareEnhancers())
280 'type' =>
'PersistedAliasMapper',
281 'tableName' =>
'pages',
282 'routeFieldName' =>
'slug',
283 'routeValuePrefix' =>
'/',
288 ->getTargetsForDataProvider();
300 $enhancerConfiguration = $builder->compileEnhancerConfiguration($testSet);
301 $additionalParameters = $builder->compileGenerateParameters($testSet);
303 $languageContext = $testSet->getSingleApplicable(LanguageContext::class);
304 $targetLanguageId = $languageContext->getLanguageId();
305 $expectation = $builder->compileUrl($testSet);
308 'routeEnhancers' => [
'Enhancer' => $enhancerConfiguration]
311 $response = $this->executeFrontendRequest(
312 (
new InternalRequest(
'https://acme.us/'))
315 $this->createTypoLinkUrlInstruction([
317 'language' => $targetLanguageId,
318 'additionalParams' => $additionalParameters,
319 'forceAbsoluteUrl' => 1,
322 $this->internalRequestContext
325 static::assertSame($expectation, (
string)$response->getBody());
338 'routePrefix' =>
'enhance',
339 'aspectName' =>
'value',
345 ->withTargetPageId(1100)
348 'https://acme.us/welcome/enhance/hello-and-welcome-[[value]][[pathSuffix]]',
354 ->withTargetPageId(1100)
357 'https://acme.fr/bienvenue/enhance/salut-et-bienvenue-[[value]][[pathSuffix]]',
363 ->withTargetPageId(3000)
366 'https://archive.acme.com/enhance/hello-and-welcome-[[value]][[pathSuffix]]',
372 ->withTargetPageId(3000)
375 'https://archive.acme.com/fr/enhance/salut-et-bienvenue-[[value]][[pathSuffix]]',
380 ->withApplicableItems($builder->declareEnhancers())
384 'type' =>
'PersistedPatternMapper',
385 'tableName' =>
'pages',
386 'routeFieldPattern' =>
'^(?P<subtitle>.+)-(?P<uid>\d+)$',
387 'routeFieldResult' =>
'{subtitle}-{uid}',
392 ->getTargetsForDataProvider();
404 $enhancerConfiguration = $builder->compileEnhancerConfiguration($testSet);
405 $additionalParameters = $builder->compileGenerateParameters($testSet);
407 $languageContext = $testSet->getSingleApplicable(LanguageContext::class);
408 $targetLanguageId = $languageContext->getLanguageId();
409 $expectation = $builder->compileUrl($testSet);
412 'routeEnhancers' => [
'Enhancer' => $enhancerConfiguration]
415 'routeEnhancers' => [
'Enhancer' => $enhancerConfiguration]
418 $response = $this->executeFrontendRequest(
419 (
new InternalRequest(
'https://acme.us/'))
422 $this->createTypoLinkUrlInstruction([
423 'parameter' => $testSet->getTargetPageId(),
424 'language' => $targetLanguageId,
425 'additionalParams' => $additionalParameters,
426 'forceAbsoluteUrl' => 1,
429 $this->internalRequestContext
432 static::assertSame($expectation, (
string)$response->getBody());
445 'routePrefix' =>
'enhance',
446 'aspectName' =>
'value',
452 ->withTargetPageId(1100)
455 'https://acme.us/welcome/enhance/hundred[[pathSuffix]]',
461 ->withTargetPageId(1100)
464 'https://acme.fr/bienvenue/enhance/cent[[pathSuffix]]',
470 ->withTargetPageId(3000)
473 'https://archive.acme.com/enhance/hundred[[pathSuffix]]',
479 ->withTargetPageId(3000)
482 'https://archive.acme.com/fr/enhance/cent[[pathSuffix]]',
487 ->withApplicableItems($builder->declareEnhancers())
491 'type' =>
'StaticValueMapper',
507 ->getTargetsForDataProvider();
519 $enhancerConfiguration = $builder->compileEnhancerConfiguration($testSet);
520 $additionalParameters = $builder->compileGenerateParameters($testSet);
522 $languageContext = $testSet->getSingleApplicable(LanguageContext::class);
523 $targetLanguageId = $languageContext->getLanguageId();
524 $expectation = $builder->compileUrl($testSet);
527 'routeEnhancers' => [
'Enhancer' => $enhancerConfiguration]
530 'routeEnhancers' => [
'Enhancer' => $enhancerConfiguration]
533 $response = $this->executeFrontendRequest(
534 (
new InternalRequest(
'https://acme.us/'))
537 $this->createTypoLinkUrlInstruction([
538 'parameter' => $testSet->getTargetPageId(),
539 'language' => $targetLanguageId,
540 'additionalParams' => $additionalParameters,
541 'forceAbsoluteUrl' => 1,
544 $this->internalRequestContext
547 static::assertStringStartsWith($expectation, (
string)$response->getBody());
556 $variableContexts = array_map(
569 'routePrefix' =>
'enhance',
570 'aspectName' =>
'value',
576 ->withTargetPageId(1100)
579 'https://acme.us/welcome/enhance/[[value]][[pathSuffix]]',
585 ->withTargetPageId(1100)
588 'https://acme.fr/bienvenue/enhance/[[value]][[pathSuffix]]',
593 ->withApplicableItems($variableContexts)
594 ->withApplicableItems($builder->declareEnhancers())
598 'type' =>
'StaticRangeMapper',
605 ->getTargetsForDataProvider();
617 $enhancerConfiguration = $builder->compileEnhancerConfiguration($testSet);
618 $additionalParameters = $builder->compileGenerateParameters($testSet);
620 $languageContext = $testSet->getSingleApplicable(LanguageContext::class);
621 $targetLanguageId = $languageContext->getLanguageId();
622 $expectation = $builder->compileUrl($testSet);
625 'routeEnhancers' => [
'Enhancer' => $enhancerConfiguration]
628 $response = $this->executeFrontendRequest(
629 (
new InternalRequest(
'https://acme.us/'))
632 $this->createTypoLinkUrlInstruction([
633 'parameter' => $testSet->getTargetPageId(),
634 'language' => $targetLanguageId,
635 'additionalParams' => $additionalParameters,
636 'forceAbsoluteUrl' => 1,
639 $this->internalRequestContext
642 static::assertStringStartsWith($expectation, (
string)$response->getBody());
656 ->withMergedApplicables($pageTypeDeclaration)
657 ->withVariables($pageTypeDeclaration->getVariables());
658 $testSets = array_merge(
679 $enhancerConfiguration = $builder->compileEnhancerConfiguration($testSet);
680 $pageTypeConfiguration = $builder->compilePageTypeConfiguration($testSet);
681 $additionalParameters = $builder->compileGenerateParameters($testSet);
683 $languageContext = $testSet->getSingleApplicable(LanguageContext::class);
684 $targetLanguageId = $languageContext->getLanguageId();
685 $expectation = $builder->compileUrl($testSet);
688 'routeEnhancers' => [
689 'Enhancer' => $enhancerConfiguration,
690 'PageType' => $pageTypeConfiguration,
695 'routeEnhancers' => [
696 'Enhancer' => $enhancerConfiguration,
697 'PageType' => $pageTypeConfiguration,
701 $response = $this->executeFrontendRequest(
702 (
new InternalRequest(
'https://acme.us/'))
705 $this->createTypoLinkUrlInstruction([
706 'parameter' => $testSet->getTargetPageId(),
707 'language' => $targetLanguageId,
708 'additionalParams' => $additionalParameters,
709 'forceAbsoluteUrl' => 1,
712 $this->internalRequestContext
715 static::assertStringStartsWith($expectation, (
string)$response->getBody());
721 $enhancerDeclarations = $builder->declareEnhancers();
724 'routePrefix' =>
'enhance',
725 'aspectName' =>
'value',
731 ->withTargetPageId(1100)
734 'https://acme.us/welcome/enhance[[uriValue]][[pathSuffix]]',
740 ->withTargetPageId(1100)
743 'https://acme.fr/bienvenue/enhance[[uriValue]][[pathSuffix]]',
749 $enhancerDeclarations[
'Simple'],
753 $enhancerDeclarations[
'Extbase']
757 'defaults' => [
'value' => 100],
763 'type' =>
'StaticValueMapper',
780 'routeParameter' =>
'{value}',
784 'routeParameter' =>
'{!value}',
796 ->getTargetsForDataProvider();
814 $enhancerDeclarations = $builder->declareEnhancers();
817 'routePrefix' =>
'enhance',
818 'aspectName' =>
'value',
824 ->withTargetPageId(1100)
827 'https://acme.us/welcome/enhance/hundred/20[[pathSuffix]]',
833 ->withTargetPageId(1100)
836 'https://acme.fr/bienvenue/enhance/cent/20[[pathSuffix]]',
842 $enhancerDeclarations[
'Simple']
843 ->withConfiguration([
'routePath' => $routePath],
true)
844 ->withGenerateParameters([
'&additional=20'],
true),
845 $enhancerDeclarations[
'Plugin']
846 ->withConfiguration([
'routePath' => $routePath],
true)
847 ->withGenerateParameters([
'&testing[additional]=20'],
true),
848 $enhancerDeclarations[
'Extbase']
849 ->withConfiguration([
'routes' => [0 => [
'routePath' => $routePath]]],
true)
850 ->withGenerateParameters([
'&tx_testing_link[additional]=20'],
true)
854 'defaults' => [
'value' => 100],
860 'type' =>
'StaticValueMapper',
877 'routeParameter' =>
'{value}',
880 'routeParameter' =>
'{!value}',
892 ->getTargetsForDataProvider();
911 'routePrefix' =>
'enhance',
912 'aspectName' =>
'value',
913 'inArguments' =>
'staticArguments'
919 ->withTargetPageId(1100)
922 'https://acme.us/welcome/enhance/[[resolveValue]][[pathSuffix]]',
930 'resolveValue' =>
'hundred',
934 'resolveValue' =>
'hundred/binary',
939 'resolveValue' =>
'hundred',
943 'value' =>
'[a-z_/]+',
950 'resolveValue' =>
'hundred/binary',
954 'value' =>
'[a-z_/]+',
959 ->withApplicableItems($builder->declareEnhancers())
963 'type' =>
'StaticValueMapper',
966 'hundred/binary' => 1100100,
972 ->getTargetsForDataProvider();
989 $enhancerConfiguration = $builder->compileEnhancerConfiguration($testSet);
990 $additionalParameters = $builder->compileGenerateParameters($testSet);
993 $targetLanguageId = $languageContext->getLanguageId();
994 $expectation = $builder->compileUrl($testSet);
997 'routeEnhancers' => [
'Enhancer' => $enhancerConfiguration]
1000 $response = $this->executeFrontendRequest(
1001 (
new InternalRequest(
'https://acme.us/'))
1003 ->withInstructions([
1004 $this->createTypoLinkUrlInstruction([
1006 'language' => $targetLanguageId,
1007 'additionalParams' => $additionalParameters,
1008 'forceAbsoluteUrl' => 1,
1011 $this->internalRequestContext
1014 static::assertStringStartsWith($expectation, (
string)$response->getBody());
1024 '&tx_testing_link[value]=1',
1025 'https://acme.us/welcome/link/index/one'
1028 '&tx_testing_link[action]=list&tx_testing_link[value]=1',
1029 'https://acme.us/welcome/link/list/one'
1033 '&tx_testing_link[controller]=Link&tx_testing_link[value]=1',
1034 'https://acme.us/welcome/link/index/one'
1038 '&tx_testing_link[controller]=Page&tx_testing_link[value]=1',
1039 'https://acme.us/welcome/link/index/one'
1042 '&tx_testing_link[controller]=Page&tx_testing_link[action]=show&tx_testing_link[value]=1',
1043 'https://acme.us/welcome/page/show/one'
1059 $targetLanguageId = 0;
1061 'routeEnhancers' => [
1063 'type' =>
'Extbase',
1065 [
'routePath' =>
'/link/index/{value}',
'_controller' =>
'Link::index'],
1066 [
'routePath' =>
'/link/list/{value}',
'_controller' =>
'Link::list'],
1067 [
'routePath' =>
'/page/show/{value}',
'_controller' =>
'Page::show'],
1069 'defaultController' =>
'Link::index',
1070 'extension' =>
'testing',
1074 'type' =>
'StaticValueMapper',
1084 $response = $this->executeFrontendRequest(
1085 (
new InternalRequest(
'https://acme.us/'))
1087 ->withInstructions([
1088 $this->createTypoLinkUrlInstruction([
1089 'parameter' => 1100,
1090 'language' => $targetLanguageId,
1091 'additionalParams' => $additionalParameters,
1092 'forceAbsoluteUrl' => 1,
1095 $this->internalRequestContext
1098 static::assertSame($expectation, (
string)$response->getBody());
1108 '&tx_testing_link[value]=1&tx_testing_link[excludedValue]=random',
1109 'https://acme.us/welcome/link/index/one?tx_testing_link%5BexcludedValue%5D=random'
1112 '&tx_testing_link[action]=list&tx_testing_link[value]=1&tx_testing_link[excludedValue]=random',
1113 'https://acme.us/welcome/link/list/one?tx_testing_link%5BexcludedValue%5D=random'
1117 '&tx_testing_link[controller]=Link&tx_testing_link[value]=1&tx_testing_link[excludedValue]=random',
1118 'https://acme.us/welcome/link/index/one?tx_testing_link%5BexcludedValue%5D=random'
1122 '&tx_testing_link[controller]=Page&tx_testing_link[value]=1&tx_testing_link[excludedValue]=random',
1123 'https://acme.us/welcome/link/index/one?tx_testing_link%5BexcludedValue%5D=random'
1126 '&tx_testing_link[controller]=Page&tx_testing_link[action]=show&tx_testing_link[value]=1&tx_testing_link[excludedValue]=random',
1127 'https://acme.us/welcome/page/show/one?tx_testing_link%5BexcludedValue%5D=random'
1144 $targetLanguageId = 0;
1146 'routeEnhancers' => [
1148 'type' =>
'Extbase',
1150 [
'routePath' =>
'/link/index/{value}',
'_controller' =>
'Link::index'],
1151 [
'routePath' =>
'/link/list/{value}',
'_controller' =>
'Link::list'],
1152 [
'routePath' =>
'/page/show/{value}',
'_controller' =>
'Page::show'],
1154 'defaultController' =>
'Link::index',
1155 'extension' =>
'testing',
1159 'type' =>
'StaticValueMapper',
1169 $response = $this->executeFrontendRequest(
1170 (
new InternalRequest(
'https://acme.us/'))
1172 ->withInstructions([
1173 $this->createTypoLinkUrlInstruction([
1174 'parameter' => 1100,
1175 'language' => $targetLanguageId,
1176 'additionalParams' => $additionalParameters,
1177 'forceAbsoluteUrl' => 1,
1180 $this->internalRequestContext
1183 self::assertSame($expectation, (
string)$response->getBody());
1192 'routeEnhancers' => [
1194 'type' =>
'PageType',
1199 'sitemap.xml' =>
'1533906435'
1205 GeneralUtility::makeInstance(SiteConfiguration::class, $this->instancePath .
'/typo3conf/sites/')->getAllExistingSites(
false);
1206 $site = GeneralUtility::makeInstance(SiteFinder::class)->getSiteByIdentifier(
'archive-acme-com');
1207 $uri = $site->getRouter()->generateUri(3000);
1208 self::assertEquals(
'https://archive.acme.com/', (
string)$uri);
1209 $uri = $site->getRouter()->generateUri(3000, [
'type' =>
'1533906435']);
1210 self::assertEquals(
'https://archive.acme.com/sitemap.xml', (
string)$uri);
1211 $uri = $site->getRouter()->generateUri(3000, [
'type' =>
'13']);
1212 self::assertEquals(
'https://archive.acme.com/?type=13', (
string)$uri);