TYPO3 CMS  TYPO3_7-6
TranslatedContentTest.php
Go to the documentation of this file.
1 <?php
2 
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 
27 {
28  const VALUE_PageId = 89;
29  const TABLE_Content = 'tt_content';
30  const TABLE_Pages = 'pages';
31 
35  protected $scenarioDataSetDirectory = 'typo3/sysext/frontend/Tests/Functional/Rendering/DataSet/';
36 
40  protected $testExtensionsToLoad = ['typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example'];
41 
45  protected $coreExtensionsToLoad = ['extbase', 'fluid'];
46 
50  protected $objectManager;
51 
55  protected $contentRepository;
56 
64  'FE' => [
65  'pageNotFound_handling' => 'READFILE:typo3/sysext/frontend/Tests/Functional/Rendering/DataSet/404Template.html'
66  ]
67  ];
68 
73  'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/AdditionalConfiguration.php' => 'typo3conf/AdditionalConfiguration.php',
74  'typo3/sysext/frontend/Tests/Functional/Fixtures/Images' => 'fileadmin/user_upload'
75  ];
76 
77  protected function setUp()
78  {
79  parent::setUp();
80  $this->importScenarioDataSet('LiveDefaultPages');
81  $this->importScenarioDataSet('LiveDefaultElements');
82 
83  $this->backendUser->workspace = 0;
84  $this->objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
85  $this->contentRepository = $this->objectManager->get(\ExtbaseTeam\BlogExample\Domain\Repository\TtContentRepository::class);
86  $this->setUpFrontendRootPage(1, [
87  'typo3/sysext/extbase/Tests/Functional/Fixtures/Extensions/blog_example/Configuration/TypoScript/setup.txt',
88  'typo3/sysext/extbase/Tests/Functional/Persistence/Fixtures/Frontend/ContentJsonRenderer.ts'
89  ]);
90  }
91 
93  {
94  return [
95  [
96  'typoScript' => 'config.sys_language_overlay = 0
97  config.sys_language_mode =',
98  ],
99  [
100  'typoScript' => 'config.sys_language_overlay = 0
101  config.sys_language_mode = content_fallback',
102  ],
103  [
104  'typoScript' => 'config.sys_language_overlay = 0
105  config.sys_language_mode = content_fallback;1,0',
106  ],
107  [
108  'typoScript' => 'config.sys_language_overlay = 0
109  config.sys_language_mode = strict',
110  ],
111  [
112  'typoScript' => 'config.sys_language_overlay = 0
113  config.sys_language_mode = ignore',
114  ],
115  [
116  'typoScript' => 'config.sys_language_overlay = 1
117  config.sys_language_mode =',
118  ],
119  [
120  'typoScript' => 'config.sys_language_overlay = 1
121  config.sys_language_mode = content_fallback',
122  ],
123  [
124  'typoScript' => 'config.sys_language_overlay = 1
125  config.sys_language_mode = content_fallback;1,0',
126  ],
127  [
128  'typoScript' => 'config.sys_language_overlay = 1
129  config.sys_language_mode = strict',
130  ],
131  [
132  'typoScript' => 'config.sys_language_overlay = 1
133  config.sys_language_mode = ignore',
134  ],
135  [
136  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
137  config.sys_language_mode =',
138  ],
139  [
140  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
141  config.sys_language_mode = content_fallback',
142  ],
143  [
144  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
145  config.sys_language_mode = content_fallback;1,0',
146  ],
147  [
148  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
149  config.sys_language_mode = strict',
150  ],
151  [
152  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
153  config.sys_language_mode = ignore',
154  ],
155  ];
156  }
157 
168  {
169  $this->addTypoScriptToTemplateRecord(1, $typoScript);
170 
171  $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 0);
172  $responseSections = $frontendResponse->getResponseSections('Extbase:list()');
173  $visibleHeaders = ['Regular Element #1', 'Regular Element #2', 'Regular Element #3'];
174 
175  $constraint = $this->getRequestSectionHasRecordConstraint()
176  ->setTable(self::TABLE_Content)
177  ->setField('header');
178  call_user_func_array([$constraint, 'setValues'],$visibleHeaders);
179 
180  $this->assertThat($responseSections, $constraint);
181  $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
182  ->setTable(self::TABLE_Content)
183  ->setField('header');
184  call_user_func_array([$constraint, 'setValues'],$this->getNonVisibleHeaders($visibleHeaders));
185  $this->assertThat($responseSections, $constraint);
186 
187  //assert FAL relations
188  $visibleRecords = [
189  297 => ['T3BOARD'],
190  298 => ['Kasper'],
191  ];
192  foreach ($visibleRecords as $ttContentUid => $visibleFileTitles) {
193  $constraint = $this->getRequestSectionStructureHasRecordConstraint()
194  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
195  ->setTable('sys_file_reference')->setField('title');
196  call_user_func_array([$constraint, 'setValues'], $visibleFileTitles);
197  $this->assertThat($responseSections, $constraint);
198 
200  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
201  ->setTable('sys_file_reference')->setField('title');
202  call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleFileTitles($visibleFileTitles));
203  $this->assertThat($responseSections, $constraint);
204  }
205  }
206 
212  public function dutchDataProvider()
213  {
214  //Expected behaviour:
215  //Page is translated to Dutch, so changing sys_language_mode does NOT change the results
216  //Page title is always [DK]Page, and both sys_language_content and sys_language_uid are always 1
217  return [
218  [
219  'typoScript' => 'config.sys_language_overlay = 0
220  config.sys_language_mode =',
221  'visibleRecords' => [
222  297 => [
223  'header' => '[Translate to Dansk:] Regular Element #1',
224  'image' => ['T3BOARD'],
225 
226  ],
227  298 => [
228  'header' => 'Regular Element #2',
229  'image' => ['Kasper'],
230  ],
231  299 => [
232  'header' => '[Translate to Dansk:] Regular Element #3',
233  'image' => []
234  ],
235  303 => [
236  'header' => '[DK] Without default language',
237  'image' => ['[T3BOARD] Image added to DK element without default language'],
238  ],
239  307 => [
240  'header' => '[DK] UnHidden Element #4',
241  'image' => [],
242  ],
243  ],
244  ],
245  [
246  'typoScript' => 'config.sys_language_overlay = 0
247  config.sys_language_mode = content_fallback',
248  'visibleRecords' => [
249  297 => [
250  'header' => '[Translate to Dansk:] Regular Element #1',
251  'image' => ['T3BOARD'],
252 
253  ],
254  298 => [
255  'header' => 'Regular Element #2',
256  'image' => ['Kasper'],
257  ],
258  299 => [
259  'header' => '[Translate to Dansk:] Regular Element #3',
260  'image' => []
261  ],
262  303 => [
263  'header' => '[DK] Without default language',
264  'image' => ['[T3BOARD] Image added to DK element without default language'],
265  ],
266  307 => [
267  'header' => '[DK] UnHidden Element #4',
268  'image' => [],
269  ],
270  ],
271  ],
272  [
273  'typoScript' => 'config.sys_language_overlay = 0
274  config.sys_language_mode = content_fallback;1,0',
275  'visibleRecords' => [
276  297 => [
277  'header' => '[Translate to Dansk:] Regular Element #1',
278  'image' => ['T3BOARD'],
279 
280  ],
281  298 => [
282  'header' => 'Regular Element #2',
283  'image' => ['Kasper'],
284  ],
285  299 => [
286  'header' => '[Translate to Dansk:] Regular Element #3',
287  'image' => []
288  ],
289  303 => [
290  'header' => '[DK] Without default language',
291  'image' => ['[T3BOARD] Image added to DK element without default language'],
292  ],
293  307 => [
294  'header' => '[DK] UnHidden Element #4',
295  'image' => [],
296  ],
297  ],
298  ],
299  [
300  'typoScript' => 'config.sys_language_overlay = 0
301  config.sys_language_mode = strict',
302  'visibleRecords' => [
303  297 => [
304  'header' => '[Translate to Dansk:] Regular Element #1',
305  'image' => [],
306  ],
307  299 => [
308  'header' => '[Translate to Dansk:] Regular Element #3',
309  'image' => []
310  ],
311  303 => [
312  'header' => '[DK] Without default language',
313  'image' => ['[T3BOARD] Image added to DK element without default language'],
314  ],
315  ],
316  ],
317  [
318  'typoScript' => 'config.sys_language_overlay = 0
319  config.sys_language_mode = ignore',
320  'visibleRecords' => [
321  297 => [
322  'header' => '[Translate to Dansk:] Regular Element #1',
323  'image' => ['T3BOARD'],
324 
325  ],
326  298 => [
327  'header' => 'Regular Element #2',
328  'image' => ['Kasper'],
329  ],
330  299 => [
331  'header' => '[Translate to Dansk:] Regular Element #3',
332  'image' => []
333  ],
334  303 => [
335  'header' => '[DK] Without default language',
336  'image' => ['[T3BOARD] Image added to DK element without default language'],
337  ],
338  307 => [
339  'header' => '[DK] UnHidden Element #4',
340  'image' => [],
341  ],
342  ],
343  ],
344  5 => [
345  'typoScript' => 'config.sys_language_overlay = 1
346  config.sys_language_mode =',
347  'visibleRecords' => [
348  297 => [
349  'header' => '[Translate to Dansk:] Regular Element #1',
350  'image' => ['T3BOARD'],
351 
352  ],
353  298 => [
354  'header' => 'Regular Element #2',
355  'image' => ['Kasper'],
356  ],
357  299 => [
358  'header' => '[Translate to Dansk:] Regular Element #3',
359  'image' => []
360  ],
361  303 => [
362  'header' => '[DK] Without default language',
363  'image' => ['[T3BOARD] Image added to DK element without default language'],
364  ],
365  307 => [
366  'header' => '[DK] UnHidden Element #4',
367  'image' => [],
368  ],
369  ],
370  ],
371 // Expected behaviour:
372 // Not translated element #2 is shown because sys_language_overlay = 1 (with sys_language_overlay = hideNonTranslated, it would be hidden)
373  [
374  'typoScript' => 'config.sys_language_overlay = 1
375  config.sys_language_mode = content_fallback',
376  'visibleRecords' => [
377  297 => [
378  'header' => '[Translate to Dansk:] Regular Element #1',
379  'image' => ['T3BOARD'],
380 
381  ],
382  298 => [
383  'header' => 'Regular Element #2',
384  'image' => ['Kasper'],
385  ],
386  299 => [
387  'header' => '[Translate to Dansk:] Regular Element #3',
388  'image' => []
389  ],
390  303 => [
391  'header' => '[DK] Without default language',
392  'image' => ['[T3BOARD] Image added to DK element without default language'],
393  ],
394  307 => [
395  'header' => '[DK] UnHidden Element #4',
396  'image' => [],
397  ],
398  ],
399  ],
400 // Expected behaviour:
401 // Same as config.sys_language_mode = content_fallback because we're requesting language 1, so no additional fallback possible
402 
403  [
404  'typoScript' => 'config.sys_language_overlay = 1
405  config.sys_language_mode = content_fallback;1,0',
406  'visibleRecords' => [
407  297 => [
408  'header' => '[Translate to Dansk:] Regular Element #1',
409  'image' => ['T3BOARD'],
410  ],
411  298 => [
412  'header' => 'Regular Element #2',
413  'image' => ['Kasper'],
414  ],
415  299 => [
416  'header' => '[Translate to Dansk:] Regular Element #3',
417  'image' => []
418  ],
419  303 => [
420  'header' => '[DK] Without default language',
421  'image' => ['[T3BOARD] Image added to DK element without default language'],
422  ],
423  307 => [
424  'header' => '[DK] UnHidden Element #4',
425  'image' => [],
426  ],
427  ],
428  ],
429  [
430  'typoScript' => 'config.sys_language_overlay = 1
431  config.sys_language_mode = strict',
432  'visibleRecords' => [
433  297 => [
434  'header' => '[Translate to Dansk:] Regular Element #1',
435  'image' => [],
436  ],
437  299 => [
438  'header' => '[Translate to Dansk:] Regular Element #3',
439  'image' => []
440  ],
441  303 => [
442  'header' => '[DK] Without default language',
443  'image' => ['[T3BOARD] Image added to DK element without default language'],
444  ],
445  ],
446  ],
447  [
448  'typoScript' => 'config.sys_language_overlay = 1
449  config.sys_language_mode = ignore',
450  'visibleRecords' => [
451  297 => [
452  'header' => '[Translate to Dansk:] Regular Element #1',
453  'image' => ['T3BOARD'],
454 
455  ],
456  298 => [
457  'header' => 'Regular Element #2',
458  'image' => ['Kasper'],
459  ],
460  299 => [
461  'header' => '[Translate to Dansk:] Regular Element #3',
462  'image' => []
463  ],
464  303 => [
465  'header' => '[DK] Without default language',
466  'image' => ['[T3BOARD] Image added to DK element without default language'],
467  ],
468  307 => [
469  'header' => '[DK] UnHidden Element #4',
470  'image' => [],
471  ],
472  ],
473  ],
474 // Expected behaviour:
475 // Non translated default language elements are not shown, because of hideNonTranslated
476  10 => [
477  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
478  config.sys_language_mode =',
479  'visibleRecords' => [
480  297 => [
481  'header' => '[Translate to Dansk:] Regular Element #1',
482  'image' => ['T3BOARD'],
483 
484  ],
485  298 => [
486  'header' => 'Regular Element #2',
487  'image' => ['Kasper'],
488  ],
489  299 => [
490  'header' => '[Translate to Dansk:] Regular Element #3',
491  'image' => []
492  ],
493  303 => [
494  'header' => '[DK] Without default language',
495  'image' => ['[T3BOARD] Image added to DK element without default language'],
496  ],
497  307 => [
498  'header' => '[DK] UnHidden Element #4',
499  'image' => [],
500  ],
501  ],
502  ],
503  [
504  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
505  config.sys_language_mode = content_fallback',
506  'visibleRecords' => [
507  297 => [
508  'header' => '[Translate to Dansk:] Regular Element #1',
509  'image' => ['T3BOARD'],
510 
511  ],
512  298 => [
513  'header' => 'Regular Element #2',
514  'image' => ['Kasper'],
515  ],
516  299 => [
517  'header' => '[Translate to Dansk:] Regular Element #3',
518  'image' => []
519  ],
520  303 => [
521  'header' => '[DK] Without default language',
522  'image' => ['[T3BOARD] Image added to DK element without default language'],
523  ],
524  307 => [
525  'header' => '[DK] UnHidden Element #4',
526  'image' => [],
527  ],
528  ],
529  ],
530  [
531  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
532  config.sys_language_mode = content_fallback;1,0',
533  'visibleRecords' => [
534  297 => [
535  'header' => '[Translate to Dansk:] Regular Element #1',
536  'image' => ['T3BOARD'],
537 
538  ],
539  298 => [
540  'header' => 'Regular Element #2',
541  'image' => ['Kasper'],
542  ],
543  299 => [
544  'header' => '[Translate to Dansk:] Regular Element #3',
545  'image' => []
546  ],
547  303 => [
548  'header' => '[DK] Without default language',
549  'image' => ['[T3BOARD] Image added to DK element without default language'],
550  ],
551  307 => [
552  'header' => '[DK] UnHidden Element #4',
553  'image' => [],
554  ],
555  ],
556  ],
557 // Setting sys_language_mode = strict has the same effect as previous data sets, because the translation of the page exists
558  [
559  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
560  config.sys_language_mode = strict',
561  'visibleRecords' => [
562  297 => [
563  'header' => '[Translate to Dansk:] Regular Element #1',
564  'image' => [],
565  ],
566  299 => [
567  'header' => '[Translate to Dansk:] Regular Element #3',
568  'image' => []
569  ],
570  303 => [
571  'header' => '[DK] Without default language',
572  'image' => ['[T3BOARD] Image added to DK element without default language'],
573  ],
574  ],
575  ],
576  [
577  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
578  config.sys_language_mode = ignore',
579  'visibleRecords' => [
580  297 => [
581  'header' => '[Translate to Dansk:] Regular Element #1',
582  'image' => ['T3BOARD'],
583  ],
584  298 => [
585  'header' => 'Regular Element #2',
586  'image' => ['Kasper'],
587  ],
588  299 => [
589  'header' => '[Translate to Dansk:] Regular Element #3',
590  'image' => []
591  ],
592  303 => [
593  'header' => '[DK] Without default language',
594  'image' => ['[T3BOARD] Image added to DK element without default language'],
595  ],
596  307 => [
597  'header' => '[DK] UnHidden Element #4',
598  'image' => [],
599  ],
600  ],
601  ],
602  ];
603  }
604 
612  public function renderingOfDutchLanguage($typoScript, array $visibleRecords)
613  {
614  $this->addTypoScriptToTemplateRecord(1, $typoScript);
615  $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 1);
616  $responseSections = $frontendResponse->getResponseSections('Extbase:list()');
617  $visibleHeaders = array_map(function ($element) {
618  return $element['header'];
619  }, $visibleRecords);
620  $constraint = $this->getRequestSectionHasRecordConstraint()
621  ->setTable(self::TABLE_Content)
622  ->setField('header');
623  call_user_func_array([$constraint, 'setValues'], $visibleHeaders);
624  $this->assertThat($responseSections, $constraint);
625 
626  $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
627  ->setTable(self::TABLE_Content)
628  ->setField('header');
629  call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleHeaders($visibleHeaders));
630  $this->assertThat($responseSections, $constraint);
631 
632  foreach ($visibleRecords as $ttContentUid => $properties) {
633  $visibleFileTitles = $properties['image'];
634  if (!empty($visibleFileTitles)) {
635  $constraint = $this->getRequestSectionStructureHasRecordConstraint()
636  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
637  ->setTable('sys_file_reference')->setField('title');
638  call_user_func_array([$constraint, 'setValues'], $visibleFileTitles);
639  $this->assertThat($responseSections, $constraint);
640  }
642  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
643  ->setTable('sys_file_reference')->setField('title');
644  call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleFileTitles($visibleFileTitles));
645  $this->assertThat($responseSections, $constraint);
646  }
647  }
648 
650  {
651  //Expected behaviour:
652  //the page is NOT translated so setting sys_language_mode to different values changes the results
653  //- setting sys_language_mode to empty value makes TYPO3 return default language records
654  //- setting it to strict throws 404, independently from other settings
655  //Setting config.sys_language_overlay = 0
656  return [
657  [
658  'typoScript' => 'config.sys_language_overlay = 0
659  config.sys_language_mode =',
660  'visibleRecords' => [
661  297 => [
662  'header' => 'Regular Element #1',
663  'image' => ['T3BOARD'],
664  ],
665  298 => [
666  'header' => 'Regular Element #2',
667  'image' => ['Kasper'],
668  ],
669  299 => [
670  'header' => 'Regular Element #3',
671  'image' => [],
672  ],
673  ],
674  ],
675  [
676  'typoScript' => 'config.sys_language_overlay = 0
677  config.sys_language_mode = content_fallback',
678  'visibleRecords' => [
679  297 => [
680  'header' => 'Regular Element #1',
681  'image' => ['T3BOARD'],
682  ],
683  298 => [
684  'header' => 'Regular Element #2',
685  'image' => ['Kasper'],
686  ],
687  299 => [
688  'header' => 'Regular Element #3',
689  'image' => [],
690  ],
691  ],
692  ],
693  [
694  'typoScript' => 'config.sys_language_overlay = 0
695  config.sys_language_mode = content_fallback;1,0',
696  'visibleRecords' => [
697  297 => [
698  'header' => '[Translate to Dansk:] Regular Element #1',
699  'image' => ['T3BOARD'],
700  ],
701  298 => [
702  'header' => 'Regular Element #2',
703  'image' => ['Kasper'],
704  ],
705  299 => [
706  'header' => '[Translate to Dansk:] Regular Element #3',
707  'image' => []
708  ],
709  303 => [
710  'header' => '[DK] Without default language',
711  'image' => ['[T3BOARD] Image added to DK element without default language'],
712  ],
713  307 => [
714  'header' => '[DK] UnHidden Element #4',
715  'image' => [],
716  ],
717  ],
718  ],
719  [
720  'typoScript' => 'config.sys_language_overlay = 0
721  config.sys_language_mode = strict',
722  'visibleRecords' => [],
723  'status' => 404,
724  ],
725  [
726  'typoScript' => 'config.sys_language_overlay = 0
727  config.sys_language_mode = ignore',
728  'visibleRecords' => [
729  297 => [
730  'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
731  'image' => ['T3BOARD'],
732  ],
733  298 => [
734  'header' => 'Regular Element #2',
735  'image' => ['Kasper'],
736  ],
737  299 => [
738  'header' => 'Regular Element #3',
739  'image' => []
740  ],
741  304 => [
742  'header' => '[DE] Without default language',
743  'image' => [],
744  ],
745  ],
746  ],
747  5 => [
748  'typoScript' => 'config.sys_language_overlay = 1
749  config.sys_language_mode =',
750  'visibleRecords' => [
751  297 => [
752  'header' => 'Regular Element #1',
753  'image' => ['T3BOARD'],
754  ],
755  298 => [
756  'header' => 'Regular Element #2',
757  'image' => ['Kasper'],
758  ],
759  299 => [
760  'header' => 'Regular Element #3',
761  'image' => [],
762  ],
763  ],
764  ],
765  //falling back to default language
766  [
767  'typoScript' => 'config.sys_language_overlay = 1
768  config.sys_language_mode = content_fallback',
769  'visibleRecords' => [
770  297 => [
771  'header' => 'Regular Element #1',
772  'image' => ['T3BOARD'],
773  ],
774  298 => [
775  'header' => 'Regular Element #2',
776  'image' => ['Kasper'],
777  ],
778  299 => [
779  'header' => 'Regular Element #3',
780  'image' => [],
781  ],
782  ],
783  ],
784  //Dutch elements are shown because of the content fallback 1,0 - first Dutch, then default language
785  //note that '[DK] Without default language' is NOT shown - due to overlays (fetch default language and overlay it with translations)
786  [
787  'typoScript' => 'config.sys_language_overlay = 1
788  config.sys_language_mode = content_fallback;1,0',
789  'visibleRecords' => [
790  297 => [
791  'header' => '[Translate to Dansk:] Regular Element #1',
792  'image' => ['T3BOARD'],
793  ],
794  298 => [
795  'header' => 'Regular Element #2',
796  'image' => ['Kasper'],
797  ],
798  299 => [
799  'header' => '[Translate to Dansk:] Regular Element #3',
800  'image' => []
801  ],
802  303 => [
803  'header' => '[DK] Without default language',
804  'image' => ['[T3BOARD] Image added to DK element without default language'],
805  ],
806  307 => [
807  'header' => '[DK] UnHidden Element #4',
808  'image' => [],
809  ],
810  ],
811  ],
812  [
813  'typoScript' => 'config.sys_language_overlay = 1
814  config.sys_language_mode = strict',
815  'visibleRecords' => [],
816  'status' => 404
817  ],
818  [
819  'typoScript' => 'config.sys_language_overlay = 1
820  config.sys_language_mode = ignore',
821  'visibleRecords' => [
822  297 => [
823  'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
824  'image' => ['T3BOARD'],
825  ],
826  298 => [
827  'header' => 'Regular Element #2',
828  'image' => ['Kasper'],
829  ],
830  299 => [
831  'header' => 'Regular Element #3',
832  'image' => []
833  ],
834  304 => [
835  'header' => '[DE] Without default language',
836  'image' => [],
837  ],
838  ],
839  ],
840  10 => [
841  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
842  config.sys_language_mode =',
843  'visibleRecords' => [
844  297 => [
845  'header' => 'Regular Element #1',
846  'image' => ['T3BOARD'],
847  ],
848  298 => [
849  'header' => 'Regular Element #2',
850  'image' => ['Kasper'],
851  ],
852  299 => [
853  'header' => 'Regular Element #3',
854  'image' => [],
855  ],
856  ],
857  ],
858  [
859  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
860  config.sys_language_mode = content_fallback',
861  'visibleRecords' => [
862  297 => [
863  'header' => 'Regular Element #1',
864  'image' => ['T3BOARD'],
865  ],
866  298 => [
867  'header' => 'Regular Element #2',
868  'image' => ['Kasper'],
869  ],
870  299 => [
871  'header' => 'Regular Element #3',
872  'image' => [],
873  ],
874  ],
875  ],
876  [
877  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
878  config.sys_language_mode = content_fallback;1,0',
879  'visibleRecords' => [
880  297 => [
881  'header' => '[Translate to Dansk:] Regular Element #1',
882  'image' => ['T3BOARD'],
883  ],
884  298 => [
885  'header' => 'Regular Element #2',
886  'image' => ['Kasper'],
887  ],
888  299 => [
889  'header' => '[Translate to Dansk:] Regular Element #3',
890  'image' => []
891  ],
892  303 => [
893  'header' => '[DK] Without default language',
894  'image' => ['[T3BOARD] Image added to DK element without default language'],
895  ],
896  307 => [
897  'header' => '[DK] UnHidden Element #4',
898  'image' => [],
899  ],
900  ],
901  ],
902  [
903  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
904  config.sys_language_mode = strict',
905  'visibleRecords' => [],
906  'status' => 404,
907  ],
908  [
909  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
910  config.sys_language_mode = ignore',
911  'visibleRecords' => [
912  297 => [
913  'header' => '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
914  'image' => ['T3BOARD'],
915  ],
916  298 => [
917  'header' => 'Regular Element #2',
918  'image' => ['Kasper'],
919  ],
920  299 => [
921  'header' => 'Regular Element #3',
922  'image' => []
923  ],
924  304 => [
925  'header' => '[DE] Without default language',
926  'image' => [],
927  ],
928  ],
929  ],
930  ];
931  }
932 
943  public function contentOnNonTranslatedPageGerman($typoScript, array $visibleRecords, $status='success')
944  {
945  $this->addTypoScriptToTemplateRecord(1, $typoScript);
946  $visibleHeaders = array_map(function ($element) {
947  return $element['header'];
948  }, $visibleRecords);
949 
950  $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 2);
951  if ($status === 'success') {
952  $responseSections = $frontendResponse->getResponseSections('Extbase:list()');
953  $constraint =
955  ->setTable(self::TABLE_Content)
956  ->setField('header');
957  call_user_func_array([$constraint, 'setValues'],$visibleHeaders);
958 
959  $this->assertThat(
960  $responseSections,$constraint);
961  $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
962  ->setTable(self::TABLE_Content)
963  ->setField('header');
964  call_user_func_array([$constraint, 'setValues'],$this->getNonVisibleHeaders($visibleHeaders));
965  $this->assertThat($responseSections, $constraint);
966 
967  foreach ($visibleRecords as $ttContentUid => $properties) {
968  $visibleFileTitles = $properties['image'];
969  if (!empty($visibleFileTitles)) {
970  $constraint = $this->getRequestSectionStructureHasRecordConstraint()
971  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
972  ->setTable('sys_file_reference')->setField('title');
973  call_user_func_array([$constraint, 'setValues'], $visibleFileTitles);
974  $this->assertThat($responseSections, $constraint);
975  }
977  ->setRecordIdentifier(self::TABLE_Content . ':' . $ttContentUid)->setRecordField('image')
978  ->setTable('sys_file_reference')->setField('title');
979  call_user_func_array([$constraint, 'setValues'], $this->getNonVisibleFileTitles($visibleFileTitles));
980  $this->assertThat($responseSections, $constraint);
981  }
982  }
983  //some configuration combinations results in 404, in that case status will be set to 404
984  $this->assertEquals($status, $frontendResponse->getStatus());
985  }
986 
988  {
989 
990  //Expected behaviour:
991  //Setting sys_language_mode to different values doesn't influence the result as the requested page is translated to Polish,
992  //Page title is always [PL]Page, and both sys_language_content and sys_language_uid are always 3
993  return [
994  [
995  'typoScript' => 'config.sys_language_overlay = 0
996  config.sys_language_mode =',
997  'visibleRecordHeaders' => ['Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
998  ],
999  [
1000  'typoScript' => 'config.sys_language_overlay = 0
1001  config.sys_language_mode = content_fallback',
1002  'visibleRecordHeaders' => ['Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
1003  ],
1004  [
1005  'typoScript' => 'config.sys_language_overlay = 0
1006  config.sys_language_mode = content_fallback;1,0',
1007  'visibleRecordHeaders' => ['Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
1008  ],
1009  [
1010  'typoScript' => 'config.sys_language_overlay = 0
1011  config.sys_language_mode = strict',
1012  'visibleRecordHeaders' => ['[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
1013  ],
1014  [
1015  'typoScript' => 'config.sys_language_overlay = 0
1016  config.sys_language_mode = ignore',
1017  'visibleRecordHeaders' => ['Regular Element #3', '[Translate to Polski:] Regular Element #1', '[PL] Without default language'],
1018  ],
1019  5 => [
1020  'typoScript' => 'config.sys_language_overlay = 1
1021  config.sys_language_mode =',
1022  'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #3'],
1023  ],
1024  // Expected behaviour:
1025  // Not translated element #2 is shown because sys_language_overlay = 1 (with sys_language_overlay = hideNonTranslated, it would be hidden)
1026  [
1027  'typoScript' => 'config.sys_language_overlay = 1
1028  config.sys_language_mode = content_fallback',
1029  'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #3'],
1030  ],
1031 // Expected behaviour:
1032 // 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
1033 // but on page level - and this page is translated to Polish, so no fallback is happening
1034  [
1035  'typoScript' => 'config.sys_language_overlay = 1
1036  config.sys_language_mode = content_fallback;1,0',
1037  'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #3'],
1038  ],
1039  [
1040  'typoScript' => 'config.sys_language_overlay = 1
1041  config.sys_language_mode = strict',
1042  'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1'],
1043  ],
1044  [
1045  'typoScript' => 'config.sys_language_overlay = 1
1046  config.sys_language_mode = ignore',
1047  'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1', 'Regular Element #3'],
1048  ],
1049  // Expected behaviour:
1050  // Non translated default language elements are not shown, because of hideNonTranslated
1051  10 => [
1052  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
1053  config.sys_language_mode =',
1054  'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
1055  ],
1056  [
1057  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
1058  config.sys_language_mode = content_fallback',
1059  'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
1060  ],
1061  [
1062  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
1063  config.sys_language_mode = content_fallback;1,0',
1064  'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
1065  ],
1066  [
1067  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
1068  config.sys_language_mode = strict',
1069  'visibleRecordHeaders' => ['[PL] Without default language', '[Translate to Polski:] Regular Element #1'],
1070  ],
1071  [
1072  'typoScript' => 'config.sys_language_overlay = hideNonTranslated
1073  config.sys_language_mode = ignore',
1074  'visibleRecordHeaders' => ['[PL] Without default language', 'Regular Element #3', '[Translate to Polski:] Regular Element #1'],
1075  ]
1076  ];
1077  }
1078 
1088  public function contentOnPartiallyTranslatedPage($typoScript, array $visibleHeaders)
1089  {
1090  $this->addTypoScriptToTemplateRecord(1, $typoScript);
1091 
1092  $frontendResponse = $this->getFrontendResponse(self::VALUE_PageId, 3);
1093  $this->assertEquals('success', $frontendResponse->getStatus());
1094  $responseSections = $frontendResponse->getResponseSections('Extbase:list()');
1095 
1096  $constraint =
1098  ->setTable(self::TABLE_Content)
1099  ->setField('header');
1100  call_user_func_array([$constraint, 'setValues'],$visibleHeaders);
1101 
1102  $this->assertThat(
1103  $responseSections,$constraint);
1104  $constraint = $this->getRequestSectionDoesNotHaveRecordConstraint()
1105  ->setTable(self::TABLE_Content)
1106  ->setField('header');
1107  call_user_func_array([$constraint, 'setValues'],$this->getNonVisibleHeaders($visibleHeaders));
1108  $this->assertThat($responseSections, $constraint);
1109  }
1110 
1117  protected function getNonVisibleHeaders(array $visibleHeaders)
1118  {
1119  $allElements = [
1120  'Regular Element #1',
1121  'Regular Element #2',
1122  'Regular Element #3',
1123  'Hidden Element #4',
1124  '[Translate to Dansk:] Regular Element #1',
1125  '[Translate to Dansk:] Regular Element #3',
1126  '[DK] Without default language',
1127  '[DK] UnHidden Element #4',
1128  '[DE] Without default language',
1129  '[Translate to Deutsch:] [Translate to Dansk:] Regular Element #1',
1130  '[Translate to Polski:] Regular Element #1',
1131  '[PL] Without default language',
1132  '[PL] Hidden Regular Element #2'
1133  ];
1134  return array_diff($allElements, $visibleHeaders);
1135  }
1136 
1143  protected function getNonVisibleFileTitles(array $visibleTitles)
1144  {
1145  $allElements = [
1146  'T3BOARD',
1147  'Kasper',
1148  '[Kasper] Image translated to Dansk',
1149  '[T3BOARD] Image added in Dansk (without parent)',
1150  '[T3BOARD] Image added to DK element without default language',
1151  '[T3BOARD] image translated to DE from DK',
1152  ];
1153  return array_diff($allElements, $visibleTitles);
1154  }
1155 }
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=true, $frontendUserId=0)
setUpFrontendRootPage($pageId, array $typoScriptFiles=[])
contentOnNonTranslatedPageGerman($typoScript, array $visibleRecords, $status='success')