‪TYPO3CMS  ‪main
TypeRenderingTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
23 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 final class ‪TypeRenderingTest extends FunctionalTestCase
27 {
29 
30  private const ‪LANGUAGE_PRESETS = [
31  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8', 'websiteTitle' => 'Site EN'],
32  ];
33 
34  public static function ‪typesDataProvider(): \Iterator
35  {
36  yield [
37  'typoScriptFile' => 'EXT:frontend/Tests/Functional/Rendering/Fixtures/TypeRenderingTestNoExplicitTypeNum.typoscript',
38  'type' => 0,
39  'expected' => 'noExplicitTypeNum',
40  ];
41  yield [
42  'typoScriptFile' => 'EXT:frontend/Tests/Functional/Rendering/Fixtures/TypeRenderingTestNoExplicitTypeNum.typoscript',
43  'type' => null,
44  'expected' => 'noExplicitTypeNum',
45  ];
46  yield [
47  'typoScriptFile' => 'EXT:frontend/Tests/Functional/Rendering/Fixtures/TypeRenderingTestTypeNumZero.typoscript',
48  'type' => 0,
49  'expected' => 'typeNumZero',
50  ];
51  yield [
52  'typoScriptFile' => 'EXT:frontend/Tests/Functional/Rendering/Fixtures/TypeRenderingTestTypeNumZero.typoscript',
53  'type' => null,
54  'expected' => 'typeNumZero',
55  ];
56  yield [
57  'typoScriptFile' => 'EXT:frontend/Tests/Functional/Rendering/Fixtures/TypeRenderingTestTwoPageNoNum.typoscript',
58  'type' => 0,
59  'expected' => 'firstPageContent',
60  ];
61  yield [
62  'typoScriptFile' => 'EXT:frontend/Tests/Functional/Rendering/Fixtures/TypeRenderingTestTwoPageNoNum.typoscript',
63  'type' => null,
64  'expected' => 'firstPageContent',
65  ];
66  yield [
67  'typoScriptFile' => 'EXT:frontend/Tests/Functional/Rendering/Fixtures/TypeRenderingTestVariousTypeNums.typoscript',
68  'type' => 0,
69  'expected' => 'defaultPage',
70  ];
71  yield [
72  'typoScriptFile' => 'EXT:frontend/Tests/Functional/Rendering/Fixtures/TypeRenderingTestVariousTypeNums.typoscript',
73  'type' => 42,
74  'expected' => 'intTypeContent',
75  ];
76  yield [
77  'typoScriptFile' => 'EXT:frontend/Tests/Functional/Rendering/Fixtures/TypeRenderingTestVariousTypeNums.typoscript',
78  'type' => 'foo',
79  'expected' => 'stringTypeContent',
80  ];
81  }
82 
83  #[DataProvider('typesDataProvider')]
84  #[Test]
85  public function ‪typesAreRendered(string $typoScriptFile, int|string|null $type, string $expected): void
86  {
87  $this->importCsvDataSet(__DIR__ . '/../Fixtures/pages.csv');
88  $this->setUpFrontendRootPage(1, [$typoScriptFile]);
90  'testing',
91  $this->‪buildSiteConfiguration(1, '/'),
92  [
93  $this->‪buildDefaultLanguageConfiguration('EN', '/'),
94  ]
95  );
96  $queryParameters = [
97  'id' => 1,
98  ];
99  if ($type !== null) {
100  $queryParameters['type'] = $type;
101  }
102  $response = $this->executeFrontendSubRequest((new InternalRequest())->withQueryParameters($queryParameters));
103  self::assertStringContainsString($expected, (string)$response->getBody());
104  }
105 }
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\TypeRenderingTest
Definition: TypeRenderingTest.php:27
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\TypeRenderingTest\LANGUAGE_PRESETS
‪const LANGUAGE_PRESETS
Definition: TypeRenderingTest.php:29
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\TypeRenderingTest\typesAreRendered
‪typesAreRendered(string $typoScriptFile, int|string|null $type, string $expected)
Definition: TypeRenderingTest.php:84
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:37
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:50
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:88
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering\TypeRenderingTest\typesDataProvider
‪static typesDataProvider()
Definition: TypeRenderingTest.php:33
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:98
‪TYPO3\CMS\Frontend\Tests\Functional\Rendering
Definition: AbsoluteUriPrefixRenderingTest.php:18