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,
91 $this->setUpFrontendRootPage(
94 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript',
95 'typo3/sysext/frontend/Tests/Functional/SiteHandling/Fixtures/JsonRenderer.typoscript',
98 'title' =>
'ACME Archive',
99 'sitetitle' => $this->siteTitle,
106 unset($this->internalRequestContext);
117 'https://localhost/',
118 'https://website.local/',
127 return $this->wrapInArray(
128 $this->keysFromValues(
142 $expectedStatusCode = 307;
143 $expectedHeaders = [
'location' => [
'index.php?id=acme-first']];
145 $response = $this->executeFrontendRequest(
146 new InternalRequest($uri),
147 $this->internalRequestContext
149 static::assertSame($expectedStatusCode, $response->getStatusCode());
150 static::assertSame($expectedHeaders, $response->getHeaders());
161 $expectedStatusCode = 200;
162 $expectedPageTitle =
'EN: Welcome';
164 $response = $this->executeFrontendRequest(
165 new InternalRequest($uri),
166 $this->internalRequestContext,
169 $responseStructure = ResponseContent::fromString(
170 (
string)$response->getBody()
175 $response->getStatusCode()
179 $responseStructure->getScopePath(
'template/sitetitle')
183 $responseStructure->getScopePath(
'page/title')
194 'https://localhost/',
195 'https://website.local/',
211 function (
string $uri) {
212 if (strpos($uri,
'&L=1') !==
false) {
213 $expectedPageTitle =
'FR: Welcome';
214 } elseif (strpos($uri,
'&L=2') !==
false) {
215 $expectedPageTitle =
'FR-CA: Welcome';
217 $expectedPageTitle =
'EN: Welcome';
219 return [$uri, $expectedPageTitle];
221 $this->keysFromValues(
234 public function pageIsRendered(
string $uri,
string $expectedPageTitle)
236 $response = $this->executeFrontendRequest(
237 new InternalRequest($uri),
238 $this->internalRequestContext
240 $responseStructure = ResponseContent::fromString(
241 (
string)$response->getBody()
246 $response->getStatusCode()
250 $responseStructure->getScopePath(
'template/sitetitle')
254 $responseStructure->getScopePath(
'page/title')
264 [
'https://archive.acme.com/?id=3100',
'EN: Statistics'],
265 [
'https://archive.acme.com/?id=3110',
'EN: Markets'],
266 [
'https://archive.acme.com/?id=3120',
'EN: Products'],
267 [
'https://archive.acme.com/?id=3130',
'EN: Partners'],
270 return $this->keysFromTemplate($instructions,
'%1$s');
282 $response = $this->executeFrontendRequest(
283 new InternalRequest($uri),
284 $this->internalRequestContext
286 $responseStructure = ResponseContent::fromString(
287 (
string)$response->getBody()
292 $response->getStatusCode()
296 $responseStructure->getScopePath(
'template/sitetitle')
300 $responseStructure->getScopePath(
'page/title')
311 [
'https://website.local/?id=1510', 1,
'Whitepapers'],
312 [
'https://website.local/?id=1511', 1,
'Products'],
313 [
'https://website.local/?id=1512', 1,
'Solutions'],
315 [
'https://website.local/?id=1510', 2,
'Whitepapers'],
316 [
'https://website.local/?id=1511', 2,
'Products'],
317 [
'https://website.local/?id=1515', 2,
'Research'],
318 [
'https://website.local/?id=1520', 2,
'Forecasts'],
319 [
'https://website.local/?id=1521', 2,
'Current Year'],
321 [
'https://website.local/?id=1510', 3,
'Whitepapers'],
322 [
'https://website.local/?id=1511', 3,
'Products'],
323 [
'https://website.local/?id=1512', 3,
'Solutions'],
324 [
'https://website.local/?id=1515', 3,
'Research'],
325 [
'https://website.local/?id=1520', 3,
'Forecasts'],
326 [
'https://website.local/?id=1521', 3,
'Current Year'],
329 return $this->keysFromTemplate($instructions,
'%1$s (user:%2$s)');
342 $response = $this->executeFrontendRequest(
343 new InternalRequest($uri),
344 $this->internalRequestContext
345 ->withFrontendUserId($frontendUserId)
347 $responseStructure = ResponseContent::fromString(
348 (
string)$response->getBody()
353 $response->getStatusCode()
357 $responseStructure->getScopePath(
'template/sitetitle')
361 $responseStructure->getScopePath(
'page/title')
372 [
'https://website.local/?id=1510', 0],
373 [
'https://website.local/?id=1511', 0],
374 [
'https://website.local/?id=1512', 0],
375 [
'https://website.local/?id=1515', 0],
376 [
'https://website.local/?id=1520', 0],
377 [
'https://website.local/?id=1521', 0],
379 [
'https://website.local/?id=1515', 1],
380 [
'https://website.local/?id=1520', 1],
381 [
'https://website.local/?id=1521', 1],
383 [
'https://website.local/?id=1512', 2],
386 return $this->keysFromTemplate($instructions,
'%1$s (user:%2$s)');
398 $response = $this->executeFrontendRequest(
399 new InternalRequest($uri),
400 $this->internalRequestContext
401 ->withFrontendUserId($frontendUserId)
406 $response->getStatusCode()
409 (
string)$response->getBody(),
411 static::stringContains(
'Reason: ID was not an accessible page'),
412 static::stringContains(
'Reason: Subsection was found and not accessible')
426 $response = $this->executeFrontendRequest(
427 new InternalRequest($uri),
428 $this->internalRequestContext
429 ->withFrontendUserId($frontendUserId)
430 ->withMergedGlobalSettings([
431 'TYPO3_CONF_VARS' => [
433 'pageNotFound_handling' =>
'READFILE:typo3/sysext/core/Tests/Functional/Fixtures/Frontend/PageError.txt',
441 $response->getStatusCode()
444 (
string)$response->getBody(),
446 static::stringContains(
'reason: ID was not an accessible page'),
447 static::stringContains(
'reason: Subsection was found and not accessible')
459 'https://localhost/',
460 'https://website.local/',
473 '&testing[value]=1&cHash=',
474 '&testing[value]=1&cHash=WRONG',
477 return $this->wrapInArray(
478 $this->keysFromValues(
493 $this->expectExceptionCode(1518472189);
494 $this->expectException(PageNotFoundException::class);
496 $this->executeFrontendRequest(
497 new InternalRequest($uri),
498 $this->internalRequestContext
510 $response = $this->executeFrontendRequest(
511 new InternalRequest($uri),
512 $this->internalRequestContext->withMergedGlobalSettings([
513 'TYPO3_CONF_VARS' => [
515 'pageNotFound_handling' =>
'READFILE:typo3/sysext/core/Tests/Functional/Fixtures/Frontend/PageError.txt',
523 $response->getStatusCode()
526 (
string)$response->getBody(),
528 static::stringContains(
'reason: Request parameters could not be validated (&cHash empty)'),
529 static::stringContains(
'reason: Request parameters could not be validated (&cHash comparison failed)')
541 'https://localhost/',
542 'https://website.local/',
551 '?&cHash=f42b850e435f0cedd366f5db749fc1af&id=1100',
552 '?&cHash=f42b850e435f0cedd366f5db749fc1af&id=acme-first',
559 $dataSet = $this->wrapInArray(
560 $this->keysFromValues(
576 $response = $this->executeFrontendRequest(
577 new InternalRequest($uri),
578 $this->internalRequestContext
580 $responseStructure = ResponseContent::fromString(
581 (
string)$response->getBody()
585 $responseStructure->getScopePath(
'getpost/testing.value')