‪TYPO3CMS  11.5
TemplatesPathsTest.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 
21 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
22 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
24 
25 class ‪TemplatesPathsTest extends FunctionalTestCase
26 {
28 
32  protected const ‪LANGUAGE_PRESETS = [
33  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
34  ];
35 
36  protected ‪$testExtensionsToLoad = [
37  'typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test',
38  ];
39 
41  'EXTCONF' => [
42  'extbase' => [
43  'extensions' => [
44  'FluidTest' => [
45  'plugins' => [
46  'Pi' => [
47  'controllers' => [
48  TemplateController::class => [
49  'className' => TemplateController::class,
50  'alias' => 'Template',
51  'actions' => [
52  'baseTemplate',
53  ],
54  'nonCacheableActions' => [
55  'baseTemplate',
56  ],
57  ],
58  ],
59  ],
60  ],
61  ],
62  ],
63  ],
64  ],
65  'FE' => [
66  'cacheHash' => [
67  'enforceValidation' => false,
68  ],
69  ],
70  ];
71 
72  public function ‪setUp(): void
73  {
74  parent::setUp();
75 
76  $this->importCSVDataSet(__DIR__ . '/../Fixtures/pages.csv');
78  'test',
79  $this->‪buildSiteConfiguration(1, 'https://website.local/'),
80  [
81  $this->‪buildDefaultLanguageConfiguration('EN', '/en/'),
82  ],
83  $this->‪buildErrorHandlingConfiguration('Fluid', [404]),
84  );
85  $this->setUpFrontendRootPage(1, ['EXT:fluid_test/Configuration/TypoScript/Basic.ts']);
86  }
87 
91  public function ‪differentOverrideScenariosDataProvider(): array
92  {
93  return [
94  'base' => [
95  'base',
96  'Base Template',
97  'Base Partial',
98  'Base Layout',
99  ],
100  'overrideAll' => [
101  'overrideAll',
102  'Override Template',
103  'Override Partial',
104  'Override Layout',
105  ],
106  'templateOverride' => [
107  'templateOverride',
108  'TemplateOverride',
109  'Base Partial',
110  'Base Layout',
111  ],
112  'templateOverrideManual' => [
113  'templateOverrideManual',
114  'TemplateOverride',
115  'Base Partial',
116  'Base Layout',
117  ],
118  'partialOverride' => [
119  'partialOverride',
120  'Base Template',
121  'PartialOverride',
122  'Base Layout',
123  ],
124  'partialOverrideManual' => [
125  'partialOverrideManual',
126  'Base Template',
127  'PartialOverride',
128  'Base Layout',
129  ],
130  'layoutOverride' => [
131  'layoutOverride',
132  'Base Template',
133  'Base Partial',
134  'LayoutOverride',
135  ],
136  'layoutOverrideManual' => [
137  'layoutOverrideManual',
138  'Base Template',
139  'Base Partial',
140  'LayoutOverride',
141  ],
142  ];
143  }
144 
153  public function ‪baseRenderingWorksForCObject($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout): void
154  {
155  $requestArguments = [
156  'id' => '1',
157  'override' => $overrideType,
158  'mode' => 'fluidTemplate',
159  ];
160 
161  $content = $this->‪fetchFrontendResponseBody($requestArguments);
162 
163  self::assertStringContainsString($expectedTemplate, $content);
164  self::assertStringContainsString($expectedPartial, $content);
165  self::assertStringContainsString($expectedLayout, $content);
166  }
167 
176  public function ‪baseRenderingWorksForControllerAsGlobalUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout): void
177  {
178  $requestArguments = [
179  'id' => '1',
180  'override' => $overrideType,
181  'mode' => 'controller',
182  ];
183 
184  $content = $this->‪fetchFrontendResponseBody($requestArguments);
185 
186  self::assertStringContainsString($expectedTemplate, $content);
187  self::assertStringContainsString($expectedPartial, $content);
188  self::assertStringContainsString($expectedLayout, $content);
189  }
190 
199  public function ‪baseRenderingWorksForControllerAsPluginUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout): void
200  {
201  $requestArguments = [
202  'id' => '1',
203  'override' => $overrideType,
204  'mode' => 'plugin',
205  'pluginConfig' => 'extensionKey',
206  ];
207 
208  $content = $this->‪fetchFrontendResponseBody($requestArguments);
209 
210  self::assertStringContainsString($expectedTemplate, $content);
211  self::assertStringContainsString($expectedPartial, $content);
212  self::assertStringContainsString($expectedLayout, $content);
213  }
214 
223  public function ‪baseRenderingWorksForControllerAsPluginUsageWithPluginConfig($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout): void
224  {
225  $requestArguments = [
226  'id' => '1',
227  'override' => $overrideType,
228  'mode' => 'plugin',
229  'pluginConfig' => 'pluginName',
230  ];
231 
232  $content = $this->‪fetchFrontendResponseBody($requestArguments);
233 
234  self::assertStringContainsString($expectedTemplate, $content);
235  self::assertStringContainsString($expectedPartial, $content);
236  self::assertStringContainsString($expectedLayout, $content);
237  }
238 
243  {
244  $requestArguments = [
245  'id' => '1',
246  'override' => 'base',
247  'mode' => 'plugin',
248  'pluginConfig' => 'incomplete',
249  ];
250 
251  $content = $this->‪fetchFrontendResponseBody($requestArguments);
252 
253  self::assertStringContainsString('Base Template', $content);
254  self::assertStringContainsString('Default Layout', $content);
255  self::assertStringContainsString('Default Partial', $content);
256  }
257 
262  {
263  $requestArguments = [
264  'id' => '1',
265  'mode' => '2plugins',
266  ];
267 
268  $content = $this->‪fetchFrontendResponseBody($requestArguments);
269 
270  self::assertStringContainsString('Base Template', $content);
271  self::assertStringContainsString('Override Template', $content);
272  }
273 
278  protected function ‪fetchFrontendResponseBody(array $requestArguments): string
279  {
280  $response = $this->executeFrontendSubRequest(
281  (new InternalRequest('https://website.local/en/'))->withQueryParameters($requestArguments)
282  );
283 
284  return (string)$response->getBody();
285  }
286 }
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\setUp
‪setUp()
Definition: TemplatesPathsTest.php:71
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsPluginUsageWithPluginConfig
‪baseRenderingWorksForControllerAsPluginUsageWithPluginConfig($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:222
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildErrorHandlingConfiguration
‪array buildErrorHandlingConfiguration(string $handler, array $codes)
Definition: SiteBasedTestTrait.php:186
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\fetchFrontendResponseBody
‪string fetchFrontendResponseBody(array $requestArguments)
Definition: TemplatesPathsTest.php:277
‪TYPO3\CMS\Fluid\Tests\Functional\View
Definition: TemplatesPathsTest.php:18
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\$testExtensionsToLoad
‪$testExtensionsToLoad
Definition: TemplatesPathsTest.php:35
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait
Definition: SiteBasedTestTrait.php:36
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\LANGUAGE_PRESETS
‪const LANGUAGE_PRESETS
Definition: TemplatesPathsTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:58
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\differentOverrideScenariosDataProvider
‪array differentOverrideScenariosDataProvider()
Definition: TemplatesPathsTest.php:90
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForCObject
‪baseRenderingWorksForCObject($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:152
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:126
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest
Definition: TemplatesPathsTest.php:26
‪TYPO3Fluid\FluidTest\Controller\TemplateController
Definition: TemplateController.php:24
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsGlobalUsage
‪baseRenderingWorksForControllerAsGlobalUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:175
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\$configurationToUseInTestInstance
‪$configurationToUseInTestInstance
Definition: TemplatesPathsTest.php:39
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:111
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsPluginUsageWithIncompleteConfig
‪baseRenderingWorksForControllerAsPluginUsageWithIncompleteConfig()
Definition: TemplatesPathsTest.php:241
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerWithTwoPlugins
‪baseRenderingWorksForControllerWithTwoPlugins()
Definition: TemplatesPathsTest.php:260
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsPluginUsage
‪baseRenderingWorksForControllerAsPluginUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:198