‪TYPO3CMS  9.5
TemplatesPathsTest.php
Go to the documentation of this file.
1 <?php
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 {
25  protected ‪$testExtensionsToLoad = [
26  'typo3/sysext/fluid/Tests/Functional/Fixtures/Extensions/fluid_test',
27  ];
28 
32  protected ‪$coreExtensionsToLoad = [
33  'fluid',
34  ];
35 
40  'EXTCONF' => [
41  'extbase' => [
42  'extensions' => [
43  'FluidTest' => [
44  'plugins' => [
45  'Pi' => [
46  'controllers' => [
47  'Template' => [
48  'actions' => [
49  'baseTemplate',
50  ],
51  'nonCacheableActions' => [
52  'baseTemplate',
53  ],
54  ],
55  ],
56  ],
57  ],
58  ],
59  ],
60  ],
61  ],
62  ];
63 
64  public function ‪setUp()
65  {
66  parent::setUp();
67 
68  $this->importDataSet('PACKAGE:typo3/testing-framework/Resources/Core/Functional/Fixtures/pages.xml');
69  $this->setUpFrontendRootPage(1, ['EXT:fluid_test/Configuration/TypoScript/Basic.ts']);
70  }
71 
75  public function ‪differentOverrideScenariosDataProvider(): array
76  {
77  return [
78  'base' => [
79  'base',
80  'Base Template',
81  'Base Partial',
82  'Base Layout',
83  ],
84  'overrideAll' => [
85  'overrideAll',
86  'Override Template',
87  'Override Partial',
88  'Override Layout',
89  ],
90  'templateOverride' => [
91  'templateOverride',
92  'TemplateOverride',
93  'Base Partial',
94  'Base Layout',
95  ],
96  'templateOverrideManual' => [
97  'templateOverrideManual',
98  'TemplateOverride',
99  'Base Partial',
100  'Base Layout',
101  ],
102  'partialOverride' => [
103  'partialOverride',
104  'Base Template',
105  'PartialOverride',
106  'Base Layout',
107  ],
108  'partialOverrideManual' => [
109  'partialOverrideManual',
110  'Base Template',
111  'PartialOverride',
112  'Base Layout',
113  ],
114  'layoutOverride' => [
115  'layoutOverride',
116  'Base Template',
117  'Base Partial',
118  'LayoutOverride',
119  ],
120  'layoutOverrideManual' => [
121  'layoutOverrideManual',
122  'Base Template',
123  'Base Partial',
124  'LayoutOverride',
125  ],
126  ];
127  }
128 
137  public function ‪baseRenderingWorksForCObject($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
138  {
139  $requestArguments = [
140  'id' => '1',
141  'override' => $overrideType,
142  'mode' => 'fluidTemplate',
143  ];
144 
145  $content = $this->‪fetchFrontendResponseBody($requestArguments);
146 
147  $this->assertContains($expectedTemplate, $content);
148  $this->assertContains($expectedPartial, $content);
149  $this->assertContains($expectedLayout, $content);
150  }
151 
160  public function ‪baseRenderingWorksForControllerAsGlobalUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
161  {
162  $requestArguments = [
163  'id' => '1',
164  'override' => $overrideType,
165  'mode' => 'controller',
166  ];
167 
168  $content = $this->‪fetchFrontendResponseBody($requestArguments);
169 
170  $this->assertContains($expectedTemplate, $content);
171  $this->assertContains($expectedPartial, $content);
172  $this->assertContains($expectedLayout, $content);
173  }
174 
183  public function ‪baseRenderingWorksForControllerAsPluginUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
184  {
185  $requestArguments = [
186  'id' => '1',
187  'override' => $overrideType,
188  'mode' => 'plugin',
189  'pluginConfig' => 'extensionKey',
190  ];
191 
192  $content = $this->‪fetchFrontendResponseBody($requestArguments);
193 
194  $this->assertContains($expectedTemplate, $content);
195  $this->assertContains($expectedPartial, $content);
196  $this->assertContains($expectedLayout, $content);
197  }
198 
207  public function ‪baseRenderingWorksForControllerAsPluginUsageWithPluginConfig($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
208  {
209  $requestArguments = [
210  'id' => '1',
211  'override' => $overrideType,
212  'mode' => 'plugin',
213  'pluginConfig' => 'pluginName',
214  ];
215 
216  $content = $this->‪fetchFrontendResponseBody($requestArguments);
217 
218  $this->assertContains($expectedTemplate, $content);
219  $this->assertContains($expectedPartial, $content);
220  $this->assertContains($expectedLayout, $content);
221  }
222 
226  public function ‪widgetTemplateCanBeOverridden()
227  {
228  $requestArguments = [
229  'id' => '1',
230  'override' => 'base',
231  'mode' => 'controller',
232  'widgetConfig' => 'new',
233  ];
234 
235  $content = $this->‪fetchFrontendResponseBody($requestArguments);
236 
237  $this->assertContains('PAGINATE WIDGET', $content);
238  }
239 
244  {
245  $requestArguments = [
246  'id' => '1',
247  'override' => 'base',
248  'mode' => 'controller',
249  'widgetConfig' => 'old',
250  ];
251 
252  $content = $this->‪fetchFrontendResponseBody($requestArguments);
253 
254  $this->assertContains('PAGINATE WIDGET', $content);
255  }
256 
261  {
262  $requestArguments = [
263  'id' => '1',
264  'override' => 'base',
265  'mode' => 'plugin',
266  'pluginConfig' => 'incomplete',
267  ];
268 
269  $content = $this->‪fetchFrontendResponseBody($requestArguments);
270 
271  $this->assertContains('Base Template', $content);
272  $this->assertContains('Default Layout', $content);
273  $this->assertContains('Default Partial', $content);
274  }
275 
280  {
281  $requestArguments = [
282  'id' => '1',
283  'mode' => '2plugins',
284  ];
285 
286  $content = $this->‪fetchFrontendResponseBody($requestArguments);
287 
288  $this->assertContains('Base Template', $content);
289  $this->assertContains('Override Template', $content);
290  }
291 
296  protected function ‪fetchFrontendResponseBody(array $requestArguments): string
297  {
298  $response = $this->executeFrontendRequest(
299  (new InternalRequest())->withQueryParameters($requestArguments)
300  );
301 
302  return (string)$response->getBody();
303  }
304 }
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\setUp
‪setUp()
Definition: TemplatesPathsTest.php:61
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsPluginUsageWithPluginConfig
‪baseRenderingWorksForControllerAsPluginUsageWithPluginConfig($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:204
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\fetchFrontendResponseBody
‪string fetchFrontendResponseBody(array $requestArguments)
Definition: TemplatesPathsTest.php:293
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\widgetTemplateCanBeOverridden
‪widgetTemplateCanBeOverridden()
Definition: TemplatesPathsTest.php:223
‪TYPO3\CMS\Fluid\Tests\Functional\View
Definition: TemplatesPathsTest.php:2
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\widgetTemplateCanBeOverriddenWithLegacyConfig
‪widgetTemplateCanBeOverriddenWithLegacyConfig()
Definition: TemplatesPathsTest.php:240
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\differentOverrideScenariosDataProvider
‪array differentOverrideScenariosDataProvider()
Definition: TemplatesPathsTest.php:72
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForCObject
‪baseRenderingWorksForCObject($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:134
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: TemplatesPathsTest.php:24
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest
Definition: TemplatesPathsTest.php:21
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\$configurationToUseInTestInstance
‪array $configurationToUseInTestInstance
Definition: TemplatesPathsTest.php:36
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: TemplatesPathsTest.php:30
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsGlobalUsage
‪baseRenderingWorksForControllerAsGlobalUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:157
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsPluginUsageWithIncompleteConfig
‪baseRenderingWorksForControllerAsPluginUsageWithIncompleteConfig()
Definition: TemplatesPathsTest.php:257
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerWithTwoPlugins
‪baseRenderingWorksForControllerWithTwoPlugins()
Definition: TemplatesPathsTest.php:276
‪TYPO3\CMS\Fluid\Tests\Functional\View\TemplatesPathsTest\baseRenderingWorksForControllerAsPluginUsage
‪baseRenderingWorksForControllerAsPluginUsage($overrideType, $expectedTemplate, $expectedPartial, $expectedLayout)
Definition: TemplatesPathsTest.php:180