[TASK] Use FQCN's when registering plugins/modules
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Functional / View / TemplatesPathsTest.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Tests\Functional\View;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
18 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
19
20 class TemplatesPathsTest extends FunctionalTestCase
21 {
22 /**
23 * @var array
24 */
25 protected $testExtensionsToLoad = [
26 'typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test',
27 ];
28
29 /**
30 * @var array
31 */
32 protected $coreExtensionsToLoad = [
33 'fluid',
34 ];
35
36 /**
37 * @var array
38 */
39 protected $configurationToUseInTestInstance = [
40 'EXTCONF' => [
41 'extbase' => [
42 'extensions' => [
43 'FluidTest' => [
44 'plugins' => [
45 'Pi' => [
46 'controllers' => [
47 \TYPO3Fluid\FluidTest\Controller\TemplateController::class => [
48 'className' => \TYPO3Fluid\FluidTest\Controller\TemplateController::class,
49 'alias' => 'Template',
50 'actions' => [
51 'baseTemplate',
52 ],
53 'nonCacheableActions' => [
54 'baseTemplate',
55 ],
56 ],
57 ],
58 ],
59 ],
60 ],
61 ],
62 ],
63 ],
64 ];
65
66 public function setUp()
67 {
68 parent::setUp();
69
70 $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml');
71 $this->setUpFrontendRootPage(1, ['EXT:fluid_test/Configuration/TypoScript/Basic.ts']);
72 }
73
74 /**
75 * @return array
76 */
77 public function differentOverrideScenariosDataProvider(): array
78 {
79 return [
80 'base' => [
81 'base',
82 'Base Template',
83 'Base Partial',
84 'Base Layout',
85 ],
86 'overrideAll' => [
87 'overrideAll',
88 'Override Template',
89 'Override Partial',
90 'Override Layout',
91 ],
92 'templateOverride' => [
93 'templateOverride',
94 'TemplateOverride',
95 'Base Partial',
96 'Base Layout',
97 ],
98 'templateOverrideManual' => [
99 'templateOverrideManual',
100 'TemplateOverride',
101 'Base Partial',
102 'Base Layout',
103 ],
104 'partialOverride' => [
105 'partialOverride',
106 'Base Template',
107 'PartialOverride',
108 'Base Layout',
109 ],
110 'partialOverrideManual' => [
111 'partialOverrideManual',
112 'Base Template',
113 'PartialOverride',
114 'Base Layout',
115 ],
116 'layoutOverride' => [
117 'layoutOverride',
118 'Base Template',
119 'Base Partial',
120 'LayoutOverride',
121 ],
122 'layoutOverrideManual' => [
123 'layoutOverrideManual',
124 'Base Template',
125 'Base Partial',
126 'LayoutOverride',
127 ],
128 ];
129 }
130
131 /**
132 * @test
133 * @param string $overrideType
134 * @param string $expectedTemplate
135 * @param string $expectedPartial
136 * @param string $expectedLayout
137 * @dataProvider differentOverrideScenariosDataProvider
138 */
139 public function baseRenderingWorksForCObject($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
140 {
141 $requestArguments = [
142 'id' => '1',
143 'override' => $overrideType,
144 'mode' => 'fluidTemplate',
145 ];
146
147 $content = $this->fetchFrontendResponseBody($requestArguments);
148
149 $this->assertContains($expectedTemplate, $content);
150 $this->assertContains($expectedPartial, $content);
151 $this->assertContains($expectedLayout, $content);
152 }
153
154 /**
155 * @test
156 * @param string $overrideType
157 * @param string $expectedTemplate
158 * @param string $expectedPartial
159 * @param string $expectedLayout
160 * @dataProvider differentOverrideScenariosDataProvider
161 */
162 public function baseRenderingWorksForControllerAsGlobalUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
163 {
164 $requestArguments = [
165 'id' => '1',
166 'override' => $overrideType,
167 'mode' => 'controller',
168 ];
169
170 $content = $this->fetchFrontendResponseBody($requestArguments);
171
172 $this->assertContains($expectedTemplate, $content);
173 $this->assertContains($expectedPartial, $content);
174 $this->assertContains($expectedLayout, $content);
175 }
176
177 /**
178 * @test
179 * @param string $overrideType
180 * @param string $expectedTemplate
181 * @param string $expectedPartial
182 * @param string $expectedLayout
183 * @dataProvider differentOverrideScenariosDataProvider
184 */
185 public function baseRenderingWorksForControllerAsPluginUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
186 {
187 $requestArguments = [
188 'id' => '1',
189 'override' => $overrideType,
190 'mode' => 'plugin',
191 'pluginConfig' => 'extensionKey',
192 ];
193
194 $content = $this->fetchFrontendResponseBody($requestArguments);
195
196 $this->assertContains($expectedTemplate, $content);
197 $this->assertContains($expectedPartial, $content);
198 $this->assertContains($expectedLayout, $content);
199 }
200
201 /**
202 * @test
203 * @param string $overrideType
204 * @param string $expectedTemplate
205 * @param string $expectedPartial
206 * @param string $expectedLayout
207 * @dataProvider differentOverrideScenariosDataProvider
208 */
209 public function baseRenderingWorksForControllerAsPluginUsageWithPluginConfig($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
210 {
211 $requestArguments = [
212 'id' => '1',
213 'override' => $overrideType,
214 'mode' => 'plugin',
215 'pluginConfig' => 'pluginName',
216 ];
217
218 $content = $this->fetchFrontendResponseBody($requestArguments);
219
220 $this->assertContains($expectedTemplate, $content);
221 $this->assertContains($expectedPartial, $content);
222 $this->assertContains($expectedLayout, $content);
223 }
224
225 /**
226 * @test
227 */
228 public function widgetTemplateCanBeOverridden()
229 {
230 $requestArguments = [
231 'id' => '1',
232 'override' => 'base',
233 'mode' => 'controller',
234 'widgetConfig' => 'new',
235 ];
236
237 $content = $this->fetchFrontendResponseBody($requestArguments);
238
239 $this->assertContains('PAGINATE WIDGET', $content);
240 }
241
242 /**
243 * @test
244 */
245 public function widgetTemplateCanBeOverriddenWithLegacyConfig()
246 {
247 $requestArguments = [
248 'id' => '1',
249 'override' => 'base',
250 'mode' => 'controller',
251 'widgetConfig' => 'old',
252 ];
253
254 $content = $this->fetchFrontendResponseBody($requestArguments);
255
256 $this->assertContains('PAGINATE WIDGET', $content);
257 }
258
259 /**
260 * @test
261 */
262 public function baseRenderingWorksForControllerAsPluginUsageWithIncompleteConfig()
263 {
264 $requestArguments = [
265 'id' => '1',
266 'override' => 'base',
267 'mode' => 'plugin',
268 'pluginConfig' => 'incomplete',
269 ];
270
271 $content = $this->fetchFrontendResponseBody($requestArguments);
272
273 $this->assertContains('Base Template', $content);
274 $this->assertContains('Default Layout', $content);
275 $this->assertContains('Default Partial', $content);
276 }
277
278 /**
279 * @test
280 */
281 public function baseRenderingWorksForControllerWithTwoPlugins()
282 {
283 $requestArguments = [
284 'id' => '1',
285 'mode' => '2plugins',
286 ];
287
288 $content = $this->fetchFrontendResponseBody($requestArguments);
289
290 $this->assertContains('Base Template', $content);
291 $this->assertContains('Override Template', $content);
292 }
293
294 /**
295 * @param array $requestArguments
296 * @return string
297 */
298 protected function fetchFrontendResponseBody(array $requestArguments): string
299 {
300 $response = $this->executeFrontendRequest(
301 (new InternalRequest())->withQueryParameters($requestArguments)
302 );
303
304 return (string)$response->getBody();
305 }
306 }