[TASK] Tests for rendering tt_content with FAL in Extbase
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Functional / Rendering / LocalizedContentRenderingTest.php
1 <?php
2
3 namespace TYPO3\CMS\Frontend\Tests\Functional\Rendering;
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
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19 use TYPO3\CMS\Core\Tests\Functional\Framework\Frontend\Response;
20
21 /**
22 * Test case checking if localized tt_content is rendered correctly with different language settings
23 *
24 * The following values are relevant:
25 *
26 * -- TypoScript --
27 * config.sys_language_uid = [0,1,2,3,4...] (set via the language parameter &L=1 from the FrontendRequest in the tests)
28 * Fetch the page overlay of the current page if the value is > 0 and if not available, then
29 * "config.sys_language_mode" is evaluated.
30 * If this setting is set to "0" or empty, then no page overlay is evaluated, and no further parameters are
31 * relevant or evaluated.
32 *
33 * config.sys_language_mode = [strict, content_fallback;2,3, ignore]
34 * Only evaluated when sys_language_uid > 0, and the requested page translation is NOT available.
35 * Decides if "pageNotFound" (strict), "content_fallback" with a fallback chain ($TSFE->sys_language_content is set
36 * to that value) or "ignore" (just render the page and the content as this translation would exist).
37 * When set to "0" or not set "", this means that the page request is using the default language for content
38 * and page properties.
39 * Content fallback is evaluated on page level, not on the CE level. So it only makes a difference when the pages_language_overlay
40 * for the requested language does not exist.
41 *
42 * config.sys_language_overlay = [0, 1, hideNonTranslated]
43 * Only relevant if $TSFE->sys_language_content is > 0.
44 * Sets the property $TSFE->sys_language_contentOL at a request. Further calls via $TSFE->sys_page->getRecordOverlay
45 * receive this value to see if an overlay should happen.
46 * 0:
47 * Just fetch records from selected ($TSFE->sys_language_content) language, no overlay will happen,
48 * no fetching of the records from the default language. This boils down to "free mode" language handling.
49 *
50 * 1:
51 * Fetch records from the default language and overlay them with translations. If some record is not translated
52 * default language version will be shown.
53 *
54 * hideNotTranslated:
55 * Fetch records from the default language and overlay them with translations. If some record is not translated
56 * it will not be shown.
57 *
58 * -- Frontend / TypoScriptFrontendController --
59 *
60 * $TSFE->sys_language_uid
61 * Defines in which language the current page was requested, this is relevant when building menus or links to other
62 * pages.
63 * $TSFE->sys_language_content
64 * Contains the language UID of the content records that should be overlaid to would be fetched.
65 * This is especially useful when a page requested with language=4 should fall back to showing content of language=2 (see config.sys_language_mode=content_fallback)
66 * $TSFE->sys_language_contentOL
67 * Contains the info if and how record overlays (when fetching content) should be handled, either "0" (no overlays done)
68 * or "1" (do overlays with possible mixed content, or "hideNonTranslated". see "config.sys_language_overlay"
69 * This is used in conjunction with $TSFE->sys_language_content.
70 * $TSFE->sys_language_mode
71 * Contains the config.sys_language_mode parameter, which is either "", "strict", "content_fallback" or "ignore"
72 * Only used within $TSFE->settingLanguage() and in Extbase.
73 */
74 class LocalizedContentRenderingTest extends \TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
75 {
76 const VALUE_PageId = 89;
77 const TABLE_Content = 'tt_content';
78 const TABLE_Pages = 'pages';
79
80 /**
81 * @var string
82 */
83 protected $scenarioDataSetDirectory = 'typo3/sysext/frontend/Tests/Functional/Rendering/DataSet/';
84
85 /**
86 * Custom 404 handler returning valid json is registered so the $this->getFrontendResponse()
87 * does not fail on 404 pages
88 *
89 * @var array
90 */
91 protected $configurationToUseInTestInstance = [
92 'FE' => [
93 'pageNotFound_handling' => 'READFILE:typo3/sysext/frontend/Tests/Functional/Rendering/DataSet/404Template.html'
94 ]
95 ];
96
97 /**
98 * @var array
99 */
100 protected $pathsToLinkInTestInstance = [
101 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/AdditionalConfiguration.php' => 'typo3conf/AdditionalConfiguration.php',
102 'typo3/sysext/frontend/Tests/Functional/Fixtures/Images' => 'fileadmin/user_upload'
103 ];
104
105 protected function setUp()
106 {
107 parent::setUp();
108 $this->importDataSet('typo3/sysext/core/Tests/Functional/Fixtures/sys_file_storage.xml');
109 $this->importScenarioDataSet('LiveDefaultPages');
110 $this->importScenarioDataSet('LiveDefaultElements');
111 $this->setUpFrontendRootPage(1, [
112 'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.ts',
113 ]);
114 $this->backendUser->workspace = 0;
115 }
116
117 public function defaultLanguageConfigurationDataProvider()
118 {
119 return [
120 [
121 'typoScript' => 'config.sys_language_overlay = 0
122 config.sys_language_mode =',
123 'sys_language_mode' => '',
124 'sys_language_contentOL' => 0
125 ],
126 [
127 'typoScript' => 'config.sys_language_overlay = 0
128 config.sys_language_mode = content_fallback',
129 'sys_language_mode' => 'content_fallback',
130 'sys_language_contentOL' => 0
131 ],
132 [
133 'typoScript' => 'config.sys_language_overlay = 0
134 config.sys_language_mode = content_fallback;1,0',
135 'sys_language_mode' => 'content_fallback',
136 'sys_language_contentOL' => 0
137 ],
138 [
139 'typoScript' => 'config.sys_language_overlay = 0
140 config.sys_language_mode = strict',
141 'sys_language_mode' => 'strict',
142 'sys_language_contentOL' => 0
143 ],
144 [
145 'typoScript' => 'config.sys_language_overlay = 0
146 config.sys_language_mode = ignore',
147 'sys_language_mode' => 'ignore',
148 'sys_language_contentOL' => 0
149 ],
150 [
151 'typoScript' => 'config.sys_language_overlay = 1
152 config.sys_language_mode =',
153 'sys_language_mode' => '',
154 'sys_language_contentOL' => 1
155 ],
156 [
157 'typoScript' => 'config.sys_language_overlay = 1
158 config.sys_language_mode = content_fallback',
159 'sys_language_mode' => 'content_fallback',
160 'sys_language_contentOL' => 1
161 ],
162 [
163 'typoScript' => 'config.sys_language_overlay = 1
164 config.sys_language_mode = content_fallback;1,0',
165 'sys_language_mode' => 'content_fallback',
166 'sys_language_contentOL' => 1
167 ],
168 [
169 'typoScript' => 'config.sys_language_overlay = 1
170 config.sys_language_mode = strict',
171 'sys_language_mode' => 'strict',
172 'sys_language_contentOL' => 1
173 ],
174 [
175 'typoScript' => 'config.sys_language_overlay = 1
176 config.sys_language_mode = ignore',
177 'sys_language_mode' => 'ignore',
178 'sys_language_contentOL' => 1
179 ],
180 [
181 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
182 config.sys_language_mode =',
183 'sys_language_mode' => '',
184 'sys_language_contentOL' => 'hideNonTranslated'
185 ],
186 [
187 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
188 config.sys_language_mode = content_fallback',
189 'sys_language_mode' => 'content_fallback',
190 'sys_language_contentOL' => 'hideNonTranslated'
191 ],
192 [
193 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
194 config.sys_language_mode = content_fallback;1,0',
195 'sys_language_mode' => 'content_fallback',
196 'sys_language_contentOL' => 'hideNonTranslated'
197 ],
198 [
199 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
200 config.sys_language_mode = strict',
201 'sys_language_mode' => 'strict',
202 'sys_language_contentOL' => 'hideNonTranslated'
203 ],
204 [
205 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
206 config.sys_language_mode = ignore',
207 'sys_language_mode' => 'ignore',
208 'sys_language_contentOL' => 'hideNonTranslated'
209 ],
210 ];
211 }
212
213 /**
214 * For the default language all combination of language settings should give the same result,
215 * regardless of TypoScript settings, if the requested language is "0" then no TypoScript settings apply.
216 *
217 * @test
218 * @dataProvider defaultLanguageConfigurationDataProvider
219 *
220 * @param string $typoScript
221 * @param string $sysLanguageMode
222 * @param string $sysLanguageContentOL
223 */
224 public function onlyEnglishContentIsRenderedForDefaultLanguage($typoScript, $sysLanguageMode, $sysLanguageContentOL)
225 {
226 $this->addTypoScriptToTemplateRecord(1, $typoScript);
227
228 $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 0);
229 $responseSections = $frontendResponse->getResponseSections();
230 $visibleHeaders = ['Regular Element #1', 'Regular Element #2', 'Regular Element #3'];
231 $constraint = $this->getRequestSectionHasRecordConstraint()
232 ->setTable(self::TABLE_Content)
233 ->setField('header');
234 call_user_func_array([$constraint, 'setValues'], $visibleHeaders);
235 $this->assertThat($responseSections, $constraint);
236
237 $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
238 ->setTable(self::TABLE_Content)
239 ->setField('header');
240 call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleHeaders($visibleHeaders));
241 $this->assertThat($responseSections, $constraint);
242
243 //assert FAL relations
244 $visibleRecords = [
245 297 => ['T3BOARD'],
246 298 => ['Kasper'],
247 ];
248 foreach ($visibleRecords as $ttContentUid => $visibleFileTitles) {
249
250 $constraint = $this->getRequestSectionStructureHasRecordConstraint()
251 ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
252 ->setTable('sys_file_reference')->setField('title');
253 call_user_func_array([$constraint, 'setValues'], $visibleFileTitles);
254 $this->assertThat($responseSections, $constraint);
255
256 $constraint = $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
257 ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
258 ->setTable('sys_file_reference')->setField('title');
259 call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleFileTitles($visibleFileTitles));
260 $this->assertThat($responseSections, $constraint);
261 }
262
263 //Assert TSFE and page record title
264 $content = json_decode($frontendResponse->getContent());
265 $this->assertEquals('Default language Page', $content->Scope->page->title);
266 $this->assertEquals(0, $content->Scope->tsfe->sys_language_uid, 'sys_language_uid doesn\'t match');
267 $this->assertEquals(0, $content->Scope->tsfe->sys_language_content, 'sys_language_content doesn\'t match');
268 $this->assertEquals($sysLanguageMode, $content->Scope->tsfe->sys_language_mode, 'sys_language_mode doesn\t match');
269 $this->assertEquals($sysLanguageContentOL, $content->Scope->tsfe->sys_language_contentOL, 'sys_language_contentOL doesn\t match');
270 }
271
272 /**
273 * Dutch language has pages_language_overlay record and some content elements are translated
274 *
275 * @return array
276 */
277 public function dutchDataProvider()
278 {
279 //Expected behaviour:
280 //Page is translated to Dutch, so changing sys_language_mode does NOT change the results
281 //Page title is always [DK]Page, and both sys_language_content and sys_language_uid are always 1
282 return [
283 [
284 'typoScript' => 'config.sys_language_overlay = 0
285 config.sys_language_mode =',
286 'visibleRecords' => [
287 300 => [
288 'header' => '[Translate to Dansk:] Regular Element #3',
289 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
290 ],
291 301 => [
292 'header' => '[Translate to Dansk:] Regular Element #1',
293 'image' => [],
294 ],
295 303 => [
296 'header' => '[DK] Without default language',
297 'image' => ['[T3BOARD] Image added to DK element without default language']
298 ],
299 308 => [
300 'header' => '[DK] UnHidden Element #4',
301 'image' => []
302 ],
303 ],
304 'sys_language_mode' => '',
305 'sys_language_contentOL' => 0
306 ],
307 [
308 'typoScript' => 'config.sys_language_overlay = 0
309 config.sys_language_mode = content_fallback',
310 'visibleRecords' => [
311 300 => [
312 'header' => '[Translate to Dansk:] Regular Element #3',
313 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
314 ],
315 301 => [
316 'header' => '[Translate to Dansk:] Regular Element #1',
317 'image' => [],
318 ],
319 303 => [
320 'header' => '[DK] Without default language',
321 'image' => ['[T3BOARD] Image added to DK element without default language']
322 ],
323 308 => [
324 'header' => '[DK] UnHidden Element #4',
325 'image' => []
326 ],
327 ],
328 'sys_language_mode' => 'content_fallback',
329 'sys_language_contentOL' => 0
330 ],
331 [
332 'typoScript' => 'config.sys_language_overlay = 0
333 config.sys_language_mode = content_fallback;1,0',
334 'visibleRecords' => [
335 300 => [
336 'header' => '[Translate to Dansk:] Regular Element #3',
337 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
338 ],
339 301 => [
340 'header' => '[Translate to Dansk:] Regular Element #1',
341 'image' => [],
342 ],
343 303 => [
344 'header' => '[DK] Without default language',
345 'image' => ['[T3BOARD] Image added to DK element without default language']
346 ],
347 308 => [
348 'header' => '[DK] UnHidden Element #4',
349 'image' => []
350 ],
351 ],
352 'sys_language_mode' => 'content_fallback',
353 'sys_language_contentOL' => 0
354 ],
355 [
356 'typoScript' => 'config.sys_language_overlay = 0
357 config.sys_language_mode = strict',
358 'visibleRecords' => [
359 300 => [
360 'header' => '[Translate to Dansk:] Regular Element #3',
361 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
362 ],
363 301 => [
364 'header' => '[Translate to Dansk:] Regular Element #1',
365 'image' => [],
366 ],
367 303 => [
368 'header' => '[DK] Without default language',
369 'image' => ['[T3BOARD] Image added to DK element without default language']
370 ],
371 308 => [
372 'header' => '[DK] UnHidden Element #4',
373 'image' => []
374 ],
375 ],
376 'sys_language_mode' => 'strict',
377 'sys_language_contentOL' => 0
378 ],
379 [
380 'typoScript' => 'config.sys_language_overlay = 0
381 config.sys_language_mode = ignore',
382 'visibleRecords' => [
383 300 => [
384 'header' => '[Translate to Dansk:] Regular Element #3',
385 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
386 ],
387 301 => [
388 'header' => '[Translate to Dansk:] Regular Element #1',
389 'image' => [],
390 ],
391 303 => [
392 'header' => '[DK] Without default language',
393 'image' => ['[T3BOARD] Image added to DK element without default language']
394 ],
395 308 => [
396 'header' => '[DK] UnHidden Element #4',
397 'image' => []
398 ],
399 ],
400 'sys_language_mode' => 'ignore',
401 'sys_language_contentOL' => 0
402 ],
403 [
404 'typoScript' => 'config.sys_language_overlay = 1
405 config.sys_language_mode =',
406 'visibleRecords' => [
407 297 => [
408 'header' => '[Translate to Dansk:] Regular Element #1',
409 'image' => [],
410 ],
411 298 => [
412 'header' => 'Regular Element #2',
413 'image' => ['Kasper'],
414 ],
415 299 => [
416 'header' => '[Translate to Dansk:] Regular Element #3',
417 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
418 ],
419 ],
420 'sys_language_mode' => '',
421 'sys_language_contentOL' => 1
422 ],
423 // Expected behaviour:
424 // Not translated element #2 is shown because sys_language_overlay = 1 (with sys_language_overlay = hideNonTranslated, it would be hidden)
425 [
426 'typoScript' => 'config.sys_language_overlay = 1
427 config.sys_language_mode = content_fallback',
428 'visibleRecords' => [
429 297 => [
430 'header' => '[Translate to Dansk:] Regular Element #1',
431 'image' => [],
432 ],
433 298 => [
434 'header' => 'Regular Element #2',
435 'image' => ['Kasper'],
436 ],
437 299 => [
438 'header' => '[Translate to Dansk:] Regular Element #3',
439 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
440 ],
441 ],
442 'sys_language_mode' => 'content_fallback',
443 'sys_language_contentOL' => 1
444 ],
445 // Expected behaviour:
446 // Same as config.sys_language_mode = content_fallback because we're requesting language 1, so no additional fallback possible
447 //
448 [
449 'typoScript' => 'config.sys_language_overlay = 1
450 config.sys_language_mode = content_fallback;1,0',
451 'visibleRecords' => [
452 297 => [
453 'header' => '[Translate to Dansk:] Regular Element #1',
454 'image' => [],
455 ],
456 298 => [
457 'header' => 'Regular Element #2',
458 'image' => ['Kasper'],
459 ],
460 299 => [
461 'header' => '[Translate to Dansk:] Regular Element #3',
462 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
463 ],
464 ],
465 'sys_language_mode' => 'content_fallback',
466 'sys_language_contentOL' => 1
467 ],
468 [
469 'typoScript' => 'config.sys_language_overlay = 1
470 config.sys_language_mode = strict',
471 'visibleRecords' => [
472 297 => [
473 'header' => '[Translate to Dansk:] Regular Element #1',
474 'image' => [],
475 ],
476 298 => [
477 'header' => 'Regular Element #2',
478 'image' => ['Kasper'],
479 ],
480 299 => [
481 'header' => '[Translate to Dansk:] Regular Element #3',
482 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
483 ],
484 ],
485 'sys_language_mode' => 'strict',
486 'sys_language_contentOL' => 1
487 ],
488 [
489 'typoScript' => 'config.sys_language_overlay = 1
490 config.sys_language_mode = ignore',
491 'visibleRecords' => [
492 297 => [
493 'header' => '[Translate to Dansk:] Regular Element #1',
494 'image' => [],
495 ],
496 298 => [
497 'header' => 'Regular Element #2',
498 'image' => ['Kasper'],
499 ],
500 299 => [
501 'header' => '[Translate to Dansk:] Regular Element #3',
502 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
503 ],
504 ],
505 'sys_language_mode' => 'ignore',
506 'sys_language_contentOL' => 1
507 ],
508 // Expected behaviour:
509 // Non translated default language elements are not shown, because of hideNonTranslated
510 [
511 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
512 config.sys_language_mode =',
513 'visibleRecords' => [
514 297 => [
515 'header' => '[Translate to Dansk:] Regular Element #1',
516 'image' => [],
517 ],
518 299 => [
519 'header' => '[Translate to Dansk:] Regular Element #3',
520 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
521 ],
522 ],
523 'sys_language_mode' => '',
524 'sys_language_contentOL' => 'hideNonTranslated'
525 ],
526 [
527 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
528 config.sys_language_mode = content_fallback',
529 'visibleRecords' => [
530 297 => [
531 'header' => '[Translate to Dansk:] Regular Element #1',
532 'image' => [],
533 ],
534 299 => [
535 'header' => '[Translate to Dansk:] Regular Element #3',
536 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
537 ],
538 ],
539 'sys_language_mode' => 'content_fallback',
540 'sys_language_contentOL' => 'hideNonTranslated'
541 ],
542 [
543 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
544 config.sys_language_mode = content_fallback;1,0',
545 'visibleRecords' => [
546 297 => [
547 'header' => '[Translate to Dansk:] Regular Element #1',
548 'image' => [],
549 ],
550 299 => [
551 'header' => '[Translate to Dansk:] Regular Element #3',
552 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
553 ],
554 ],
555 'sys_language_mode' => 'content_fallback',
556 'sys_language_contentOL' => 'hideNonTranslated'
557 ],
558 //Setting sys_language_mode = strict has the same effect as previous data sets, because the translation of the page exists
559 [
560 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
561 config.sys_language_mode = strict',
562 'visibleRecords' => [
563 297 => [
564 'header' => '[Translate to Dansk:] Regular Element #1',
565 'image' => [],
566 ],
567 299 => [
568 'header' => '[Translate to Dansk:] Regular Element #3',
569 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
570 ],
571 ],
572 'sys_language_mode' => 'strict',
573 'sys_language_contentOL' => 'hideNonTranslated'
574 ],
575 [
576 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
577 config.sys_language_mode = ignore',
578 'visibleRecords' => [
579 297 => [
580 'header' => '[Translate to Dansk:] Regular Element #1',
581 'image' => [],
582 ],
583 299 => [
584 'header' => '[Translate to Dansk:] Regular Element #3',
585 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
586 ],
587 ],
588 'sys_language_mode' => 'ignore',
589 'sys_language_contentOL' => 'hideNonTranslated'
590 ],
591 ];
592 }
593
594 /**
595 * @test
596 * @dataProvider dutchDataProvider
597 *
598 * @param string $typoScript
599 * @param array $visibleRecords
600 * @param string $sysLanguageMode
601 * @param string $sysLanguageContentOL
602 */
603 public function renderingOfDutchLanguage($typoScript, array $visibleRecords, $sysLanguageMode, $sysLanguageContentOL)
604 {
605 $this->addTypoScriptToTemplateRecord(1, $typoScript);
606 $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 1);
607 $responseSections = $frontendResponse->getResponseSections();
608 $visibleHeaders = array_map(function ($element) {
609 return $element['header'];
610 }, $visibleRecords);
611 $constraint = $this->getRequestSectionHasRecordConstraint()
612 ->setTable(self::TABLE_Content)
613 ->setField('header');
614 call_user_func_array([$constraint, 'setValues'], $visibleHeaders);
615 $this->assertThat($responseSections, $constraint);
616
617 $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
618 ->setTable(self::TABLE_Content)
619 ->setField('header');
620 call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleHeaders($visibleHeaders));
621 $this->assertThat($responseSections, $constraint);
622
623 foreach ($visibleRecords as $ttContentUid => $properties) {
624 $visibleFileTitles = $properties['image'];
625 if (!empty($visibleFileTitles)) {
626 $constraint = $this->getRequestSectionStructureHasRecordConstraint()
627 ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
628 ->setTable('sys_file_reference')->setField('title');
629 call_user_func_array([$constraint, 'setValues'], $visibleFileTitles);
630 $this->assertThat($responseSections, $constraint);
631 }
632 $constraint = $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
633 ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
634 ->setTable('sys_file_reference')->setField('title');
635 call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleFileTitles($visibleFileTitles));
636 $this->assertThat($responseSections, $constraint);
637 }
638
639 $content = json_decode($frontendResponse->getContent());
640 $this->assertEquals('[DK]Page', $content->Scope->page->title);
641 $this->assertEquals(1, $content->Scope->tsfe->sys_language_uid, 'sys_language_uid doesn\'t match');
642 $this->assertEquals(1, $content->Scope->tsfe->sys_language_content, 'sys_language_content doesn\'t match');
643 $this->assertEquals($sysLanguageMode, $content->Scope->tsfe->sys_language_mode, 'sys_language_mode doesn\t match');
644 $this->assertEquals($sysLanguageContentOL, $content->Scope->tsfe->sys_language_contentOL, 'sys_language_contentOL doesn\t match');
645 }
646
647 public function contentOnNonTranslatedPageDataProvider()
648 {
649 //Expected behaviour:
650 //the page is NOT translated so setting sys_language_mode to different values changes the results
651 //- setting sys_language_mode to empty value makes TYPO3 return default language records
652 //- setting it to strict throws 404, independently from other settings
653 //Setting config.sys_language_overlay = 0
654 return [
655 [
656 'typoScript' => 'config.sys_language_overlay = 0
657 config.sys_language_mode =',
658 'visibleRecords' => [
659 297 => [
660 'header' => 'Regular Element #1',
661 'image' => ['T3BOARD'],
662 ],
663 298 => [
664 'header' => 'Regular Element #2',
665 'image' => ['Kasper'],
666 ],
667 299 => [
668 'header' => 'Regular Element #3',
669 'image' => [],
670 ],
671 ],
672 'pageTitle' => 'Default language Page',
673 'sys_language_uid' => 0,
674 'sys_language_content' => 0,
675 'sys_language_mode' => '',
676 'sys_language_contentOL' => 0,
677 ],
678 [
679 'typoScript' => 'config.sys_language_overlay = 0
680 config.sys_language_mode = content_fallback',
681 'visibleRecords' => [
682 297 => [
683 'header' => 'Regular Element #1',
684 'image' => ['T3BOARD'],
685 ],
686 298 => [
687 'header' => 'Regular Element #2',
688 'image' => ['Kasper'],
689 ],
690 299 => [
691 'header' => 'Regular Element #3',
692 'image' => [],
693 ],
694 ],
695 'pageTitle' => 'Default language Page',
696 'sys_language_uid' => 2,
697 'sys_language_content' => 0,
698 'sys_language_mode' => 'content_fallback',
699 'sys_language_contentOL' => 0,
700 ],
701 [
702 'typoScript' => 'config.sys_language_overlay = 0
703 config.sys_language_mode = content_fallback;1,0',
704 'visibleRecords' => [
705 300 => [
706 'header' => '[Translate to Dansk:] Regular Element #3',
707 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
708 ],
709 301 => [
710 'header' => '[Translate to Dansk:] Regular Element #1',
711 'image' => [],
712 ],
713 303 => [
714 'header' => '[DK] Without default language',
715 'image' => ['[T3BOARD] Image added to DK element without default language'],
716 ],
717 308 => [
718 'header' => '[DK] UnHidden Element #4',
719 'image' => [],
720 ],
721 ],
722 'pageTitle' => 'Default language Page', //TODO: change it to "[DK]Page" once #81657 is fixed
723 'sys_language_uid' => 2,
724 'sys_language_content' => 1,
725 'sys_language_mode' => 'content_fallback',
726 'sys_language_contentOL' => 0,
727 ],
728 [
729 'typoScript' => 'config.sys_language_overlay = 0
730 config.sys_language_mode = strict',
731 'visibleRecords' => [],
732 'pageTitle' => '',
733 'sys_language_uid' => 2,
734 'sys_language_content' => 2,
735 'sys_language_mode' => 'strict',
736 'sys_language_contentOL' => 0,
737 'status' => 404,
738 ],
739 [
740 'typoScript' => 'config.sys_language_overlay = 0
741 config.sys_language_mode = ignore',
742 'visibleRecords' => [
743 302 => [
744 'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
745 'image' => ['[T3BOARD] image translated to DE from DK'],
746 ],
747 304 => [
748 'header' => '[DE] Without default language',
749 'image' => [],
750 ],
751 ],
752 'pageTitle' => 'Default language Page',
753 'sys_language_uid' => 2,
754 'sys_language_content' => 2,
755 'sys_language_mode' => 'ignore',
756 'sys_language_contentOL' => 0,
757 ],
758 5 => [
759 'typoScript' => 'config.sys_language_overlay = 1
760 config.sys_language_mode =',
761 'visibleRecords' => [
762 297 => [
763 'header' => 'Regular Element #1',
764 'image' => ['T3BOARD'],
765 ],
766 298 => [
767 'header' => 'Regular Element #2',
768 'image' => ['Kasper'],
769 ],
770 299 => [
771 'header' => 'Regular Element #3',
772 'image' => [],
773 ],
774 ],
775 'pageTitle' => 'Default language Page',
776 'sys_language_uid' => 0,
777 'sys_language_content' => 0,
778 'sys_language_mode' => '',
779 'sys_language_contentOL' => 1,
780 ],
781 //falling back to default language
782 [
783 'typoScript' => 'config.sys_language_overlay = 1
784 config.sys_language_mode = content_fallback',
785 'visibleRecords' => [
786 297 => [
787 'header' => 'Regular Element #1',
788 'image' => ['T3BOARD'],
789 ],
790 298 => [
791 'header' => 'Regular Element #2',
792 'image' => ['Kasper'],
793 ],
794 299 => [
795 'header' => 'Regular Element #3',
796 'image' => [],
797 ],
798 ],
799 'pageTitle' => 'Default language Page',
800 'sys_language_uid' => 2,
801 'sys_language_content' => 0,
802 'sys_language_mode' => 'content_fallback',
803 'sys_language_contentOL' => 1,
804 ],
805 //Dutch elements are shown because of the content fallback 1,0 - first Dutch, then default language
806 //note that '[DK] Without default language' is NOT shown - due to overlays (fetch default language and overlay it with translations)
807 [
808 'typoScript' => 'config.sys_language_overlay = 1
809 config.sys_language_mode = content_fallback;1,0',
810 'visibleRecords' => [
811 297 => [
812 'header' => '[Translate to Dansk:] Regular Element #1',
813 'image' => [],
814 ],
815 298 => [
816 'header' => 'Regular Element #2',
817 'image' => ['Kasper'],
818 ],
819 299 => [
820 'header' => '[Translate to Dansk:] Regular Element #3',
821 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
822 ],
823 ],
824 'pageTitle' => 'Default language Page', //TODO: change it to "[DK]Page" once #81657 is fixed
825 'sys_language_uid' => 2,
826 'sys_language_content' => 1,
827 'sys_language_mode' => 'content_fallback',
828 'sys_language_contentOL' => 1,
829 ],
830 [
831 'typoScript' => 'config.sys_language_overlay = 1
832 config.sys_language_mode = strict',
833 'visibleRecords' => [],
834 'pageTitle' => '',
835 'sys_language_uid' => 2,
836 'sys_language_content' => 2,
837 'sys_language_mode' => 'strict',
838 'sys_language_contentOL' => 1,
839 'status' => 404
840 ],
841 [
842 'typoScript' => 'config.sys_language_overlay = 1
843 config.sys_language_mode = ignore',
844 'visibleRecords' => [
845 297 => [
846 'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
847 'image' => ['[T3BOARD] image translated to DE from DK'],
848 ],
849 298 => [
850 'header' => 'Regular Element #2',
851 'image' => ['Kasper'],
852 ],
853 299 => [
854 'header' => 'Regular Element #3',
855 'image' => [],
856 ],
857 ],
858 'pageTitle' => 'Default language Page',
859 'sys_language_uid' => 2,
860 'sys_language_content' => 2,
861 'sys_language_mode' => 'ignore',
862 'sys_language_contentOL' => 1,
863 ],
864 10 => [
865 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
866 config.sys_language_mode =',
867 'visibleRecords' => [
868 297 => [
869 'header' => 'Regular Element #1',
870 'image' => ['T3BOARD'],
871 ],
872 298 => [
873 'header' => 'Regular Element #2',
874 'image' => ['Kasper'],
875 ],
876 299 => [
877 'header' => 'Regular Element #3',
878 'image' => [],
879 ],
880 ],
881 'pageTitle' => 'Default language Page',
882 'sys_language_uid' => 0,
883 'sys_language_content' => 0,
884 'sys_language_mode' => '',
885 'sys_language_contentOL' => 'hideNonTranslated',
886 ],
887 [
888 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
889 config.sys_language_mode = content_fallback',
890 'visibleRecords' => [
891 297 => [
892 'header' => 'Regular Element #1',
893 'image' => ['T3BOARD'],
894 ],
895 298 => [
896 'header' => 'Regular Element #2',
897 'image' => ['Kasper'],
898 ],
899 299 => [
900 'header' => 'Regular Element #3',
901 'image' => [],
902 ],
903 ],
904 'pageTitle' => 'Default language Page',
905 'sys_language_uid' => 2,
906 'sys_language_content' => 0,
907 'sys_language_mode' => 'content_fallback',
908 'sys_language_contentOL' => 'hideNonTranslated',
909 ],
910 [
911 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
912 config.sys_language_mode = content_fallback;1,0',
913 'visibleRecords' => [
914 297 => [
915 'header' => '[Translate to Dansk:] Regular Element #1',
916 'image' => [],
917 ],
918 299 => [
919 'header' => '[Translate to Dansk:] Regular Element #3',
920 'image' => ['[Kasper] Image translated to Dansk', '[T3BOARD] Image added in Dansk (without parent)'],
921 ],
922 ],
923 'pageTitle' => 'Default language Page', //TODO: change it to "[DK]Page" once #81657 is fixed
924 'sys_language_uid' => 2,
925 'sys_language_content' => 1,
926 'sys_language_mode' => 'content_fallback',
927 'sys_language_contentOL' => 'hideNonTranslated',
928 ],
929 [
930 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
931 config.sys_language_mode = strict',
932 'visibleRecords' => [],
933 'pageTitle' => '',
934 'sys_language_uid' => 2,
935 'sys_language_content' => 2,
936 'sys_language_mode' => 'strict',
937 'sys_language_contentOL' => 'hideNonTranslated',
938 'status' => 404,
939 ],
940 [
941 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
942 config.sys_language_mode = ignore',
943 'visibleRecords' => [
944 297 => [
945 'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
946 'image' => ['[T3BOARD] image translated to DE from DK'],
947 ],
948 ],
949 'pageTitle' => 'Default language Page',
950 'sys_language_uid' => 2,
951 'sys_language_content' => 2,
952 'sys_language_mode' => 'ignore',
953 'sys_language_contentOL' => 'hideNonTranslated',
954 ],
955 ];
956 }
957
958 /**
959 * Page uid 89 is NOT translated to german
960 *
961 * @test
962 * @dataProvider contentOnNonTranslatedPageDataProvider
963 *
964 * @param string $typoScript
965 * @param array $visibleRecords
966 * @param string $pageTitle
967 * @param int $sysLanguageUid
968 * @param int $sysLanguageContent
969 * @param string $sysLanguageMode
970 * @param string $sysLanguageContentOL
971 * @param string $status 'success' or 404
972 */
973 public function contentOnNonTranslatedPageGerman($typoScript, array $visibleRecords, $pageTitle, $sysLanguageUid, $sysLanguageContent, $sysLanguageMode, $sysLanguageContentOL, $status='success')
974 {
975 $this->addTypoScriptToTemplateRecord(1, $typoScript);
976 $visibleHeaders = array_map(function ($element) {
977 return $element['header'];
978 }, $visibleRecords);
979
980 $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 2);
981 if ($status === Response::STATUS_Success) {
982 $responseSections = $frontendResponse->getResponseSections();
983 $constraint = $this->getRequestSectionHasRecordConstraint()
984 ->setTable(self::TABLE_Content)
985 ->setField('header');
986 call_user_func_array([$constraint, 'setValues'], $visibleHeaders);
987 $this->assertThat($responseSections, $constraint);
988
989 $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
990 ->setTable(self::TABLE_Content)
991 ->setField('header');
992 call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleHeaders($visibleHeaders));
993 $this->assertThat($responseSections, $constraint);
994
995 foreach ($visibleRecords as $ttContentUid => $properties) {
996 $visibleFileTitles = $properties['image'];
997 if (!empty($visibleFileTitles)) {
998 $constraint = $this->getRequestSectionStructureHasRecordConstraint()
999 ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
1000 ->setTable('sys_file_reference')->setField('title');
1001 call_user_func_array([$constraint, 'setValues'], $visibleFileTitles);
1002 $this->assertThat($responseSections, $constraint);
1003 }
1004 $constraint = $this->getRequestSectionStructureDoesNotHaveRecordConstraint()
1005 ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
1006 ->setTable('sys_file_reference')->setField('title');
1007 call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleFileTitles($visibleFileTitles));
1008 $this->assertThat($responseSections, $constraint);
1009 }
1010
1011 $content = json_decode($frontendResponse->getContent());
1012 $this->assertEquals($pageTitle, $content->Scope->page->title);
1013 $this->assertEquals($sysLanguageUid, $content->Scope->tsfe->sys_language_uid, 'sys_language_uid doesn\'t match');
1014 $this->assertEquals($sysLanguageContent, $content->Scope->tsfe->sys_language_content, 'sys_language_content doesn\'t match');
1015 $this->assertEquals($sysLanguageMode, $content->Scope->tsfe->sys_language_mode, 'sys_language_mode doesn\t match');
1016 $this->assertEquals($sysLanguageContentOL, $content->Scope->tsfe->sys_language_contentOL, 'sys_language_contentOL doesn\t match');
1017 }
1018 //some configuration combinations results in 404, in that case status will be set to 404
1019 $this->assertEquals($status, $frontendResponse->getStatus());
1020 }
1021
1022 public function contentOnPartiallyTranslatedPageDataProvider()
1023 {
1024
1025 //Expected behaviour:
1026 //Setting sys_language_mode to different values doesn't influence the result as the requested page is translated to Polish,
1027 //Page title is always [PL]Page, and both sys_language_content and sys_language_uid are always 3
1028 return [
1029 [
1030 'typoScript' => 'config.sys_language_overlay = 0
1031 config.sys_language_mode =',
1032 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
1033 'sys_language_mode' => '',
1034 'sys_language_contentOL' => 0
1035 ],
1036 [
1037 'typoScript' => 'config.sys_language_overlay = 0
1038 config.sys_language_mode = content_fallback',
1039 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
1040 'sys_language_mode' => 'content_fallback',
1041 'sys_language_contentOL' => 0
1042 ],
1043 [
1044 'typoScript' => 'config.sys_language_overlay = 0
1045 config.sys_language_mode = content_fallback;1,0',
1046 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
1047 'sys_language_mode' => 'content_fallback',
1048 'sys_language_contentOL' => 0
1049 ],
1050 [
1051 'typoScript' => 'config.sys_language_overlay = 0
1052 config.sys_language_mode = strict',
1053 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
1054 'sys_language_mode' => 'strict',
1055 'sys_language_contentOL' => 0
1056 ],
1057 [
1058 'typoScript' => 'config.sys_language_overlay = 0
1059 config.sys_language_mode = ignore',
1060 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
1061 'sys_language_mode' => 'ignore',
1062 'sys_language_contentOL' => 0
1063 ],
1064 5 => [
1065 'typoScript' => 'config.sys_language_overlay = 1
1066 config.sys_language_mode =',
1067 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
1068 'sys_language_mode' => '',
1069 'sys_language_contentOL' => 1
1070 ],
1071 // Expected behaviour:
1072 // Not translated element #2 is shown because sys_language_overlay = 1 (with sys_language_overlay = hideNonTranslated, it would be hidden)
1073 [
1074 'typoScript' => 'config.sys_language_overlay = 1
1075 config.sys_language_mode = content_fallback',
1076 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
1077 'sys_language_mode' => 'content_fallback',
1078 'sys_language_contentOL' => 1
1079 ],
1080 // Expected behaviour:
1081 // Element #3 is not translated in PL and it is translated in DK. It's not shown as content_fallback is not related to single CE level
1082 // but on page level - and this page is translated to Polish, so no fallback is happening
1083 [
1084 'typoScript' => 'config.sys_language_overlay = 1
1085 config.sys_language_mode = content_fallback;1,0',
1086 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
1087 'sys_language_mode' => 'content_fallback',
1088 'sys_language_contentOL' => 1
1089 ],
1090 [
1091 'typoScript' => 'config.sys_language_overlay = 1
1092 config.sys_language_mode = strict',
1093 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
1094 'sys_language_mode' => 'strict',
1095 'sys_language_contentOL' => 1
1096 ],
1097 [
1098 'typoScript' => 'config.sys_language_overlay = 1
1099 config.sys_language_mode = ignore',
1100 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', 'Regular Element #2', 'Regular Element #3'],
1101 'sys_language_mode' => 'ignore',
1102 'sys_language_contentOL' => 1
1103 ],
1104 // Expected behaviour:
1105 // Non translated default language elements are not shown, because of hideNonTranslated
1106 10 => [
1107 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
1108 config.sys_language_mode =',
1109 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1'],
1110 'sys_language_mode' => '',
1111 'sys_language_contentOL' => 'hideNonTranslated'
1112 ],
1113 [
1114 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
1115 config.sys_language_mode = content_fallback',
1116 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1'],
1117 'sys_language_mode' => 'content_fallback',
1118 'sys_language_contentOL' => 'hideNonTranslated'
1119 ],
1120 [
1121 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
1122 config.sys_language_mode = content_fallback;1,0',
1123 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1'],
1124 'sys_language_mode' => 'content_fallback',
1125 'sys_language_contentOL' => 'hideNonTranslated'
1126 ],
1127 [
1128 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
1129 config.sys_language_mode = strict',
1130 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1'],
1131 'sys_language_mode' => 'strict',
1132 'sys_language_contentOL' => 'hideNonTranslated'
1133 ],
1134 [
1135 'typoScript' => 'config.sys_language_overlay = hideNonTranslated
1136 config.sys_language_mode = ignore',
1137 'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1'],
1138 'sys_language_mode' => 'ignore',
1139 'sys_language_contentOL' => 'hideNonTranslated'
1140 ]
1141 ];
1142 }
1143
1144 /**
1145 * Page uid 89 is translated to to Polish, but not all CE are translated
1146 *
1147 * @test
1148 * @dataProvider contentOnPartiallyTranslatedPageDataProvider
1149 *
1150 * @param string $typoScript
1151 * @param array $visibleHeaders
1152 * @param string $sysLanguageMode
1153 * @param string $sysLanguageContentOL
1154 */
1155 public function contentOnPartiallyTranslatedPage($typoScript, array $visibleHeaders, $sysLanguageMode, $sysLanguageContentOL)
1156 {
1157 $this->addTypoScriptToTemplateRecord(1, $typoScript);
1158
1159 $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 3);
1160 $this->assertEquals('success', $frontendResponse->getStatus());
1161 $responseSections = $frontendResponse->getResponseSections();
1162
1163 $constraint = $this->getRequestSectionHasRecordConstraint()
1164 ->setTable(self::TABLE_Content)
1165 ->setField('header');
1166 call_user_func_array([$constraint, 'setValues'], $visibleHeaders);
1167 $this->assertThat($responseSections, $constraint);
1168
1169 $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
1170 ->setTable(self::TABLE_Content)
1171 ->setField('header');
1172 call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleHeaders($visibleHeaders));
1173 $this->assertThat($responseSections, $constraint);
1174
1175 $content = json_decode($frontendResponse->getContent());
1176 $this->assertEquals('[PL]Page', $content->Scope->page->title);
1177 $this->assertEquals(3, $content->Scope->tsfe->sys_language_uid, 'sys_language_uid doesn\'t match');
1178 $this->assertEquals(3, $content->Scope->tsfe->sys_language_content, 'sys_language_content doesn\'t match');
1179 $this->assertEquals($sysLanguageMode, $content->Scope->tsfe->sys_language_mode, 'sys_language_mode doesn\t match');
1180 $this->assertEquals($sysLanguageContentOL, $content->Scope->tsfe->sys_language_contentOL, 'sys_language_contentOL doesn\t match');
1181 }
1182
1183 /**
1184 * Helper function to ease asserting that rest of the data set is not visible
1185 *
1186 * @param array $visibleHeaders
1187 * @return array
1188 */
1189 protected function getNonVisibleHeaders(array $visibleHeaders)
1190 {
1191 $allElements = [
1192 'Regular Element #1',
1193 'Regular Element #2',
1194 'Regular Element #3',
1195 'Hidden Element #4',
1196 '[Translate to Dansk:] Regular Element #1',
1197 '[Translate to Dansk:] Regular Element #3',
1198 '[DK] Without default language',
1199 '[DK] UnHidden Element #4',
1200 '[DE] Without default language',
1201 '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
1202 '[Translate to Polski:] Regular Element #1',
1203 '[PL] Without default language',
1204 '[PL] Hidden Regular Element #2'
1205 ];
1206 return array_diff($allElements, $visibleHeaders);
1207 }
1208
1209 /**
1210 * Helper function to ease asserting that rest of the files are not present
1211 *
1212 * @param array $visibleTitles
1213 * @return array
1214 */
1215 protected function getNonVisibleFileTitles(array $visibleTitles)
1216 {
1217 $allElements = [
1218 'T3BOARD',
1219 'Kasper',
1220 '[Kasper] Image translated to Dansk',
1221 '[T3BOARD] Image added in Dansk (without parent)',
1222 '[T3BOARD] Image added to DK element without default language',
1223 '[T3BOARD] image translated to DE from DK',
1224 ];
1225 return array_diff($allElements, $visibleTitles);
1226 }
1227
1228 /**
1229 * Adds TypoScript setup snippet to the existing template record
1230 *
1231 * @param int $pageId
1232 * @param string $typoScript
1233 */
1234 protected function addTypoScriptToTemplateRecord($pageId, $typoScript)
1235 {
1236 $connection = $this->getDatabaseConnection();
1237
1238 $template = $connection->exec_SELECTgetSingleRow('*', 'sys_template', 'pid = '. $pageId . ' AND root = 1');
1239 if (empty($template)) {
1240 $this->fail('Cannot find root template on page with id: "' . $pageId . '"');
1241 }
1242 $updateFields['config'] = $template['config'] . LF . $typoScript;
1243 $connection->exec_UPDATEquery(
1244 'sys_template',
1245 'uid = ' . $template['uid'],
1246 $updateFields
1247 );
1248 }
1249 }