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\InternalRequest;
24 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequestContext;
25 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\ResponseContent;
35 private $siteTitle =
'A Company that Manufactures Everything Inc';
44 parent::setUpBeforeClass();
45 static::initializeDatabaseSnapshot();
50 static::destroyDatabaseSnapshot();
51 parent::tearDownAfterClass();
54 protected function setUp()
59 $this->internalRequestContext = (
new InternalRequestContext())
60 ->withGlobalSettings([
'TYPO3_CONF_VARS' => static::TYPO3_CONF_VARS]);
62 $this->withDatabaseSnapshot(
function () {
69 $backendUser = $this->setUpBackendUserFromFixture(1);
72 $scenarioFile = __DIR__ .
'/Fixtures/PlainScenario.yaml';
73 $factory = DataHandlerFactory::fromYamlFile($scenarioFile);
74 $writer = DataHandlerWriter::withBackendUser($backendUser);
75 $writer->invokeFactory($factory);
76 static::failIfArrayIsNotEmpty(
80 $this->setUpFrontendRootPage(
83 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript',
84 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/JsonRenderer.typoscript',
87 'title' =>
'ACME Root',
88 'sitetitle' => $this->siteTitle,
95 unset($this->internalRequestContext);
108 'https://website.local/',
115 return $this->wrapInArray(
116 $this->keysFromValues(
138 $expectedStatusCode = 307;
139 $expectedHeaders = [
'location' => [
'https://website.local/en-en/']];
141 $response = $this->executeFrontendRequest(
142 new InternalRequest($uri),
143 $this->internalRequestContext
145 static::assertSame($expectedStatusCode, $response->getStatusCode());
146 static::assertSame($expectedHeaders, $response->getHeaders());
165 $expectedStatusCode = 200;
166 $expectedPageTitle =
'EN: Welcome';
168 $response = $this->executeFrontendRequest(
169 new InternalRequest($uri),
170 $this->internalRequestContext,
173 $responseStructure = ResponseContent::fromString(
174 (
string)$response->getBody()
179 $response->getStatusCode()
183 $responseStructure->getScopePath(
'template/sitetitle')
187 $responseStructure->getScopePath(
'page/title')
199 'https://website.local/',
214 function (
string $uri) {
215 if (strpos($uri,
'/fr-fr/') !==
false) {
216 $expectedPageTitle =
'FR: Welcome';
217 } elseif (strpos($uri,
'/fr-ca/') !==
false) {
218 $expectedPageTitle =
'FR-CA: Welcome';
220 $expectedPageTitle =
'EN: Welcome';
222 return [$uri, $expectedPageTitle];
224 $this->keysFromValues(
249 $response = $this->executeFrontendRequest(
250 new InternalRequest($uri),
251 $this->internalRequestContext
253 $responseStructure = ResponseContent::fromString(
254 (
string)$response->getBody()
259 $response->getStatusCode()
263 $responseStructure->getScopePath(
'template/sitetitle')
267 $responseStructure->getScopePath(
'page/title')
279 'https://website.us/',
280 'https://website.fr/',
282 'https://wäbsite.ca/',
293 function (
string $uri) {
294 if (strpos($uri,
'.fr/') !==
false) {
295 $expectedPageTitle =
'FR: Welcome';
296 } elseif (strpos($uri,
'.ca/') !==
false) {
297 $expectedPageTitle =
'FR-CA: Welcome';
299 $expectedPageTitle =
'EN: Welcome';
301 return [$uri, $expectedPageTitle];
303 $this->keysFromValues(
328 $response = $this->executeFrontendRequest(
329 new InternalRequest($uri),
330 $this->internalRequestContext
332 $responseStructure = ResponseContent::fromString(
333 (
string)$response->getBody()
338 $response->getStatusCode()
342 $responseStructure->getScopePath(
'template/sitetitle')
346 $responseStructure->getScopePath(
'page/title')
357 [
'https://website.local/?id=1510', 1,
'Whitepapers'],
358 [
'https://website.local/?id=1511', 1,
'Products'],
359 [
'https://website.local/?id=1512', 1,
'Solutions'],
361 [
'https://website.local/?id=1510', 2,
'Whitepapers'],
362 [
'https://website.local/?id=1511', 2,
'Products'],
363 [
'https://website.local/?id=1515', 2,
'Research'],
364 [
'https://website.local/?id=1520', 2,
'Forecasts'],
365 [
'https://website.local/?id=1521', 2,
'Current Year'],
367 [
'https://website.local/?id=1510', 3,
'Whitepapers'],
368 [
'https://website.local/?id=1511', 3,
'Products'],
369 [
'https://website.local/?id=1512', 3,
'Solutions'],
370 [
'https://website.local/?id=1515', 3,
'Research'],
371 [
'https://website.local/?id=1520', 3,
'Forecasts'],
372 [
'https://website.local/?id=1521', 3,
'Current Year'],
375 return $this->keysFromTemplate($instructions,
'%1$s (user:%2$s)');
393 $response = $this->executeFrontendRequest(
394 new InternalRequest($uri),
395 $this->internalRequestContext
396 ->withFrontendUserId($frontendUserId)
398 $responseStructure = ResponseContent::fromString(
399 (
string)$response->getBody()
404 $response->getStatusCode()
408 $responseStructure->getScopePath(
'template/sitetitle')
412 $responseStructure->getScopePath(
'page/title')
423 [
'https://website.local/?id=1510', 0],
424 [
'https://website.local/?id=1511', 0],
425 [
'https://website.local/?id=1512', 0],
426 [
'https://website.local/?id=1515', 0],
427 [
'https://website.local/?id=1520', 0],
428 [
'https://website.local/?id=1521', 0],
430 [
'https://website.local/?id=1515', 1],
431 [
'https://website.local/?id=1520', 1],
432 [
'https://website.local/?id=1521', 1],
434 [
'https://website.local/?id=1512', 2],
437 return $this->keysFromTemplate($instructions,
'%1$s (user:%2$s)');
454 $response = $this->executeFrontendRequest(
455 new InternalRequest($uri),
456 $this->internalRequestContext
457 ->withFrontendUserId($frontendUserId)
462 $response->getStatusCode()
465 (
string)$response->getBody(),
467 static::stringContains(
'Reason: ID was not an accessible page'),
468 static::stringContains(
'Reason: Subsection was found and not accessible')
489 $response = $this->executeFrontendRequest(
490 new InternalRequest($uri),
491 $this->internalRequestContext
492 ->withFrontendUserId($frontendUserId)
497 $response->getStatusCode()
499 static::assertContains(
500 'reasons: code,fe_group',
501 (
string)$response->getBody()
504 (
string)$response->getBody(),
506 static::stringContains(
'message: ID was not an accessible page'),
507 static::stringContains(
'message: Subsection was found and not accessible')
522 $this->markTestSkipped(
'Skipped until PageContentErrorHandler::handlePageError does not use HTTP anymore');
531 $response = $this->executeFrontendRequest(
532 new InternalRequest($uri),
533 $this->internalRequestContext
534 ->withFrontendUserId($frontendUserId)
539 $response->getStatusCode()
559 $response = $this->executeFrontendRequest(
560 new InternalRequest($uri),
561 $this->internalRequestContext
562 ->withFrontendUserId($frontendUserId)
564 $json = json_decode((
string)$response->getBody(),
true);
568 $response->getStatusCode()
571 $json[
'message'] ??
null,
573 static::identicalTo(
'ID was not an accessible page'),
574 static::identicalTo(
'Subsection was found and not accessible')
585 'https://website.local/',
598 '&testing[value]=1&cHash=',
599 '&testing[value]=1&cHash=WRONG',
602 return $this->wrapInArray(
603 $this->keysFromValues(
622 $this->expectExceptionCode(1518472189);
623 $this->expectException(PageNotFoundException::class);
625 $this->executeFrontendRequest(
626 new InternalRequest($uri),
627 $this->internalRequestContext
639 $response = $this->executeFrontendRequest(
640 new InternalRequest($uri),
641 $this->internalRequestContext->withMergedGlobalSettings([
642 'TYPO3_CONF_VARS' => [
644 'pageNotFound_handling' =>
'READFILE:typo3/sysext/core/Tests/Functional/Fixtures/Frontend/PageError.txt',
652 $response->getStatusCode()
655 (
string)$response->getBody(),
657 static::stringContains(
'reason: Request parameters could not be validated (&cHash empty)'),
658 static::stringContains(
'reason: Request parameters could not be validated (&cHash comparison failed)')
678 $response = $this->executeFrontendRequest(
679 new InternalRequest($uri),
680 $this->internalRequestContext
685 $response->getStatusCode()
688 (
string)$response->getBody(),
690 static::stringContains(
'message: Request parameters could not be validated (&cHash empty)'),
691 static::stringContains(
'message: Request parameters could not be validated (&cHash comparison failed)')
705 $this->markTestSkipped(
'Skipped until PageContentErrorHandler::handlePageError does not use HTTP anymore');
714 $response = $this->executeFrontendRequest(
715 new InternalRequest($uri),
716 $this->internalRequestContext
721 $response->getStatusCode()
740 $response = $this->executeFrontendRequest(
741 new InternalRequest($uri),
742 $this->internalRequestContext
744 $json = json_decode((
string)$response->getBody(),
true);
748 $response->getStatusCode()
751 $json[
'message'] ??
null,
753 static::identicalTo(
'Request parameters could not be validated (&cHash empty)'),
754 static::identicalTo(
'Request parameters could not be validated (&cHash comparison failed)')
768 'https://website.local/',
777 '?&cHash=f42b850e435f0cedd366f5db749fc1af&id=1100',
778 '?&cHash=f42b850e435f0cedd366f5db749fc1af&id=acme-first',
785 $dataSet = $this->wrapInArray(
786 $this->keysFromValues(
807 $response = $this->executeFrontendRequest(
808 new InternalRequest($uri),
809 $this->internalRequestContext
811 $responseStructure = ResponseContent::fromString(
812 (
string)$response->getBody()
816 $responseStructure->getScopePath(
'getpost/testing.value')