‪TYPO3CMS  10.4
TemplatesPathsTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
20 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 
23 class ‪TemplatesPathsTest extends FunctionalTestCase
24 {
26 
30  protected const ‪LANGUAGE_PRESETS = [
31  'EN' => ['id' => 0, 'title' => 'English', 'locale' => 'en_US.UTF8'],
32  ];
36  protected ‪$testExtensionsToLoad = [
37  'typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test',
38  ];
39 
43  protected ‪$coreExtensionsToLoad = [
44  'fluid',
45  ];
46 
51  'EXTCONF' => [
52  'extbase' => [
53  'extensions' => [
54  'FluidTest' => [
55  'plugins' => [
56  'Pi' => [
57  'controllers' => [
58  TemplateController::class => [
59  'className' => TemplateController::class,
60  'alias' => 'Template',
61  'actions' => [
62  'baseTemplate',
63  ],
64  'nonCacheableActions' => [
65  'baseTemplate',
66  ],
67  ],
68  ],
69  ],
70  ],
71  ],
72  ],
73  ],
74  ],
75  'FE' => [
76  'cacheHash' => [
77  'enforceValidation' => false,
78  ],
79  ],
80  ];
81 
82  public function ‪setUp(): void
83  {
84  parent::setUp();
85 
86  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml');
88  'test',
89  $this->‪buildSiteConfiguration(1, 'https://website.local/'),
90  [
91  $this->‪buildDefaultLanguageConfiguration('EN', '/en/'),
92  ],
93  [
94  $this->‪buildErrorHandlingConfiguration('Fluid', [404])
95  ]
96  );
97  $this->setUpFrontendRootPage(1, ['EXT:fluid_test/Configuration/TypoScript/Basic.ts']);
98  }
99 
103  public function ‪differentOverrideScenariosDataProvider(): array
104  {
105  return [
106  'base' => [
107  'base',
108  'Base Template',
109  'Base Partial',
110  'Base Layout',
111  ],
112  'overrideAll' => [
113  'overrideAll',
114  'Override Template',
115  'Override Partial',
116  'Override Layout',
117  ],
118  'templateOverride' => [
119  'templateOverride',
120  'TemplateOverride',
121  'Base Partial',
122  'Base Layout',
123  ],
124  'templateOverrideManual' => [
125  'templateOverrideManual',
126  'TemplateOverride',
127  'Base Partial',
128  'Base Layout',
129  ],
130  'partialOverride' => [
131  'partialOverride',
132  'Base Template',
133  'PartialOverride',
134  'Base Layout',
135  ],
136  'partialOverrideManual' => [
137  'partialOverrideManual',
138  'Base Template',
139  'PartialOverride',
140  'Base Layout',
141  ],
142  'layoutOverride' => [
143  'layoutOverride',
144  'Base Template',
145  'Base Partial',
146  'LayoutOverride',
147  ],
148  'layoutOverrideManual' => [
149  'layoutOverrideManual',
150  'Base Template',
151  'Base Partial',
152  'LayoutOverride',
153  ],
154  ];
155  }
156 
165  public function ‪baseRenderingWorksForCObject($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
166  {
167  $requestArguments = [
168  'id' => '1',
169  'override' => $overrideType,
170  'mode' => 'fluidTemplate',
171  ];
172 
173  $content = $this->‪fetchFrontendResponseBody($requestArguments);
174 
175  self::assertStringContainsString($expectedTemplate, $content);
176  self::assertStringContainsString($expectedPartial, $content);
177  self::assertStringContainsString($expectedLayout, $content);
178  }
179 
188  public function ‪baseRenderingWorksForControllerAsGlobalUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
189  {
190  $requestArguments = [
191  'id' => '1',
192  'override' => $overrideType,
193  'mode' => 'controller',
194  ];
195 
196  $content = $this->‪fetchFrontendResponseBody($requestArguments);
197 
198  self::assertStringContainsString($expectedTemplate, $content);
199  self::assertStringContainsString($expectedPartial, $content);
200  self::assertStringContainsString($expectedLayout, $content);
201  }
202 
211  public function ‪baseRenderingWorksForControllerAsPluginUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
212  {
213  $requestArguments = [
214  'id' => '1',
215  'override' => $overrideType,
216  'mode' => 'plugin',
217  'pluginConfig' => 'extensionKey',
218  ];
219 
220  $content = $this->‪fetchFrontendResponseBody($requestArguments);
221 
222  self::assertStringContainsString($expectedTemplate, $content);
223  self::assertStringContainsString($expectedPartial, $content);
224  self::assertStringContainsString($expectedLayout, $content);
225  }
226 
235  public function ‪baseRenderingWorksForControllerAsPluginUsageWithPluginConfig($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
236  {
237  $requestArguments = [
238  'id' => '1',
239  'override' => $overrideType,
240  'mode' => 'plugin',
241  'pluginConfig' => 'pluginName',
242  ];
243 
244  $content = $this->‪fetchFrontendResponseBody($requestArguments);
245 
246  self::assertStringContainsString($expectedTemplate, $content);
247  self::assertStringContainsString($expectedPartial, $content);
248  self::assertStringContainsString($expectedLayout, $content);
249  }
250 
254  public function ‪widgetTemplateCanBeOverridden()
255  {
256  $requestArguments = [
257  'id' => '1',
258  'override' => 'base',
259  'mode' => 'controller',
260  'widgetConfig' => 'new',
261  ];
262 
263  $content = $this->‪fetchFrontendResponseBody($requestArguments);
264 
265  self::assertStringContainsString('PAGINATE WIDGET', $content);
266  }
267 
272  {
273  $requestArguments = [
274  'id' => '1',
275  'override' => 'base',
276  'mode' => 'controller',
277  'widgetConfig' => 'old',
278  ];
279 
280  $content = $this->‪fetchFrontendResponseBody($requestArguments);
281 
282  self::assertStringContainsString('PAGINATE WIDGET', $content);
283  }
284 
289  {
290  $requestArguments = [
291  'id' => '1',
292  'override' => 'base',
293  'mode' => 'plugin',
294  'pluginConfig' => 'incomplete',
295  ];
296 
297  $content = $this->‪fetchFrontendResponseBody($requestArguments);
298 
299  self::assertStringContainsString('Base Template', $content);
300  self::assertStringContainsString('Default Layout', $content);
301  self::assertStringContainsString('Default Partial', $content);
302  }
303 
308  {
309  $requestArguments = [
310  'id' => '1',
311  'mode' => '2plugins',
312  ];
313 
314  $content = $this->‪fetchFrontendResponseBody($requestArguments);
315 
316  self::assertStringContainsString('Base Template', $content);
317  self::assertStringContainsString('Override Template', $content);
318  }
319 
324  protected function ‪fetchFrontendResponseBody(array $requestArguments): string
325  {
326  $response = $this->executeFrontendRequest(
327  (new InternalRequest('https://website.local/en/'))->withQueryParameters($requestArguments)
328  );
329 
330  return (string)$response->getBody();
331  }
332 }
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\setUp
‪setUp()
Definition: TemplatesPathsTest.php:78
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsPluginUsageWithPluginConfig
‪baseRenderingWorksForControllerAsPluginUsageWithPluginConfig($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:231
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildErrorHandlingConfiguration
‪array buildErrorHandlingConfiguration(string $handler, array $codes)
Definition: SiteBasedTestTrait.php:184
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\fetchFrontendResponseBody
‪string fetchFrontendResponseBody(array $requestArguments)
Definition: TemplatesPathsTest.php:320
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\widgetTemplateCanBeOverridden
‪widgetTemplateCanBeOverridden()
Definition: TemplatesPathsTest.php:250
‪TYPO3\CMS\Fluid\Tests\Functional\View
Definition: TemplatesPathsTest.php:16
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\widgetTemplateCanBeOverriddenWithLegacyConfig
‪widgetTemplateCanBeOverriddenWithLegacyConfig()
Definition: TemplatesPathsTest.php:267
‪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:29
‪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:99
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForCObject
‪baseRenderingWorksForCObject($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:161
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: TemplatesPathsTest.php:34
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:124
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest
Definition: TemplatesPathsTest.php:24
‪TYPO3Fluid\FluidTest\Controller\TemplateController
Definition: TemplateController.php:24
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\$configurationToUseInTestInstance
‪array $configurationToUseInTestInstance
Definition: TemplatesPathsTest.php:46
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: TemplatesPathsTest.php:40
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsGlobalUsage
‪baseRenderingWorksForControllerAsGlobalUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:184
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:109
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsPluginUsageWithIncompleteConfig
‪baseRenderingWorksForControllerAsPluginUsageWithIncompleteConfig()
Definition: TemplatesPathsTest.php:284
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerWithTwoPlugins
‪baseRenderingWorksForControllerWithTwoPlugins()
Definition: TemplatesPathsTest.php:303
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsPluginUsage
‪baseRenderingWorksForControllerAsPluginUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:207